From dc071e0bc624b7245bcdbaca473ac51c022ac2e6 Mon Sep 17 00:00:00 2001 From: Wei Hu Date: Fri, 25 Oct 2024 10:21:25 +0800 Subject: [PATCH] Default to enable use-write-core for mgmt (#5126) --- .../AvailabilitySetData.Serialization.cs | 60 +++--------------- .../src/Generated/Configuration.json | 1 + .../DedicatedHostData.Serialization.cs | 60 +++--------------- .../DedicatedHostGroupData.Serialization.cs | 60 +++--------------- .../src/Generated/ImageData.Serialization.cs | 60 +++--------------- .../AdditionalCapabilities.Serialization.cs | 11 +++- ...AdditionalUnattendContent.Serialization.cs | 11 +++- .../Models/ApiError.Serialization.cs | 11 +++- .../Models/ApiErrorBase.Serialization.cs | 11 +++- .../AutomaticOSUpgradePolicy.Serialization.cs | 11 +++- ...omaticOSUpgradeProperties.Serialization.cs | 11 +++- .../AutomaticRepairsPolicy.Serialization.cs | 11 +++- ...AvailabilitySetListResult.Serialization.cs | 11 +++- .../AvailabilitySetPatch.Serialization.cs | 38 +++--------- .../AvailablePatchSummary.Serialization.cs | 11 +++- ...ResourceManagerSamplePlan.Serialization.cs | 11 +++- ...eResourceManagerSampleSku.Serialization.cs | 11 +++- ...esourceManagerSampleUsage.Serialization.cs | 11 +++- ...rceManagerSampleUsageName.Serialization.cs | 11 +++- .../Models/BillingProfile.Serialization.cs | 11 +++- .../Models/BootDiagnostics.Serialization.cs | 11 +++- ...otDiagnosticsInstanceView.Serialization.cs | 11 +++- .../Models/DataDisk.Serialization.cs | 11 +++- .../Models/DataDiskImage.Serialization.cs | 11 +++- ...edicatedHostAllocatableVm.Serialization.cs | 11 +++- ...atedHostAvailableCapacity.Serialization.cs | 11 +++- ...atedHostGroupInstanceView.Serialization.cs | 11 +++- ...icatedHostGroupListResult.Serialization.cs | 11 +++- .../DedicatedHostGroupPatch.Serialization.cs | 38 +++--------- ...DedicatedHostInstanceView.Serialization.cs | 11 +++- ...dHostInstanceViewWithName.Serialization.cs | 47 +++----------- .../DedicatedHostListResult.Serialization.cs | 11 +++- .../DedicatedHostPatch.Serialization.cs | 38 +++--------- .../DiagnosticsProfile.Serialization.cs | 11 +++- .../Models/DiffDiskSettings.Serialization.cs | 11 +++- .../DisallowedConfiguration.Serialization.cs | 11 +++- .../DiskEncryptionSettings.Serialization.cs | 11 +++- .../Models/DiskInstanceView.Serialization.cs | 11 +++- .../Models/HardwareProfile.Serialization.cs | 11 +++- .../Models/ImageDataDisk.Serialization.cs | 62 +++---------------- .../Models/ImageDisk.Serialization.cs | 11 +++- .../Models/ImageListResult.Serialization.cs | 11 +++- .../Models/ImageOSDisk.Serialization.cs | 62 +++---------------- .../Models/ImagePatch.Serialization.cs | 38 +++--------- .../Models/ImageReference.Serialization.cs | 32 +++------- .../ImageStorageProfile.Serialization.cs | 11 +++- .../Models/InnerError.Serialization.cs | 11 +++- .../InstanceViewStatus.Serialization.cs | 11 +++- .../KeyVaultKeyReference.Serialization.cs | 11 +++- .../KeyVaultSecretReference.Serialization.cs | 11 +++- ...tPatchInstallationSummary.Serialization.cs | 11 +++- .../LinuxConfiguration.Serialization.cs | 11 +++- .../Models/ListUsagesResult.Serialization.cs | 11 +++- .../Models/LogAnalytics.Serialization.cs | 11 +++- .../LogAnalyticsInputBase.Serialization.cs | 11 +++- .../LogAnalyticsOutput.Serialization.cs | 11 +++- ...MaintenanceRedeployStatus.Serialization.cs | 11 +++- .../ManagedDiskParameters.Serialization.cs | 32 +++------- ...NetworkInterfaceReference.Serialization.cs | 32 +++------- .../Models/NetworkProfile.Serialization.cs | 11 +++- .../Generated/Models/OSDisk.Serialization.cs | 11 +++- .../Models/OSDiskImage.Serialization.cs | 11 +++- .../Models/OSProfile.Serialization.cs | 11 +++- ...rationServiceStateContent.Serialization.cs | 11 +++- ...chestrationServiceSummary.Serialization.cs | 11 +++- .../Models/PatchSettings.Serialization.cs | 11 +++- ...yPlacementGroupListResult.Serialization.cs | 11 +++- ...ximityPlacementGroupPatch.Serialization.cs | 38 +++--------- .../Models/PurchasePlan.Serialization.cs | 11 +++- .../RecoveryWalkResponse.Serialization.cs | 11 +++- ...uestRateByIntervalContent.Serialization.cs | 48 +++----------- ...BootDiagnosticsDataResult.Serialization.cs | 11 +++- .../RollbackStatusInfo.Serialization.cs | 11 +++- .../RollingUpgradePolicy.Serialization.cs | 11 +++- ...ollingUpgradeProgressInfo.Serialization.cs | 11 +++- ...llingUpgradeRunningStatus.Serialization.cs | 11 +++- .../Models/ScaleInPolicy.Serialization.cs | 11 +++- .../ScheduledEventsProfile.Serialization.cs | 11 +++- .../Models/SecurityProfile.Serialization.cs | 11 +++- .../Models/SshConfiguration.Serialization.cs | 11 +++- ...cKeyGenerateKeyPairResult.Serialization.cs | 11 +++- .../Models/SshPublicKeyInfo.Serialization.cs | 11 +++- .../Models/SshPublicKeyPatch.Serialization.cs | 38 +++--------- ...PublicKeysGroupListResult.Serialization.cs | 11 +++- .../Models/StorageProfile.Serialization.cs | 11 +++- .../Models/SubResource.Serialization.cs | 11 +++- .../SubResourceReadOnly.Serialization.cs | 11 +++- ...ourceWithColocationStatus.Serialization.cs | 32 +++------- ...minateNotificationProfile.Serialization.cs | 11 +++- .../ThrottledRequestsContent.Serialization.cs | 48 +++----------- .../Models/UpdateResource.Serialization.cs | 11 +++- ...ationHistoricalStatusInfo.Serialization.cs | 11 +++- ...ricalStatusInfoProperties.Serialization.cs | 11 +++- ...adeOperationHistoryStatus.Serialization.cs | 11 +++- .../Models/UpgradePolicy.Serialization.cs | 11 +++- .../Models/VaultCertificate.Serialization.cs | 11 +++- .../Models/VaultSecretGroup.Serialization.cs | 11 +++- .../Models/VirtualHardDisk.Serialization.cs | 11 +++- ...lMachineAgentInstanceView.Serialization.cs | 11 +++- ...achineAssessPatchesResult.Serialization.cs | 11 +++- ...tualMachineCaptureContent.Serialization.cs | 11 +++- ...rtualMachineCaptureResult.Serialization.cs | 32 +++------- ...ensionHandlerInstanceView.Serialization.cs | 11 +++- ...hineExtensionInstanceView.Serialization.cs | 11 +++- ...ualMachineExtensionUpdate.Serialization.cs | 38 +++--------- ...chineExtensionsListResult.Serialization.cs | 11 +++- ...irtualMachineHealthStatus.Serialization.cs | 11 +++- .../VirtualMachineImage.Serialization.cs | 47 +++----------- ...rtualMachineImageResource.Serialization.cs | 32 +++------- ...irtualMachineInstanceView.Serialization.cs | 11 +++- .../VirtualMachineListResult.Serialization.cs | 11 +++- .../VirtualMachinePatch.Serialization.cs | 38 +++--------- ...VirtualMachinePatchStatus.Serialization.cs | 11 +++- ...tualMachineReimageContent.Serialization.cs | 11 +++- ...alMachineScaleSetDataDisk.Serialization.cs | 11 +++- ...aleSetExtensionListResult.Serialization.cs | 11 +++- ...ineScaleSetExtensionPatch.Serialization.cs | 47 +++----------- ...eScaleSetExtensionProfile.Serialization.cs | 11 +++- ...neScaleSetIPConfiguration.Serialization.cs | 32 +++------- ...rtualMachineScaleSetIPTag.Serialization.cs | 11 +++- ...chineScaleSetInstanceView.Serialization.cs | 11 +++- ...stanceViewStatusesSummary.Serialization.cs | 11 +++- ...leSetListOSUpgradeHistory.Serialization.cs | 11 +++- ...MachineScaleSetListResult.Serialization.cs | 11 +++- ...ineScaleSetListSkusResult.Serialization.cs | 11 +++- ...caleSetListWithLinkResult.Serialization.cs | 11 +++- ...eSetManagedDiskParameters.Serialization.cs | 11 +++- ...leSetNetworkConfiguration.Serialization.cs | 32 +++------- ...kConfigurationDnsSettings.Serialization.cs | 11 +++- ...ineScaleSetNetworkProfile.Serialization.cs | 11 +++- ...tualMachineScaleSetOSDisk.Serialization.cs | 11 +++- ...lMachineScaleSetOSProfile.Serialization.cs | 11 +++- ...rtualMachineScaleSetPatch.Serialization.cs | 38 +++--------- ...licIPAddressConfiguration.Serialization.cs | 11 +++- ...sConfigurationDnsSettings.Serialization.cs | 11 +++- ...ineScaleSetReimageContent.Serialization.cs | 32 +++------- ...VirtualMachineScaleSetSku.Serialization.cs | 11 +++- ...achineScaleSetSkuCapacity.Serialization.cs | 11 +++- ...ineScaleSetStorageProfile.Serialization.cs | 11 +++- ...eSetUpdateIPConfiguration.Serialization.cs | 32 +++------- ...pdateNetworkConfiguration.Serialization.cs | 32 +++------- ...leSetUpdateNetworkProfile.Serialization.cs | 11 +++- ...chineScaleSetUpdateOSDisk.Serialization.cs | 11 +++- ...neScaleSetUpdateOSProfile.Serialization.cs | 11 +++- ...licIPAddressConfiguration.Serialization.cs | 11 +++- ...leSetUpdateStorageProfile.Serialization.cs | 11 +++- ...neScaleSetUpdateVmProfile.Serialization.cs | 11 +++- ...aleSetVmExtensionsSummary.Serialization.cs | 11 +++- ...hineScaleSetVmInstanceIds.Serialization.cs | 11 +++- ...eSetVmInstanceRequiredIds.Serialization.cs | 11 +++- ...ineScaleSetVmInstanceView.Serialization.cs | 11 +++- ...chineScaleSetVmListResult.Serialization.cs | 11 +++- ...tworkProfileConfiguration.Serialization.cs | 11 +++- ...lMachineScaleSetVmProfile.Serialization.cs | 11 +++- ...caleSetVmProtectionPolicy.Serialization.cs | 11 +++- ...eScaleSetVmReimageContent.Serialization.cs | 32 +++------- .../VirtualMachineSize.Serialization.cs | 11 +++- ...tualMachineSizeListResult.Serialization.cs | 11 +++- ...neSoftwarePatchProperties.Serialization.cs | 11 +++- ...ualMachineStatusCodeCount.Serialization.cs | 11 +++- ...nglePlacementGroupContent.Serialization.cs | 11 +++- .../WinRMConfiguration.Serialization.cs | 11 +++- .../Models/WinRMListener.Serialization.cs | 11 +++- .../WindowsConfiguration.Serialization.cs | 11 +++- ...oximityPlacementGroupData.Serialization.cs | 60 +++--------------- .../SshPublicKeyData.Serialization.cs | 60 +++--------------- .../VirtualMachineData.Serialization.cs | 60 +++--------------- ...rtualMachineExtensionData.Serialization.cs | 60 +++--------------- ...MachineExtensionImageData.Serialization.cs | 60 +++--------------- ...irtualMachineScaleSetData.Serialization.cs | 60 +++--------------- ...hineScaleSetExtensionData.Serialization.cs | 32 +++------- ...caleSetRollingUpgradeData.Serialization.cs | 60 +++--------------- ...tualMachineScaleSetVmData.Serialization.cs | 60 +++--------------- .../src/Generated/Configuration.json | 1 + .../Common/Input/Configuration.cs | 3 +- .../Emitter.Csharp/src/emitter.ts | 4 +- .../Emitter.Csharp/src/options.ts | 2 +- .../managed-identity/Configuration.json | 3 +- .../models/resources/Configuration.json | 3 +- .../src/Generated/Configuration.json | 1 + .../src/Generated/Configuration.json | 1 + .../src/Generated/Configuration.json | 1 + .../src/Generated/Configuration.json | 1 + .../src/Generated/Models/Cat.Serialization.cs | 60 +++--------------- .../src/Generated/Models/Dog.Serialization.cs | 57 +++-------------- .../src/Generated/Models/Pet.Serialization.cs | 11 +++- .../PetStoreListResult.Serialization.cs | 11 +++- .../PetStoreProperties.Serialization.cs | 11 +++- .../Models/UnknownPet.Serialization.cs | 60 +++--------------- .../Generated/PetStoreData.Serialization.cs | 47 +++----------- .../Generated/ArtifactData.Serialization.cs | 47 +++----------- .../src/Generated/Configuration.json | 1 + .../DeliveryRuleData.Serialization.cs | 47 +++----------- .../Models/ArtifactList.Serialization.cs | 11 +++- .../Models/BaseModel.Serialization.cs | 11 +++- ...xpirationActionParameters.Serialization.cs | 11 +++- ...eryStringActionParameters.Serialization.cs | 11 +++- .../src/Generated/Models/Cat.Serialization.cs | 39 +++--------- .../DeliveryRuleAction.Serialization.cs | 11 +++- ...RuleCacheExpirationAction.Serialization.cs | 34 +++------- ...CacheKeyQueryStringAction.Serialization.cs | 34 +++------- .../DeliveryRuleCondition.Serialization.cs | 11 +++- .../DeliveryRuleListResult.Serialization.cs | 11 +++- .../DeliveryRuleProperties.Serialization.cs | 11 +++- ...yRuleQueryStringCondition.Serialization.cs | 34 +++------- ...uleRemoteAddressCondition.Serialization.cs | 34 +++------- ...ryRuleRequestHeaderAction.Serialization.cs | 34 +++------- ...uleRequestMethodCondition.Serialization.cs | 34 +++------- ...yRuleResponseHeaderAction.Serialization.cs | 34 +++------- ...nfigurationOverrideAction.Serialization.cs | 34 +++------- .../Models/DerivedModel.Serialization.cs | 32 +++------- .../src/Generated/Models/Dog.Serialization.cs | 39 +++--------- .../HeaderActionParameters.Serialization.cs | 11 +++- .../OriginGroupOverride.Serialization.cs | 11 +++- ...OriginGroupOverrideAction.Serialization.cs | 34 +++------- ...pOverrideActionParameters.Serialization.cs | 11 +++- .../src/Generated/Models/Pet.Serialization.cs | 11 +++- ...gMatchConditionParameters.Serialization.cs | 11 +++- ...sMatchConditionParameters.Serialization.cs | 11 +++- ...dMatchConditionParameters.Serialization.cs | 11 +++- .../RoleAssignmentArtifact.Serialization.cs | 49 +++------------ ...nOverrideActionParameters.Serialization.cs | 11 +++- .../Generated/Models/Shell.Serialization.cs | 11 +++- .../Generated/Models/Sku1.Serialization.cs | 11 +++- .../Generated/Models/Sku2.Serialization.cs | 11 +++- .../Models/TemplateArtifact.Serialization.cs | 49 +++------------ .../Models/Unflattened.Serialization.cs | 11 +++- .../Models/UnknownArtifact.Serialization.cs | 49 +++------------ ...UnknownDeliveryRuleAction.Serialization.cs | 34 +++------- ...nownDeliveryRuleCondition.Serialization.cs | 34 +++------- .../Models/UnknownPet.Serialization.cs | 39 +++--------- .../Models/UrlRedirectAction.Serialization.cs | 34 +++------- ...lRedirectActionParameters.Serialization.cs | 11 +++- .../Models/UrlRewriteAction.Serialization.cs | 34 +++------- ...rlRewriteActionParameters.Serialization.cs | 11 +++- .../Models/UrlSigningAction.Serialization.cs | 34 +++------- ...rlSigningActionParameters.Serialization.cs | 11 +++- ...UrlSigningParamIdentifier.Serialization.cs | 11 +++- .../src/Generated/Configuration.json | 1 + .../src/Generated/Configuration.json | 1 + .../src/Generated/Configuration.json | 1 + .../src/Generated/Configuration.json | 1 + .../src/Generated/Configuration.json | 1 + .../src/Generated/Configuration.json | 1 + .../MgmtLRO/src/Generated/Configuration.json | 1 + .../src/Generated/Configuration.json | 1 + .../src/Generated/Configuration.json | 1 + .../src/Generated/Configuration.json | 1 + .../src/Generated/Configuration.json | 1 + .../src/Generated/Configuration.json | 1 + .../src/Generated/Configuration.json | 1 + .../src/Generated/Configuration.json | 1 + .../src/Generated/Configuration.json | 1 + .../src/Generated/Configuration.json | 1 + .../src/Generated/Configuration.json | 1 + .../src/Generated/Configuration.json | 1 + .../src/Generated/Configuration.json | 1 + .../src/Generated/Configuration.json | 1 + .../src/Generated/Configuration.json | 1 + .../src/Generated/Configuration.json | 1 + .../src/Generated/Configuration.json | 1 + .../src/Generated/Configuration.json | 1 + .../src/Generated/Configuration.json | 1 + .../src/Generated/Configuration.json | 1 + .../src/Generated/Configuration.json | 1 + .../MgmtTypeSpec/Configuration.json | 3 +- .../src/Generated/Configuration.json | 1 + .../Models/XmlCollection.Serialization.cs | 11 +++- .../XmlInstanceData.Serialization.cs | 47 +++----------- 269 files changed, 2163 insertions(+), 2615 deletions(-) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/AvailabilitySetData.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/AvailabilitySetData.Serialization.cs index 8f4a358c5fa..bbbd3e73199 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/AvailabilitySetData.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/AvailabilitySetData.Serialization.cs @@ -24,6 +24,15 @@ public partial class AvailabilitySetData : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -31,45 +40,12 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWri throw new FormatException($"The model {nameof(AvailabilitySetData)} does not support writing '{format}' format."); } - writer.WriteStartObject(); + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(Sku)) { writer.WritePropertyName("sku"u8); writer.WriteObjectValue(Sku, options); } - if (Optional.IsCollectionDefined(Tags)) - { - writer.WritePropertyName("tags"u8); - writer.WriteStartObject(); - foreach (var item in Tags) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - writer.WritePropertyName("location"u8); - writer.WriteStringValue(Location); - if (options.Format != "W") - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (options.Format != "W") - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (options.Format != "W") - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(ResourceType); - } - if (options.Format != "W" && Optional.IsDefined(SystemData)) - { - writer.WritePropertyName("systemData"u8); - JsonSerializer.Serialize(writer, SystemData); - } writer.WritePropertyName("properties"u8); writer.WriteStartObject(); if (Optional.IsDefined(PlatformUpdateDomainCount)) @@ -108,22 +84,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWri writer.WriteEndArray(); } writer.WriteEndObject(); - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } AvailabilitySetData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Configuration.json b/samples/AzureSample.ResourceManager.Sample/src/Generated/Configuration.json index 096638edd94..2bd0ae439ab 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Configuration.json +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Configuration.json @@ -10,6 +10,7 @@ "public-clients": true, "skip-csproj-packagereference": true, "use-model-reader-writer": true, + "use-write-core": true, "enable-bicep-serialization": true, "KeepOrphanedModels": [ "AvailabilitySetSkuType" diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/DedicatedHostData.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/DedicatedHostData.Serialization.cs index 827093cc6a5..282a8fe24d5 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/DedicatedHostData.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/DedicatedHostData.Serialization.cs @@ -24,6 +24,15 @@ public partial class DedicatedHostData : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -31,42 +40,9 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrite throw new FormatException($"The model {nameof(DedicatedHostData)} does not support writing '{format}' format."); } - writer.WriteStartObject(); + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("sku"u8); writer.WriteObjectValue(Sku, options); - if (Optional.IsCollectionDefined(Tags)) - { - writer.WritePropertyName("tags"u8); - writer.WriteStartObject(); - foreach (var item in Tags) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - writer.WritePropertyName("location"u8); - writer.WriteStringValue(Location); - if (options.Format != "W") - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (options.Format != "W") - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (options.Format != "W") - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(ResourceType); - } - if (options.Format != "W" && Optional.IsDefined(SystemData)) - { - writer.WritePropertyName("systemData"u8); - JsonSerializer.Serialize(writer, SystemData); - } writer.WritePropertyName("properties"u8); writer.WriteStartObject(); if (Optional.IsDefined(PlatformFaultDomain)) @@ -115,22 +91,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrite writer.WriteObjectValue(InstanceView, options); } writer.WriteEndObject(); - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } DedicatedHostData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/DedicatedHostGroupData.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/DedicatedHostGroupData.Serialization.cs index 9c9c5883dde..e0a38816f77 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/DedicatedHostGroupData.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/DedicatedHostGroupData.Serialization.cs @@ -24,6 +24,15 @@ public partial class DedicatedHostGroupData : IUtf8JsonSerializable, IJsonModel< void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -31,7 +40,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReader throw new FormatException($"The model {nameof(DedicatedHostGroupData)} does not support writing '{format}' format."); } - writer.WriteStartObject(); + base.JsonModelWriteCore(writer, options); if (Optional.IsCollectionDefined(Zones)) { writer.WritePropertyName("zones"u8); @@ -62,39 +71,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReader writer.WritePropertyName("tenantId"u8); writer.WriteStringValue(TenantId.Value); } - if (Optional.IsCollectionDefined(Tags)) - { - writer.WritePropertyName("tags"u8); - writer.WriteStartObject(); - foreach (var item in Tags) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - writer.WritePropertyName("location"u8); - writer.WriteStringValue(Location); - if (options.Format != "W") - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (options.Format != "W") - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (options.Format != "W") - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(ResourceType); - } - if (options.Format != "W" && Optional.IsDefined(SystemData)) - { - writer.WritePropertyName("systemData"u8); - JsonSerializer.Serialize(writer, SystemData); - } writer.WritePropertyName("properties"u8); writer.WriteStartObject(); if (Optional.IsDefined(PlatformFaultDomainCount)) @@ -123,22 +99,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReader writer.WriteBooleanValue(SupportAutomaticPlacement.Value); } writer.WriteEndObject(); - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } DedicatedHostGroupData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/ImageData.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/ImageData.Serialization.cs index 4528aa38aa8..27bddd11d18 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/ImageData.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/ImageData.Serialization.cs @@ -24,6 +24,15 @@ public partial class ImageData : IUtf8JsonSerializable, IJsonModel void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -31,40 +40,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions throw new FormatException($"The model {nameof(ImageData)} does not support writing '{format}' format."); } - writer.WriteStartObject(); - if (Optional.IsCollectionDefined(Tags)) - { - writer.WritePropertyName("tags"u8); - writer.WriteStartObject(); - foreach (var item in Tags) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - writer.WritePropertyName("location"u8); - writer.WriteStringValue(Location); - if (options.Format != "W") - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (options.Format != "W") - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (options.Format != "W") - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(ResourceType); - } - if (options.Format != "W" && Optional.IsDefined(SystemData)) - { - writer.WritePropertyName("systemData"u8); - JsonSerializer.Serialize(writer, SystemData); - } + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("properties"u8); writer.WriteStartObject(); if (Optional.IsDefined(SourceVirtualMachine)) @@ -88,22 +64,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions writer.WriteStringValue(HyperVGeneration.Value.ToString()); } writer.WriteEndObject(); - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } ImageData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AdditionalCapabilities.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AdditionalCapabilities.Serialization.cs index 51eceaec38f..e517927dfcc 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AdditionalCapabilities.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AdditionalCapabilities.Serialization.cs @@ -20,6 +20,15 @@ internal partial class AdditionalCapabilities : IUtf8JsonSerializable, IJsonMode void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReader throw new FormatException($"The model {nameof(AdditionalCapabilities)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(UltraSSDEnabled)) { writer.WritePropertyName("ultraSSDEnabled"u8); @@ -48,7 +56,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReader #endif } } - writer.WriteEndObject(); } AdditionalCapabilities IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AdditionalUnattendContent.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AdditionalUnattendContent.Serialization.cs index ea420844c17..f4117ac7e40 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AdditionalUnattendContent.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AdditionalUnattendContent.Serialization.cs @@ -20,6 +20,15 @@ public partial class AdditionalUnattendContent : IUtf8JsonSerializable, IJsonMod void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRea throw new FormatException($"The model {nameof(AdditionalUnattendContent)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(PassName)) { writer.WritePropertyName("passName"u8); @@ -63,7 +71,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRea #endif } } - writer.WriteEndObject(); } AdditionalUnattendContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ApiError.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ApiError.Serialization.cs index 8639d5e7073..07ea875fe23 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ApiError.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ApiError.Serialization.cs @@ -21,6 +21,15 @@ public partial class ApiError : IUtf8JsonSerializable, IJsonModel void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions throw new FormatException($"The model {nameof(ApiError)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsCollectionDefined(Details)) { writer.WritePropertyName("details"u8); @@ -74,7 +82,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions #endif } } - writer.WriteEndObject(); } ApiError IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ApiErrorBase.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ApiErrorBase.Serialization.cs index c9bcd907835..34e68d22b93 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ApiErrorBase.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ApiErrorBase.Serialization.cs @@ -20,6 +20,15 @@ public partial class ApiErrorBase : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOpti throw new FormatException($"The model {nameof(ApiErrorBase)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(Code)) { writer.WritePropertyName("code"u8); @@ -58,7 +66,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOpti #endif } } - writer.WriteEndObject(); } ApiErrorBase IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AutomaticOSUpgradePolicy.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AutomaticOSUpgradePolicy.Serialization.cs index 9842efd32cb..ac7e6e485c0 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AutomaticOSUpgradePolicy.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AutomaticOSUpgradePolicy.Serialization.cs @@ -20,6 +20,15 @@ public partial class AutomaticOSUpgradePolicy : IUtf8JsonSerializable, IJsonMode void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRead throw new FormatException($"The model {nameof(AutomaticOSUpgradePolicy)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(EnableAutomaticOSUpgrade)) { writer.WritePropertyName("enableAutomaticOSUpgrade"u8); @@ -53,7 +61,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRead #endif } } - writer.WriteEndObject(); } AutomaticOSUpgradePolicy IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AutomaticOSUpgradeProperties.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AutomaticOSUpgradeProperties.Serialization.cs index f02d9fed6b7..39e3a96073c 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AutomaticOSUpgradeProperties.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AutomaticOSUpgradeProperties.Serialization.cs @@ -20,6 +20,15 @@ internal partial class AutomaticOSUpgradeProperties : IUtf8JsonSerializable, IJs void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, Model throw new FormatException($"The model {nameof(AutomaticOSUpgradeProperties)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("automaticOSUpgradeSupported"u8); writer.WriteBooleanValue(AutomaticOSUpgradeSupported); if (options.Format != "W" && _serializedAdditionalRawData != null) @@ -45,7 +53,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, Model #endif } } - writer.WriteEndObject(); } AutomaticOSUpgradeProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AutomaticRepairsPolicy.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AutomaticRepairsPolicy.Serialization.cs index 9850a48e3ab..5658c76abee 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AutomaticRepairsPolicy.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AutomaticRepairsPolicy.Serialization.cs @@ -20,6 +20,15 @@ public partial class AutomaticRepairsPolicy : IUtf8JsonSerializable, IJsonModel< void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReader throw new FormatException($"The model {nameof(AutomaticRepairsPolicy)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(Enabled)) { writer.WritePropertyName("enabled"u8); @@ -53,7 +61,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReader #endif } } - writer.WriteEndObject(); } AutomaticRepairsPolicy IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AvailabilitySetListResult.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AvailabilitySetListResult.Serialization.cs index b200cf99d0e..730a574337c 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AvailabilitySetListResult.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AvailabilitySetListResult.Serialization.cs @@ -21,6 +21,15 @@ internal partial class AvailabilitySetListResult : IUtf8JsonSerializable, IJsonM void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRea throw new FormatException($"The model {nameof(AvailabilitySetListResult)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("value"u8); writer.WriteStartArray(); foreach (var item in Value) @@ -56,7 +64,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRea #endif } } - writer.WriteEndObject(); } AvailabilitySetListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AvailabilitySetPatch.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AvailabilitySetPatch.Serialization.cs index aa7384ea0d9..8c1c013afe7 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AvailabilitySetPatch.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AvailabilitySetPatch.Serialization.cs @@ -19,6 +19,15 @@ public partial class AvailabilitySetPatch : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -26,23 +35,12 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWr throw new FormatException($"The model {nameof(AvailabilitySetPatch)} does not support writing '{format}' format."); } - writer.WriteStartObject(); + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(Sku)) { writer.WritePropertyName("sku"u8); writer.WriteObjectValue(Sku, options); } - if (Optional.IsCollectionDefined(Tags)) - { - writer.WritePropertyName("tags"u8); - writer.WriteStartObject(); - foreach (var item in Tags) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } writer.WritePropertyName("properties"u8); writer.WriteStartObject(); if (Optional.IsDefined(PlatformUpdateDomainCount)) @@ -81,22 +79,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWr writer.WriteEndArray(); } writer.WriteEndObject(); - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } AvailabilitySetPatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AvailablePatchSummary.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AvailablePatchSummary.Serialization.cs index d6b6d6cb964..5bee2cddcaf 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AvailablePatchSummary.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AvailablePatchSummary.Serialization.cs @@ -20,6 +20,15 @@ public partial class AvailablePatchSummary : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderW throw new FormatException($"The model {nameof(AvailablePatchSummary)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (options.Format != "W" && Optional.IsDefined(Status)) { writer.WritePropertyName("status"u8); @@ -83,7 +91,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderW #endif } } - writer.WriteEndObject(); } AvailablePatchSummary IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AzureSampleResourceManagerSamplePlan.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AzureSampleResourceManagerSamplePlan.Serialization.cs index 26636470068..cd01219268c 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AzureSampleResourceManagerSamplePlan.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AzureSampleResourceManagerSamplePlan.Serialization.cs @@ -20,6 +20,15 @@ public partial class AzureSampleResourceManagerSamplePlan : IUtf8JsonSerializabl void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter write throw new FormatException($"The model {nameof(AzureSampleResourceManagerSamplePlan)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(Name)) { writer.WritePropertyName("name"u8); @@ -63,7 +71,6 @@ void IJsonModel.Write(Utf8JsonWriter write #endif } } - writer.WriteEndObject(); } AzureSampleResourceManagerSamplePlan IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AzureSampleResourceManagerSampleSku.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AzureSampleResourceManagerSampleSku.Serialization.cs index 236e88c8f8b..f45df8ee807 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AzureSampleResourceManagerSampleSku.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AzureSampleResourceManagerSampleSku.Serialization.cs @@ -20,6 +20,15 @@ public partial class AzureSampleResourceManagerSampleSku : IUtf8JsonSerializable void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer throw new FormatException($"The model {nameof(AzureSampleResourceManagerSampleSku)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(Name)) { writer.WritePropertyName("name"u8); @@ -58,7 +66,6 @@ void IJsonModel.Write(Utf8JsonWriter writer #endif } } - writer.WriteEndObject(); } AzureSampleResourceManagerSampleSku IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AzureSampleResourceManagerSampleUsage.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AzureSampleResourceManagerSampleUsage.Serialization.cs index 0073d0bb7ba..2e6f28877f9 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AzureSampleResourceManagerSampleUsage.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AzureSampleResourceManagerSampleUsage.Serialization.cs @@ -20,6 +20,15 @@ public partial class AzureSampleResourceManagerSampleUsage : IUtf8JsonSerializab void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writ throw new FormatException($"The model {nameof(AzureSampleResourceManagerSampleUsage)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("unit"u8); writer.WriteStringValue(Unit.ToString()); writer.WritePropertyName("currentValue"u8); @@ -51,7 +59,6 @@ void IJsonModel.Write(Utf8JsonWriter writ #endif } } - writer.WriteEndObject(); } AzureSampleResourceManagerSampleUsage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AzureSampleResourceManagerSampleUsageName.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AzureSampleResourceManagerSampleUsageName.Serialization.cs index 45bdfb86a45..ee82295b77d 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AzureSampleResourceManagerSampleUsageName.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AzureSampleResourceManagerSampleUsageName.Serialization.cs @@ -20,6 +20,15 @@ public partial class AzureSampleResourceManagerSampleUsageName : IUtf8JsonSerial void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter throw new FormatException($"The model {nameof(AzureSampleResourceManagerSampleUsageName)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(Value)) { writer.WritePropertyName("value"u8); @@ -53,7 +61,6 @@ void IJsonModel.Write(Utf8JsonWriter #endif } } - writer.WriteEndObject(); } AzureSampleResourceManagerSampleUsageName IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/BillingProfile.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/BillingProfile.Serialization.cs index 8ef185c22f6..0f2dc763818 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/BillingProfile.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/BillingProfile.Serialization.cs @@ -20,6 +20,15 @@ internal partial class BillingProfile : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOp throw new FormatException($"The model {nameof(BillingProfile)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(MaxPrice)) { writer.WritePropertyName("maxPrice"u8); @@ -48,7 +56,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOp #endif } } - writer.WriteEndObject(); } BillingProfile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/BootDiagnostics.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/BootDiagnostics.Serialization.cs index cb1baa11abe..f05a110a275 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/BootDiagnostics.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/BootDiagnostics.Serialization.cs @@ -20,6 +20,15 @@ public partial class BootDiagnostics : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterO throw new FormatException($"The model {nameof(BootDiagnostics)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(Enabled)) { writer.WritePropertyName("enabled"u8); @@ -53,7 +61,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterO #endif } } - writer.WriteEndObject(); } BootDiagnostics IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/BootDiagnosticsInstanceView.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/BootDiagnosticsInstanceView.Serialization.cs index fe824fcb43d..855da9f4295 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/BootDiagnosticsInstanceView.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/BootDiagnosticsInstanceView.Serialization.cs @@ -20,6 +20,15 @@ public partial class BootDiagnosticsInstanceView : IUtf8JsonSerializable, IJsonM void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelR throw new FormatException($"The model {nameof(BootDiagnosticsInstanceView)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (options.Format != "W" && Optional.IsDefined(ConsoleScreenshotBlobUri)) { writer.WritePropertyName("consoleScreenshotBlobUri"u8); @@ -58,7 +66,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelR #endif } } - writer.WriteEndObject(); } BootDiagnosticsInstanceView IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DataDisk.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DataDisk.Serialization.cs index 8881edf7181..36b3ec3119d 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DataDisk.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DataDisk.Serialization.cs @@ -20,6 +20,15 @@ public partial class DataDisk : IUtf8JsonSerializable, IJsonModel void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions throw new FormatException($"The model {nameof(DataDisk)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("lun"u8); writer.WriteNumberValue(Lun); if (Optional.IsDefined(Name)) @@ -97,7 +105,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions #endif } } - writer.WriteEndObject(); } DataDisk IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DataDiskImage.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DataDiskImage.Serialization.cs index 68660c73202..fa9d26ceb88 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DataDiskImage.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DataDiskImage.Serialization.cs @@ -20,6 +20,15 @@ public partial class DataDiskImage : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOpt throw new FormatException($"The model {nameof(DataDiskImage)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (options.Format != "W" && Optional.IsDefined(Lun)) { writer.WritePropertyName("lun"u8); @@ -48,7 +56,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOpt #endif } } - writer.WriteEndObject(); } DataDiskImage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DedicatedHostAllocatableVm.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DedicatedHostAllocatableVm.Serialization.cs index 17d767390f2..2cea637bac0 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DedicatedHostAllocatableVm.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DedicatedHostAllocatableVm.Serialization.cs @@ -20,6 +20,15 @@ public partial class DedicatedHostAllocatableVm : IUtf8JsonSerializable, IJsonMo void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRe throw new FormatException($"The model {nameof(DedicatedHostAllocatableVm)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(VmSize)) { writer.WritePropertyName("vmSize"u8); @@ -53,7 +61,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRe #endif } } - writer.WriteEndObject(); } DedicatedHostAllocatableVm IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DedicatedHostAvailableCapacity.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DedicatedHostAvailableCapacity.Serialization.cs index ca1ec46e36b..ac7d91a106d 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DedicatedHostAvailableCapacity.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DedicatedHostAvailableCapacity.Serialization.cs @@ -21,6 +21,15 @@ internal partial class DedicatedHostAvailableCapacity : IUtf8JsonSerializable, I void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mod throw new FormatException($"The model {nameof(DedicatedHostAvailableCapacity)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsCollectionDefined(AllocatableVms)) { writer.WritePropertyName("allocatableVMs"u8); @@ -54,7 +62,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mod #endif } } - writer.WriteEndObject(); } DedicatedHostAvailableCapacity IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DedicatedHostGroupInstanceView.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DedicatedHostGroupInstanceView.Serialization.cs index 3851be1d988..34c5362caab 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DedicatedHostGroupInstanceView.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DedicatedHostGroupInstanceView.Serialization.cs @@ -21,6 +21,15 @@ internal partial class DedicatedHostGroupInstanceView : IUtf8JsonSerializable, I void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mod throw new FormatException($"The model {nameof(DedicatedHostGroupInstanceView)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsCollectionDefined(Hosts)) { writer.WritePropertyName("hosts"u8); @@ -54,7 +62,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mod #endif } } - writer.WriteEndObject(); } DedicatedHostGroupInstanceView IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DedicatedHostGroupListResult.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DedicatedHostGroupListResult.Serialization.cs index 54f0db2549f..c6ed3ee555b 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DedicatedHostGroupListResult.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DedicatedHostGroupListResult.Serialization.cs @@ -21,6 +21,15 @@ internal partial class DedicatedHostGroupListResult : IUtf8JsonSerializable, IJs void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, Model throw new FormatException($"The model {nameof(DedicatedHostGroupListResult)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("value"u8); writer.WriteStartArray(); foreach (var item in Value) @@ -56,7 +64,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, Model #endif } } - writer.WriteEndObject(); } DedicatedHostGroupListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DedicatedHostGroupPatch.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DedicatedHostGroupPatch.Serialization.cs index de4c5b988d5..4fbbee3989d 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DedicatedHostGroupPatch.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DedicatedHostGroupPatch.Serialization.cs @@ -19,6 +19,15 @@ public partial class DedicatedHostGroupPatch : IUtf8JsonSerializable, IJsonModel void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -26,7 +35,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReade throw new FormatException($"The model {nameof(DedicatedHostGroupPatch)} does not support writing '{format}' format."); } - writer.WriteStartObject(); + base.JsonModelWriteCore(writer, options); if (Optional.IsCollectionDefined(Zones)) { writer.WritePropertyName("zones"u8); @@ -37,17 +46,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReade } writer.WriteEndArray(); } - if (Optional.IsCollectionDefined(Tags)) - { - writer.WritePropertyName("tags"u8); - writer.WriteStartObject(); - foreach (var item in Tags) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } writer.WritePropertyName("properties"u8); writer.WriteStartObject(); if (Optional.IsDefined(PlatformFaultDomainCount)) @@ -76,22 +74,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReade writer.WriteBooleanValue(SupportAutomaticPlacement.Value); } writer.WriteEndObject(); - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } DedicatedHostGroupPatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DedicatedHostInstanceView.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DedicatedHostInstanceView.Serialization.cs index c0d79ff229d..a036f529bd0 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DedicatedHostInstanceView.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DedicatedHostInstanceView.Serialization.cs @@ -21,6 +21,15 @@ public partial class DedicatedHostInstanceView : IUtf8JsonSerializable, IJsonMod void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRea throw new FormatException($"The model {nameof(DedicatedHostInstanceView)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (options.Format != "W" && Optional.IsDefined(AssetId)) { writer.WritePropertyName("assetId"u8); @@ -64,7 +72,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRea #endif } } - writer.WriteEndObject(); } DedicatedHostInstanceView IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DedicatedHostInstanceViewWithName.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DedicatedHostInstanceViewWithName.Serialization.cs index 8d3b9a5b75b..2bd1b4f5bf7 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DedicatedHostInstanceViewWithName.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DedicatedHostInstanceViewWithName.Serialization.cs @@ -21,6 +21,15 @@ public partial class DedicatedHostInstanceViewWithName : IUtf8JsonSerializable, void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,48 +37,12 @@ void IJsonModel.Write(Utf8JsonWriter writer, throw new FormatException($"The model {nameof(DedicatedHostInstanceViewWithName)} does not support writing '{format}' format."); } - writer.WriteStartObject(); + base.JsonModelWriteCore(writer, options); if (options.Format != "W" && Optional.IsDefined(Name)) { writer.WritePropertyName("name"u8); writer.WriteStringValue(Name); } - if (options.Format != "W" && Optional.IsDefined(AssetId)) - { - writer.WritePropertyName("assetId"u8); - writer.WriteStringValue(AssetId); - } - if (Optional.IsDefined(AvailableCapacity)) - { - writer.WritePropertyName("availableCapacity"u8); - writer.WriteObjectValue(AvailableCapacity, options); - } - if (Optional.IsCollectionDefined(Statuses)) - { - writer.WritePropertyName("statuses"u8); - writer.WriteStartArray(); - foreach (var item in Statuses) - { - writer.WriteObjectValue(item, options); - } - writer.WriteEndArray(); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } DedicatedHostInstanceViewWithName IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DedicatedHostListResult.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DedicatedHostListResult.Serialization.cs index 57c28765ffa..4c36dd0231a 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DedicatedHostListResult.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DedicatedHostListResult.Serialization.cs @@ -21,6 +21,15 @@ internal partial class DedicatedHostListResult : IUtf8JsonSerializable, IJsonMod void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReade throw new FormatException($"The model {nameof(DedicatedHostListResult)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("value"u8); writer.WriteStartArray(); foreach (var item in Value) @@ -56,7 +64,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReade #endif } } - writer.WriteEndObject(); } DedicatedHostListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DedicatedHostPatch.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DedicatedHostPatch.Serialization.cs index 879111cd2c6..5f0e3793a3f 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DedicatedHostPatch.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DedicatedHostPatch.Serialization.cs @@ -19,6 +19,15 @@ public partial class DedicatedHostPatch : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -26,18 +35,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrit throw new FormatException($"The model {nameof(DedicatedHostPatch)} does not support writing '{format}' format."); } - writer.WriteStartObject(); - if (Optional.IsCollectionDefined(Tags)) - { - writer.WritePropertyName("tags"u8); - writer.WriteStartObject(); - foreach (var item in Tags) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("properties"u8); writer.WriteStartObject(); if (Optional.IsDefined(PlatformFaultDomain)) @@ -86,22 +84,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrit writer.WriteObjectValue(InstanceView, options); } writer.WriteEndObject(); - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } DedicatedHostPatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DiagnosticsProfile.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DiagnosticsProfile.Serialization.cs index 3dc5c6b4bf6..57063e84654 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DiagnosticsProfile.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DiagnosticsProfile.Serialization.cs @@ -20,6 +20,15 @@ internal partial class DiagnosticsProfile : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrit throw new FormatException($"The model {nameof(DiagnosticsProfile)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(BootDiagnostics)) { writer.WritePropertyName("bootDiagnostics"u8); @@ -48,7 +56,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrit #endif } } - writer.WriteEndObject(); } DiagnosticsProfile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DiffDiskSettings.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DiffDiskSettings.Serialization.cs index 47c207db2e5..f45868e371c 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DiffDiskSettings.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DiffDiskSettings.Serialization.cs @@ -20,6 +20,15 @@ public partial class DiffDiskSettings : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriter throw new FormatException($"The model {nameof(DiffDiskSettings)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(Option)) { writer.WritePropertyName("option"u8); @@ -53,7 +61,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriter #endif } } - writer.WriteEndObject(); } DiffDiskSettings IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DisallowedConfiguration.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DisallowedConfiguration.Serialization.cs index adee5eaf93f..fdbb294954c 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DisallowedConfiguration.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DisallowedConfiguration.Serialization.cs @@ -20,6 +20,15 @@ internal partial class DisallowedConfiguration : IUtf8JsonSerializable, IJsonMod void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReade throw new FormatException($"The model {nameof(DisallowedConfiguration)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(VmDiskType)) { writer.WritePropertyName("vmDiskType"u8); @@ -48,7 +56,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReade #endif } } - writer.WriteEndObject(); } DisallowedConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DiskEncryptionSettings.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DiskEncryptionSettings.Serialization.cs index 6f2a035e8ea..1b4aa07a8da 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DiskEncryptionSettings.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DiskEncryptionSettings.Serialization.cs @@ -20,6 +20,15 @@ public partial class DiskEncryptionSettings : IUtf8JsonSerializable, IJsonModel< void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReader throw new FormatException($"The model {nameof(DiskEncryptionSettings)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(DiskEncryptionKey)) { writer.WritePropertyName("diskEncryptionKey"u8); @@ -58,7 +66,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReader #endif } } - writer.WriteEndObject(); } DiskEncryptionSettings IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DiskInstanceView.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DiskInstanceView.Serialization.cs index 497b89cb664..eef22dd177e 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DiskInstanceView.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DiskInstanceView.Serialization.cs @@ -21,6 +21,15 @@ public partial class DiskInstanceView : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriter throw new FormatException($"The model {nameof(DiskInstanceView)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(Name)) { writer.WritePropertyName("name"u8); @@ -69,7 +77,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriter #endif } } - writer.WriteEndObject(); } DiskInstanceView IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/HardwareProfile.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/HardwareProfile.Serialization.cs index f0418b28a14..a53c0dfdcd5 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/HardwareProfile.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/HardwareProfile.Serialization.cs @@ -20,6 +20,15 @@ internal partial class HardwareProfile : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterO throw new FormatException($"The model {nameof(HardwareProfile)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(VmSize)) { writer.WritePropertyName("vmSize"u8); @@ -48,7 +56,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterO #endif } } - writer.WriteEndObject(); } HardwareProfile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ImageDataDisk.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ImageDataDisk.Serialization.cs index 888188fea8b..4f1434818fa 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ImageDataDisk.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ImageDataDisk.Serialization.cs @@ -21,6 +21,15 @@ public partial class ImageDataDisk : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,60 +37,9 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOpt throw new FormatException($"The model {nameof(ImageDataDisk)} does not support writing '{format}' format."); } - writer.WriteStartObject(); + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("lun"u8); writer.WriteNumberValue(Lun); - if (Optional.IsDefined(Snapshot)) - { - writer.WritePropertyName("snapshot"u8); - JsonSerializer.Serialize(writer, Snapshot); - } - if (Optional.IsDefined(ManagedDisk)) - { - writer.WritePropertyName("managedDisk"u8); - JsonSerializer.Serialize(writer, ManagedDisk); - } - if (Optional.IsDefined(BlobUri)) - { - writer.WritePropertyName("blobUri"u8); - writer.WriteStringValue(BlobUri.AbsoluteUri); - } - if (Optional.IsDefined(Caching)) - { - writer.WritePropertyName("caching"u8); - writer.WriteStringValue(Caching.Value.ToSerialString()); - } - if (Optional.IsDefined(DiskSizeGB)) - { - writer.WritePropertyName("diskSizeGB"u8); - writer.WriteNumberValue(DiskSizeGB.Value); - } - if (Optional.IsDefined(StorageAccountType)) - { - writer.WritePropertyName("storageAccountType"u8); - writer.WriteStringValue(StorageAccountType.Value.ToString()); - } - if (Optional.IsDefined(DiskEncryptionSet)) - { - writer.WritePropertyName("diskEncryptionSet"u8); - JsonSerializer.Serialize(writer, DiskEncryptionSet); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } ImageDataDisk IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ImageDisk.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ImageDisk.Serialization.cs index 1d5a7403d75..36bb6bedcd5 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ImageDisk.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ImageDisk.Serialization.cs @@ -21,6 +21,15 @@ public partial class ImageDisk : IUtf8JsonSerializable, IJsonModel void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions throw new FormatException($"The model {nameof(ImageDisk)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(Snapshot)) { writer.WritePropertyName("snapshot"u8); @@ -79,7 +87,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions #endif } } - writer.WriteEndObject(); } ImageDisk IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ImageListResult.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ImageListResult.Serialization.cs index bd929bba217..83b64166273 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ImageListResult.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ImageListResult.Serialization.cs @@ -21,6 +21,15 @@ internal partial class ImageListResult : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterO throw new FormatException($"The model {nameof(ImageListResult)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("value"u8); writer.WriteStartArray(); foreach (var item in Images) @@ -56,7 +64,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterO #endif } } - writer.WriteEndObject(); } ImageListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ImageOSDisk.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ImageOSDisk.Serialization.cs index e469a68128e..ac51791de7a 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ImageOSDisk.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ImageOSDisk.Serialization.cs @@ -21,6 +21,15 @@ public partial class ImageOSDisk : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,62 +37,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptio throw new FormatException($"The model {nameof(ImageOSDisk)} does not support writing '{format}' format."); } - writer.WriteStartObject(); + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("osType"u8); writer.WriteStringValue(OSType.ToSerialString()); writer.WritePropertyName("osState"u8); writer.WriteStringValue(OSState.ToSerialString()); - if (Optional.IsDefined(Snapshot)) - { - writer.WritePropertyName("snapshot"u8); - JsonSerializer.Serialize(writer, Snapshot); - } - if (Optional.IsDefined(ManagedDisk)) - { - writer.WritePropertyName("managedDisk"u8); - JsonSerializer.Serialize(writer, ManagedDisk); - } - if (Optional.IsDefined(BlobUri)) - { - writer.WritePropertyName("blobUri"u8); - writer.WriteStringValue(BlobUri.AbsoluteUri); - } - if (Optional.IsDefined(Caching)) - { - writer.WritePropertyName("caching"u8); - writer.WriteStringValue(Caching.Value.ToSerialString()); - } - if (Optional.IsDefined(DiskSizeGB)) - { - writer.WritePropertyName("diskSizeGB"u8); - writer.WriteNumberValue(DiskSizeGB.Value); - } - if (Optional.IsDefined(StorageAccountType)) - { - writer.WritePropertyName("storageAccountType"u8); - writer.WriteStringValue(StorageAccountType.Value.ToString()); - } - if (Optional.IsDefined(DiskEncryptionSet)) - { - writer.WritePropertyName("diskEncryptionSet"u8); - JsonSerializer.Serialize(writer, DiskEncryptionSet); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } ImageOSDisk IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ImagePatch.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ImagePatch.Serialization.cs index 3edc017f96b..c26d4c4ba59 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ImagePatch.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ImagePatch.Serialization.cs @@ -19,6 +19,15 @@ public partial class ImagePatch : IUtf8JsonSerializable, IJsonModel void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -26,18 +35,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOption throw new FormatException($"The model {nameof(ImagePatch)} does not support writing '{format}' format."); } - writer.WriteStartObject(); - if (Optional.IsCollectionDefined(Tags)) - { - writer.WritePropertyName("tags"u8); - writer.WriteStartObject(); - foreach (var item in Tags) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("properties"u8); writer.WriteStartObject(); if (Optional.IsDefined(SourceVirtualMachine)) @@ -61,22 +59,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOption writer.WriteStringValue(HyperVGeneration.Value.ToString()); } writer.WriteEndObject(); - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } ImagePatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ImageReference.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ImageReference.Serialization.cs index d3dbe069a04..e56fe6ae964 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ImageReference.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ImageReference.Serialization.cs @@ -20,6 +20,15 @@ public partial class ImageReference : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOp throw new FormatException($"The model {nameof(ImageReference)} does not support writing '{format}' format."); } - writer.WriteStartObject(); + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(Publisher)) { writer.WritePropertyName("publisher"u8); @@ -53,27 +62,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOp writer.WritePropertyName("exactVersion"u8); writer.WriteStringValue(ExactVersion); } - if (Optional.IsDefined(Id)) - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } ImageReference IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ImageStorageProfile.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ImageStorageProfile.Serialization.cs index dffc292e2fb..fff6f462a59 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ImageStorageProfile.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ImageStorageProfile.Serialization.cs @@ -21,6 +21,15 @@ public partial class ImageStorageProfile : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWri throw new FormatException($"The model {nameof(ImageStorageProfile)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(OSDisk)) { writer.WritePropertyName("osDisk"u8); @@ -64,7 +72,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWri #endif } } - writer.WriteEndObject(); } ImageStorageProfile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/InnerError.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/InnerError.Serialization.cs index d63a4b6f389..9e30a7b9755 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/InnerError.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/InnerError.Serialization.cs @@ -20,6 +20,15 @@ public partial class InnerError : IUtf8JsonSerializable, IJsonModel void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOption throw new FormatException($"The model {nameof(InnerError)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(Exceptiontype)) { writer.WritePropertyName("exceptiontype"u8); @@ -53,7 +61,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOption #endif } } - writer.WriteEndObject(); } InnerError IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/InstanceViewStatus.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/InstanceViewStatus.Serialization.cs index 2266ed6656f..e50502fa787 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/InstanceViewStatus.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/InstanceViewStatus.Serialization.cs @@ -20,6 +20,15 @@ public partial class InstanceViewStatus : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrit throw new FormatException($"The model {nameof(InstanceViewStatus)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(Code)) { writer.WritePropertyName("code"u8); @@ -68,7 +76,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrit #endif } } - writer.WriteEndObject(); } InstanceViewStatus IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/KeyVaultKeyReference.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/KeyVaultKeyReference.Serialization.cs index 1813f8bed2d..20bb4d040af 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/KeyVaultKeyReference.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/KeyVaultKeyReference.Serialization.cs @@ -21,6 +21,15 @@ public partial class KeyVaultKeyReference : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWr throw new FormatException($"The model {nameof(KeyVaultKeyReference)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("keyUrl"u8); writer.WriteStringValue(KeyUri.AbsoluteUri); writer.WritePropertyName("sourceVault"u8); @@ -48,7 +56,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWr #endif } } - writer.WriteEndObject(); } KeyVaultKeyReference IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/KeyVaultSecretReference.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/KeyVaultSecretReference.Serialization.cs index b90075c4551..19c22ad1a32 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/KeyVaultSecretReference.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/KeyVaultSecretReference.Serialization.cs @@ -21,6 +21,15 @@ public partial class KeyVaultSecretReference : IUtf8JsonSerializable, IJsonModel void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReade throw new FormatException($"The model {nameof(KeyVaultSecretReference)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("secretUrl"u8); writer.WriteStringValue(SecretUri.AbsoluteUri); writer.WritePropertyName("sourceVault"u8); @@ -48,7 +56,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReade #endif } } - writer.WriteEndObject(); } KeyVaultSecretReference IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/LastPatchInstallationSummary.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/LastPatchInstallationSummary.Serialization.cs index 9fcd14fca60..60a22997bc9 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/LastPatchInstallationSummary.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/LastPatchInstallationSummary.Serialization.cs @@ -20,6 +20,15 @@ public partial class LastPatchInstallationSummary : IUtf8JsonSerializable, IJson void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, Model throw new FormatException($"The model {nameof(LastPatchInstallationSummary)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (options.Format != "W" && Optional.IsDefined(Status)) { writer.WritePropertyName("status"u8); @@ -108,7 +116,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, Model #endif } } - writer.WriteEndObject(); } LastPatchInstallationSummary IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/LinuxConfiguration.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/LinuxConfiguration.Serialization.cs index 81ab683ad49..b4b248eabca 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/LinuxConfiguration.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/LinuxConfiguration.Serialization.cs @@ -20,6 +20,15 @@ public partial class LinuxConfiguration : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrit throw new FormatException($"The model {nameof(LinuxConfiguration)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(DisablePasswordAuthentication)) { writer.WritePropertyName("disablePasswordAuthentication"u8); @@ -58,7 +66,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrit #endif } } - writer.WriteEndObject(); } LinuxConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ListUsagesResult.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ListUsagesResult.Serialization.cs index 9d30ec531bc..0edaa7dc5ad 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ListUsagesResult.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ListUsagesResult.Serialization.cs @@ -21,6 +21,15 @@ internal partial class ListUsagesResult : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriter throw new FormatException($"The model {nameof(ListUsagesResult)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("value"u8); writer.WriteStartArray(); foreach (var item in Value) @@ -56,7 +64,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriter #endif } } - writer.WriteEndObject(); } ListUsagesResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/LogAnalytics.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/LogAnalytics.Serialization.cs index 2a7eb8cc4e3..3f7c4be3bfa 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/LogAnalytics.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/LogAnalytics.Serialization.cs @@ -20,6 +20,15 @@ public partial class LogAnalytics : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOpti throw new FormatException($"The model {nameof(LogAnalytics)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (options.Format != "W" && Optional.IsDefined(Properties)) { writer.WritePropertyName("properties"u8); @@ -48,7 +56,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOpti #endif } } - writer.WriteEndObject(); } LogAnalytics IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/LogAnalyticsInputBase.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/LogAnalyticsInputBase.Serialization.cs index 6e302d145be..c92886b87b2 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/LogAnalyticsInputBase.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/LogAnalyticsInputBase.Serialization.cs @@ -18,6 +18,15 @@ public partial class LogAnalyticsInputBase : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -25,7 +34,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderW throw new FormatException($"The model {nameof(LogAnalyticsInputBase)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("blobContainerSasUri"u8); writer.WriteStringValue(BlobContainerSasUri.AbsoluteUri); writer.WritePropertyName("fromTime"u8); @@ -62,7 +70,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderW #endif } } - writer.WriteEndObject(); } LogAnalyticsInputBase IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/LogAnalyticsOutput.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/LogAnalyticsOutput.Serialization.cs index 0f75ce21fc4..20f9ff42dcd 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/LogAnalyticsOutput.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/LogAnalyticsOutput.Serialization.cs @@ -20,6 +20,15 @@ internal partial class LogAnalyticsOutput : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrit throw new FormatException($"The model {nameof(LogAnalyticsOutput)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (options.Format != "W" && Optional.IsDefined(Output)) { writer.WritePropertyName("output"u8); @@ -48,7 +56,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrit #endif } } - writer.WriteEndObject(); } LogAnalyticsOutput IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/MaintenanceRedeployStatus.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/MaintenanceRedeployStatus.Serialization.cs index d37270dbb24..d6711d50ab0 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/MaintenanceRedeployStatus.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/MaintenanceRedeployStatus.Serialization.cs @@ -20,6 +20,15 @@ public partial class MaintenanceRedeployStatus : IUtf8JsonSerializable, IJsonMod void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRea throw new FormatException($"The model {nameof(MaintenanceRedeployStatus)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(IsCustomerInitiatedMaintenanceAllowed)) { writer.WritePropertyName("isCustomerInitiatedMaintenanceAllowed"u8); @@ -78,7 +86,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRea #endif } } - writer.WriteEndObject(); } MaintenanceRedeployStatus IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ManagedDiskParameters.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ManagedDiskParameters.Serialization.cs index d5466b096e0..adc92f0aeda 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ManagedDiskParameters.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ManagedDiskParameters.Serialization.cs @@ -21,6 +21,15 @@ public partial class ManagedDiskParameters : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderW throw new FormatException($"The model {nameof(ManagedDiskParameters)} does not support writing '{format}' format."); } - writer.WriteStartObject(); + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(StorageAccountType)) { writer.WritePropertyName("storageAccountType"u8); @@ -39,27 +48,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderW writer.WritePropertyName("diskEncryptionSet"u8); JsonSerializer.Serialize(writer, DiskEncryptionSet); } - if (Optional.IsDefined(Id)) - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } ManagedDiskParameters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/NetworkInterfaceReference.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/NetworkInterfaceReference.Serialization.cs index 9e0100c9078..cef66f2509c 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/NetworkInterfaceReference.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/NetworkInterfaceReference.Serialization.cs @@ -20,6 +20,15 @@ public partial class NetworkInterfaceReference : IUtf8JsonSerializable, IJsonMod void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,12 +36,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRea throw new FormatException($"The model {nameof(NetworkInterfaceReference)} does not support writing '{format}' format."); } - writer.WriteStartObject(); - if (Optional.IsDefined(Id)) - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("properties"u8); writer.WriteStartObject(); if (Optional.IsDefined(Primary)) @@ -41,22 +45,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRea writer.WriteBooleanValue(Primary.Value); } writer.WriteEndObject(); - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } NetworkInterfaceReference IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/NetworkProfile.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/NetworkProfile.Serialization.cs index 4e60c98c93d..ec12be915c6 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/NetworkProfile.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/NetworkProfile.Serialization.cs @@ -21,6 +21,15 @@ internal partial class NetworkProfile : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOp throw new FormatException($"The model {nameof(NetworkProfile)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsCollectionDefined(NetworkInterfaces)) { writer.WritePropertyName("networkInterfaces"u8); @@ -54,7 +62,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOp #endif } } - writer.WriteEndObject(); } NetworkProfile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/OSDisk.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/OSDisk.Serialization.cs index 1c6d803f007..2d326298a9d 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/OSDisk.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/OSDisk.Serialization.cs @@ -20,6 +20,15 @@ public partial class OSDisk : IUtf8JsonSerializable, IJsonModel void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions op throw new FormatException($"The model {nameof(OSDisk)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(OSType)) { writer.WritePropertyName("osType"u8); @@ -95,7 +103,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions op #endif } } - writer.WriteEndObject(); } OSDisk IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/OSDiskImage.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/OSDiskImage.Serialization.cs index 341f567c4e2..a816de56436 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/OSDiskImage.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/OSDiskImage.Serialization.cs @@ -20,6 +20,15 @@ internal partial class OSDiskImage : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptio throw new FormatException($"The model {nameof(OSDiskImage)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("operatingSystem"u8); writer.WriteStringValue(OperatingSystem.ToSerialString()); if (options.Format != "W" && _serializedAdditionalRawData != null) @@ -45,7 +53,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptio #endif } } - writer.WriteEndObject(); } OSDiskImage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/OSProfile.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/OSProfile.Serialization.cs index dab67e79ee0..418863115e1 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/OSProfile.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/OSProfile.Serialization.cs @@ -21,6 +21,15 @@ public partial class OSProfile : IUtf8JsonSerializable, IJsonModel void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions throw new FormatException($"The model {nameof(OSProfile)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(ComputerName)) { writer.WritePropertyName("computerName"u8); @@ -94,7 +102,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions #endif } } - writer.WriteEndObject(); } OSProfile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/OrchestrationServiceStateContent.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/OrchestrationServiceStateContent.Serialization.cs index 27e1d6d2064..41ac7f00c3e 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/OrchestrationServiceStateContent.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/OrchestrationServiceStateContent.Serialization.cs @@ -18,6 +18,15 @@ public partial class OrchestrationServiceStateContent : IUtf8JsonSerializable, I void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -25,7 +34,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, M throw new FormatException($"The model {nameof(OrchestrationServiceStateContent)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("serviceName"u8); writer.WriteStringValue(ServiceName.ToString()); writer.WritePropertyName("action"u8); @@ -45,7 +53,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, M #endif } } - writer.WriteEndObject(); } OrchestrationServiceStateContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/OrchestrationServiceSummary.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/OrchestrationServiceSummary.Serialization.cs index b4286bbe1c6..c84ccfd5c3b 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/OrchestrationServiceSummary.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/OrchestrationServiceSummary.Serialization.cs @@ -20,6 +20,15 @@ public partial class OrchestrationServiceSummary : IUtf8JsonSerializable, IJsonM void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelR throw new FormatException($"The model {nameof(OrchestrationServiceSummary)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (options.Format != "W" && Optional.IsDefined(ServiceName)) { writer.WritePropertyName("serviceName"u8); @@ -53,7 +61,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelR #endif } } - writer.WriteEndObject(); } OrchestrationServiceSummary IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/PatchSettings.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/PatchSettings.Serialization.cs index a792f7a2571..f9c816afa0e 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/PatchSettings.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/PatchSettings.Serialization.cs @@ -20,6 +20,15 @@ internal partial class PatchSettings : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOpt throw new FormatException($"The model {nameof(PatchSettings)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(PatchMode)) { writer.WritePropertyName("patchMode"u8); @@ -48,7 +56,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOpt #endif } } - writer.WriteEndObject(); } PatchSettings IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ProximityPlacementGroupListResult.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ProximityPlacementGroupListResult.Serialization.cs index d798e56185a..6c60bcb18f3 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ProximityPlacementGroupListResult.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ProximityPlacementGroupListResult.Serialization.cs @@ -21,6 +21,15 @@ internal partial class ProximityPlacementGroupListResult : IUtf8JsonSerializable void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, throw new FormatException($"The model {nameof(ProximityPlacementGroupListResult)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("value"u8); writer.WriteStartArray(); foreach (var item in Value) @@ -56,7 +64,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, #endif } } - writer.WriteEndObject(); } ProximityPlacementGroupListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ProximityPlacementGroupPatch.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ProximityPlacementGroupPatch.Serialization.cs index c8ae4b7aaa6..29597b26af1 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ProximityPlacementGroupPatch.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ProximityPlacementGroupPatch.Serialization.cs @@ -18,6 +18,15 @@ public partial class ProximityPlacementGroupPatch : IUtf8JsonSerializable, IJson void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -25,34 +34,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, Model throw new FormatException($"The model {nameof(ProximityPlacementGroupPatch)} does not support writing '{format}' format."); } - writer.WriteStartObject(); - if (Optional.IsCollectionDefined(Tags)) - { - writer.WritePropertyName("tags"u8); - writer.WriteStartObject(); - foreach (var item in Tags) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); + base.JsonModelWriteCore(writer, options); } ProximityPlacementGroupPatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/PurchasePlan.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/PurchasePlan.Serialization.cs index c460a882727..11dc1163002 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/PurchasePlan.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/PurchasePlan.Serialization.cs @@ -20,6 +20,15 @@ public partial class PurchasePlan : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOpti throw new FormatException($"The model {nameof(PurchasePlan)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("publisher"u8); writer.WriteStringValue(Publisher); writer.WritePropertyName("name"u8); @@ -49,7 +57,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOpti #endif } } - writer.WriteEndObject(); } PurchasePlan IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/RecoveryWalkResponse.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/RecoveryWalkResponse.Serialization.cs index fd41e007c05..cfbc75ab17f 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/RecoveryWalkResponse.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/RecoveryWalkResponse.Serialization.cs @@ -20,6 +20,15 @@ public partial class RecoveryWalkResponse : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWr throw new FormatException($"The model {nameof(RecoveryWalkResponse)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (options.Format != "W" && Optional.IsDefined(WalkPerformed)) { writer.WritePropertyName("walkPerformed"u8); @@ -53,7 +61,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWr #endif } } - writer.WriteEndObject(); } RecoveryWalkResponse IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/RequestRateByIntervalContent.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/RequestRateByIntervalContent.Serialization.cs index 000e5b7f7f7..7478331be63 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/RequestRateByIntervalContent.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/RequestRateByIntervalContent.Serialization.cs @@ -18,6 +18,15 @@ public partial class RequestRateByIntervalContent : IUtf8JsonSerializable, IJson void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -25,46 +34,9 @@ void IJsonModel.Write(Utf8JsonWriter writer, Model throw new FormatException($"The model {nameof(RequestRateByIntervalContent)} does not support writing '{format}' format."); } - writer.WriteStartObject(); + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("intervalLength"u8); writer.WriteStringValue(IntervalLength.ToSerialString()); - writer.WritePropertyName("blobContainerSasUri"u8); - writer.WriteStringValue(BlobContainerSasUri.AbsoluteUri); - writer.WritePropertyName("fromTime"u8); - writer.WriteStringValue(FromTime, "O"); - writer.WritePropertyName("toTime"u8); - writer.WriteStringValue(ToTime, "O"); - if (Optional.IsDefined(GroupByThrottlePolicy)) - { - writer.WritePropertyName("groupByThrottlePolicy"u8); - writer.WriteBooleanValue(GroupByThrottlePolicy.Value); - } - if (Optional.IsDefined(GroupByOperationName)) - { - writer.WritePropertyName("groupByOperationName"u8); - writer.WriteBooleanValue(GroupByOperationName.Value); - } - if (Optional.IsDefined(GroupByResourceName)) - { - writer.WritePropertyName("groupByResourceName"u8); - writer.WriteBooleanValue(GroupByResourceName.Value); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } RequestRateByIntervalContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/RetrieveBootDiagnosticsDataResult.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/RetrieveBootDiagnosticsDataResult.Serialization.cs index 9a98adbeaaf..55136d71c52 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/RetrieveBootDiagnosticsDataResult.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/RetrieveBootDiagnosticsDataResult.Serialization.cs @@ -20,6 +20,15 @@ public partial class RetrieveBootDiagnosticsDataResult : IUtf8JsonSerializable, void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, throw new FormatException($"The model {nameof(RetrieveBootDiagnosticsDataResult)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (options.Format != "W" && Optional.IsDefined(ConsoleScreenshotBlobUri)) { writer.WritePropertyName("consoleScreenshotBlobUri"u8); @@ -53,7 +61,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, #endif } } - writer.WriteEndObject(); } RetrieveBootDiagnosticsDataResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/RollbackStatusInfo.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/RollbackStatusInfo.Serialization.cs index 07764a64678..00ba9af1ac6 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/RollbackStatusInfo.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/RollbackStatusInfo.Serialization.cs @@ -20,6 +20,15 @@ public partial class RollbackStatusInfo : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrit throw new FormatException($"The model {nameof(RollbackStatusInfo)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (options.Format != "W" && Optional.IsDefined(SuccessfullyRolledbackInstanceCount)) { writer.WritePropertyName("successfullyRolledbackInstanceCount"u8); @@ -58,7 +66,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrit #endif } } - writer.WriteEndObject(); } RollbackStatusInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/RollingUpgradePolicy.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/RollingUpgradePolicy.Serialization.cs index cc8e50a6b5d..aa10fec3cb9 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/RollingUpgradePolicy.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/RollingUpgradePolicy.Serialization.cs @@ -20,6 +20,15 @@ public partial class RollingUpgradePolicy : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWr throw new FormatException($"The model {nameof(RollingUpgradePolicy)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(MaxBatchInstancePercent)) { writer.WritePropertyName("maxBatchInstancePercent"u8); @@ -63,7 +71,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWr #endif } } - writer.WriteEndObject(); } RollingUpgradePolicy IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/RollingUpgradeProgressInfo.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/RollingUpgradeProgressInfo.Serialization.cs index 19968d8b2e6..a5ac2056c28 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/RollingUpgradeProgressInfo.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/RollingUpgradeProgressInfo.Serialization.cs @@ -20,6 +20,15 @@ public partial class RollingUpgradeProgressInfo : IUtf8JsonSerializable, IJsonMo void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRe throw new FormatException($"The model {nameof(RollingUpgradeProgressInfo)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (options.Format != "W" && Optional.IsDefined(SuccessfulInstanceCount)) { writer.WritePropertyName("successfulInstanceCount"u8); @@ -63,7 +71,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRe #endif } } - writer.WriteEndObject(); } RollingUpgradeProgressInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/RollingUpgradeRunningStatus.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/RollingUpgradeRunningStatus.Serialization.cs index 803fc05c109..5dd9ff070ee 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/RollingUpgradeRunningStatus.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/RollingUpgradeRunningStatus.Serialization.cs @@ -20,6 +20,15 @@ public partial class RollingUpgradeRunningStatus : IUtf8JsonSerializable, IJsonM void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelR throw new FormatException($"The model {nameof(RollingUpgradeRunningStatus)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (options.Format != "W" && Optional.IsDefined(Code)) { writer.WritePropertyName("code"u8); @@ -63,7 +71,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelR #endif } } - writer.WriteEndObject(); } RollingUpgradeRunningStatus IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ScaleInPolicy.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ScaleInPolicy.Serialization.cs index d48598ae5fc..5f4f3cb6dd8 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ScaleInPolicy.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ScaleInPolicy.Serialization.cs @@ -21,6 +21,15 @@ internal partial class ScaleInPolicy : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOpt throw new FormatException($"The model {nameof(ScaleInPolicy)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsCollectionDefined(Rules)) { writer.WritePropertyName("rules"u8); @@ -54,7 +62,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOpt #endif } } - writer.WriteEndObject(); } ScaleInPolicy IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ScheduledEventsProfile.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ScheduledEventsProfile.Serialization.cs index c1665565c7e..88eb9c915c9 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ScheduledEventsProfile.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ScheduledEventsProfile.Serialization.cs @@ -20,6 +20,15 @@ internal partial class ScheduledEventsProfile : IUtf8JsonSerializable, IJsonMode void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReader throw new FormatException($"The model {nameof(ScheduledEventsProfile)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(TerminateNotificationProfile)) { writer.WritePropertyName("terminateNotificationProfile"u8); @@ -48,7 +56,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReader #endif } } - writer.WriteEndObject(); } ScheduledEventsProfile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/SecurityProfile.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/SecurityProfile.Serialization.cs index ddffbd3e6bb..9bc54ad95b4 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/SecurityProfile.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/SecurityProfile.Serialization.cs @@ -20,6 +20,15 @@ internal partial class SecurityProfile : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterO throw new FormatException($"The model {nameof(SecurityProfile)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(EncryptionAtHost)) { writer.WritePropertyName("encryptionAtHost"u8); @@ -48,7 +56,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterO #endif } } - writer.WriteEndObject(); } SecurityProfile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/SshConfiguration.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/SshConfiguration.Serialization.cs index e55ad6eca3d..815eecc7c6d 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/SshConfiguration.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/SshConfiguration.Serialization.cs @@ -21,6 +21,15 @@ internal partial class SshConfiguration : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriter throw new FormatException($"The model {nameof(SshConfiguration)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsCollectionDefined(PublicKeys)) { writer.WritePropertyName("publicKeys"u8); @@ -54,7 +62,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriter #endif } } - writer.WriteEndObject(); } SshConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/SshPublicKeyGenerateKeyPairResult.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/SshPublicKeyGenerateKeyPairResult.Serialization.cs index 7a07bc3a14a..a1549870b75 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/SshPublicKeyGenerateKeyPairResult.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/SshPublicKeyGenerateKeyPairResult.Serialization.cs @@ -20,6 +20,15 @@ public partial class SshPublicKeyGenerateKeyPairResult : IUtf8JsonSerializable, void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, throw new FormatException($"The model {nameof(SshPublicKeyGenerateKeyPairResult)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("privateKey"u8); writer.WriteStringValue(PrivateKey); writer.WritePropertyName("publicKey"u8); @@ -49,7 +57,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, #endif } } - writer.WriteEndObject(); } SshPublicKeyGenerateKeyPairResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/SshPublicKeyInfo.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/SshPublicKeyInfo.Serialization.cs index 987d0d85c52..aa8955769ea 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/SshPublicKeyInfo.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/SshPublicKeyInfo.Serialization.cs @@ -20,6 +20,15 @@ public partial class SshPublicKeyInfo : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriter throw new FormatException($"The model {nameof(SshPublicKeyInfo)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(Path)) { writer.WritePropertyName("path"u8); @@ -53,7 +61,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriter #endif } } - writer.WriteEndObject(); } SshPublicKeyInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/SshPublicKeyPatch.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/SshPublicKeyPatch.Serialization.cs index 025f5b96e48..d43fe4e6f99 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/SshPublicKeyPatch.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/SshPublicKeyPatch.Serialization.cs @@ -18,6 +18,15 @@ public partial class SshPublicKeyPatch : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -25,18 +34,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrite throw new FormatException($"The model {nameof(SshPublicKeyPatch)} does not support writing '{format}' format."); } - writer.WriteStartObject(); - if (Optional.IsCollectionDefined(Tags)) - { - writer.WritePropertyName("tags"u8); - writer.WriteStartObject(); - foreach (var item in Tags) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("properties"u8); writer.WriteStartObject(); if (Optional.IsDefined(PublicKey)) @@ -45,22 +43,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrite writer.WriteStringValue(PublicKey); } writer.WriteEndObject(); - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } SshPublicKeyPatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/SshPublicKeysGroupListResult.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/SshPublicKeysGroupListResult.Serialization.cs index eba538ba9dd..2a484f6ee10 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/SshPublicKeysGroupListResult.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/SshPublicKeysGroupListResult.Serialization.cs @@ -21,6 +21,15 @@ internal partial class SshPublicKeysGroupListResult : IUtf8JsonSerializable, IJs void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, Model throw new FormatException($"The model {nameof(SshPublicKeysGroupListResult)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("value"u8); writer.WriteStartArray(); foreach (var item in Value) @@ -56,7 +64,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, Model #endif } } - writer.WriteEndObject(); } SshPublicKeysGroupListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/StorageProfile.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/StorageProfile.Serialization.cs index 16f0ecfa3a4..58484f7e794 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/StorageProfile.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/StorageProfile.Serialization.cs @@ -21,6 +21,15 @@ public partial class StorageProfile : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOp throw new FormatException($"The model {nameof(StorageProfile)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(ImageReference)) { writer.WritePropertyName("imageReference"u8); @@ -64,7 +72,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOp #endif } } - writer.WriteEndObject(); } StorageProfile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/SubResource.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/SubResource.Serialization.cs index ae5167c52e3..f2b8c17653a 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/SubResource.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/SubResource.Serialization.cs @@ -20,6 +20,15 @@ public partial class SubResource : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptio throw new FormatException($"The model {nameof(SubResource)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(Id)) { writer.WritePropertyName("id"u8); @@ -48,7 +56,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptio #endif } } - writer.WriteEndObject(); } SubResource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/SubResourceReadOnly.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/SubResourceReadOnly.Serialization.cs index a063d1f855f..f11b81c7d41 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/SubResourceReadOnly.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/SubResourceReadOnly.Serialization.cs @@ -20,6 +20,15 @@ public partial class SubResourceReadOnly : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWri throw new FormatException($"The model {nameof(SubResourceReadOnly)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (options.Format != "W" && Optional.IsDefined(Id)) { writer.WritePropertyName("id"u8); @@ -48,7 +56,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWri #endif } } - writer.WriteEndObject(); } SubResourceReadOnly IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/SubResourceWithColocationStatus.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/SubResourceWithColocationStatus.Serialization.cs index f0ee28c52ee..ecd11b154e3 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/SubResourceWithColocationStatus.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/SubResourceWithColocationStatus.Serialization.cs @@ -20,6 +20,15 @@ public partial class SubResourceWithColocationStatus : IUtf8JsonSerializable, IJ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,33 +36,12 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mo throw new FormatException($"The model {nameof(SubResourceWithColocationStatus)} does not support writing '{format}' format."); } - writer.WriteStartObject(); + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(ColocationStatus)) { writer.WritePropertyName("colocationStatus"u8); writer.WriteObjectValue(ColocationStatus, options); } - if (Optional.IsDefined(Id)) - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } SubResourceWithColocationStatus IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/TerminateNotificationProfile.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/TerminateNotificationProfile.Serialization.cs index 5fc51414249..0ac5b73c8c4 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/TerminateNotificationProfile.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/TerminateNotificationProfile.Serialization.cs @@ -20,6 +20,15 @@ public partial class TerminateNotificationProfile : IUtf8JsonSerializable, IJson void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, Model throw new FormatException($"The model {nameof(TerminateNotificationProfile)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(NotBeforeTimeout)) { writer.WritePropertyName("notBeforeTimeout"u8); @@ -53,7 +61,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, Model #endif } } - writer.WriteEndObject(); } TerminateNotificationProfile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ThrottledRequestsContent.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ThrottledRequestsContent.Serialization.cs index 72edc2998ee..c5130ce61db 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ThrottledRequestsContent.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ThrottledRequestsContent.Serialization.cs @@ -18,6 +18,15 @@ public partial class ThrottledRequestsContent : IUtf8JsonSerializable, IJsonMode void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -25,44 +34,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRead throw new FormatException($"The model {nameof(ThrottledRequestsContent)} does not support writing '{format}' format."); } - writer.WriteStartObject(); - writer.WritePropertyName("blobContainerSasUri"u8); - writer.WriteStringValue(BlobContainerSasUri.AbsoluteUri); - writer.WritePropertyName("fromTime"u8); - writer.WriteStringValue(FromTime, "O"); - writer.WritePropertyName("toTime"u8); - writer.WriteStringValue(ToTime, "O"); - if (Optional.IsDefined(GroupByThrottlePolicy)) - { - writer.WritePropertyName("groupByThrottlePolicy"u8); - writer.WriteBooleanValue(GroupByThrottlePolicy.Value); - } - if (Optional.IsDefined(GroupByOperationName)) - { - writer.WritePropertyName("groupByOperationName"u8); - writer.WriteBooleanValue(GroupByOperationName.Value); - } - if (Optional.IsDefined(GroupByResourceName)) - { - writer.WritePropertyName("groupByResourceName"u8); - writer.WriteBooleanValue(GroupByResourceName.Value); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); + base.JsonModelWriteCore(writer, options); } ThrottledRequestsContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/UpdateResource.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/UpdateResource.Serialization.cs index f169e1da8f5..769fbd690e6 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/UpdateResource.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/UpdateResource.Serialization.cs @@ -18,6 +18,15 @@ public partial class UpdateResource : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -25,7 +34,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOp throw new FormatException($"The model {nameof(UpdateResource)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsCollectionDefined(Tags)) { writer.WritePropertyName("tags"u8); @@ -52,7 +60,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOp #endif } } - writer.WriteEndObject(); } UpdateResource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/UpgradeOperationHistoricalStatusInfo.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/UpgradeOperationHistoricalStatusInfo.Serialization.cs index 6836dc7eb1f..4c2198dbf8a 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/UpgradeOperationHistoricalStatusInfo.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/UpgradeOperationHistoricalStatusInfo.Serialization.cs @@ -20,6 +20,15 @@ public partial class UpgradeOperationHistoricalStatusInfo : IUtf8JsonSerializabl void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter write throw new FormatException($"The model {nameof(UpgradeOperationHistoricalStatusInfo)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (options.Format != "W" && Optional.IsDefined(Properties)) { writer.WritePropertyName("properties"u8); @@ -58,7 +66,6 @@ void IJsonModel.Write(Utf8JsonWriter write #endif } } - writer.WriteEndObject(); } UpgradeOperationHistoricalStatusInfo IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/UpgradeOperationHistoricalStatusInfoProperties.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/UpgradeOperationHistoricalStatusInfoProperties.Serialization.cs index f11a939b504..68715917918 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/UpgradeOperationHistoricalStatusInfoProperties.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/UpgradeOperationHistoricalStatusInfoProperties.Serialization.cs @@ -20,6 +20,15 @@ public partial class UpgradeOperationHistoricalStatusInfoProperties : IUtf8JsonS void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWr throw new FormatException($"The model {nameof(UpgradeOperationHistoricalStatusInfoProperties)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (options.Format != "W" && Optional.IsDefined(RunningStatus)) { writer.WritePropertyName("runningStatus"u8); @@ -73,7 +81,6 @@ void IJsonModel.Write(Utf8JsonWr #endif } } - writer.WriteEndObject(); } UpgradeOperationHistoricalStatusInfoProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/UpgradeOperationHistoryStatus.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/UpgradeOperationHistoryStatus.Serialization.cs index 812c4b8a467..c94e7ffbb26 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/UpgradeOperationHistoryStatus.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/UpgradeOperationHistoryStatus.Serialization.cs @@ -20,6 +20,15 @@ public partial class UpgradeOperationHistoryStatus : IUtf8JsonSerializable, IJso void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mode throw new FormatException($"The model {nameof(UpgradeOperationHistoryStatus)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (options.Format != "W" && Optional.IsDefined(Code)) { writer.WritePropertyName("code"u8); @@ -58,7 +66,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mode #endif } } - writer.WriteEndObject(); } UpgradeOperationHistoryStatus IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/UpgradePolicy.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/UpgradePolicy.Serialization.cs index e9e8c259f41..7eb2cee79f7 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/UpgradePolicy.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/UpgradePolicy.Serialization.cs @@ -20,6 +20,15 @@ public partial class UpgradePolicy : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOpt throw new FormatException($"The model {nameof(UpgradePolicy)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(Mode)) { writer.WritePropertyName("mode"u8); @@ -58,7 +66,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOpt #endif } } - writer.WriteEndObject(); } UpgradePolicy IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VaultCertificate.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VaultCertificate.Serialization.cs index 074b01f6c0e..ab32d429f4f 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VaultCertificate.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VaultCertificate.Serialization.cs @@ -20,6 +20,15 @@ public partial class VaultCertificate : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriter throw new FormatException($"The model {nameof(VaultCertificate)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(CertificateUri)) { writer.WritePropertyName("certificateUrl"u8); @@ -53,7 +61,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriter #endif } } - writer.WriteEndObject(); } VaultCertificate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VaultSecretGroup.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VaultSecretGroup.Serialization.cs index 7d350994942..7bdbc2824d1 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VaultSecretGroup.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VaultSecretGroup.Serialization.cs @@ -22,6 +22,15 @@ public partial class VaultSecretGroup : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -29,7 +38,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriter throw new FormatException($"The model {nameof(VaultSecretGroup)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(SourceVault)) { writer.WritePropertyName("sourceVault"u8); @@ -60,7 +68,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriter #endif } } - writer.WriteEndObject(); } VaultSecretGroup IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualHardDisk.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualHardDisk.Serialization.cs index 871853c726c..912837b2381 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualHardDisk.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualHardDisk.Serialization.cs @@ -20,6 +20,15 @@ internal partial class VirtualHardDisk : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterO throw new FormatException($"The model {nameof(VirtualHardDisk)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(Uri)) { writer.WritePropertyName("uri"u8); @@ -48,7 +56,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterO #endif } } - writer.WriteEndObject(); } VirtualHardDisk IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineAgentInstanceView.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineAgentInstanceView.Serialization.cs index b3775b6afe6..50e4965d274 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineAgentInstanceView.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineAgentInstanceView.Serialization.cs @@ -21,6 +21,15 @@ public partial class VirtualMachineAgentInstanceView : IUtf8JsonSerializable, IJ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mo throw new FormatException($"The model {nameof(VirtualMachineAgentInstanceView)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(VmAgentVersion)) { writer.WritePropertyName("vmAgentVersion"u8); @@ -69,7 +77,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mo #endif } } - writer.WriteEndObject(); } VirtualMachineAgentInstanceView IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineAssessPatchesResult.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineAssessPatchesResult.Serialization.cs index a23b3499cee..5345d241f56 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineAssessPatchesResult.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineAssessPatchesResult.Serialization.cs @@ -21,6 +21,15 @@ public partial class VirtualMachineAssessPatchesResult : IUtf8JsonSerializable, void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, throw new FormatException($"The model {nameof(VirtualMachineAssessPatchesResult)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (options.Format != "W" && Optional.IsDefined(Status)) { writer.WritePropertyName("status"u8); @@ -89,7 +97,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, #endif } } - writer.WriteEndObject(); } VirtualMachineAssessPatchesResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineCaptureContent.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineCaptureContent.Serialization.cs index 3918a3d3682..5d38bc8fa9a 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineCaptureContent.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineCaptureContent.Serialization.cs @@ -18,6 +18,15 @@ public partial class VirtualMachineCaptureContent : IUtf8JsonSerializable, IJson void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -25,7 +34,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, Model throw new FormatException($"The model {nameof(VirtualMachineCaptureContent)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("vhdPrefix"u8); writer.WriteStringValue(VhdPrefix); writer.WritePropertyName("destinationContainerName"u8); @@ -47,7 +55,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, Model #endif } } - writer.WriteEndObject(); } VirtualMachineCaptureContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineCaptureResult.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineCaptureResult.Serialization.cs index 58f1a85c212..3c576415ae7 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineCaptureResult.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineCaptureResult.Serialization.cs @@ -21,6 +21,15 @@ public partial class VirtualMachineCaptureResult : IUtf8JsonSerializable, IJsonM void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelR throw new FormatException($"The model {nameof(VirtualMachineCaptureResult)} does not support writing '{format}' format."); } - writer.WriteStartObject(); + base.JsonModelWriteCore(writer, options); if (options.Format != "W" && Optional.IsDefined(Schema)) { writer.WritePropertyName("$schema"u8); @@ -73,27 +82,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelR } writer.WriteEndArray(); } - if (Optional.IsDefined(Id)) - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } VirtualMachineCaptureResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineExtensionHandlerInstanceView.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineExtensionHandlerInstanceView.Serialization.cs index 18b35531989..49e421dbf62 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineExtensionHandlerInstanceView.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineExtensionHandlerInstanceView.Serialization.cs @@ -20,6 +20,15 @@ public partial class VirtualMachineExtensionHandlerInstanceView : IUtf8JsonSeria void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter throw new FormatException($"The model {nameof(VirtualMachineExtensionHandlerInstanceView)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(VirtualMachineExtensionHandlerInstanceViewType)) { writer.WritePropertyName("type"u8); @@ -58,7 +66,6 @@ void IJsonModel.Write(Utf8JsonWriter #endif } } - writer.WriteEndObject(); } VirtualMachineExtensionHandlerInstanceView IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineExtensionInstanceView.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineExtensionInstanceView.Serialization.cs index ed71675587c..d1a8fa33bf4 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineExtensionInstanceView.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineExtensionInstanceView.Serialization.cs @@ -21,6 +21,15 @@ public partial class VirtualMachineExtensionInstanceView : IUtf8JsonSerializable void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter writer throw new FormatException($"The model {nameof(VirtualMachineExtensionInstanceView)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(Name)) { writer.WritePropertyName("name"u8); @@ -79,7 +87,6 @@ void IJsonModel.Write(Utf8JsonWriter writer #endif } } - writer.WriteEndObject(); } VirtualMachineExtensionInstanceView IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineExtensionUpdate.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineExtensionUpdate.Serialization.cs index 0787a427e68..6a7453d739d 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineExtensionUpdate.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineExtensionUpdate.Serialization.cs @@ -18,6 +18,15 @@ public partial class VirtualMachineExtensionUpdate : IUtf8JsonSerializable, IJso void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -25,18 +34,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mode throw new FormatException($"The model {nameof(VirtualMachineExtensionUpdate)} does not support writing '{format}' format."); } - writer.WriteStartObject(); - if (Optional.IsCollectionDefined(Tags)) - { - writer.WritePropertyName("tags"u8); - writer.WriteStartObject(); - foreach (var item in Tags) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("properties"u8); writer.WriteStartObject(); if (Optional.IsDefined(ForceUpdateTag)) @@ -94,22 +92,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mode #endif } writer.WriteEndObject(); - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } VirtualMachineExtensionUpdate IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineExtensionsListResult.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineExtensionsListResult.Serialization.cs index 1ba70631f4a..c0e6a05aaa2 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineExtensionsListResult.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineExtensionsListResult.Serialization.cs @@ -21,6 +21,15 @@ internal partial class VirtualMachineExtensionsListResult : IUtf8JsonSerializabl void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, throw new FormatException($"The model {nameof(VirtualMachineExtensionsListResult)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsCollectionDefined(Value)) { writer.WritePropertyName("value"u8); @@ -54,7 +62,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, #endif } } - writer.WriteEndObject(); } VirtualMachineExtensionsListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineHealthStatus.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineHealthStatus.Serialization.cs index 5a97fe20b40..444974f7298 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineHealthStatus.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineHealthStatus.Serialization.cs @@ -20,6 +20,15 @@ internal partial class VirtualMachineHealthStatus : IUtf8JsonSerializable, IJson void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRe throw new FormatException($"The model {nameof(VirtualMachineHealthStatus)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (options.Format != "W" && Optional.IsDefined(Status)) { writer.WritePropertyName("status"u8); @@ -48,7 +56,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRe #endif } } - writer.WriteEndObject(); } VirtualMachineHealthStatus IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineImage.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineImage.Serialization.cs index 7d8220037bf..80fdaffc8d3 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineImage.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineImage.Serialization.cs @@ -21,6 +21,15 @@ public partial class VirtualMachineImage : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,27 +37,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWri throw new FormatException($"The model {nameof(VirtualMachineImage)} does not support writing '{format}' format."); } - writer.WriteStartObject(); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - writer.WritePropertyName("location"u8); - writer.WriteStringValue(Location); - if (Optional.IsCollectionDefined(Tags)) - { - writer.WritePropertyName("tags"u8); - writer.WriteStartObject(); - foreach (var item in Tags) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - if (Optional.IsDefined(Id)) - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("properties"u8); writer.WriteStartObject(); if (Optional.IsDefined(Plan)) @@ -87,22 +76,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWri writer.WriteObjectValue(Disallowed, options); } writer.WriteEndObject(); - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } VirtualMachineImage IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineImageResource.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineImageResource.Serialization.cs index 1bd39ddb3e6..dbe8bfe73f6 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineImageResource.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineImageResource.Serialization.cs @@ -21,6 +21,15 @@ public partial class VirtualMachineImageResource : IUtf8JsonSerializable, IJsonM void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelR throw new FormatException($"The model {nameof(VirtualMachineImageResource)} does not support writing '{format}' format."); } - writer.WriteStartObject(); + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("name"u8); writer.WriteStringValue(Name); writer.WritePropertyName("location"u8); @@ -44,27 +53,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelR } writer.WriteEndObject(); } - if (Optional.IsDefined(Id)) - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } VirtualMachineImageResource IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineInstanceView.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineInstanceView.Serialization.cs index 283c1bbe6b1..0a0d9f3bc80 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineInstanceView.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineInstanceView.Serialization.cs @@ -21,6 +21,15 @@ public partial class VirtualMachineInstanceView : IUtf8JsonSerializable, IJsonMo void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRe throw new FormatException($"The model {nameof(VirtualMachineInstanceView)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(PlatformUpdateDomain)) { writer.WritePropertyName("platformUpdateDomain"u8); @@ -139,7 +147,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRe #endif } } - writer.WriteEndObject(); } VirtualMachineInstanceView IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineListResult.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineListResult.Serialization.cs index b88a597b93c..8bbfac08318 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineListResult.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineListResult.Serialization.cs @@ -21,6 +21,15 @@ internal partial class VirtualMachineListResult : IUtf8JsonSerializable, IJsonMo void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRead throw new FormatException($"The model {nameof(VirtualMachineListResult)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("value"u8); writer.WriteStartArray(); foreach (var item in Value) @@ -56,7 +64,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRead #endif } } - writer.WriteEndObject(); } VirtualMachineListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachinePatch.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachinePatch.Serialization.cs index 1447dbb7a6d..6f9c1e38007 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachinePatch.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachinePatch.Serialization.cs @@ -20,6 +20,15 @@ public partial class VirtualMachinePatch : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWri throw new FormatException($"The model {nameof(VirtualMachinePatch)} does not support writing '{format}' format."); } - writer.WriteStartObject(); + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(Plan)) { writer.WritePropertyName("plan"u8); @@ -48,17 +57,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWri } writer.WriteEndArray(); } - if (Optional.IsCollectionDefined(Tags)) - { - writer.WritePropertyName("tags"u8); - writer.WriteStartObject(); - foreach (var item in Tags) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } writer.WritePropertyName("properties"u8); writer.WriteStartObject(); if (Optional.IsDefined(HardwareProfile)) @@ -162,22 +160,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWri writer.WriteStringValue(ExtensionsTimeBudget); } writer.WriteEndObject(); - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } VirtualMachinePatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachinePatchStatus.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachinePatchStatus.Serialization.cs index 6cbe07cf983..f13f166772a 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachinePatchStatus.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachinePatchStatus.Serialization.cs @@ -20,6 +20,15 @@ public partial class VirtualMachinePatchStatus : IUtf8JsonSerializable, IJsonMod void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRea throw new FormatException($"The model {nameof(VirtualMachinePatchStatus)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(AvailablePatchSummary)) { writer.WritePropertyName("availablePatchSummary"u8); @@ -53,7 +61,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRea #endif } } - writer.WriteEndObject(); } VirtualMachinePatchStatus IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineReimageContent.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineReimageContent.Serialization.cs index 233927763ae..08bff2a4811 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineReimageContent.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineReimageContent.Serialization.cs @@ -18,6 +18,15 @@ public partial class VirtualMachineReimageContent : IUtf8JsonSerializable, IJson void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -25,7 +34,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, Model throw new FormatException($"The model {nameof(VirtualMachineReimageContent)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(TempDisk)) { writer.WritePropertyName("tempDisk"u8); @@ -46,7 +54,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, Model #endif } } - writer.WriteEndObject(); } VirtualMachineReimageContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetDataDisk.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetDataDisk.Serialization.cs index ec94b32d46b..28a12499f58 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetDataDisk.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetDataDisk.Serialization.cs @@ -20,6 +20,15 @@ public partial class VirtualMachineScaleSetDataDisk : IUtf8JsonSerializable, IJs void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mod throw new FormatException($"The model {nameof(VirtualMachineScaleSetDataDisk)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(Name)) { writer.WritePropertyName("name"u8); @@ -82,7 +90,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mod #endif } } - writer.WriteEndObject(); } VirtualMachineScaleSetDataDisk IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetExtensionListResult.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetExtensionListResult.Serialization.cs index dd1a9f558f4..d7d1b351746 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetExtensionListResult.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetExtensionListResult.Serialization.cs @@ -21,6 +21,15 @@ internal partial class VirtualMachineScaleSetExtensionListResult : IUtf8JsonSeri void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter throw new FormatException($"The model {nameof(VirtualMachineScaleSetExtensionListResult)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("value"u8); writer.WriteStartArray(); foreach (var item in Value) @@ -56,7 +64,6 @@ void IJsonModel.Write(Utf8JsonWriter #endif } } - writer.WriteEndObject(); } VirtualMachineScaleSetExtensionListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetExtensionPatch.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetExtensionPatch.Serialization.cs index 0de77b75e41..55b8616219e 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetExtensionPatch.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetExtensionPatch.Serialization.cs @@ -22,6 +22,15 @@ public partial class VirtualMachineScaleSetExtensionPatch : IUtf8JsonSerializabl void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -29,27 +38,7 @@ void IJsonModel.Write(Utf8JsonWriter write throw new FormatException($"The model {nameof(VirtualMachineScaleSetExtensionPatch)} does not support writing '{format}' format."); } - writer.WriteStartObject(); - if (options.Format != "W") - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (options.Format != "W") - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (options.Format != "W") - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(ResourceType); - } - if (options.Format != "W" && Optional.IsDefined(SystemData)) - { - writer.WritePropertyName("systemData"u8); - JsonSerializer.Serialize(writer, SystemData); - } + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("properties"u8); writer.WriteStartObject(); if (Optional.IsDefined(ForceUpdateTag)) @@ -122,22 +111,6 @@ void IJsonModel.Write(Utf8JsonWriter write writer.WriteEndArray(); } writer.WriteEndObject(); - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } VirtualMachineScaleSetExtensionPatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetExtensionProfile.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetExtensionProfile.Serialization.cs index b5c79f71eea..1768e43ffdb 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetExtensionProfile.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetExtensionProfile.Serialization.cs @@ -21,6 +21,15 @@ public partial class VirtualMachineScaleSetExtensionProfile : IUtf8JsonSerializa void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter wri throw new FormatException($"The model {nameof(VirtualMachineScaleSetExtensionProfile)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsCollectionDefined(Extensions)) { writer.WritePropertyName("extensions"u8); @@ -59,7 +67,6 @@ void IJsonModel.Write(Utf8JsonWriter wri #endif } } - writer.WriteEndObject(); } VirtualMachineScaleSetExtensionProfile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetIPConfiguration.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetIPConfiguration.Serialization.cs index b6bd2fb1a48..4192610d8c4 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetIPConfiguration.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetIPConfiguration.Serialization.cs @@ -22,6 +22,15 @@ public partial class VirtualMachineScaleSetIPConfiguration : IUtf8JsonSerializab void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -29,14 +38,9 @@ void IJsonModel.Write(Utf8JsonWriter writ throw new FormatException($"The model {nameof(VirtualMachineScaleSetIPConfiguration)} does not support writing '{format}' format."); } - writer.WriteStartObject(); + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("name"u8); writer.WriteStringValue(Name); - if (Optional.IsDefined(Id)) - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } writer.WritePropertyName("properties"u8); writer.WriteStartObject(); if (Optional.IsDefined(Subnet)) @@ -100,22 +104,6 @@ void IJsonModel.Write(Utf8JsonWriter writ writer.WriteEndArray(); } writer.WriteEndObject(); - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } VirtualMachineScaleSetIPConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetIPTag.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetIPTag.Serialization.cs index cd32597b075..b98e2d83569 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetIPTag.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetIPTag.Serialization.cs @@ -20,6 +20,15 @@ public partial class VirtualMachineScaleSetIPTag : IUtf8JsonSerializable, IJsonM void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelR throw new FormatException($"The model {nameof(VirtualMachineScaleSetIPTag)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(IPTagType)) { writer.WritePropertyName("ipTagType"u8); @@ -53,7 +61,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelR #endif } } - writer.WriteEndObject(); } VirtualMachineScaleSetIPTag IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetInstanceView.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetInstanceView.Serialization.cs index 3e894e79e43..2654249a3fe 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetInstanceView.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetInstanceView.Serialization.cs @@ -21,6 +21,15 @@ public partial class VirtualMachineScaleSetInstanceView : IUtf8JsonSerializable, void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, throw new FormatException($"The model {nameof(VirtualMachineScaleSetInstanceView)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (options.Format != "W" && Optional.IsDefined(VirtualMachine)) { writer.WritePropertyName("virtualMachine"u8); @@ -79,7 +87,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, #endif } } - writer.WriteEndObject(); } VirtualMachineScaleSetInstanceView IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetInstanceViewStatusesSummary.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetInstanceViewStatusesSummary.Serialization.cs index ad666da53b0..e77797e393d 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetInstanceViewStatusesSummary.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetInstanceViewStatusesSummary.Serialization.cs @@ -21,6 +21,15 @@ internal partial class VirtualMachineScaleSetInstanceViewStatusesSummary : IUtf8 void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8Jso throw new FormatException($"The model {nameof(VirtualMachineScaleSetInstanceViewStatusesSummary)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (options.Format != "W" && Optional.IsCollectionDefined(StatusesSummary)) { writer.WritePropertyName("statusesSummary"u8); @@ -54,7 +62,6 @@ void IJsonModel.Write(Utf8Jso #endif } } - writer.WriteEndObject(); } VirtualMachineScaleSetInstanceViewStatusesSummary IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetListOSUpgradeHistory.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetListOSUpgradeHistory.Serialization.cs index 12abbd6c3c4..6ec670b766f 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetListOSUpgradeHistory.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetListOSUpgradeHistory.Serialization.cs @@ -21,6 +21,15 @@ internal partial class VirtualMachineScaleSetListOSUpgradeHistory : IUtf8JsonSer void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter throw new FormatException($"The model {nameof(VirtualMachineScaleSetListOSUpgradeHistory)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("value"u8); writer.WriteStartArray(); foreach (var item in Value) @@ -61,7 +69,6 @@ void IJsonModel.Write(Utf8JsonWriter #endif } } - writer.WriteEndObject(); } VirtualMachineScaleSetListOSUpgradeHistory IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetListResult.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetListResult.Serialization.cs index eb3f59c6302..dd0f1954e1a 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetListResult.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetListResult.Serialization.cs @@ -21,6 +21,15 @@ internal partial class VirtualMachineScaleSetListResult : IUtf8JsonSerializable, void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, M throw new FormatException($"The model {nameof(VirtualMachineScaleSetListResult)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("value"u8); writer.WriteStartArray(); foreach (var item in Value) @@ -56,7 +64,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, M #endif } } - writer.WriteEndObject(); } VirtualMachineScaleSetListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetListSkusResult.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetListSkusResult.Serialization.cs index 46005b9ee56..e204a090aa5 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetListSkusResult.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetListSkusResult.Serialization.cs @@ -21,6 +21,15 @@ internal partial class VirtualMachineScaleSetListSkusResult : IUtf8JsonSerializa void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter write throw new FormatException($"The model {nameof(VirtualMachineScaleSetListSkusResult)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("VmssSkus"u8); writer.WriteStartArray(); foreach (var item in VmssSkus) @@ -56,7 +64,6 @@ void IJsonModel.Write(Utf8JsonWriter write #endif } } - writer.WriteEndObject(); } VirtualMachineScaleSetListSkusResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetListWithLinkResult.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetListWithLinkResult.Serialization.cs index 2ba39de03b1..a689162eae8 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetListWithLinkResult.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetListWithLinkResult.Serialization.cs @@ -21,6 +21,15 @@ internal partial class VirtualMachineScaleSetListWithLinkResult : IUtf8JsonSeria void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter w throw new FormatException($"The model {nameof(VirtualMachineScaleSetListWithLinkResult)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("value"u8); writer.WriteStartArray(); foreach (var item in Value) @@ -56,7 +64,6 @@ void IJsonModel.Write(Utf8JsonWriter w #endif } } - writer.WriteEndObject(); } VirtualMachineScaleSetListWithLinkResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetManagedDiskParameters.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetManagedDiskParameters.Serialization.cs index c7b750c207f..782f3c2a4d3 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetManagedDiskParameters.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetManagedDiskParameters.Serialization.cs @@ -21,6 +21,15 @@ public partial class VirtualMachineScaleSetManagedDiskParameters : IUtf8JsonSeri void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWrite throw new FormatException($"The model {nameof(VirtualMachineScaleSetManagedDiskParameters)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(StorageAccountType)) { writer.WritePropertyName("storageAccountType"u8); @@ -54,7 +62,6 @@ void IJsonModel.Write(Utf8JsonWrite #endif } } - writer.WriteEndObject(); } VirtualMachineScaleSetManagedDiskParameters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetNetworkConfiguration.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetNetworkConfiguration.Serialization.cs index 7548d0a34cf..3d2fbbe0e23 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetNetworkConfiguration.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetNetworkConfiguration.Serialization.cs @@ -22,6 +22,15 @@ public partial class VirtualMachineScaleSetNetworkConfiguration : IUtf8JsonSeria void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -29,14 +38,9 @@ void IJsonModel.Write(Utf8JsonWriter throw new FormatException($"The model {nameof(VirtualMachineScaleSetNetworkConfiguration)} does not support writing '{format}' format."); } - writer.WriteStartObject(); + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("name"u8); writer.WriteStringValue(Name); - if (Optional.IsDefined(Id)) - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } writer.WritePropertyName("properties"u8); writer.WriteStartObject(); if (Optional.IsDefined(Primary)) @@ -75,22 +79,6 @@ void IJsonModel.Write(Utf8JsonWriter writer.WriteBooleanValue(EnableIPForwarding.Value); } writer.WriteEndObject(); - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } VirtualMachineScaleSetNetworkConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetNetworkConfigurationDnsSettings.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetNetworkConfigurationDnsSettings.Serialization.cs index 5c853decc59..a4ab4d8e8bd 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetNetworkConfigurationDnsSettings.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetNetworkConfigurationDnsSettings.Serialization.cs @@ -21,6 +21,15 @@ internal partial class VirtualMachineScaleSetNetworkConfigurationDnsSettings : I void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf throw new FormatException($"The model {nameof(VirtualMachineScaleSetNetworkConfigurationDnsSettings)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsCollectionDefined(DnsServers)) { writer.WritePropertyName("dnsServers"u8); @@ -54,7 +62,6 @@ void IJsonModel.Write(Utf #endif } } - writer.WriteEndObject(); } VirtualMachineScaleSetNetworkConfigurationDnsSettings IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetNetworkProfile.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetNetworkProfile.Serialization.cs index 52b31f92cab..0745bc0c623 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetNetworkProfile.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetNetworkProfile.Serialization.cs @@ -22,6 +22,15 @@ public partial class VirtualMachineScaleSetNetworkProfile : IUtf8JsonSerializabl void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -29,7 +38,6 @@ void IJsonModel.Write(Utf8JsonWriter write throw new FormatException($"The model {nameof(VirtualMachineScaleSetNetworkProfile)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(HealthProbe)) { writer.WritePropertyName("healthProbe"u8); @@ -60,7 +68,6 @@ void IJsonModel.Write(Utf8JsonWriter write #endif } } - writer.WriteEndObject(); } VirtualMachineScaleSetNetworkProfile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetOSDisk.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetOSDisk.Serialization.cs index 0df4a50e0fc..b9ed9ef4199 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetOSDisk.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetOSDisk.Serialization.cs @@ -21,6 +21,15 @@ public partial class VirtualMachineScaleSetOSDisk : IUtf8JsonSerializable, IJson void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, Model throw new FormatException($"The model {nameof(VirtualMachineScaleSetOSDisk)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(Name)) { writer.WritePropertyName("name"u8); @@ -96,7 +104,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, Model #endif } } - writer.WriteEndObject(); } VirtualMachineScaleSetOSDisk IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetOSProfile.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetOSProfile.Serialization.cs index 0acefb939e4..4e4e44584c4 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetOSProfile.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetOSProfile.Serialization.cs @@ -21,6 +21,15 @@ public partial class VirtualMachineScaleSetOSProfile : IUtf8JsonSerializable, IJ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mo throw new FormatException($"The model {nameof(VirtualMachineScaleSetOSProfile)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(ComputerNamePrefix)) { writer.WritePropertyName("computerNamePrefix"u8); @@ -84,7 +92,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mo #endif } } - writer.WriteEndObject(); } VirtualMachineScaleSetOSProfile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetPatch.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetPatch.Serialization.cs index df4abe99979..89e55823d8f 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetPatch.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetPatch.Serialization.cs @@ -20,6 +20,15 @@ public partial class VirtualMachineScaleSetPatch : IUtf8JsonSerializable, IJsonM void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelR throw new FormatException($"The model {nameof(VirtualMachineScaleSetPatch)} does not support writing '{format}' format."); } - writer.WriteStartObject(); + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(Sku)) { writer.WritePropertyName("sku"u8); @@ -43,17 +52,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelR writer.WritePropertyName("identity"u8); JsonSerializer.Serialize(writer, Identity); } - if (Optional.IsCollectionDefined(Tags)) - { - writer.WritePropertyName("tags"u8); - writer.WriteStartObject(); - foreach (var item in Tags) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } writer.WritePropertyName("properties"u8); writer.WriteStartObject(); if (Optional.IsDefined(UpgradePolicy)) @@ -102,22 +100,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelR JsonSerializer.Serialize(writer, ProximityPlacementGroup); } writer.WriteEndObject(); - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } VirtualMachineScaleSetPatch IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetPublicIPAddressConfiguration.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetPublicIPAddressConfiguration.Serialization.cs index 1bee55742fc..6c3d8334b4e 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetPublicIPAddressConfiguration.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetPublicIPAddressConfiguration.Serialization.cs @@ -22,6 +22,15 @@ public partial class VirtualMachineScaleSetPublicIPAddressConfiguration : IUtf8J void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -29,7 +38,6 @@ void IJsonModel.Write(Utf8Js throw new FormatException($"The model {nameof(VirtualMachineScaleSetPublicIPAddressConfiguration)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("name"u8); writer.WriteStringValue(Name); writer.WritePropertyName("properties"u8); @@ -80,7 +88,6 @@ void IJsonModel.Write(Utf8Js #endif } } - writer.WriteEndObject(); } VirtualMachineScaleSetPublicIPAddressConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings.Serialization.cs index 46e139f20de..987bfec679b 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings.Serialization.cs @@ -20,6 +20,15 @@ internal partial class VirtualMachineScaleSetPublicIPAddressConfigurationDnsSett void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.W throw new FormatException($"The model {nameof(VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("domainNameLabel"u8); writer.WriteStringValue(DomainNameLabel); if (options.Format != "W" && _serializedAdditionalRawData != null) @@ -45,7 +53,6 @@ void IJsonModel.W #endif } } - writer.WriteEndObject(); } VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetReimageContent.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetReimageContent.Serialization.cs index d4c0b59dabf..23c0e6f014a 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetReimageContent.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetReimageContent.Serialization.cs @@ -18,6 +18,15 @@ public partial class VirtualMachineScaleSetReimageContent : IUtf8JsonSerializabl void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -25,7 +34,7 @@ void IJsonModel.Write(Utf8JsonWriter write throw new FormatException($"The model {nameof(VirtualMachineScaleSetReimageContent)} does not support writing '{format}' format."); } - writer.WriteStartObject(); + base.JsonModelWriteCore(writer, options); if (Optional.IsCollectionDefined(InstanceIds)) { writer.WritePropertyName("instanceIds"u8); @@ -36,27 +45,6 @@ void IJsonModel.Write(Utf8JsonWriter write } writer.WriteEndArray(); } - if (Optional.IsDefined(TempDisk)) - { - writer.WritePropertyName("tempDisk"u8); - writer.WriteBooleanValue(TempDisk.Value); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } VirtualMachineScaleSetReimageContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetSku.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetSku.Serialization.cs index 0a77b73698b..679bcc39d49 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetSku.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetSku.Serialization.cs @@ -20,6 +20,15 @@ public partial class VirtualMachineScaleSetSku : IUtf8JsonSerializable, IJsonMod void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRea throw new FormatException($"The model {nameof(VirtualMachineScaleSetSku)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (options.Format != "W" && Optional.IsDefined(ResourceType)) { writer.WritePropertyName("resourceType"u8); @@ -58,7 +66,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRea #endif } } - writer.WriteEndObject(); } VirtualMachineScaleSetSku IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetSkuCapacity.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetSkuCapacity.Serialization.cs index ace53011a4d..45d591b0c07 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetSkuCapacity.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetSkuCapacity.Serialization.cs @@ -20,6 +20,15 @@ public partial class VirtualMachineScaleSetSkuCapacity : IUtf8JsonSerializable, void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, throw new FormatException($"The model {nameof(VirtualMachineScaleSetSkuCapacity)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (options.Format != "W" && Optional.IsDefined(Minimum)) { writer.WritePropertyName("minimum"u8); @@ -63,7 +71,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, #endif } } - writer.WriteEndObject(); } VirtualMachineScaleSetSkuCapacity IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetStorageProfile.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetStorageProfile.Serialization.cs index 2ea93b49d6f..e9dda75b7bd 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetStorageProfile.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetStorageProfile.Serialization.cs @@ -21,6 +21,15 @@ public partial class VirtualMachineScaleSetStorageProfile : IUtf8JsonSerializabl void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter write throw new FormatException($"The model {nameof(VirtualMachineScaleSetStorageProfile)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(ImageReference)) { writer.WritePropertyName("imageReference"u8); @@ -64,7 +72,6 @@ void IJsonModel.Write(Utf8JsonWriter write #endif } } - writer.WriteEndObject(); } VirtualMachineScaleSetStorageProfile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetUpdateIPConfiguration.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetUpdateIPConfiguration.Serialization.cs index a01d0610158..95e03c2f8c0 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetUpdateIPConfiguration.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetUpdateIPConfiguration.Serialization.cs @@ -22,6 +22,15 @@ public partial class VirtualMachineScaleSetUpdateIPConfiguration : IUtf8JsonSeri void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -29,17 +38,12 @@ void IJsonModel.Write(Utf8JsonWrite throw new FormatException($"The model {nameof(VirtualMachineScaleSetUpdateIPConfiguration)} does not support writing '{format}' format."); } - writer.WriteStartObject(); + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(Name)) { writer.WritePropertyName("name"u8); writer.WriteStringValue(Name); } - if (Optional.IsDefined(Id)) - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } writer.WritePropertyName("properties"u8); writer.WriteStartObject(); if (Optional.IsDefined(Subnet)) @@ -103,22 +107,6 @@ void IJsonModel.Write(Utf8JsonWrite writer.WriteEndArray(); } writer.WriteEndObject(); - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } VirtualMachineScaleSetUpdateIPConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetUpdateNetworkConfiguration.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetUpdateNetworkConfiguration.Serialization.cs index abff754037f..4de83b7df12 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetUpdateNetworkConfiguration.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetUpdateNetworkConfiguration.Serialization.cs @@ -22,6 +22,15 @@ public partial class VirtualMachineScaleSetUpdateNetworkConfiguration : IUtf8Jso void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -29,17 +38,12 @@ void IJsonModel.Write(Utf8Json throw new FormatException($"The model {nameof(VirtualMachineScaleSetUpdateNetworkConfiguration)} does not support writing '{format}' format."); } - writer.WriteStartObject(); + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(Name)) { writer.WritePropertyName("name"u8); writer.WriteStringValue(Name); } - if (Optional.IsDefined(Id)) - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } writer.WritePropertyName("properties"u8); writer.WriteStartObject(); if (Optional.IsDefined(Primary)) @@ -78,22 +82,6 @@ void IJsonModel.Write(Utf8Json writer.WriteBooleanValue(EnableIPForwarding.Value); } writer.WriteEndObject(); - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } VirtualMachineScaleSetUpdateNetworkConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetUpdateNetworkProfile.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetUpdateNetworkProfile.Serialization.cs index 7d470e6e6fe..704725458b5 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetUpdateNetworkProfile.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetUpdateNetworkProfile.Serialization.cs @@ -19,6 +19,15 @@ public partial class VirtualMachineScaleSetUpdateNetworkProfile : IUtf8JsonSeria void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -26,7 +35,6 @@ void IJsonModel.Write(Utf8JsonWriter throw new FormatException($"The model {nameof(VirtualMachineScaleSetUpdateNetworkProfile)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(HealthProbe)) { writer.WritePropertyName("healthProbe"u8); @@ -57,7 +65,6 @@ void IJsonModel.Write(Utf8JsonWriter #endif } } - writer.WriteEndObject(); } VirtualMachineScaleSetUpdateNetworkProfile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetUpdateOSDisk.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetUpdateOSDisk.Serialization.cs index 2966a36276b..70f5abe2e9e 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetUpdateOSDisk.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetUpdateOSDisk.Serialization.cs @@ -18,6 +18,15 @@ public partial class VirtualMachineScaleSetUpdateOSDisk : IUtf8JsonSerializable, void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -25,7 +34,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, throw new FormatException($"The model {nameof(VirtualMachineScaleSetUpdateOSDisk)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(Caching)) { writer.WritePropertyName("caching"u8); @@ -76,7 +84,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, #endif } } - writer.WriteEndObject(); } VirtualMachineScaleSetUpdateOSDisk IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetUpdateOSProfile.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetUpdateOSProfile.Serialization.cs index 39b99d54793..11d29a066f0 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetUpdateOSProfile.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetUpdateOSProfile.Serialization.cs @@ -18,6 +18,15 @@ public partial class VirtualMachineScaleSetUpdateOSProfile : IUtf8JsonSerializab void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -25,7 +34,6 @@ void IJsonModel.Write(Utf8JsonWriter writ throw new FormatException($"The model {nameof(VirtualMachineScaleSetUpdateOSProfile)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(CustomData)) { writer.WritePropertyName("customData"u8); @@ -66,7 +74,6 @@ void IJsonModel.Write(Utf8JsonWriter writ #endif } } - writer.WriteEndObject(); } VirtualMachineScaleSetUpdateOSProfile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetUpdatePublicIPAddressConfiguration.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetUpdatePublicIPAddressConfiguration.Serialization.cs index 89a5a569319..4f6d84a1e0f 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetUpdatePublicIPAddressConfiguration.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetUpdatePublicIPAddressConfiguration.Serialization.cs @@ -20,6 +20,15 @@ public partial class VirtualMachineScaleSetUpdatePublicIPAddressConfiguration : void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write( throw new FormatException($"The model {nameof(VirtualMachineScaleSetUpdatePublicIPAddressConfiguration)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(Name)) { writer.WritePropertyName("name"u8); @@ -61,7 +69,6 @@ void IJsonModel.Write( #endif } } - writer.WriteEndObject(); } VirtualMachineScaleSetUpdatePublicIPAddressConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetUpdateStorageProfile.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetUpdateStorageProfile.Serialization.cs index 8190c9290e1..cd81b949f15 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetUpdateStorageProfile.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetUpdateStorageProfile.Serialization.cs @@ -18,6 +18,15 @@ public partial class VirtualMachineScaleSetUpdateStorageProfile : IUtf8JsonSeria void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -25,7 +34,6 @@ void IJsonModel.Write(Utf8JsonWriter throw new FormatException($"The model {nameof(VirtualMachineScaleSetUpdateStorageProfile)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(ImageReference)) { writer.WritePropertyName("imageReference"u8); @@ -61,7 +69,6 @@ void IJsonModel.Write(Utf8JsonWriter #endif } } - writer.WriteEndObject(); } VirtualMachineScaleSetUpdateStorageProfile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetUpdateVmProfile.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetUpdateVmProfile.Serialization.cs index 08c33ddba73..0062b2e1fa8 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetUpdateVmProfile.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetUpdateVmProfile.Serialization.cs @@ -18,6 +18,15 @@ public partial class VirtualMachineScaleSetUpdateVmProfile : IUtf8JsonSerializab void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -25,7 +34,6 @@ void IJsonModel.Write(Utf8JsonWriter writ throw new FormatException($"The model {nameof(VirtualMachineScaleSetUpdateVmProfile)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(OSProfile)) { writer.WritePropertyName("osProfile"u8); @@ -86,7 +94,6 @@ void IJsonModel.Write(Utf8JsonWriter writ #endif } } - writer.WriteEndObject(); } VirtualMachineScaleSetUpdateVmProfile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetVmExtensionsSummary.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetVmExtensionsSummary.Serialization.cs index 873559c2871..723c66f500d 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetVmExtensionsSummary.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetVmExtensionsSummary.Serialization.cs @@ -21,6 +21,15 @@ public partial class VirtualMachineScaleSetVmExtensionsSummary : IUtf8JsonSerial void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter throw new FormatException($"The model {nameof(VirtualMachineScaleSetVmExtensionsSummary)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (options.Format != "W" && Optional.IsDefined(Name)) { writer.WritePropertyName("name"u8); @@ -59,7 +67,6 @@ void IJsonModel.Write(Utf8JsonWriter #endif } } - writer.WriteEndObject(); } VirtualMachineScaleSetVmExtensionsSummary IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetVmInstanceIds.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetVmInstanceIds.Serialization.cs index 6c76b9b6803..efece261049 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetVmInstanceIds.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetVmInstanceIds.Serialization.cs @@ -18,6 +18,15 @@ public partial class VirtualMachineScaleSetVmInstanceIds : IUtf8JsonSerializable void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -25,7 +34,6 @@ void IJsonModel.Write(Utf8JsonWriter writer throw new FormatException($"The model {nameof(VirtualMachineScaleSetVmInstanceIds)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsCollectionDefined(InstanceIds)) { writer.WritePropertyName("instanceIds"u8); @@ -51,7 +59,6 @@ void IJsonModel.Write(Utf8JsonWriter writer #endif } } - writer.WriteEndObject(); } VirtualMachineScaleSetVmInstanceIds IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetVmInstanceRequiredIds.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetVmInstanceRequiredIds.Serialization.cs index 3529f656919..756c84f065a 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetVmInstanceRequiredIds.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetVmInstanceRequiredIds.Serialization.cs @@ -18,6 +18,15 @@ public partial class VirtualMachineScaleSetVmInstanceRequiredIds : IUtf8JsonSeri void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -25,7 +34,6 @@ void IJsonModel.Write(Utf8JsonWrite throw new FormatException($"The model {nameof(VirtualMachineScaleSetVmInstanceRequiredIds)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("instanceIds"u8); writer.WriteStartArray(); foreach (var item in InstanceIds) @@ -48,7 +56,6 @@ void IJsonModel.Write(Utf8JsonWrite #endif } } - writer.WriteEndObject(); } VirtualMachineScaleSetVmInstanceRequiredIds IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetVmInstanceView.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetVmInstanceView.Serialization.cs index b36dcf7fe25..5ec79bf99f8 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetVmInstanceView.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetVmInstanceView.Serialization.cs @@ -21,6 +21,15 @@ public partial class VirtualMachineScaleSetVmInstanceView : IUtf8JsonSerializabl void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter write throw new FormatException($"The model {nameof(VirtualMachineScaleSetVmInstanceView)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(PlatformUpdateDomain)) { writer.WritePropertyName("platformUpdateDomain"u8); @@ -119,7 +127,6 @@ void IJsonModel.Write(Utf8JsonWriter write #endif } } - writer.WriteEndObject(); } VirtualMachineScaleSetVmInstanceView IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetVmListResult.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetVmListResult.Serialization.cs index 7ed57d9f0af..29aa701c7d9 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetVmListResult.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetVmListResult.Serialization.cs @@ -21,6 +21,15 @@ internal partial class VirtualMachineScaleSetVmListResult : IUtf8JsonSerializabl void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, throw new FormatException($"The model {nameof(VirtualMachineScaleSetVmListResult)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("value"u8); writer.WriteStartArray(); foreach (var item in Value) @@ -56,7 +64,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, #endif } } - writer.WriteEndObject(); } VirtualMachineScaleSetVmListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetVmNetworkProfileConfiguration.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetVmNetworkProfileConfiguration.Serialization.cs index a88df3e19f6..76586e61197 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetVmNetworkProfileConfiguration.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetVmNetworkProfileConfiguration.Serialization.cs @@ -21,6 +21,15 @@ internal partial class VirtualMachineScaleSetVmNetworkProfileConfiguration : IUt void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8J throw new FormatException($"The model {nameof(VirtualMachineScaleSetVmNetworkProfileConfiguration)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsCollectionDefined(NetworkInterfaceConfigurations)) { writer.WritePropertyName("networkInterfaceConfigurations"u8); @@ -54,7 +62,6 @@ void IJsonModel.Write(Utf8J #endif } } - writer.WriteEndObject(); } VirtualMachineScaleSetVmNetworkProfileConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetVmProfile.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetVmProfile.Serialization.cs index d276fbd248c..97f71c052e0 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetVmProfile.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetVmProfile.Serialization.cs @@ -20,6 +20,15 @@ public partial class VirtualMachineScaleSetVmProfile : IUtf8JsonSerializable, IJ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mo throw new FormatException($"The model {nameof(VirtualMachineScaleSetVmProfile)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(OSProfile)) { writer.WritePropertyName("osProfile"u8); @@ -98,7 +106,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mo #endif } } - writer.WriteEndObject(); } VirtualMachineScaleSetVmProfile IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetVmProtectionPolicy.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetVmProtectionPolicy.Serialization.cs index 4eca5cf7b73..f09fec22b68 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetVmProtectionPolicy.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetVmProtectionPolicy.Serialization.cs @@ -20,6 +20,15 @@ public partial class VirtualMachineScaleSetVmProtectionPolicy : IUtf8JsonSeriali void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter w throw new FormatException($"The model {nameof(VirtualMachineScaleSetVmProtectionPolicy)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(ProtectFromScaleIn)) { writer.WritePropertyName("protectFromScaleIn"u8); @@ -53,7 +61,6 @@ void IJsonModel.Write(Utf8JsonWriter w #endif } } - writer.WriteEndObject(); } VirtualMachineScaleSetVmProtectionPolicy IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetVmReimageContent.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetVmReimageContent.Serialization.cs index 9cb7d70436a..7d81a8103f9 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetVmReimageContent.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetVmReimageContent.Serialization.cs @@ -18,6 +18,15 @@ public partial class VirtualMachineScaleSetVmReimageContent : IUtf8JsonSerializa void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -25,28 +34,7 @@ void IJsonModel.Write(Utf8JsonWriter wri throw new FormatException($"The model {nameof(VirtualMachineScaleSetVmReimageContent)} does not support writing '{format}' format."); } - writer.WriteStartObject(); - if (Optional.IsDefined(TempDisk)) - { - writer.WritePropertyName("tempDisk"u8); - writer.WriteBooleanValue(TempDisk.Value); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); + base.JsonModelWriteCore(writer, options); } VirtualMachineScaleSetVmReimageContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineSize.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineSize.Serialization.cs index a27db23a8ac..ec90519d8c4 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineSize.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineSize.Serialization.cs @@ -20,6 +20,15 @@ public partial class VirtualMachineSize : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrit throw new FormatException($"The model {nameof(VirtualMachineSize)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(Name)) { writer.WritePropertyName("name"u8); @@ -73,7 +81,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrit #endif } } - writer.WriteEndObject(); } VirtualMachineSize IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineSizeListResult.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineSizeListResult.Serialization.cs index 196fcaaa940..b55601d81df 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineSizeListResult.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineSizeListResult.Serialization.cs @@ -21,6 +21,15 @@ internal partial class VirtualMachineSizeListResult : IUtf8JsonSerializable, IJs void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, Model throw new FormatException($"The model {nameof(VirtualMachineSizeListResult)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsCollectionDefined(Value)) { writer.WritePropertyName("value"u8); @@ -54,7 +62,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, Model #endif } } - writer.WriteEndObject(); } VirtualMachineSizeListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineSoftwarePatchProperties.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineSoftwarePatchProperties.Serialization.cs index d63cf2c2a3f..0a60aeb8edd 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineSoftwarePatchProperties.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineSoftwarePatchProperties.Serialization.cs @@ -21,6 +21,15 @@ public partial class VirtualMachineSoftwarePatchProperties : IUtf8JsonSerializab void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter writ throw new FormatException($"The model {nameof(VirtualMachineSoftwarePatchProperties)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (options.Format != "W" && Optional.IsDefined(PatchId)) { writer.WritePropertyName("patchId"u8); @@ -99,7 +107,6 @@ void IJsonModel.Write(Utf8JsonWriter writ #endif } } - writer.WriteEndObject(); } VirtualMachineSoftwarePatchProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineStatusCodeCount.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineStatusCodeCount.Serialization.cs index c535dd9e9ce..3a750d02417 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineStatusCodeCount.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineStatusCodeCount.Serialization.cs @@ -20,6 +20,15 @@ public partial class VirtualMachineStatusCodeCount : IUtf8JsonSerializable, IJso void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mode throw new FormatException($"The model {nameof(VirtualMachineStatusCodeCount)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (options.Format != "W" && Optional.IsDefined(Code)) { writer.WritePropertyName("code"u8); @@ -53,7 +61,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mode #endif } } - writer.WriteEndObject(); } VirtualMachineStatusCodeCount IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VmScaleSetConvertToSinglePlacementGroupContent.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VmScaleSetConvertToSinglePlacementGroupContent.Serialization.cs index e5b0e9bfc23..043d579613e 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VmScaleSetConvertToSinglePlacementGroupContent.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VmScaleSetConvertToSinglePlacementGroupContent.Serialization.cs @@ -18,6 +18,15 @@ public partial class VmScaleSetConvertToSinglePlacementGroupContent : IUtf8JsonS void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -25,7 +34,6 @@ void IJsonModel.Write(Utf8JsonWr throw new FormatException($"The model {nameof(VmScaleSetConvertToSinglePlacementGroupContent)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(ActivePlacementGroupId)) { writer.WritePropertyName("activePlacementGroupId"u8); @@ -46,7 +54,6 @@ void IJsonModel.Write(Utf8JsonWr #endif } } - writer.WriteEndObject(); } VmScaleSetConvertToSinglePlacementGroupContent IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/WinRMConfiguration.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/WinRMConfiguration.Serialization.cs index a9679ad33fd..3fbdfd2a587 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/WinRMConfiguration.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/WinRMConfiguration.Serialization.cs @@ -21,6 +21,15 @@ internal partial class WinRMConfiguration : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrit throw new FormatException($"The model {nameof(WinRMConfiguration)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsCollectionDefined(Listeners)) { writer.WritePropertyName("listeners"u8); @@ -54,7 +62,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrit #endif } } - writer.WriteEndObject(); } WinRMConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/WinRMListener.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/WinRMListener.Serialization.cs index 8ae797a1edb..8177b3b8d2d 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/WinRMListener.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/WinRMListener.Serialization.cs @@ -20,6 +20,15 @@ public partial class WinRMListener : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOpt throw new FormatException($"The model {nameof(WinRMListener)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(Protocol)) { writer.WritePropertyName("protocol"u8); @@ -53,7 +61,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOpt #endif } } - writer.WriteEndObject(); } WinRMListener IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/WindowsConfiguration.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/WindowsConfiguration.Serialization.cs index 5ca9bfb5015..14d6d20c3aa 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/WindowsConfiguration.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/WindowsConfiguration.Serialization.cs @@ -21,6 +21,15 @@ public partial class WindowsConfiguration : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWr throw new FormatException($"The model {nameof(WindowsConfiguration)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(ProvisionVmAgent)) { writer.WritePropertyName("provisionVMAgent"u8); @@ -79,7 +87,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWr #endif } } - writer.WriteEndObject(); } WindowsConfiguration IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/ProximityPlacementGroupData.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/ProximityPlacementGroupData.Serialization.cs index e01a5e293f2..024ac4a5544 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/ProximityPlacementGroupData.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/ProximityPlacementGroupData.Serialization.cs @@ -24,6 +24,15 @@ public partial class ProximityPlacementGroupData : IUtf8JsonSerializable, IJsonM void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -31,45 +40,12 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelR throw new FormatException($"The model {nameof(ProximityPlacementGroupData)} does not support writing '{format}' format."); } - writer.WriteStartObject(); + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(ExtendedLocation)) { writer.WritePropertyName("extendedLocation"u8); JsonSerializer.Serialize(writer, ExtendedLocation); } - if (Optional.IsCollectionDefined(Tags)) - { - writer.WritePropertyName("tags"u8); - writer.WriteStartObject(); - foreach (var item in Tags) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - writer.WritePropertyName("location"u8); - writer.WriteStringValue(Location); - if (options.Format != "W") - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (options.Format != "W") - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (options.Format != "W") - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(ResourceType); - } - if (options.Format != "W" && Optional.IsDefined(SystemData)) - { - writer.WritePropertyName("systemData"u8); - JsonSerializer.Serialize(writer, SystemData); - } writer.WritePropertyName("properties"u8); writer.WriteStartObject(); if (Optional.IsDefined(ProximityPlacementGroupType)) @@ -113,22 +89,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelR writer.WriteObjectValue(ColocationStatus, options); } writer.WriteEndObject(); - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } ProximityPlacementGroupData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/SshPublicKeyData.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/SshPublicKeyData.Serialization.cs index 36db1c62a6d..f219e35e2c3 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/SshPublicKeyData.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/SshPublicKeyData.Serialization.cs @@ -22,6 +22,15 @@ public partial class SshPublicKeyData : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -29,40 +38,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriter throw new FormatException($"The model {nameof(SshPublicKeyData)} does not support writing '{format}' format."); } - writer.WriteStartObject(); - if (Optional.IsCollectionDefined(Tags)) - { - writer.WritePropertyName("tags"u8); - writer.WriteStartObject(); - foreach (var item in Tags) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - writer.WritePropertyName("location"u8); - writer.WriteStringValue(Location); - if (options.Format != "W") - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (options.Format != "W") - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (options.Format != "W") - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(ResourceType); - } - if (options.Format != "W" && Optional.IsDefined(SystemData)) - { - writer.WritePropertyName("systemData"u8); - JsonSerializer.Serialize(writer, SystemData); - } + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("properties"u8); writer.WriteStartObject(); if (Optional.IsDefined(PublicKey)) @@ -71,22 +47,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriter writer.WriteStringValue(PublicKey); } writer.WriteEndObject(); - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } SshPublicKeyData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineData.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineData.Serialization.cs index 67e56dd5fc8..4d13033f373 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineData.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineData.Serialization.cs @@ -24,6 +24,15 @@ public partial class VirtualMachineData : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -31,7 +40,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrit throw new FormatException($"The model {nameof(VirtualMachineData)} does not support writing '{format}' format."); } - writer.WriteStartObject(); + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(Plan)) { writer.WritePropertyName("plan"u8); @@ -62,39 +71,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrit } writer.WriteEndArray(); } - if (Optional.IsCollectionDefined(Tags)) - { - writer.WritePropertyName("tags"u8); - writer.WriteStartObject(); - foreach (var item in Tags) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - writer.WritePropertyName("location"u8); - writer.WriteStringValue(Location); - if (options.Format != "W") - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (options.Format != "W") - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (options.Format != "W") - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(ResourceType); - } - if (options.Format != "W" && Optional.IsDefined(SystemData)) - { - writer.WritePropertyName("systemData"u8); - JsonSerializer.Serialize(writer, SystemData); - } writer.WritePropertyName("properties"u8); writer.WriteStartObject(); if (Optional.IsDefined(HardwareProfile)) @@ -198,22 +174,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrit writer.WriteStringValue(ExtensionsTimeBudget); } writer.WriteEndObject(); - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } VirtualMachineData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineExtensionData.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineExtensionData.Serialization.cs index 080e47dbeeb..913eb81877b 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineExtensionData.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineExtensionData.Serialization.cs @@ -23,6 +23,15 @@ public partial class VirtualMachineExtensionData : IUtf8JsonSerializable, IJsonM void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -30,40 +39,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelR throw new FormatException($"The model {nameof(VirtualMachineExtensionData)} does not support writing '{format}' format."); } - writer.WriteStartObject(); - if (Optional.IsCollectionDefined(Tags)) - { - writer.WritePropertyName("tags"u8); - writer.WriteStartObject(); - foreach (var item in Tags) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - writer.WritePropertyName("location"u8); - writer.WriteStringValue(Location); - if (options.Format != "W") - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (options.Format != "W") - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (options.Format != "W") - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(ResourceType); - } - if (options.Format != "W" && Optional.IsDefined(SystemData)) - { - writer.WritePropertyName("systemData"u8); - JsonSerializer.Serialize(writer, SystemData); - } + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("properties"u8); writer.WriteStartObject(); if (Optional.IsDefined(ForceUpdateTag)) @@ -131,22 +107,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelR writer.WriteObjectValue(InstanceView, options); } writer.WriteEndObject(); - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } VirtualMachineExtensionData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineExtensionImageData.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineExtensionImageData.Serialization.cs index 30c6d8fbc9a..7006c782a73 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineExtensionImageData.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineExtensionImageData.Serialization.cs @@ -22,6 +22,15 @@ public partial class VirtualMachineExtensionImageData : IUtf8JsonSerializable, I void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -29,40 +38,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, M throw new FormatException($"The model {nameof(VirtualMachineExtensionImageData)} does not support writing '{format}' format."); } - writer.WriteStartObject(); - if (Optional.IsCollectionDefined(Tags)) - { - writer.WritePropertyName("tags"u8); - writer.WriteStartObject(); - foreach (var item in Tags) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - writer.WritePropertyName("location"u8); - writer.WriteStringValue(Location); - if (options.Format != "W") - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (options.Format != "W") - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (options.Format != "W") - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(ResourceType); - } - if (options.Format != "W" && Optional.IsDefined(SystemData)) - { - writer.WritePropertyName("systemData"u8); - JsonSerializer.Serialize(writer, SystemData); - } + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("properties"u8); writer.WriteStartObject(); if (Optional.IsDefined(OperatingSystem)) @@ -91,22 +67,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, M writer.WriteBooleanValue(SupportsMultipleExtensions.Value); } writer.WriteEndObject(); - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } VirtualMachineExtensionImageData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineScaleSetData.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineScaleSetData.Serialization.cs index d7788a575a4..6ab39d8fe6b 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineScaleSetData.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineScaleSetData.Serialization.cs @@ -24,6 +24,15 @@ public partial class VirtualMachineScaleSetData : IUtf8JsonSerializable, IJsonMo void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -31,7 +40,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRe throw new FormatException($"The model {nameof(VirtualMachineScaleSetData)} does not support writing '{format}' format."); } - writer.WriteStartObject(); + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(Sku)) { writer.WritePropertyName("sku"u8); @@ -57,39 +66,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRe } writer.WriteEndArray(); } - if (Optional.IsCollectionDefined(Tags)) - { - writer.WritePropertyName("tags"u8); - writer.WriteStartObject(); - foreach (var item in Tags) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - writer.WritePropertyName("location"u8); - writer.WriteStringValue(Location); - if (options.Format != "W") - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (options.Format != "W") - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (options.Format != "W") - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(ResourceType); - } - if (options.Format != "W" && Optional.IsDefined(SystemData)) - { - writer.WritePropertyName("systemData"u8); - JsonSerializer.Serialize(writer, SystemData); - } writer.WritePropertyName("properties"u8); writer.WriteStartObject(); if (Optional.IsDefined(UpgradePolicy)) @@ -163,22 +139,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRe writer.WriteObjectValue(ScaleInPolicy, options); } writer.WriteEndObject(); - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } VirtualMachineScaleSetData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineScaleSetExtensionData.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineScaleSetExtensionData.Serialization.cs index 83dabd57c37..556965317ad 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineScaleSetExtensionData.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineScaleSetExtensionData.Serialization.cs @@ -21,6 +21,15 @@ public partial class VirtualMachineScaleSetExtensionData : IUtf8JsonSerializable void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,7 @@ void IJsonModel.Write(Utf8JsonWriter writer throw new FormatException($"The model {nameof(VirtualMachineScaleSetExtensionData)} does not support writing '{format}' format."); } - writer.WriteStartObject(); + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(Name)) { writer.WritePropertyName("name"u8); @@ -39,11 +48,6 @@ void IJsonModel.Write(Utf8JsonWriter writer writer.WritePropertyName("type"u8); writer.WriteStringValue(ResourceType.Value); } - if (options.Format != "W" && Optional.IsDefined(Id)) - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } writer.WritePropertyName("properties"u8); writer.WriteStartObject(); if (Optional.IsDefined(ForceUpdateTag)) @@ -116,22 +120,6 @@ void IJsonModel.Write(Utf8JsonWriter writer writer.WriteEndArray(); } writer.WriteEndObject(); - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } VirtualMachineScaleSetExtensionData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineScaleSetRollingUpgradeData.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineScaleSetRollingUpgradeData.Serialization.cs index caf7e8071d2..f3e05c486f9 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineScaleSetRollingUpgradeData.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineScaleSetRollingUpgradeData.Serialization.cs @@ -23,6 +23,15 @@ public partial class VirtualMachineScaleSetRollingUpgradeData : IUtf8JsonSeriali void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -30,40 +39,7 @@ void IJsonModel.Write(Utf8JsonWriter w throw new FormatException($"The model {nameof(VirtualMachineScaleSetRollingUpgradeData)} does not support writing '{format}' format."); } - writer.WriteStartObject(); - if (Optional.IsCollectionDefined(Tags)) - { - writer.WritePropertyName("tags"u8); - writer.WriteStartObject(); - foreach (var item in Tags) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - writer.WritePropertyName("location"u8); - writer.WriteStringValue(Location); - if (options.Format != "W") - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (options.Format != "W") - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (options.Format != "W") - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(ResourceType); - } - if (options.Format != "W" && Optional.IsDefined(SystemData)) - { - writer.WritePropertyName("systemData"u8); - JsonSerializer.Serialize(writer, SystemData); - } + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("properties"u8); writer.WriteStartObject(); if (options.Format != "W" && Optional.IsDefined(Policy)) @@ -87,22 +63,6 @@ void IJsonModel.Write(Utf8JsonWriter w writer.WriteObjectValue(Error, options); } writer.WriteEndObject(); - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } VirtualMachineScaleSetRollingUpgradeData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineScaleSetVmData.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineScaleSetVmData.Serialization.cs index 8c4cd544732..a339477585a 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineScaleSetVmData.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineScaleSetVmData.Serialization.cs @@ -24,6 +24,15 @@ public partial class VirtualMachineScaleSetVmData : IUtf8JsonSerializable, IJson void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -31,7 +40,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, Model throw new FormatException($"The model {nameof(VirtualMachineScaleSetVmData)} does not support writing '{format}' format."); } - writer.WriteStartObject(); + base.JsonModelWriteCore(writer, options); if (options.Format != "W" && Optional.IsDefined(InstanceId)) { writer.WritePropertyName("instanceId"u8); @@ -67,39 +76,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, Model } writer.WriteEndArray(); } - if (Optional.IsCollectionDefined(Tags)) - { - writer.WritePropertyName("tags"u8); - writer.WriteStartObject(); - foreach (var item in Tags) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - writer.WritePropertyName("location"u8); - writer.WriteStringValue(Location); - if (options.Format != "W") - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (options.Format != "W") - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (options.Format != "W") - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(ResourceType); - } - if (options.Format != "W" && Optional.IsDefined(SystemData)) - { - writer.WritePropertyName("systemData"u8); - JsonSerializer.Serialize(writer, SystemData); - } writer.WritePropertyName("properties"u8); writer.WriteStartObject(); if (options.Format != "W" && Optional.IsDefined(LatestModelApplied)) @@ -183,22 +159,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, Model writer.WriteObjectValue(ProtectionPolicy, options); } writer.WriteEndObject(); - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } VirtualMachineScaleSetVmData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/samples/AzureSample.ResourceManager.Storage/src/Generated/Configuration.json b/samples/AzureSample.ResourceManager.Storage/src/Generated/Configuration.json index 7b056ddbe2b..8b86a4673d1 100644 --- a/samples/AzureSample.ResourceManager.Storage/src/Generated/Configuration.json +++ b/samples/AzureSample.ResourceManager.Storage/src/Generated/Configuration.json @@ -10,6 +10,7 @@ "public-clients": true, "head-as-boolean": true, "skip-csproj-packagereference": true, + "use-write-core": true, "RequestPathToParent": { "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}" diff --git a/src/AutoRest.CSharp/Common/Input/Configuration.cs b/src/AutoRest.CSharp/Common/Input/Configuration.cs index f462cb1d8a8..814a959a686 100644 --- a/src/AutoRest.CSharp/Common/Input/Configuration.cs +++ b/src/AutoRest.CSharp/Common/Input/Configuration.cs @@ -147,7 +147,8 @@ public static void Initialize( ShouldTreatBase64AsBinaryData = !azureArm && !generation1ConvenienceClient ? shouldTreatBase64AsBinaryData : false; UseCoreDataFactoryReplacements = useCoreDataFactoryReplacements; UseModelReaderWriter = useModelReaderWriter; - UseWriteCore = useWriteCore; + // TODO: remove use-writ-core after we enable all RPs for DPG + UseWriteCore = azureArm ? true : useWriteCore; EnableBicepSerialization = enableBicepSerialization; EnableInternalRawData = enableInternalRawData; projectFolder ??= ProjectFolderDefault; diff --git a/src/TypeSpec.Extension/Emitter.Csharp/src/emitter.ts b/src/TypeSpec.Extension/Emitter.Csharp/src/emitter.ts index 3cff16ca5d6..ae6532a88e1 100644 --- a/src/TypeSpec.Extension/Emitter.Csharp/src/emitter.ts +++ b/src/TypeSpec.Extension/Emitter.Csharp/src/emitter.ts @@ -91,9 +91,7 @@ export async function $onEmit(context: EmitContext) { ); configurations["azure-arm"] = sdkContext.arm === false ? undefined : sdkContext.arm; - configurations["use-write-core"] = - options["use-write-core"] ?? - (configurations["azure-arm"] ? true : undefined); + configurations["use-write-core"] = options["use-write-core"]; await program.host.writeFile( resolvePath(outputFolder, configurationFileName), prettierOutput(JSON.stringify(configurations, null, 2)) diff --git a/src/TypeSpec.Extension/Emitter.Csharp/src/options.ts b/src/TypeSpec.Extension/Emitter.Csharp/src/options.ts index 6c131b36fa9..05381a37261 100644 --- a/src/TypeSpec.Extension/Emitter.Csharp/src/options.ts +++ b/src/TypeSpec.Extension/Emitter.Csharp/src/options.ts @@ -30,7 +30,7 @@ export const AzureNetEmitterOptionsSchema: JSONSchemaType void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -25,7 +34,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions optio throw new FormatException($"The model {nameof(Cat)} does not support writing '{format}' format."); } - writer.WriteStartObject(); + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(Sleep)) { writer.WritePropertyName("sleep"u8); @@ -41,55 +50,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions optio writer.WritePropertyName("meow"u8); writer.WriteStringValue(Meow); } - writer.WritePropertyName("kind"u8); - writer.WriteStringValue(Kind.ToSerialString()); - if (options.Format != "W" && Optional.IsDefined(Name)) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - writer.WritePropertyName("size"u8); - SerializeSizeProperty(writer, options); - if (Optional.IsDefined(DateOfBirth)) - { - writer.WritePropertyName("dateOfBirth"u8); - SerializeDateOfBirthProperty(writer, options); - } - if (Optional.IsCollectionDefined(Tags)) - { - writer.WritePropertyName("tags"u8); - writer.WriteStartObject(); - foreach (var item in Tags) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - writer.WritePropertyName("properties"u8); - writer.WriteStartObject(); - if (Optional.IsDefined(Color)) - { - writer.WritePropertyName("color"u8); - SerializeColorProperty(writer, options); - } - writer.WriteEndObject(); - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } Cat IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtCustomizations/src/Generated/Models/Dog.Serialization.cs b/test/TestProjects/MgmtCustomizations/src/Generated/Models/Dog.Serialization.cs index 037ac6b3be4..4b90079c96e 100644 --- a/test/TestProjects/MgmtCustomizations/src/Generated/Models/Dog.Serialization.cs +++ b/test/TestProjects/MgmtCustomizations/src/Generated/Models/Dog.Serialization.cs @@ -18,6 +18,15 @@ public partial class Dog : IUtf8JsonSerializable, IJsonModel void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -25,44 +34,14 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions optio throw new FormatException($"The model {nameof(Dog)} does not support writing '{format}' format."); } - writer.WriteStartObject(); + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(Jump)) { writer.WritePropertyName("jump"u8); writer.WriteStringValue(Jump); } - writer.WritePropertyName("kind"u8); - writer.WriteStringValue(Kind.ToSerialString()); - if (options.Format != "W" && Optional.IsDefined(Name)) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - writer.WritePropertyName("size"u8); - SerializeSizeProperty(writer, options); - if (Optional.IsDefined(DateOfBirth)) - { - writer.WritePropertyName("dateOfBirth"u8); - SerializeDateOfBirthProperty(writer, options); - } - if (Optional.IsCollectionDefined(Tags)) - { - writer.WritePropertyName("tags"u8); - writer.WriteStartObject(); - foreach (var item in Tags) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } writer.WritePropertyName("properties"u8); writer.WriteStartObject(); - if (Optional.IsDefined(Color)) - { - writer.WritePropertyName("color"u8); - SerializeColorProperty(writer, options); - } writer.WritePropertyName("dog"u8); writer.WriteStartObject(); if (Optional.IsDefined(Bark)) @@ -77,22 +56,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions optio } writer.WriteEndObject(); writer.WriteEndObject(); - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } Dog IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtCustomizations/src/Generated/Models/Pet.Serialization.cs b/test/TestProjects/MgmtCustomizations/src/Generated/Models/Pet.Serialization.cs index 93561d01c94..1abae524c5a 100644 --- a/test/TestProjects/MgmtCustomizations/src/Generated/Models/Pet.Serialization.cs +++ b/test/TestProjects/MgmtCustomizations/src/Generated/Models/Pet.Serialization.cs @@ -18,6 +18,15 @@ public partial class Pet : IUtf8JsonSerializable, IJsonModel void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -25,7 +34,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions optio throw new FormatException($"The model {nameof(Pet)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("kind"u8); writer.WriteStringValue(Kind.ToSerialString()); if (options.Format != "W" && Optional.IsDefined(Name)) @@ -74,7 +82,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions optio #endif } } - writer.WriteEndObject(); } Pet IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtCustomizations/src/Generated/Models/PetStoreListResult.Serialization.cs b/test/TestProjects/MgmtCustomizations/src/Generated/Models/PetStoreListResult.Serialization.cs index be978d4a78e..9afc80b9538 100644 --- a/test/TestProjects/MgmtCustomizations/src/Generated/Models/PetStoreListResult.Serialization.cs +++ b/test/TestProjects/MgmtCustomizations/src/Generated/Models/PetStoreListResult.Serialization.cs @@ -18,6 +18,15 @@ internal partial class PetStoreListResult : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -25,7 +34,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrit throw new FormatException($"The model {nameof(PetStoreListResult)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsCollectionDefined(Value)) { writer.WritePropertyName("value"u8); @@ -51,7 +59,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrit #endif } } - writer.WriteEndObject(); } PetStoreListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtCustomizations/src/Generated/Models/PetStoreProperties.Serialization.cs b/test/TestProjects/MgmtCustomizations/src/Generated/Models/PetStoreProperties.Serialization.cs index 82b4306443a..bf15e6dd1c0 100644 --- a/test/TestProjects/MgmtCustomizations/src/Generated/Models/PetStoreProperties.Serialization.cs +++ b/test/TestProjects/MgmtCustomizations/src/Generated/Models/PetStoreProperties.Serialization.cs @@ -18,6 +18,15 @@ public partial class PetStoreProperties : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -25,7 +34,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrit throw new FormatException($"The model {nameof(PetStoreProperties)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(Order)) { writer.WritePropertyName("order"u8); @@ -51,7 +59,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrit #endif } } - writer.WriteEndObject(); } PetStoreProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtCustomizations/src/Generated/Models/UnknownPet.Serialization.cs b/test/TestProjects/MgmtCustomizations/src/Generated/Models/UnknownPet.Serialization.cs index 40568b62fae..26833dc7925 100644 --- a/test/TestProjects/MgmtCustomizations/src/Generated/Models/UnknownPet.Serialization.cs +++ b/test/TestProjects/MgmtCustomizations/src/Generated/Models/UnknownPet.Serialization.cs @@ -18,6 +18,15 @@ internal partial class UnknownPet : IUtf8JsonSerializable, IJsonModel void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -25,56 +34,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions optio throw new FormatException($"The model {nameof(Pet)} does not support writing '{format}' format."); } - writer.WriteStartObject(); - writer.WritePropertyName("kind"u8); - writer.WriteStringValue(Kind.ToSerialString()); - if (options.Format != "W" && Optional.IsDefined(Name)) - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - writer.WritePropertyName("size"u8); - SerializeSizeProperty(writer, options); - if (Optional.IsDefined(DateOfBirth)) - { - writer.WritePropertyName("dateOfBirth"u8); - SerializeDateOfBirthProperty(writer, options); - } - if (Optional.IsCollectionDefined(Tags)) - { - writer.WritePropertyName("tags"u8); - writer.WriteStartObject(); - foreach (var item in Tags) - { - writer.WritePropertyName(item.Key); - writer.WriteStringValue(item.Value); - } - writer.WriteEndObject(); - } - writer.WritePropertyName("properties"u8); - writer.WriteStartObject(); - if (Optional.IsDefined(Color)) - { - writer.WritePropertyName("color"u8); - SerializeColorProperty(writer, options); - } - writer.WriteEndObject(); - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); + base.JsonModelWriteCore(writer, options); } Pet IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtCustomizations/src/Generated/PetStoreData.Serialization.cs b/test/TestProjects/MgmtCustomizations/src/Generated/PetStoreData.Serialization.cs index f23e2decaeb..8de02d731b6 100644 --- a/test/TestProjects/MgmtCustomizations/src/Generated/PetStoreData.Serialization.cs +++ b/test/TestProjects/MgmtCustomizations/src/Generated/PetStoreData.Serialization.cs @@ -20,6 +20,15 @@ public partial class PetStoreData : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,48 +36,12 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOpti throw new FormatException($"The model {nameof(PetStoreData)} does not support writing '{format}' format."); } - writer.WriteStartObject(); + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(Properties)) { writer.WritePropertyName("properties"u8); writer.WriteObjectValue(Properties, options); } - if (options.Format != "W") - { - writer.WritePropertyName("id"u8); - WriteId(writer, options); - } - if (options.Format != "W") - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (options.Format != "W") - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(ResourceType); - } - if (options.Format != "W" && Optional.IsDefined(SystemData)) - { - writer.WritePropertyName("systemData"u8); - JsonSerializer.Serialize(writer, SystemData); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } PetStoreData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/ArtifactData.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/ArtifactData.Serialization.cs index 1d1b5da9ca6..fc75eb32d22 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/ArtifactData.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/ArtifactData.Serialization.cs @@ -22,6 +22,15 @@ public partial class ArtifactData : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -29,45 +38,9 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOpti throw new FormatException($"The model {nameof(ArtifactData)} does not support writing '{format}' format."); } - writer.WriteStartObject(); + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("kind"u8); writer.WriteStringValue(Kind.ToString()); - if (options.Format != "W") - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (options.Format != "W") - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (options.Format != "W") - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(ResourceType); - } - if (options.Format != "W" && Optional.IsDefined(SystemData)) - { - writer.WritePropertyName("systemData"u8); - JsonSerializer.Serialize(writer, SystemData); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } ArtifactData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Configuration.json b/test/TestProjects/MgmtDiscriminator/src/Generated/Configuration.json index 29892da7517..492631bc72a 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Configuration.json +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Configuration.json @@ -10,6 +10,7 @@ "public-clients": true, "skip-csproj-packagereference": true, "use-model-reader-writer": true, + "use-write-core": true, "enable-bicep-serialization": true, "suppress-abstract-base-class": [ "DeliveryRuleAction" diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/DeliveryRuleData.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/DeliveryRuleData.Serialization.cs index 395144b6dc1..32c3d4d5214 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/DeliveryRuleData.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/DeliveryRuleData.Serialization.cs @@ -22,6 +22,15 @@ public partial class DeliveryRuleData : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -29,7 +38,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriter throw new FormatException($"The model {nameof(DeliveryRuleData)} does not support writing '{format}' format."); } - writer.WriteStartObject(); + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(BoolProperty)) { writer.WritePropertyName("boolProperty"u8); @@ -85,47 +94,11 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriter writer.WritePropertyName("properties"u8); writer.WriteObjectValue(Properties, options); } - if (options.Format != "W") - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (options.Format != "W") - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (options.Format != "W") - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(ResourceType); - } - if (options.Format != "W" && Optional.IsDefined(SystemData)) - { - writer.WritePropertyName("systemData"u8); - JsonSerializer.Serialize(writer, SystemData); - } foreach (var item in AdditionalProperties) { writer.WritePropertyName(item.Key); writer.WriteStringValue(item.Value); } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } DeliveryRuleData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/ArtifactList.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/ArtifactList.Serialization.cs index f0fb22e0fad..1e538b4cb77 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/ArtifactList.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/ArtifactList.Serialization.cs @@ -21,6 +21,15 @@ internal partial class ArtifactList : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOpti throw new FormatException($"The model {nameof(ArtifactList)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsCollectionDefined(Value)) { writer.WritePropertyName("value"u8); @@ -59,7 +67,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOpti #endif } } - writer.WriteEndObject(); } ArtifactList IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/BaseModel.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/BaseModel.Serialization.cs index a040cc858ff..4e1f34c45af 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/BaseModel.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/BaseModel.Serialization.cs @@ -20,6 +20,15 @@ public partial class BaseModel : IUtf8JsonSerializable, IJsonModel void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions throw new FormatException($"The model {nameof(BaseModel)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(OptionalString)) { writer.WritePropertyName("optionalString"u8); @@ -48,7 +56,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions #endif } } - writer.WriteEndObject(); } BaseModel IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/CacheExpirationActionParameters.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/CacheExpirationActionParameters.Serialization.cs index 4d4eb4d5762..1c14e80d284 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/CacheExpirationActionParameters.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/CacheExpirationActionParameters.Serialization.cs @@ -20,6 +20,15 @@ public partial class CacheExpirationActionParameters : IUtf8JsonSerializable, IJ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mo throw new FormatException($"The model {nameof(CacheExpirationActionParameters)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("typeName"u8); writer.WriteStringValue(TypeName.ToString()); writer.WritePropertyName("cacheBehavior"u8); @@ -61,7 +69,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mo #endif } } - writer.WriteEndObject(); } CacheExpirationActionParameters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/CacheKeyQueryStringActionParameters.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/CacheKeyQueryStringActionParameters.Serialization.cs index 3dd909ff24e..7d45c1c4f1e 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/CacheKeyQueryStringActionParameters.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/CacheKeyQueryStringActionParameters.Serialization.cs @@ -20,6 +20,15 @@ public partial class CacheKeyQueryStringActionParameters : IUtf8JsonSerializable void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer throw new FormatException($"The model {nameof(CacheKeyQueryStringActionParameters)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("typeName"u8); writer.WriteStringValue(TypeName.ToString()); writer.WritePropertyName("queryStringBehavior"u8); @@ -59,7 +67,6 @@ void IJsonModel.Write(Utf8JsonWriter writer #endif } } - writer.WriteEndObject(); } CacheKeyQueryStringActionParameters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/Cat.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/Cat.Serialization.cs index d0033da92d6..be6f64cab45 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/Cat.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/Cat.Serialization.cs @@ -20,6 +20,15 @@ public partial class Cat : IUtf8JsonSerializable, IJsonModel void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,40 +36,12 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions optio throw new FormatException($"The model {nameof(Cat)} does not support writing '{format}' format."); } - writer.WriteStartObject(); + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(Meow)) { writer.WritePropertyName("meow"u8); writer.WriteStringValue(Meow); } - writer.WritePropertyName("kind"u8); - writer.WriteStringValue(Kind.ToSerialString()); - if (options.Format != "W" && Optional.IsDefined(Id)) - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (Optional.IsDefined(PetType)) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(PetType); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } Cat IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DeliveryRuleAction.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DeliveryRuleAction.Serialization.cs index 48598577d95..7efcb320e99 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DeliveryRuleAction.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DeliveryRuleAction.Serialization.cs @@ -20,6 +20,15 @@ public partial class DeliveryRuleAction : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrit throw new FormatException($"The model {nameof(DeliveryRuleAction)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("name"u8); writer.WriteStringValue(Name.ToString()); if (options.Format != "W" && Optional.IsDefined(Foo)) @@ -50,7 +58,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrit #endif } } - writer.WriteEndObject(); } DeliveryRuleAction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DeliveryRuleCacheExpirationAction.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DeliveryRuleCacheExpirationAction.Serialization.cs index a95d5326ece..20621e065e8 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DeliveryRuleCacheExpirationAction.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DeliveryRuleCacheExpirationAction.Serialization.cs @@ -20,6 +20,15 @@ public partial class DeliveryRuleCacheExpirationAction : IUtf8JsonSerializable, void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,32 +36,9 @@ void IJsonModel.Write(Utf8JsonWriter writer, throw new FormatException($"The model {nameof(DeliveryRuleCacheExpirationAction)} does not support writing '{format}' format."); } - writer.WriteStartObject(); + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("parameters"u8); writer.WriteObjectValue(Parameters, options); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name.ToString()); - if (options.Format != "W" && Optional.IsDefined(Foo)) - { - writer.WritePropertyName("foo"u8); - writer.WriteStringValue(Foo); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } DeliveryRuleCacheExpirationAction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DeliveryRuleCacheKeyQueryStringAction.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DeliveryRuleCacheKeyQueryStringAction.Serialization.cs index 773006b3a5e..bc65407be83 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DeliveryRuleCacheKeyQueryStringAction.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DeliveryRuleCacheKeyQueryStringAction.Serialization.cs @@ -20,6 +20,15 @@ public partial class DeliveryRuleCacheKeyQueryStringAction : IUtf8JsonSerializab void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,32 +36,9 @@ void IJsonModel.Write(Utf8JsonWriter writ throw new FormatException($"The model {nameof(DeliveryRuleCacheKeyQueryStringAction)} does not support writing '{format}' format."); } - writer.WriteStartObject(); + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("parameters"u8); writer.WriteObjectValue(Parameters, options); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name.ToString()); - if (options.Format != "W" && Optional.IsDefined(Foo)) - { - writer.WritePropertyName("foo"u8); - writer.WriteStringValue(Foo); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } DeliveryRuleCacheKeyQueryStringAction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DeliveryRuleCondition.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DeliveryRuleCondition.Serialization.cs index cdf20855ded..624857061ba 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DeliveryRuleCondition.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DeliveryRuleCondition.Serialization.cs @@ -21,6 +21,15 @@ public partial class DeliveryRuleCondition : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderW throw new FormatException($"The model {nameof(DeliveryRuleCondition)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("name"u8); writer.WriteStringValue(Name.ToString()); if (options.Format != "W" && Optional.IsDefined(Foo)) @@ -51,7 +59,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderW #endif } } - writer.WriteEndObject(); } DeliveryRuleCondition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DeliveryRuleListResult.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DeliveryRuleListResult.Serialization.cs index 2ffa154e8b4..1251da6100a 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DeliveryRuleListResult.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DeliveryRuleListResult.Serialization.cs @@ -21,6 +21,15 @@ internal partial class DeliveryRuleListResult : IUtf8JsonSerializable, IJsonMode void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReader throw new FormatException($"The model {nameof(DeliveryRuleListResult)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsCollectionDefined(Value)) { writer.WritePropertyName("value"u8); @@ -54,7 +62,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReader #endif } } - writer.WriteEndObject(); } DeliveryRuleListResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DeliveryRuleProperties.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DeliveryRuleProperties.Serialization.cs index dc5740639aa..22ac05d181a 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DeliveryRuleProperties.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DeliveryRuleProperties.Serialization.cs @@ -21,6 +21,15 @@ public partial class DeliveryRuleProperties : IUtf8JsonSerializable, IJsonModel< void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReader throw new FormatException($"The model {nameof(DeliveryRuleProperties)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(Order)) { writer.WritePropertyName("order"u8); @@ -85,7 +93,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReader #endif } } - writer.WriteEndObject(); } DeliveryRuleProperties IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DeliveryRuleQueryStringCondition.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DeliveryRuleQueryStringCondition.Serialization.cs index 2a2748ce73e..c33d7d497cf 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DeliveryRuleQueryStringCondition.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DeliveryRuleQueryStringCondition.Serialization.cs @@ -20,6 +20,15 @@ public partial class DeliveryRuleQueryStringCondition : IUtf8JsonSerializable, I void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,32 +36,9 @@ void IJsonModel.Write(Utf8JsonWriter writer, M throw new FormatException($"The model {nameof(DeliveryRuleQueryStringCondition)} does not support writing '{format}' format."); } - writer.WriteStartObject(); + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("parameters"u8); writer.WriteObjectValue(Parameters, options); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name.ToString()); - if (options.Format != "W" && Optional.IsDefined(Foo)) - { - writer.WritePropertyName("foo"u8); - writer.WriteStringValue(Foo); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } DeliveryRuleQueryStringCondition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DeliveryRuleRemoteAddressCondition.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DeliveryRuleRemoteAddressCondition.Serialization.cs index a41fe57ff69..dab3c2e8be5 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DeliveryRuleRemoteAddressCondition.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DeliveryRuleRemoteAddressCondition.Serialization.cs @@ -20,6 +20,15 @@ public partial class DeliveryRuleRemoteAddressCondition : IUtf8JsonSerializable, void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,32 +36,9 @@ void IJsonModel.Write(Utf8JsonWriter writer, throw new FormatException($"The model {nameof(DeliveryRuleRemoteAddressCondition)} does not support writing '{format}' format."); } - writer.WriteStartObject(); + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("parameters"u8); writer.WriteObjectValue(Parameters, options); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name.ToString()); - if (options.Format != "W" && Optional.IsDefined(Foo)) - { - writer.WritePropertyName("foo"u8); - writer.WriteStringValue(Foo); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } DeliveryRuleRemoteAddressCondition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DeliveryRuleRequestHeaderAction.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DeliveryRuleRequestHeaderAction.Serialization.cs index 0bf1f7ed7c9..5e949140c1e 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DeliveryRuleRequestHeaderAction.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DeliveryRuleRequestHeaderAction.Serialization.cs @@ -20,6 +20,15 @@ public partial class DeliveryRuleRequestHeaderAction : IUtf8JsonSerializable, IJ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,32 +36,9 @@ void IJsonModel.Write(Utf8JsonWriter writer, Mo throw new FormatException($"The model {nameof(DeliveryRuleRequestHeaderAction)} does not support writing '{format}' format."); } - writer.WriteStartObject(); + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("parameters"u8); writer.WriteObjectValue(Parameters, options); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name.ToString()); - if (options.Format != "W" && Optional.IsDefined(Foo)) - { - writer.WritePropertyName("foo"u8); - writer.WriteStringValue(Foo); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } DeliveryRuleRequestHeaderAction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DeliveryRuleRequestMethodCondition.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DeliveryRuleRequestMethodCondition.Serialization.cs index b6f5b5e9216..fc5f7b8a079 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DeliveryRuleRequestMethodCondition.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DeliveryRuleRequestMethodCondition.Serialization.cs @@ -20,6 +20,15 @@ public partial class DeliveryRuleRequestMethodCondition : IUtf8JsonSerializable, void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,32 +36,9 @@ void IJsonModel.Write(Utf8JsonWriter writer, throw new FormatException($"The model {nameof(DeliveryRuleRequestMethodCondition)} does not support writing '{format}' format."); } - writer.WriteStartObject(); + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("parameters"u8); writer.WriteObjectValue(Parameters, options); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name.ToString()); - if (options.Format != "W" && Optional.IsDefined(Foo)) - { - writer.WritePropertyName("foo"u8); - writer.WriteStringValue(Foo); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } DeliveryRuleRequestMethodCondition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DeliveryRuleResponseHeaderAction.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DeliveryRuleResponseHeaderAction.Serialization.cs index dda857d2d54..41bb3a422c4 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DeliveryRuleResponseHeaderAction.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DeliveryRuleResponseHeaderAction.Serialization.cs @@ -20,6 +20,15 @@ public partial class DeliveryRuleResponseHeaderAction : IUtf8JsonSerializable, I void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,32 +36,9 @@ void IJsonModel.Write(Utf8JsonWriter writer, M throw new FormatException($"The model {nameof(DeliveryRuleResponseHeaderAction)} does not support writing '{format}' format."); } - writer.WriteStartObject(); + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("parameters"u8); writer.WriteObjectValue(Parameters, options); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name.ToString()); - if (options.Format != "W" && Optional.IsDefined(Foo)) - { - writer.WritePropertyName("foo"u8); - writer.WriteStringValue(Foo); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } DeliveryRuleResponseHeaderAction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DeliveryRuleRouteConfigurationOverrideAction.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DeliveryRuleRouteConfigurationOverrideAction.Serialization.cs index f148e6244a1..78f64ce8660 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DeliveryRuleRouteConfigurationOverrideAction.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DeliveryRuleRouteConfigurationOverrideAction.Serialization.cs @@ -20,6 +20,15 @@ public partial class DeliveryRuleRouteConfigurationOverrideAction : IUtf8JsonSer void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,32 +36,9 @@ void IJsonModel.Write(Utf8JsonWrit throw new FormatException($"The model {nameof(DeliveryRuleRouteConfigurationOverrideAction)} does not support writing '{format}' format."); } - writer.WriteStartObject(); + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("parameters"u8); writer.WriteObjectValue(Parameters, options); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name.ToString()); - if (options.Format != "W" && Optional.IsDefined(Foo)) - { - writer.WritePropertyName("foo"u8); - writer.WriteStringValue(Foo); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } DeliveryRuleRouteConfigurationOverrideAction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DerivedModel.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DerivedModel.Serialization.cs index e2a7ccc6013..e7aca24e692 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DerivedModel.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/DerivedModel.Serialization.cs @@ -21,6 +21,15 @@ public partial class DerivedModel : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOpti throw new FormatException($"The model {nameof(DerivedModel)} does not support writing '{format}' format."); } - writer.WriteStartObject(); + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("requiredCollection"u8); writer.WriteStartArray(); foreach (var item in RequiredCollection) @@ -36,27 +45,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOpti writer.WriteStringValue(item); } writer.WriteEndArray(); - if (Optional.IsDefined(OptionalString)) - { - writer.WritePropertyName("optionalString"u8); - writer.WriteStringValue(OptionalString); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } DerivedModel IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/Dog.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/Dog.Serialization.cs index 26a501e0d03..73dad1f79f6 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/Dog.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/Dog.Serialization.cs @@ -20,6 +20,15 @@ public partial class Dog : IUtf8JsonSerializable, IJsonModel void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions optio throw new FormatException($"The model {nameof(Dog)} does not support writing '{format}' format."); } - writer.WriteStartObject(); + base.JsonModelWriteCore(writer, options); if (Optional.IsDefined(Bark)) { writer.WritePropertyName("bark"u8); @@ -38,34 +47,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions optio writer.WritePropertyName("dogKind"u8); writer.WriteStringValue(DogKind.Value.ToSerialString()); } - writer.WritePropertyName("kind"u8); - writer.WriteStringValue(Kind.ToSerialString()); - if (options.Format != "W" && Optional.IsDefined(Id)) - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (Optional.IsDefined(PetType)) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(PetType); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } Dog IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/HeaderActionParameters.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/HeaderActionParameters.Serialization.cs index 5b8e084545d..0e2f9872786 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/HeaderActionParameters.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/HeaderActionParameters.Serialization.cs @@ -20,6 +20,15 @@ public partial class HeaderActionParameters : IUtf8JsonSerializable, IJsonModel< void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReader throw new FormatException($"The model {nameof(HeaderActionParameters)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("typeName"u8); writer.WriteStringValue(TypeName.ToString()); writer.WritePropertyName("headerAction"u8); @@ -54,7 +62,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReader #endif } } - writer.WriteEndObject(); } HeaderActionParameters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/OriginGroupOverride.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/OriginGroupOverride.Serialization.cs index 84d8a6b9bfe..e8614bc8490 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/OriginGroupOverride.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/OriginGroupOverride.Serialization.cs @@ -21,6 +21,15 @@ public partial class OriginGroupOverride : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWri throw new FormatException($"The model {nameof(OriginGroupOverride)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(OriginGroup)) { writer.WritePropertyName("originGroup"u8); @@ -54,7 +62,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWri #endif } } - writer.WriteEndObject(); } OriginGroupOverride IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/OriginGroupOverrideAction.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/OriginGroupOverrideAction.Serialization.cs index d90102497b5..034024d79a5 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/OriginGroupOverrideAction.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/OriginGroupOverrideAction.Serialization.cs @@ -20,6 +20,15 @@ public partial class OriginGroupOverrideAction : IUtf8JsonSerializable, IJsonMod void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,32 +36,9 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRea throw new FormatException($"The model {nameof(OriginGroupOverrideAction)} does not support writing '{format}' format."); } - writer.WriteStartObject(); + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("parameters"u8); writer.WriteObjectValue(Parameters, options); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name.ToString()); - if (options.Format != "W" && Optional.IsDefined(Foo)) - { - writer.WritePropertyName("foo"u8); - writer.WriteStringValue(Foo); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } OriginGroupOverrideAction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/OriginGroupOverrideActionParameters.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/OriginGroupOverrideActionParameters.Serialization.cs index 2127b7badb1..5b147d494ca 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/OriginGroupOverrideActionParameters.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/OriginGroupOverrideActionParameters.Serialization.cs @@ -21,6 +21,15 @@ public partial class OriginGroupOverrideActionParameters : IUtf8JsonSerializable void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter writer throw new FormatException($"The model {nameof(OriginGroupOverrideActionParameters)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("typeName"u8); writer.WriteStringValue(TypeName.ToString()); writer.WritePropertyName("originGroup"u8); @@ -48,7 +56,6 @@ void IJsonModel.Write(Utf8JsonWriter writer #endif } } - writer.WriteEndObject(); } OriginGroupOverrideActionParameters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/Pet.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/Pet.Serialization.cs index 8401aa12526..a3e843e052d 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/Pet.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/Pet.Serialization.cs @@ -21,6 +21,15 @@ public partial class Pet : IUtf8JsonSerializable, IJsonModel void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions optio throw new FormatException($"The model {nameof(Pet)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("kind"u8); writer.WriteStringValue(Kind.ToSerialString()); if (options.Format != "W" && Optional.IsDefined(Id)) @@ -56,7 +64,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions optio #endif } } - writer.WriteEndObject(); } Pet IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/QueryStringMatchConditionParameters.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/QueryStringMatchConditionParameters.Serialization.cs index 5b5b2b927e2..6d47c085bed 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/QueryStringMatchConditionParameters.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/QueryStringMatchConditionParameters.Serialization.cs @@ -21,6 +21,15 @@ public partial class QueryStringMatchConditionParameters : IUtf8JsonSerializable void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter writer throw new FormatException($"The model {nameof(QueryStringMatchConditionParameters)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("typeName"u8); writer.WriteStringValue(TypeName.ToString()); writer.WritePropertyName("operator"u8); @@ -73,7 +81,6 @@ void IJsonModel.Write(Utf8JsonWriter writer #endif } } - writer.WriteEndObject(); } QueryStringMatchConditionParameters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/RemoteAddressMatchConditionParameters.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/RemoteAddressMatchConditionParameters.Serialization.cs index 23bb54802cc..473bcfa1e47 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/RemoteAddressMatchConditionParameters.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/RemoteAddressMatchConditionParameters.Serialization.cs @@ -21,6 +21,15 @@ public partial class RemoteAddressMatchConditionParameters : IUtf8JsonSerializab void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter writ throw new FormatException($"The model {nameof(RemoteAddressMatchConditionParameters)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("typeName"u8); writer.WriteStringValue(TypeName.ToString()); writer.WritePropertyName("operator"u8); @@ -73,7 +81,6 @@ void IJsonModel.Write(Utf8JsonWriter writ #endif } } - writer.WriteEndObject(); } RemoteAddressMatchConditionParameters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/RequestMethodMatchConditionParameters.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/RequestMethodMatchConditionParameters.Serialization.cs index 4f37cd7b1e6..144131869c3 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/RequestMethodMatchConditionParameters.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/RequestMethodMatchConditionParameters.Serialization.cs @@ -21,6 +21,15 @@ public partial class RequestMethodMatchConditionParameters : IUtf8JsonSerializab void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter writ throw new FormatException($"The model {nameof(RequestMethodMatchConditionParameters)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("typeName"u8); writer.WriteStringValue(TypeName.ToString()); writer.WritePropertyName("operator"u8); @@ -73,7 +81,6 @@ void IJsonModel.Write(Utf8JsonWriter writ #endif } } - writer.WriteEndObject(); } RequestMethodMatchConditionParameters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/RoleAssignmentArtifact.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/RoleAssignmentArtifact.Serialization.cs index 87b0d341938..c5b6845ddcf 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/RoleAssignmentArtifact.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/RoleAssignmentArtifact.Serialization.cs @@ -21,6 +21,15 @@ public partial class RoleAssignmentArtifact : IUtf8JsonSerializable, IJsonModel< void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,29 +37,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReader throw new FormatException($"The model {nameof(RoleAssignmentArtifact)} does not support writing '{format}' format."); } - writer.WriteStartObject(); - writer.WritePropertyName("kind"u8); - writer.WriteStringValue(Kind.ToString()); - if (options.Format != "W") - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (options.Format != "W") - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (options.Format != "W") - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(ResourceType); - } - if (options.Format != "W" && Optional.IsDefined(SystemData)) - { - writer.WritePropertyName("systemData"u8); - JsonSerializer.Serialize(writer, SystemData); - } + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("properties"u8); writer.WriteStartObject(); writer.WritePropertyName("roleDefinitionId"u8); @@ -70,22 +57,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReader writer.WriteStringValue(ResourceGroup); } writer.WriteEndObject(); - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } RoleAssignmentArtifact IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/RouteConfigurationOverrideActionParameters.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/RouteConfigurationOverrideActionParameters.Serialization.cs index e8fa95bd6dc..e761a0bdf8e 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/RouteConfigurationOverrideActionParameters.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/RouteConfigurationOverrideActionParameters.Serialization.cs @@ -20,6 +20,15 @@ public partial class RouteConfigurationOverrideActionParameters : IUtf8JsonSeria void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter throw new FormatException($"The model {nameof(RouteConfigurationOverrideActionParameters)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("typeName"u8); writer.WriteStringValue(TypeName.ToString()); if (Optional.IsDefined(OriginGroupOverride)) @@ -50,7 +58,6 @@ void IJsonModel.Write(Utf8JsonWriter #endif } } - writer.WriteEndObject(); } RouteConfigurationOverrideActionParameters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/Shell.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/Shell.Serialization.cs index 84bbe71bea7..ae604a5628e 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/Shell.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/Shell.Serialization.cs @@ -20,6 +20,15 @@ public partial class Shell : IUtf8JsonSerializable, IJsonModel void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions opt throw new FormatException($"The model {nameof(Shell)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(Name)) { writer.WritePropertyName("name"u8); @@ -53,7 +61,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions opt #endif } } - writer.WriteEndObject(); } Shell IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/Sku1.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/Sku1.Serialization.cs index ac6c54ea51a..1a78ae4da63 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/Sku1.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/Sku1.Serialization.cs @@ -20,6 +20,15 @@ internal partial class Sku1 : IUtf8JsonSerializable, IJsonModel void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions opti throw new FormatException($"The model {nameof(Sku1)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(Name1)) { writer.WritePropertyName("name1"u8); @@ -48,7 +56,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions opti #endif } } - writer.WriteEndObject(); } Sku1 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/Sku2.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/Sku2.Serialization.cs index d9419dc9204..fc148d63b9b 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/Sku2.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/Sku2.Serialization.cs @@ -20,6 +20,15 @@ internal partial class Sku2 : IUtf8JsonSerializable, IJsonModel void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions opti throw new FormatException($"The model {nameof(Sku2)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("nestedName"u8); writer.WriteStringValue(NestedName); if (options.Format != "W" && _serializedAdditionalRawData != null) @@ -45,7 +53,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions opti #endif } } - writer.WriteEndObject(); } Sku2 IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/TemplateArtifact.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/TemplateArtifact.Serialization.cs index 3df16d65c19..eab5b9fc92b 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/TemplateArtifact.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/TemplateArtifact.Serialization.cs @@ -22,6 +22,15 @@ public partial class TemplateArtifact : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -29,29 +38,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriter throw new FormatException($"The model {nameof(TemplateArtifact)} does not support writing '{format}' format."); } - writer.WriteStartObject(); - writer.WritePropertyName("kind"u8); - writer.WriteStringValue(Kind.ToString()); - if (options.Format != "W") - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (options.Format != "W") - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (options.Format != "W") - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(ResourceType); - } - if (options.Format != "W" && Optional.IsDefined(SystemData)) - { - writer.WritePropertyName("systemData"u8); - JsonSerializer.Serialize(writer, SystemData); - } + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("properties"u8); writer.WriteStartObject(); writer.WritePropertyName("template"u8); @@ -89,22 +76,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriter } writer.WriteEndObject(); writer.WriteEndObject(); - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } TemplateArtifact IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/Unflattened.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/Unflattened.Serialization.cs index 3b22e5adde2..16ebabf5b29 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/Unflattened.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/Unflattened.Serialization.cs @@ -20,6 +20,15 @@ public partial class Unflattened : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptio throw new FormatException($"The model {nameof(Unflattened)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsDefined(Name)) { writer.WritePropertyName("name"u8); @@ -53,7 +61,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptio #endif } } - writer.WriteEndObject(); } Unflattened IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/UnknownArtifact.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/UnknownArtifact.Serialization.cs index a537fb4f26d..5dbdc89cee2 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/UnknownArtifact.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/UnknownArtifact.Serialization.cs @@ -21,6 +21,15 @@ internal partial class UnknownArtifact : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,45 +37,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOpti throw new FormatException($"The model {nameof(ArtifactData)} does not support writing '{format}' format."); } - writer.WriteStartObject(); - writer.WritePropertyName("kind"u8); - writer.WriteStringValue(Kind.ToString()); - if (options.Format != "W") - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (options.Format != "W") - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (options.Format != "W") - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(ResourceType); - } - if (options.Format != "W" && Optional.IsDefined(SystemData)) - { - writer.WritePropertyName("systemData"u8); - JsonSerializer.Serialize(writer, SystemData); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); + base.JsonModelWriteCore(writer, options); } ArtifactData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/UnknownDeliveryRuleAction.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/UnknownDeliveryRuleAction.Serialization.cs index 3111fac7502..cc041168c48 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/UnknownDeliveryRuleAction.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/UnknownDeliveryRuleAction.Serialization.cs @@ -20,6 +20,15 @@ internal partial class UnknownDeliveryRuleAction : IUtf8JsonSerializable, IJsonM void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,30 +36,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrit throw new FormatException($"The model {nameof(DeliveryRuleAction)} does not support writing '{format}' format."); } - writer.WriteStartObject(); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name.ToString()); - if (options.Format != "W" && Optional.IsDefined(Foo)) - { - writer.WritePropertyName("foo"u8); - writer.WriteStringValue(Foo); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); + base.JsonModelWriteCore(writer, options); } DeliveryRuleAction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/UnknownDeliveryRuleCondition.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/UnknownDeliveryRuleCondition.Serialization.cs index 1e2804300eb..de17638ee43 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/UnknownDeliveryRuleCondition.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/UnknownDeliveryRuleCondition.Serialization.cs @@ -20,6 +20,15 @@ internal partial class UnknownDeliveryRuleCondition : IUtf8JsonSerializable, IJs void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,30 +36,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderW throw new FormatException($"The model {nameof(DeliveryRuleCondition)} does not support writing '{format}' format."); } - writer.WriteStartObject(); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name.ToString()); - if (options.Format != "W" && Optional.IsDefined(Foo)) - { - writer.WritePropertyName("foo"u8); - writer.WriteStringValue(Foo); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); + base.JsonModelWriteCore(writer, options); } DeliveryRuleCondition IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/UnknownPet.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/UnknownPet.Serialization.cs index d24993744d9..882b743392b 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/UnknownPet.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/UnknownPet.Serialization.cs @@ -20,6 +20,15 @@ internal partial class UnknownPet : IUtf8JsonSerializable, IJsonModel void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,35 +36,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions optio throw new FormatException($"The model {nameof(Pet)} does not support writing '{format}' format."); } - writer.WriteStartObject(); - writer.WritePropertyName("kind"u8); - writer.WriteStringValue(Kind.ToSerialString()); - if (options.Format != "W" && Optional.IsDefined(Id)) - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (Optional.IsDefined(PetType)) - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(PetType); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); + base.JsonModelWriteCore(writer, options); } Pet IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/UrlRedirectAction.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/UrlRedirectAction.Serialization.cs index 390aae5fa32..37e787baebe 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/UrlRedirectAction.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/UrlRedirectAction.Serialization.cs @@ -20,6 +20,15 @@ public partial class UrlRedirectAction : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,32 +36,9 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWrite throw new FormatException($"The model {nameof(UrlRedirectAction)} does not support writing '{format}' format."); } - writer.WriteStartObject(); + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("parameters"u8); writer.WriteObjectValue(Parameters, options); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name.ToString()); - if (options.Format != "W" && Optional.IsDefined(Foo)) - { - writer.WritePropertyName("foo"u8); - writer.WriteStringValue(Foo); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } UrlRedirectAction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/UrlRedirectActionParameters.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/UrlRedirectActionParameters.Serialization.cs index 608212254cd..97f3682ad0d 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/UrlRedirectActionParameters.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/UrlRedirectActionParameters.Serialization.cs @@ -20,6 +20,15 @@ public partial class UrlRedirectActionParameters : IUtf8JsonSerializable, IJsonM void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelR throw new FormatException($"The model {nameof(UrlRedirectActionParameters)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("typeName"u8); writer.WriteStringValue(TypeName.ToString()); writer.WritePropertyName("redirectType"u8); @@ -72,7 +80,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelR #endif } } - writer.WriteEndObject(); } UrlRedirectActionParameters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/UrlRewriteAction.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/UrlRewriteAction.Serialization.cs index 21ac5fd8b81..be00de35f86 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/UrlRewriteAction.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/UrlRewriteAction.Serialization.cs @@ -20,6 +20,15 @@ public partial class UrlRewriteAction : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,32 +36,9 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriter throw new FormatException($"The model {nameof(UrlRewriteAction)} does not support writing '{format}' format."); } - writer.WriteStartObject(); + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("parameters"u8); writer.WriteObjectValue(Parameters, options); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name.ToString()); - if (options.Format != "W" && Optional.IsDefined(Foo)) - { - writer.WritePropertyName("foo"u8); - writer.WriteStringValue(Foo); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } UrlRewriteAction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/UrlRewriteActionParameters.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/UrlRewriteActionParameters.Serialization.cs index 3a8474471e3..0b5717ca528 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/UrlRewriteActionParameters.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/UrlRewriteActionParameters.Serialization.cs @@ -20,6 +20,15 @@ public partial class UrlRewriteActionParameters : IUtf8JsonSerializable, IJsonMo void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRe throw new FormatException($"The model {nameof(UrlRewriteActionParameters)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("typeName"u8); writer.WriteStringValue(TypeName.ToString()); writer.WritePropertyName("sourcePattern"u8); @@ -54,7 +62,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRe #endif } } - writer.WriteEndObject(); } UrlRewriteActionParameters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/UrlSigningAction.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/UrlSigningAction.Serialization.cs index 8e58d990ebb..7bb872d190d 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/UrlSigningAction.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/UrlSigningAction.Serialization.cs @@ -20,6 +20,15 @@ public partial class UrlSigningAction : IUtf8JsonSerializable, IJsonModel ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,32 +36,9 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriter throw new FormatException($"The model {nameof(UrlSigningAction)} does not support writing '{format}' format."); } - writer.WriteStartObject(); + base.JsonModelWriteCore(writer, options); writer.WritePropertyName("parameters"u8); writer.WriteObjectValue(Parameters, options); - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name.ToString()); - if (options.Format != "W" && Optional.IsDefined(Foo)) - { - writer.WritePropertyName("foo"u8); - writer.WriteStringValue(Foo); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); } UrlSigningAction IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/UrlSigningActionParameters.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/UrlSigningActionParameters.Serialization.cs index 3590f0f1ca3..d3f5fee7231 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/UrlSigningActionParameters.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/UrlSigningActionParameters.Serialization.cs @@ -21,6 +21,15 @@ public partial class UrlSigningActionParameters : IUtf8JsonSerializable, IJsonMo void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -28,7 +37,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRe throw new FormatException($"The model {nameof(UrlSigningActionParameters)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("typeName"u8); writer.WriteStringValue(TypeName.ToString()); if (Optional.IsDefined(Algorithm)) @@ -61,7 +69,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRe #endif } } - writer.WriteEndObject(); } UrlSigningActionParameters IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/UrlSigningParamIdentifier.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/UrlSigningParamIdentifier.Serialization.cs index bb504cb3faf..30628f118c9 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/UrlSigningParamIdentifier.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/UrlSigningParamIdentifier.Serialization.cs @@ -20,6 +20,15 @@ public partial class UrlSigningParamIdentifier : IUtf8JsonSerializable, IJsonMod void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -27,7 +36,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRea throw new FormatException($"The model {nameof(UrlSigningParamIdentifier)} does not support writing '{format}' format."); } - writer.WriteStartObject(); writer.WritePropertyName("paramIndicator"u8); writer.WriteStringValue(ParamIndicator.ToString()); writer.WritePropertyName("paramName"u8); @@ -47,7 +55,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelRea #endif } } - writer.WriteEndObject(); } UrlSigningParamIdentifier IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtExactMatchFlattenInheritance/src/Generated/Configuration.json b/test/TestProjects/MgmtExactMatchFlattenInheritance/src/Generated/Configuration.json index 06e5f57ca16..1e733a0162e 100644 --- a/test/TestProjects/MgmtExactMatchFlattenInheritance/src/Generated/Configuration.json +++ b/test/TestProjects/MgmtExactMatchFlattenInheritance/src/Generated/Configuration.json @@ -10,6 +10,7 @@ "public-clients": true, "head-as-boolean": true, "skip-csproj-packagereference": true, + "use-write-core": true, "flavor": "azure", "generate-test-project": true, "helper-namespace": "MgmtExactMatchFlattenInheritance" diff --git a/test/TestProjects/MgmtExactMatchInheritance/src/Generated/Configuration.json b/test/TestProjects/MgmtExactMatchInheritance/src/Generated/Configuration.json index ce6fbc65b08..573a4022a0e 100644 --- a/test/TestProjects/MgmtExactMatchInheritance/src/Generated/Configuration.json +++ b/test/TestProjects/MgmtExactMatchInheritance/src/Generated/Configuration.json @@ -10,6 +10,7 @@ "public-clients": true, "head-as-boolean": true, "skip-csproj-packagereference": true, + "use-write-core": true, "models-to-treat-empty-string-as-null": [ "ExactMatchModel11", "ExactMatchModel1Data" diff --git a/test/TestProjects/MgmtExpandResourceTypes/src/Generated/Configuration.json b/test/TestProjects/MgmtExpandResourceTypes/src/Generated/Configuration.json index d754ce1898b..2d6595752bc 100644 --- a/test/TestProjects/MgmtExpandResourceTypes/src/Generated/Configuration.json +++ b/test/TestProjects/MgmtExpandResourceTypes/src/Generated/Configuration.json @@ -10,6 +10,7 @@ "public-clients": true, "head-as-boolean": true, "skip-csproj-packagereference": true, + "use-write-core": true, "ListException": [ "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/dnsZones/{zoneName}/{recordType}/{relativeRecordSetName}" ], diff --git a/test/TestProjects/MgmtExtensionCommonRestOperation/src/Generated/Configuration.json b/test/TestProjects/MgmtExtensionCommonRestOperation/src/Generated/Configuration.json index 6adeb03b465..a32be86a560 100644 --- a/test/TestProjects/MgmtExtensionCommonRestOperation/src/Generated/Configuration.json +++ b/test/TestProjects/MgmtExtensionCommonRestOperation/src/Generated/Configuration.json @@ -10,6 +10,7 @@ "public-clients": true, "head-as-boolean": true, "skip-csproj-packagereference": true, + "use-write-core": true, "flavor": "azure", "generate-test-project": true, "helper-namespace": "MgmtExtensionCommonRestOperation" diff --git a/test/TestProjects/MgmtExtensionResource/src/Generated/Configuration.json b/test/TestProjects/MgmtExtensionResource/src/Generated/Configuration.json index 30e56a797d7..a340c9cfa78 100644 --- a/test/TestProjects/MgmtExtensionResource/src/Generated/Configuration.json +++ b/test/TestProjects/MgmtExtensionResource/src/Generated/Configuration.json @@ -10,6 +10,7 @@ "public-clients": true, "head-as-boolean": true, "skip-csproj-packagereference": true, + "use-write-core": true, "RequestPathToResourceName": { "/providers/Microsoft.Authorization/policyDefinitions/{policyDefinitionName}": "BuiltInPolicyDefinition" }, diff --git a/test/TestProjects/MgmtHierarchicalNonResource/src/Generated/Configuration.json b/test/TestProjects/MgmtHierarchicalNonResource/src/Generated/Configuration.json index ca988768521..d2e75648875 100644 --- a/test/TestProjects/MgmtHierarchicalNonResource/src/Generated/Configuration.json +++ b/test/TestProjects/MgmtHierarchicalNonResource/src/Generated/Configuration.json @@ -10,6 +10,7 @@ "public-clients": true, "head-as-boolean": true, "skip-csproj-packagereference": true, + "use-write-core": true, "RequestPathToResourceData": { "/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/sharedGalleries/{galleryUniqueName}": "SharedGallery" }, diff --git a/test/TestProjects/MgmtLRO/src/Generated/Configuration.json b/test/TestProjects/MgmtLRO/src/Generated/Configuration.json index f17adffca50..1781151a4bc 100644 --- a/test/TestProjects/MgmtLRO/src/Generated/Configuration.json +++ b/test/TestProjects/MgmtLRO/src/Generated/Configuration.json @@ -10,6 +10,7 @@ "public-clients": true, "head-as-boolean": true, "skip-csproj-packagereference": true, + "use-write-core": true, "OperationsToLroApiVersionOverride": { "Fakes_Update": "2021-06-01" }, diff --git a/test/TestProjects/MgmtListMethods/src/Generated/Configuration.json b/test/TestProjects/MgmtListMethods/src/Generated/Configuration.json index b5cc826c3d4..bbb71e99027 100644 --- a/test/TestProjects/MgmtListMethods/src/Generated/Configuration.json +++ b/test/TestProjects/MgmtListMethods/src/Generated/Configuration.json @@ -10,6 +10,7 @@ "public-clients": true, "head-as-boolean": true, "skip-csproj-packagereference": true, + "use-write-core": true, "OverrideOperationName": { "FakeParentWithAncestorWithNonResChWithLocs_ListBySubscription": "GetFakeParentWithAncestorWithNonResourceChWithLoc" }, diff --git a/test/TestProjects/MgmtMockAndSample/src/Generated/Configuration.json b/test/TestProjects/MgmtMockAndSample/src/Generated/Configuration.json index b2e2ad84339..33f36dedd5f 100644 --- a/test/TestProjects/MgmtMockAndSample/src/Generated/Configuration.json +++ b/test/TestProjects/MgmtMockAndSample/src/Generated/Configuration.json @@ -10,6 +10,7 @@ "public-clients": true, "head-as-boolean": true, "skip-csproj-packagereference": true, + "use-write-core": true, "models-to-treat-empty-string-as-null": [ "EventData", "ManagedHsmProperties" diff --git a/test/TestProjects/MgmtMultipleParentResource/src/Generated/Configuration.json b/test/TestProjects/MgmtMultipleParentResource/src/Generated/Configuration.json index c493a38031a..653ef7e9816 100644 --- a/test/TestProjects/MgmtMultipleParentResource/src/Generated/Configuration.json +++ b/test/TestProjects/MgmtMultipleParentResource/src/Generated/Configuration.json @@ -10,6 +10,7 @@ "public-clients": true, "head-as-boolean": true, "skip-csproj-packagereference": true, + "use-write-core": true, "FormatByNameRules": { "tenantId": "uuid", "resourceType": "resource-type", diff --git a/test/TestProjects/MgmtNoTypeReplacement/src/Generated/Configuration.json b/test/TestProjects/MgmtNoTypeReplacement/src/Generated/Configuration.json index be99bc40e62..4a597df6430 100644 --- a/test/TestProjects/MgmtNoTypeReplacement/src/Generated/Configuration.json +++ b/test/TestProjects/MgmtNoTypeReplacement/src/Generated/Configuration.json @@ -10,6 +10,7 @@ "public-clients": true, "head-as-boolean": true, "skip-csproj-packagereference": true, + "use-write-core": true, "NoPropertyTypeReplacement": [ "NoSubResourceModel", "NoSubResourceModel2" diff --git a/test/TestProjects/MgmtNonStringPathVariable/src/Generated/Configuration.json b/test/TestProjects/MgmtNonStringPathVariable/src/Generated/Configuration.json index 562e2e9aa49..66a87fc838c 100644 --- a/test/TestProjects/MgmtNonStringPathVariable/src/Generated/Configuration.json +++ b/test/TestProjects/MgmtNonStringPathVariable/src/Generated/Configuration.json @@ -10,6 +10,7 @@ "public-clients": true, "head-as-boolean": true, "skip-csproj-packagereference": true, + "use-write-core": true, "ListException": [ "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Fake/bars/{barName}" ], diff --git a/test/TestProjects/MgmtOmitOperationGroups/src/Generated/Configuration.json b/test/TestProjects/MgmtOmitOperationGroups/src/Generated/Configuration.json index 667ff0aa33b..b299cf2d54f 100644 --- a/test/TestProjects/MgmtOmitOperationGroups/src/Generated/Configuration.json +++ b/test/TestProjects/MgmtOmitOperationGroups/src/Generated/Configuration.json @@ -10,6 +10,7 @@ "public-clients": true, "head-as-boolean": true, "skip-csproj-packagereference": true, + "use-write-core": true, "OperationGroupsToOmit": [ "Model1s" ], diff --git a/test/TestProjects/MgmtOperations/src/Generated/Configuration.json b/test/TestProjects/MgmtOperations/src/Generated/Configuration.json index aca19769c0f..b976da6b7a4 100644 --- a/test/TestProjects/MgmtOperations/src/Generated/Configuration.json +++ b/test/TestProjects/MgmtOperations/src/Generated/Configuration.json @@ -10,6 +10,7 @@ "public-clients": true, "head-as-boolean": true, "skip-csproj-packagereference": true, + "use-write-core": true, "flavor": "azure", "generate-test-project": true, "helper-namespace": "MgmtOperations" diff --git a/test/TestProjects/MgmtPagination/src/Generated/Configuration.json b/test/TestProjects/MgmtPagination/src/Generated/Configuration.json index 4647a30efa0..823cdbce457 100644 --- a/test/TestProjects/MgmtPagination/src/Generated/Configuration.json +++ b/test/TestProjects/MgmtPagination/src/Generated/Configuration.json @@ -10,6 +10,7 @@ "public-clients": true, "head-as-boolean": true, "skip-csproj-packagereference": true, + "use-write-core": true, "flavor": "azure", "generate-test-project": true, "helper-namespace": "MgmtPagination" diff --git a/test/TestProjects/MgmtParamOrdering/src/Generated/Configuration.json b/test/TestProjects/MgmtParamOrdering/src/Generated/Configuration.json index 6d3321d6c9c..8b0b8364eef 100644 --- a/test/TestProjects/MgmtParamOrdering/src/Generated/Configuration.json +++ b/test/TestProjects/MgmtParamOrdering/src/Generated/Configuration.json @@ -10,6 +10,7 @@ "public-clients": true, "head-as-boolean": true, "skip-csproj-packagereference": true, + "use-write-core": true, "KeepOrphanedModels": [ "LocationFormatObject" ], diff --git a/test/TestProjects/MgmtParent/src/Generated/Configuration.json b/test/TestProjects/MgmtParent/src/Generated/Configuration.json index d3553067330..a6eae8487f7 100644 --- a/test/TestProjects/MgmtParent/src/Generated/Configuration.json +++ b/test/TestProjects/MgmtParent/src/Generated/Configuration.json @@ -9,6 +9,7 @@ "azure-arm": true, "public-clients": true, "skip-csproj-packagereference": true, + "use-write-core": true, "ListException": [ "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}" ], diff --git a/test/TestProjects/MgmtPartialResource/src/Generated/Configuration.json b/test/TestProjects/MgmtPartialResource/src/Generated/Configuration.json index 50fe7ca1241..f9412afa464 100644 --- a/test/TestProjects/MgmtPartialResource/src/Generated/Configuration.json +++ b/test/TestProjects/MgmtPartialResource/src/Generated/Configuration.json @@ -10,6 +10,7 @@ "public-clients": true, "head-as-boolean": true, "skip-csproj-packagereference": true, + "use-write-core": true, "RequestPathToResourceName": { "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{virtualMachineScaleSetName}": "PartialVmss" }, diff --git a/test/TestProjects/MgmtPropertyBag/src/Generated/Configuration.json b/test/TestProjects/MgmtPropertyBag/src/Generated/Configuration.json index d792e69c460..6c14c324543 100644 --- a/test/TestProjects/MgmtPropertyBag/src/Generated/Configuration.json +++ b/test/TestProjects/MgmtPropertyBag/src/Generated/Configuration.json @@ -10,6 +10,7 @@ "public-clients": true, "head-as-boolean": true, "skip-csproj-packagereference": true, + "use-write-core": true, "RenamePropertyBag": { "Foos_Reconnect": "FooReconnectTestOptions" }, diff --git a/test/TestProjects/MgmtPropertyChooser/src/Generated/Configuration.json b/test/TestProjects/MgmtPropertyChooser/src/Generated/Configuration.json index 270c77322e7..57a7725cf74 100644 --- a/test/TestProjects/MgmtPropertyChooser/src/Generated/Configuration.json +++ b/test/TestProjects/MgmtPropertyChooser/src/Generated/Configuration.json @@ -10,6 +10,7 @@ "public-clients": true, "head-as-boolean": true, "skip-csproj-packagereference": true, + "use-write-core": true, "RawAcronymMapping": { "Os": "OS", "Ip": "IP", diff --git a/test/TestProjects/MgmtResourceName/src/Generated/Configuration.json b/test/TestProjects/MgmtResourceName/src/Generated/Configuration.json index c0e9ed03631..9245e0f4b19 100644 --- a/test/TestProjects/MgmtResourceName/src/Generated/Configuration.json +++ b/test/TestProjects/MgmtResourceName/src/Generated/Configuration.json @@ -11,6 +11,7 @@ "head-as-boolean": true, "skip-csproj-packagereference": true, "generate-model-factory": false, + "use-write-core": true, "NoResourceSuffix": [ "Disk", "Memory" diff --git a/test/TestProjects/MgmtSafeFlatten/src/Generated/Configuration.json b/test/TestProjects/MgmtSafeFlatten/src/Generated/Configuration.json index a3cdbf56057..86d0dad1793 100644 --- a/test/TestProjects/MgmtSafeFlatten/src/Generated/Configuration.json +++ b/test/TestProjects/MgmtSafeFlatten/src/Generated/Configuration.json @@ -10,6 +10,7 @@ "public-clients": true, "head-as-boolean": true, "skip-csproj-packagereference": true, + "use-write-core": true, "KeepOrphanedModels": [ "LayerOneProperties", "TypeFour" diff --git a/test/TestProjects/MgmtScopeResource/src/Generated/Configuration.json b/test/TestProjects/MgmtScopeResource/src/Generated/Configuration.json index d98740d1955..880b96150b2 100644 --- a/test/TestProjects/MgmtScopeResource/src/Generated/Configuration.json +++ b/test/TestProjects/MgmtScopeResource/src/Generated/Configuration.json @@ -10,6 +10,7 @@ "public-clients": true, "head-as-boolean": true, "skip-csproj-packagereference": true, + "use-write-core": true, "ListException": [ "/{linkId}" ], diff --git a/test/TestProjects/MgmtSingletonResource/src/Generated/Configuration.json b/test/TestProjects/MgmtSingletonResource/src/Generated/Configuration.json index d9997885fe4..7ab3a2cefee 100644 --- a/test/TestProjects/MgmtSingletonResource/src/Generated/Configuration.json +++ b/test/TestProjects/MgmtSingletonResource/src/Generated/Configuration.json @@ -10,6 +10,7 @@ "public-clients": true, "head-as-boolean": true, "skip-csproj-packagereference": true, + "use-write-core": true, "RequestPathToSingletonResource": { "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/cars/{carName}/brakes/{default}": "brakes/default" }, diff --git a/test/TestProjects/MgmtSubscriptionNameParameter/src/Generated/Configuration.json b/test/TestProjects/MgmtSubscriptionNameParameter/src/Generated/Configuration.json index 5b2afeebf05..3c37c948775 100644 --- a/test/TestProjects/MgmtSubscriptionNameParameter/src/Generated/Configuration.json +++ b/test/TestProjects/MgmtSubscriptionNameParameter/src/Generated/Configuration.json @@ -10,6 +10,7 @@ "public-clients": true, "head-as-boolean": true, "skip-csproj-packagereference": true, + "use-write-core": true, "flavor": "azure", "generate-test-project": true, "helper-namespace": "MgmtSubscriptionNameParameter" diff --git a/test/TestProjects/MgmtSupersetFlattenInheritance/src/Generated/Configuration.json b/test/TestProjects/MgmtSupersetFlattenInheritance/src/Generated/Configuration.json index 781f30f52bd..dfc2500514b 100644 --- a/test/TestProjects/MgmtSupersetFlattenInheritance/src/Generated/Configuration.json +++ b/test/TestProjects/MgmtSupersetFlattenInheritance/src/Generated/Configuration.json @@ -10,6 +10,7 @@ "public-clients": true, "head-as-boolean": true, "skip-csproj-packagereference": true, + "use-write-core": true, "flavor": "azure", "generate-test-project": true, "helper-namespace": "MgmtSupersetFlattenInheritance" diff --git a/test/TestProjects/MgmtSupersetInheritance/src/Generated/Configuration.json b/test/TestProjects/MgmtSupersetInheritance/src/Generated/Configuration.json index a89a69b78a9..3d6fa687274 100644 --- a/test/TestProjects/MgmtSupersetInheritance/src/Generated/Configuration.json +++ b/test/TestProjects/MgmtSupersetInheritance/src/Generated/Configuration.json @@ -10,6 +10,7 @@ "public-clients": true, "head-as-boolean": true, "skip-csproj-packagereference": true, + "use-write-core": true, "KeepOrphanedModels": [ "SupersetModel5" ], diff --git a/test/TestProjects/MgmtTypeSpec/Configuration.json b/test/TestProjects/MgmtTypeSpec/Configuration.json index aee00908937..a1b6c95c139 100644 --- a/test/TestProjects/MgmtTypeSpec/Configuration.json +++ b/test/TestProjects/MgmtTypeSpec/Configuration.json @@ -9,6 +9,5 @@ "../../../../../artifacts/bin/AutoRest.CSharp/Debug/net8.0/Azure.Core.Shared" ], "examples-dir": "examples", - "azure-arm": true, - "use-write-core": true + "azure-arm": true } diff --git a/test/TestProjects/MgmtXmlDeserialization/src/Generated/Configuration.json b/test/TestProjects/MgmtXmlDeserialization/src/Generated/Configuration.json index fb112372d76..7cccb43cf4c 100644 --- a/test/TestProjects/MgmtXmlDeserialization/src/Generated/Configuration.json +++ b/test/TestProjects/MgmtXmlDeserialization/src/Generated/Configuration.json @@ -11,6 +11,7 @@ "head-as-boolean": true, "skip-csproj-packagereference": true, "use-model-reader-writer": true, + "use-write-core": true, "flavor": "azure", "generate-test-project": true, "helper-namespace": "MgmtXmlDeserialization" diff --git a/test/TestProjects/MgmtXmlDeserialization/src/Generated/Models/XmlCollection.Serialization.cs b/test/TestProjects/MgmtXmlDeserialization/src/Generated/Models/XmlCollection.Serialization.cs index 2434cb6abd6..76e7b5ecd86 100644 --- a/test/TestProjects/MgmtXmlDeserialization/src/Generated/Models/XmlCollection.Serialization.cs +++ b/test/TestProjects/MgmtXmlDeserialization/src/Generated/Models/XmlCollection.Serialization.cs @@ -72,6 +72,15 @@ internal static XmlCollection DeserializeXmlCollection(XElement element, ModelRe void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -79,7 +88,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOpt throw new FormatException($"The model {nameof(XmlCollection)} does not support writing '{format}' format."); } - writer.WriteStartObject(); if (Optional.IsCollectionDefined(Value)) { writer.WritePropertyName("value"u8); @@ -115,7 +123,6 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOpt #endif } } - writer.WriteEndObject(); } XmlCollection IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) diff --git a/test/TestProjects/MgmtXmlDeserialization/src/Generated/XmlInstanceData.Serialization.cs b/test/TestProjects/MgmtXmlDeserialization/src/Generated/XmlInstanceData.Serialization.cs index 946ef75cc52..a5fd49090b1 100644 --- a/test/TestProjects/MgmtXmlDeserialization/src/Generated/XmlInstanceData.Serialization.cs +++ b/test/TestProjects/MgmtXmlDeserialization/src/Generated/XmlInstanceData.Serialization.cs @@ -81,6 +81,15 @@ internal static XmlInstanceData DeserializeXmlInstanceData(XElement element, Mod void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) + { + writer.WriteStartObject(); + JsonModelWriteCore(writer, options); + writer.WriteEndObject(); + } + + /// The JSON writer. + /// The client options for reading and writing models. + protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) { var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; if (format != "J") @@ -88,43 +97,7 @@ void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterO throw new FormatException($"The model {nameof(XmlInstanceData)} does not support writing '{format}' format."); } - writer.WriteStartObject(); - if (options.Format != "W") - { - writer.WritePropertyName("id"u8); - writer.WriteStringValue(Id); - } - if (options.Format != "W") - { - writer.WritePropertyName("name"u8); - writer.WriteStringValue(Name); - } - if (options.Format != "W") - { - writer.WritePropertyName("type"u8); - writer.WriteStringValue(ResourceType); - } - if (options.Format != "W" && Optional.IsDefined(SystemData)) - { - writer.WritePropertyName("systemData"u8); - JsonSerializer.Serialize(writer, SystemData); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); + base.JsonModelWriteCore(writer, options); } XmlInstanceData IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options)