diff --git a/Packages.Data.props b/Packages.Data.props index bf22e9cc2b1..b9fe7d356fc 100644 --- a/Packages.Data.props +++ b/Packages.Data.props @@ -37,10 +37,10 @@ - + - + @@ -49,7 +49,7 @@ - + diff --git a/eng/DownloadSharedSource.ps1 b/eng/DownloadSharedSource.ps1 index eceef09848c..95e07fa4335 100644 --- a/eng/DownloadSharedSource.ps1 +++ b/eng/DownloadSharedSource.ps1 @@ -85,7 +85,7 @@ Get-ChildItem $destinationPath -Filter *.cs | Remove-Item; CopyAll $files $sourcePath $destinationPath #Download management Shared -$files = 'SharedExtensions.cs', 'ManagedServiceIdentityTypeV3Converter.cs' +$files = 'SharedExtensions.cs' $sourcePath = "$clonedPath/sdk/resourcemanager/Azure.ResourceManager/src/Shared" $destinationPath = "$repoRoot/src/assets/Management.Shared" diff --git a/eng/scripts/Download-SharedSource.ps1 b/eng/scripts/Download-SharedSource.ps1 index 38d97f68639..d171ed43ae8 100644 --- a/eng/scripts/Download-SharedSource.ps1 +++ b/eng/scripts/Download-SharedSource.ps1 @@ -94,8 +94,7 @@ CopyAll $files $sourcePath $destinationPath #Download management Shared $files = @( - 'SharedExtensions.cs', - 'ManagedServiceIdentityTypeV3Converter.cs' + 'SharedExtensions.cs' ) $sourcePath = "$clonedPath/sdk/resourcemanager/Azure.ResourceManager/src/Shared" diff --git a/samples/AnomalyDetector/src/Generated/Internal/ModelSerializationExtensions.cs b/samples/AnomalyDetector/src/Generated/Internal/ModelSerializationExtensions.cs index 35c3f9f6206..242ef2744aa 100644 --- a/samples/AnomalyDetector/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/samples/AnomalyDetector/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, AnomalyDetectorContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/AvailabilitySetData.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/AvailabilitySetData.Serialization.cs index 7a9207b0524..def9d5136a5 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/AvailabilitySetData.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/AvailabilitySetData.Serialization.cs @@ -9,6 +9,7 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Linq; +using System.Runtime.InteropServices; using System.Text; using System.Text.Json; using Azure.Core; @@ -64,14 +65,14 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri writer.WriteStartArray(); foreach (var item in VirtualMachines) { - JsonSerializer.Serialize(writer, item); + ((IJsonModel)item).Write(writer, options); } writer.WriteEndArray(); } if (Optional.IsDefined(ProximityPlacementGroup)) { writer.WritePropertyName("proximityPlacementGroup"u8); - JsonSerializer.Serialize(writer, ProximityPlacementGroup); + ((IJsonModel)ProximityPlacementGroup).Write(writer, options); } if (options.Format != "W" && Optional.IsCollectionDefined(Statuses)) { @@ -171,7 +172,13 @@ internal static AvailabilitySetData DeserializeAvailabilitySetData(JsonElement e { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::AzureSample.ResourceManager.Sample.ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) @@ -210,7 +217,13 @@ internal static AvailabilitySetData DeserializeAvailabilitySetData(JsonElement e List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(JsonSerializer.Deserialize(item.GetRawText())); + array.Add( +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(item).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(item.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +); } virtualMachines = array; continue; @@ -221,7 +234,13 @@ internal static AvailabilitySetData DeserializeAvailabilitySetData(JsonElement e { continue; } - proximityPlacementGroup = JsonSerializer.Deserialize(property0.Value.GetRawText()); + proximityPlacementGroup = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property0.Value).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property0.NameEquals("statuses"u8)) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/DedicatedHostData.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/DedicatedHostData.Serialization.cs index e286888b99e..de9b6c05a47 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/DedicatedHostData.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/DedicatedHostData.Serialization.cs @@ -9,6 +9,7 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Linq; +using System.Runtime.InteropServices; using System.Text; using System.Text.Json; using Azure.Core; @@ -66,7 +67,7 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri writer.WriteStartArray(); foreach (var item in VirtualMachines) { - JsonSerializer.Serialize(writer, item); + ((IJsonModel)item).Write(writer, options); } writer.WriteEndArray(); } @@ -177,7 +178,13 @@ internal static DedicatedHostData DeserializeDedicatedHostData(JsonElement eleme { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::AzureSample.ResourceManager.Sample.ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) @@ -221,7 +228,13 @@ internal static DedicatedHostData DeserializeDedicatedHostData(JsonElement eleme List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(JsonSerializer.Deserialize(item.GetRawText())); + array.Add( +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(item).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(item.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +); } virtualMachines = array; continue; diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/DedicatedHostGroupData.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/DedicatedHostGroupData.Serialization.cs index 553b82baf6a..f31e5338090 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/DedicatedHostGroupData.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/DedicatedHostGroupData.Serialization.cs @@ -9,6 +9,7 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Linq; +using System.Runtime.InteropServices; using System.Text; using System.Text.Json; using Azure.Core; @@ -84,7 +85,7 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri writer.WriteStartArray(); foreach (var item in Hosts) { - JsonSerializer.Serialize(writer, item); + ((IJsonModel)item).Write(writer, options); } writer.WriteEndArray(); } @@ -222,7 +223,13 @@ internal static DedicatedHostGroupData DeserializeDedicatedHostGroupData(JsonEle { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::AzureSample.ResourceManager.Sample.ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) @@ -252,7 +259,13 @@ internal static DedicatedHostGroupData DeserializeDedicatedHostGroupData(JsonEle List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(JsonSerializer.Deserialize(item.GetRawText())); + array.Add( +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(item).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(item.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +); } hosts = array; continue; diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/ImageData.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/ImageData.Serialization.cs index f3fd9d72b62..de5ee76406f 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/ImageData.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/ImageData.Serialization.cs @@ -9,6 +9,7 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Linq; +using System.Runtime.InteropServices; using System.Text; using System.Text.Json; using Azure.Core; @@ -46,7 +47,7 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri if (Optional.IsDefined(SourceVirtualMachine)) { writer.WritePropertyName("sourceVirtualMachine"u8); - JsonSerializer.Serialize(writer, SourceVirtualMachine); + ((IJsonModel)SourceVirtualMachine).Write(writer, options); } if (Optional.IsDefined(StorageProfile)) { @@ -140,7 +141,13 @@ internal static ImageData DeserializeImageData(JsonElement element, ModelReaderW { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::AzureSample.ResourceManager.Sample.ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) @@ -158,7 +165,13 @@ internal static ImageData DeserializeImageData(JsonElement element, ModelReaderW { continue; } - sourceVirtualMachine = JsonSerializer.Deserialize(property0.Value.GetRawText()); + sourceVirtualMachine = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property0.Value).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property0.NameEquals("storageProfile"u8)) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/Internal/ModelSerializationExtensions.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/Internal/ModelSerializationExtensions.cs index fe7cf0128da..1e013076578 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,12 +9,10 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; using Azure.Core; -using Azure.ResourceManager.Models; namespace AzureSample.ResourceManager.Sample { @@ -23,8 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, AzureSampleResourceManagerSampleContext.Default) } }; - internal static readonly JsonSerializerOptions OptionsUseManagedServiceIdentityV3 = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, AzureSampleResourceManagerSampleContext.Default), new Azure.ResourceManager.Models.ManagedServiceIdentityTypeV3Converter() } }; public static object GetObject(this JsonElement element) { @@ -269,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/LongRunningOperation/SampleArmOperation.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/LongRunningOperation/SampleArmOperation.cs index 8b9a2fa4687..fc8438c41ce 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/LongRunningOperation/SampleArmOperation.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/LongRunningOperation/SampleArmOperation.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, AzureSampleResourceManagerSampleContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, AzureSampleResourceManagerSampleContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/LongRunningOperation/SampleArmOperationOfT.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/LongRunningOperation/SampleArmOperationOfT.cs index e9cd674eda8..125e8f921ec 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/LongRunningOperation/SampleArmOperationOfT.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/LongRunningOperation/SampleArmOperationOfT.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, AzureSampleResourceManagerSampleContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, AzureSampleResourceManagerSampleContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; 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 58388197e91..31c3d5ba3e1 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AvailabilitySetPatch.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/AvailabilitySetPatch.Serialization.cs @@ -8,6 +8,8 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Resources.Models; @@ -59,14 +61,14 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri writer.WriteStartArray(); foreach (var item in VirtualMachines) { - JsonSerializer.Serialize(writer, item); + ((IJsonModel)item).Write(writer, options); } writer.WriteEndArray(); } if (Optional.IsDefined(ProximityPlacementGroup)) { writer.WritePropertyName("proximityPlacementGroup"u8); - JsonSerializer.Serialize(writer, ProximityPlacementGroup); + ((IJsonModel)ProximityPlacementGroup).Write(writer, options); } if (options.Format != "W" && Optional.IsCollectionDefined(Statuses)) { @@ -171,7 +173,13 @@ internal static AvailabilitySetPatch DeserializeAvailabilitySetPatch(JsonElement List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(JsonSerializer.Deserialize(item.GetRawText())); + array.Add( +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(item).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(item.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +); } virtualMachines = array; continue; @@ -182,7 +190,13 @@ internal static AvailabilitySetPatch DeserializeAvailabilitySetPatch(JsonElement { continue; } - proximityPlacementGroup = JsonSerializer.Deserialize(property0.Value.GetRawText()); + proximityPlacementGroup = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property0.Value).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property0.NameEquals("statuses"u8)) 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 301b6473e9c..07112848d3b 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DedicatedHostGroupPatch.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DedicatedHostGroupPatch.Serialization.cs @@ -8,6 +8,8 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Resources.Models; @@ -59,7 +61,7 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri writer.WriteStartArray(); foreach (var item in Hosts) { - JsonSerializer.Serialize(writer, item); + ((IJsonModel)item).Write(writer, options); } writer.WriteEndArray(); } @@ -161,7 +163,13 @@ internal static DedicatedHostGroupPatch DeserializeDedicatedHostGroupPatch(JsonE List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(JsonSerializer.Deserialize(item.GetRawText())); + array.Add( +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(item).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(item.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +); } hosts = array; continue; 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 7df63a6239f..12efb5732b6 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DedicatedHostPatch.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/DedicatedHostPatch.Serialization.cs @@ -8,6 +8,8 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Resources.Models; @@ -59,7 +61,7 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri writer.WriteStartArray(); foreach (var item in VirtualMachines) { - JsonSerializer.Serialize(writer, item); + ((IJsonModel)item).Write(writer, options); } writer.WriteEndArray(); } @@ -174,7 +176,13 @@ internal static DedicatedHostPatch DeserializeDedicatedHostPatch(JsonElement ele List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(JsonSerializer.Deserialize(item.GetRawText())); + array.Add( +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(item).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(item.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +); } virtualMachines = array; continue; 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 3b14aa5f603..efd854095cd 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ImageDataDisk.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ImageDataDisk.Serialization.cs @@ -8,6 +8,7 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; using System.Text; using System.Text.Json; using Azure.Core; @@ -85,7 +86,13 @@ internal static ImageDataDisk DeserializeImageDataDisk(JsonElement element, Mode { continue; } - snapshot = JsonSerializer.Deserialize(property.Value.GetRawText()); + snapshot = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property.NameEquals("managedDisk"u8)) @@ -94,7 +101,13 @@ internal static ImageDataDisk DeserializeImageDataDisk(JsonElement element, Mode { continue; } - managedDisk = JsonSerializer.Deserialize(property.Value.GetRawText()); + managedDisk = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property.NameEquals("blobUri"u8)) @@ -139,7 +152,13 @@ internal static ImageDataDisk DeserializeImageDataDisk(JsonElement element, Mode { continue; } - diskEncryptionSet = JsonSerializer.Deserialize(property.Value.GetRawText()); + diskEncryptionSet = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (options.Format != "W") 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 b38220e4e19..323be6122bf 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ImageDisk.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ImageDisk.Serialization.cs @@ -8,6 +8,7 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; using System.Text; using System.Text.Json; using Azure.Core; @@ -40,12 +41,12 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit if (Optional.IsDefined(Snapshot)) { writer.WritePropertyName("snapshot"u8); - JsonSerializer.Serialize(writer, Snapshot); + ((IJsonModel)Snapshot).Write(writer, options); } if (Optional.IsDefined(ManagedDisk)) { writer.WritePropertyName("managedDisk"u8); - JsonSerializer.Serialize(writer, ManagedDisk); + ((IJsonModel)ManagedDisk).Write(writer, options); } if (Optional.IsDefined(BlobUri)) { @@ -70,7 +71,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit if (Optional.IsDefined(DiskEncryptionSet)) { writer.WritePropertyName("diskEncryptionSet"u8); - JsonSerializer.Serialize(writer, DiskEncryptionSet); + ((IJsonModel)DiskEncryptionSet).Write(writer, options); } if (options.Format != "W" && _serializedAdditionalRawData != null) { @@ -126,7 +127,13 @@ internal static ImageDisk DeserializeImageDisk(JsonElement element, ModelReaderW { continue; } - snapshot = JsonSerializer.Deserialize(property.Value.GetRawText()); + snapshot = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property.NameEquals("managedDisk"u8)) @@ -135,7 +142,13 @@ internal static ImageDisk DeserializeImageDisk(JsonElement element, ModelReaderW { continue; } - managedDisk = JsonSerializer.Deserialize(property.Value.GetRawText()); + managedDisk = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property.NameEquals("blobUri"u8)) @@ -180,7 +193,13 @@ internal static ImageDisk DeserializeImageDisk(JsonElement element, ModelReaderW { continue; } - diskEncryptionSet = JsonSerializer.Deserialize(property.Value.GetRawText()); + diskEncryptionSet = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (options.Format != "W") 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 b70ec35d247..d93fbf4f2e4 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ImageOSDisk.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ImageOSDisk.Serialization.cs @@ -8,6 +8,7 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; using System.Text; using System.Text.Json; using Azure.Core; @@ -93,7 +94,13 @@ internal static ImageOSDisk DeserializeImageOSDisk(JsonElement element, ModelRea { continue; } - snapshot = JsonSerializer.Deserialize(property.Value.GetRawText()); + snapshot = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property.NameEquals("managedDisk"u8)) @@ -102,7 +109,13 @@ internal static ImageOSDisk DeserializeImageOSDisk(JsonElement element, ModelRea { continue; } - managedDisk = JsonSerializer.Deserialize(property.Value.GetRawText()); + managedDisk = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property.NameEquals("blobUri"u8)) @@ -147,7 +160,13 @@ internal static ImageOSDisk DeserializeImageOSDisk(JsonElement element, ModelRea { continue; } - diskEncryptionSet = JsonSerializer.Deserialize(property.Value.GetRawText()); + diskEncryptionSet = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (options.Format != "W") 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 88c99fb4080..b0903443783 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ImagePatch.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ImagePatch.Serialization.cs @@ -8,6 +8,8 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Resources.Models; @@ -41,7 +43,7 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri if (Optional.IsDefined(SourceVirtualMachine)) { writer.WritePropertyName("sourceVirtualMachine"u8); - JsonSerializer.Serialize(writer, SourceVirtualMachine); + ((IJsonModel)SourceVirtualMachine).Write(writer, options); } if (Optional.IsDefined(StorageProfile)) { @@ -119,7 +121,13 @@ internal static ImagePatch DeserializeImagePatch(JsonElement element, ModelReade { continue; } - sourceVirtualMachine = JsonSerializer.Deserialize(property0.Value.GetRawText()); + sourceVirtualMachine = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property0.Value).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property0.NameEquals("storageProfile"u8)) 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 fa2744ec819..d83382511d5 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/KeyVaultKeyReference.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/KeyVaultKeyReference.Serialization.cs @@ -8,6 +8,7 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; using System.Text; using System.Text.Json; using Azure.Core; @@ -40,7 +41,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("keyUrl"u8); writer.WriteStringValue(KeyUri.AbsoluteUri); writer.WritePropertyName("sourceVault"u8); - JsonSerializer.Serialize(writer, SourceVault); + ((IJsonModel)SourceVault).Write(writer, options); if (options.Format != "W" && _serializedAdditionalRawData != null) { foreach (var item in _serializedAdditionalRawData) @@ -91,7 +92,13 @@ internal static KeyVaultKeyReference DeserializeKeyVaultKeyReference(JsonElement } if (property.NameEquals("sourceVault"u8)) { - sourceVault = JsonSerializer.Deserialize(property.Value.GetRawText()); + sourceVault = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (options.Format != "W") 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 57da69518d9..56cad4ccb80 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/KeyVaultSecretReference.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/KeyVaultSecretReference.Serialization.cs @@ -8,6 +8,7 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; using System.Text; using System.Text.Json; using Azure.Core; @@ -40,7 +41,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("secretUrl"u8); writer.WriteStringValue(SecretUri.AbsoluteUri); writer.WritePropertyName("sourceVault"u8); - JsonSerializer.Serialize(writer, SourceVault); + ((IJsonModel)SourceVault).Write(writer, options); if (options.Format != "W" && _serializedAdditionalRawData != null) { foreach (var item in _serializedAdditionalRawData) @@ -91,7 +92,13 @@ internal static KeyVaultSecretReference DeserializeKeyVaultSecretReference(JsonE } if (property.NameEquals("sourceVault"u8)) { - sourceVault = JsonSerializer.Deserialize(property.Value.GetRawText()); + sourceVault = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (options.Format != "W") 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 7e4e760cb5c..99d4ada09a8 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ManagedDiskParameters.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/ManagedDiskParameters.Serialization.cs @@ -8,6 +8,7 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; using System.Text; using System.Text.Json; using Azure.Core; @@ -46,7 +47,7 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri if (Optional.IsDefined(DiskEncryptionSet)) { writer.WritePropertyName("diskEncryptionSet"u8); - JsonSerializer.Serialize(writer, DiskEncryptionSet); + ((IJsonModel)DiskEncryptionSet).Write(writer, options); } } @@ -92,7 +93,13 @@ internal static ManagedDiskParameters DeserializeManagedDiskParameters(JsonEleme { continue; } - diskEncryptionSet = JsonSerializer.Deserialize(property.Value.GetRawText()); + diskEncryptionSet = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property.NameEquals("id"u8)) 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 320d472117e..fa22a4a0dc3 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VaultSecretGroup.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VaultSecretGroup.Serialization.cs @@ -9,6 +9,7 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Linq; +using System.Runtime.InteropServices; using System.Text; using System.Text.Json; using Azure.Core; @@ -41,7 +42,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit if (Optional.IsDefined(SourceVault)) { writer.WritePropertyName("sourceVault"u8); - JsonSerializer.Serialize(writer, SourceVault); + ((IJsonModel)SourceVault).Write(writer, options); } if (Optional.IsCollectionDefined(VaultCertificates)) { @@ -102,7 +103,13 @@ internal static VaultSecretGroup DeserializeVaultSecretGroup(JsonElement element { continue; } - sourceVault = JsonSerializer.Deserialize(property.Value.GetRawText()); + sourceVault = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property.NameEquals("vaultCertificates"u8)) 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 c175ff05581..0e076c3b75e 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachinePatch.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachinePatch.Serialization.cs @@ -8,6 +8,8 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -45,7 +47,7 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri if (Optional.IsDefined(Identity)) { writer.WritePropertyName("identity"u8); - JsonSerializer.Serialize(writer, Identity); + ((IJsonModel)Identity).Write(writer, options); } if (Optional.IsCollectionDefined(Zones)) { @@ -97,17 +99,17 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri if (Optional.IsDefined(AvailabilitySet)) { writer.WritePropertyName("availabilitySet"u8); - JsonSerializer.Serialize(writer, AvailabilitySet); + ((IJsonModel)AvailabilitySet).Write(writer, options); } if (Optional.IsDefined(VirtualMachineScaleSet)) { writer.WritePropertyName("virtualMachineScaleSet"u8); - JsonSerializer.Serialize(writer, VirtualMachineScaleSet); + ((IJsonModel)VirtualMachineScaleSet).Write(writer, options); } if (Optional.IsDefined(ProximityPlacementGroup)) { writer.WritePropertyName("proximityPlacementGroup"u8); - JsonSerializer.Serialize(writer, ProximityPlacementGroup); + ((IJsonModel)ProximityPlacementGroup).Write(writer, options); } if (Optional.IsDefined(Priority)) { @@ -127,12 +129,12 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri if (Optional.IsDefined(Host)) { writer.WritePropertyName("host"u8); - JsonSerializer.Serialize(writer, Host); + ((IJsonModel)Host).Write(writer, options); } if (Optional.IsDefined(HostGroup)) { writer.WritePropertyName("hostGroup"u8); - JsonSerializer.Serialize(writer, HostGroup); + ((IJsonModel)HostGroup).Write(writer, options); } if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) { @@ -225,7 +227,13 @@ internal static VirtualMachinePatch DeserializeVirtualMachinePatch(JsonElement e { continue; } - identity = JsonSerializer.Deserialize(property.Value.GetRawText()); + identity = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property.NameEquals("zones"u8)) @@ -334,7 +342,13 @@ internal static VirtualMachinePatch DeserializeVirtualMachinePatch(JsonElement e { continue; } - availabilitySet = JsonSerializer.Deserialize(property0.Value.GetRawText()); + availabilitySet = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property0.Value).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property0.NameEquals("virtualMachineScaleSet"u8)) @@ -343,7 +357,13 @@ internal static VirtualMachinePatch DeserializeVirtualMachinePatch(JsonElement e { continue; } - virtualMachineScaleSet = JsonSerializer.Deserialize(property0.Value.GetRawText()); + virtualMachineScaleSet = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property0.Value).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property0.NameEquals("proximityPlacementGroup"u8)) @@ -352,7 +372,13 @@ internal static VirtualMachinePatch DeserializeVirtualMachinePatch(JsonElement e { continue; } - proximityPlacementGroup = JsonSerializer.Deserialize(property0.Value.GetRawText()); + proximityPlacementGroup = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property0.Value).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property0.NameEquals("priority"u8)) @@ -388,7 +414,13 @@ internal static VirtualMachinePatch DeserializeVirtualMachinePatch(JsonElement e { continue; } - host = JsonSerializer.Deserialize(property0.Value.GetRawText()); + host = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property0.Value).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property0.NameEquals("hostGroup"u8)) @@ -397,7 +429,13 @@ internal static VirtualMachinePatch DeserializeVirtualMachinePatch(JsonElement e { continue; } - hostGroup = JsonSerializer.Deserialize(property0.Value.GetRawText()); + hostGroup = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property0.Value).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property0.NameEquals("provisioningState"u8)) 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 c7a978e9040..da8ee3dd72c 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetExtensionPatch.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetExtensionPatch.Serialization.cs @@ -9,6 +9,7 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Linq; +using System.Runtime.InteropServices; using System.Text; using System.Text.Json; using Azure.Core; @@ -172,7 +173,13 @@ internal static VirtualMachineScaleSetExtensionPatch DeserializeVirtualMachineSc { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::AzureSample.ResourceManager.Sample.ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) 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 b0df2196f8d..601ae2423a3 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetIPConfiguration.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetIPConfiguration.Serialization.cs @@ -9,6 +9,7 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Linq; +using System.Runtime.InteropServices; using System.Text; using System.Text.Json; using Azure.Core; @@ -46,7 +47,7 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri if (Optional.IsDefined(Subnet)) { writer.WritePropertyName("subnet"u8); - JsonSerializer.Serialize(writer, Subnet); + ((IJsonModel)Subnet).Write(writer, options); } if (Optional.IsDefined(Primary)) { @@ -69,7 +70,7 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri writer.WriteStartArray(); foreach (var item in ApplicationGatewayBackendAddressPools) { - JsonSerializer.Serialize(writer, item); + ((IJsonModel)item).Write(writer, options); } writer.WriteEndArray(); } @@ -79,7 +80,7 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri writer.WriteStartArray(); foreach (var item in ApplicationSecurityGroups) { - JsonSerializer.Serialize(writer, item); + ((IJsonModel)item).Write(writer, options); } writer.WriteEndArray(); } @@ -89,7 +90,7 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri writer.WriteStartArray(); foreach (var item in LoadBalancerBackendAddressPools) { - JsonSerializer.Serialize(writer, item); + ((IJsonModel)item).Write(writer, options); } writer.WriteEndArray(); } @@ -99,7 +100,7 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri writer.WriteStartArray(); foreach (var item in LoadBalancerInboundNatPools) { - JsonSerializer.Serialize(writer, item); + ((IJsonModel)item).Write(writer, options); } writer.WriteEndArray(); } @@ -165,7 +166,13 @@ internal static VirtualMachineScaleSetIPConfiguration DeserializeVirtualMachineS { continue; } - subnet = JsonSerializer.Deserialize(property0.Value.GetRawText()); + subnet = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property0.Value).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property0.NameEquals("primary"u8)) @@ -204,7 +211,13 @@ internal static VirtualMachineScaleSetIPConfiguration DeserializeVirtualMachineS List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(JsonSerializer.Deserialize(item.GetRawText())); + array.Add( +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(item).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(item.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +); } applicationGatewayBackendAddressPools = array; continue; @@ -218,7 +231,13 @@ internal static VirtualMachineScaleSetIPConfiguration DeserializeVirtualMachineS List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(JsonSerializer.Deserialize(item.GetRawText())); + array.Add( +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(item).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(item.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +); } applicationSecurityGroups = array; continue; @@ -232,7 +251,13 @@ internal static VirtualMachineScaleSetIPConfiguration DeserializeVirtualMachineS List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(JsonSerializer.Deserialize(item.GetRawText())); + array.Add( +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(item).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(item.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +); } loadBalancerBackendAddressPools = array; continue; @@ -246,7 +271,13 @@ internal static VirtualMachineScaleSetIPConfiguration DeserializeVirtualMachineS List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(JsonSerializer.Deserialize(item.GetRawText())); + array.Add( +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(item).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(item.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +); } loadBalancerInboundNatPools = array; continue; 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 bd144673c0f..1b8f76ae195 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetManagedDiskParameters.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetManagedDiskParameters.Serialization.cs @@ -8,6 +8,7 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; using System.Text; using System.Text.Json; using Azure.Core; @@ -45,7 +46,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit if (Optional.IsDefined(DiskEncryptionSet)) { writer.WritePropertyName("diskEncryptionSet"u8); - JsonSerializer.Serialize(writer, DiskEncryptionSet); + ((IJsonModel)DiskEncryptionSet).Write(writer, options); } if (options.Format != "W" && _serializedAdditionalRawData != null) { @@ -105,7 +106,13 @@ internal static VirtualMachineScaleSetManagedDiskParameters DeserializeVirtualMa { continue; } - diskEncryptionSet = JsonSerializer.Deserialize(property.Value.GetRawText()); + diskEncryptionSet = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (options.Format != "W") 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 8d3650b99fe..eb1b2b2f7a3 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetNetworkConfiguration.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetNetworkConfiguration.Serialization.cs @@ -9,6 +9,7 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Linq; +using System.Runtime.InteropServices; using System.Text; using System.Text.Json; using Azure.Core; @@ -56,7 +57,7 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri if (Optional.IsDefined(NetworkSecurityGroup)) { writer.WritePropertyName("networkSecurityGroup"u8); - JsonSerializer.Serialize(writer, NetworkSecurityGroup); + ((IJsonModel)NetworkSecurityGroup).Write(writer, options); } if (Optional.IsDefined(DnsSettings)) { @@ -156,7 +157,13 @@ internal static VirtualMachineScaleSetNetworkConfiguration DeserializeVirtualMac { continue; } - networkSecurityGroup = JsonSerializer.Deserialize(property0.Value.GetRawText()); + networkSecurityGroup = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property0.Value).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property0.NameEquals("dnsSettings"u8)) 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 1cc084b64e0..e07bd1ca558 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetNetworkProfile.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetNetworkProfile.Serialization.cs @@ -9,6 +9,7 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Linq; +using System.Runtime.InteropServices; using System.Text; using System.Text.Json; using Azure.Core; @@ -41,7 +42,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit if (Optional.IsDefined(HealthProbe)) { writer.WritePropertyName("healthProbe"u8); - JsonSerializer.Serialize(writer, HealthProbe); + ((IJsonModel)HealthProbe).Write(writer, options); } if (Optional.IsCollectionDefined(NetworkInterfaceConfigurations)) { @@ -102,7 +103,13 @@ internal static VirtualMachineScaleSetNetworkProfile DeserializeVirtualMachineSc { continue; } - healthProbe = JsonSerializer.Deserialize(property.Value.GetRawText()); + healthProbe = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property.NameEquals("networkInterfaceConfigurations"u8)) 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 38479a107da..f1c6ef56db2 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetPatch.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetPatch.Serialization.cs @@ -8,6 +8,8 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -50,7 +52,7 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri if (Optional.IsDefined(Identity)) { writer.WritePropertyName("identity"u8); - JsonSerializer.Serialize(writer, Identity); + ((IJsonModel)Identity).Write(writer, options); } writer.WritePropertyName("properties"u8); writer.WriteStartObject(); @@ -97,7 +99,7 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri if (Optional.IsDefined(ProximityPlacementGroup)) { writer.WritePropertyName("proximityPlacementGroup"u8); - JsonSerializer.Serialize(writer, ProximityPlacementGroup); + ((IJsonModel)ProximityPlacementGroup).Write(writer, options); } writer.WriteEndObject(); } @@ -163,7 +165,13 @@ internal static VirtualMachineScaleSetPatch DeserializeVirtualMachineScaleSetPat { continue; } - identity = JsonSerializer.Deserialize(property.Value.GetRawText()); + identity = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property.NameEquals("tags"u8)) @@ -267,7 +275,13 @@ internal static VirtualMachineScaleSetPatch DeserializeVirtualMachineScaleSetPat { continue; } - proximityPlacementGroup = JsonSerializer.Deserialize(property0.Value.GetRawText()); + proximityPlacementGroup = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property0.Value).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } } 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 921b6c90021..7b0f93122db 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetPublicIPAddressConfiguration.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetPublicIPAddressConfiguration.Serialization.cs @@ -9,6 +9,7 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Linq; +using System.Runtime.InteropServices; using System.Text; using System.Text.Json; using Azure.Core; @@ -65,7 +66,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit if (Optional.IsDefined(PublicIPPrefix)) { writer.WritePropertyName("publicIPPrefix"u8); - JsonSerializer.Serialize(writer, PublicIPPrefix); + ((IJsonModel)PublicIPPrefix).Write(writer, options); } if (Optional.IsDefined(PublicIPAddressVersion)) { @@ -172,7 +173,13 @@ internal static VirtualMachineScaleSetPublicIPAddressConfiguration DeserializeVi { continue; } - publicIPPrefix = JsonSerializer.Deserialize(property0.Value.GetRawText()); + publicIPPrefix = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property0.Value).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property0.NameEquals("publicIPAddressVersion"u8)) 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 024cc9844a7..fb8b82c52c5 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetUpdateIPConfiguration.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetUpdateIPConfiguration.Serialization.cs @@ -9,6 +9,7 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Linq; +using System.Runtime.InteropServices; using System.Text; using System.Text.Json; using Azure.Core; @@ -49,7 +50,7 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri if (Optional.IsDefined(Subnet)) { writer.WritePropertyName("subnet"u8); - JsonSerializer.Serialize(writer, Subnet); + ((IJsonModel)Subnet).Write(writer, options); } if (Optional.IsDefined(Primary)) { @@ -72,7 +73,7 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri writer.WriteStartArray(); foreach (var item in ApplicationGatewayBackendAddressPools) { - JsonSerializer.Serialize(writer, item); + ((IJsonModel)item).Write(writer, options); } writer.WriteEndArray(); } @@ -82,7 +83,7 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri writer.WriteStartArray(); foreach (var item in ApplicationSecurityGroups) { - JsonSerializer.Serialize(writer, item); + ((IJsonModel)item).Write(writer, options); } writer.WriteEndArray(); } @@ -92,7 +93,7 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri writer.WriteStartArray(); foreach (var item in LoadBalancerBackendAddressPools) { - JsonSerializer.Serialize(writer, item); + ((IJsonModel)item).Write(writer, options); } writer.WriteEndArray(); } @@ -102,7 +103,7 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri writer.WriteStartArray(); foreach (var item in LoadBalancerInboundNatPools) { - JsonSerializer.Serialize(writer, item); + ((IJsonModel)item).Write(writer, options); } writer.WriteEndArray(); } @@ -168,7 +169,13 @@ internal static VirtualMachineScaleSetUpdateIPConfiguration DeserializeVirtualMa { continue; } - subnet = JsonSerializer.Deserialize(property0.Value.GetRawText()); + subnet = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property0.Value).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property0.NameEquals("primary"u8)) @@ -207,7 +214,13 @@ internal static VirtualMachineScaleSetUpdateIPConfiguration DeserializeVirtualMa List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(JsonSerializer.Deserialize(item.GetRawText())); + array.Add( +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(item).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(item.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +); } applicationGatewayBackendAddressPools = array; continue; @@ -221,7 +234,13 @@ internal static VirtualMachineScaleSetUpdateIPConfiguration DeserializeVirtualMa List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(JsonSerializer.Deserialize(item.GetRawText())); + array.Add( +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(item).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(item.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +); } applicationSecurityGroups = array; continue; @@ -235,7 +254,13 @@ internal static VirtualMachineScaleSetUpdateIPConfiguration DeserializeVirtualMa List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(JsonSerializer.Deserialize(item.GetRawText())); + array.Add( +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(item).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(item.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +); } loadBalancerBackendAddressPools = array; continue; @@ -249,7 +274,13 @@ internal static VirtualMachineScaleSetUpdateIPConfiguration DeserializeVirtualMa List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(JsonSerializer.Deserialize(item.GetRawText())); + array.Add( +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(item).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(item.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +); } loadBalancerInboundNatPools = array; continue; 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 76d0dc21cfe..8ba971d704d 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetUpdateNetworkConfiguration.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetUpdateNetworkConfiguration.Serialization.cs @@ -9,6 +9,7 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Linq; +using System.Runtime.InteropServices; using System.Text; using System.Text.Json; using Azure.Core; @@ -59,7 +60,7 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri if (Optional.IsDefined(NetworkSecurityGroup)) { writer.WritePropertyName("networkSecurityGroup"u8); - JsonSerializer.Serialize(writer, NetworkSecurityGroup); + ((IJsonModel)NetworkSecurityGroup).Write(writer, options); } if (Optional.IsDefined(DnsSettings)) { @@ -159,7 +160,13 @@ internal static VirtualMachineScaleSetUpdateNetworkConfiguration DeserializeVirt { continue; } - networkSecurityGroup = JsonSerializer.Deserialize(property0.Value.GetRawText()); + networkSecurityGroup = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property0.Value).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property0.NameEquals("dnsSettings"u8)) 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 300a47a5ade..bea4b774f82 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetUpdateNetworkProfile.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/Models/VirtualMachineScaleSetUpdateNetworkProfile.Serialization.cs @@ -8,6 +8,8 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Resources.Models; @@ -38,7 +40,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit if (Optional.IsDefined(HealthProbe)) { writer.WritePropertyName("healthProbe"u8); - JsonSerializer.Serialize(writer, HealthProbe); + ((IJsonModel)HealthProbe).Write(writer, options); } if (Optional.IsCollectionDefined(NetworkInterfaceConfigurations)) { @@ -99,7 +101,13 @@ internal static VirtualMachineScaleSetUpdateNetworkProfile DeserializeVirtualMac { continue; } - healthProbe = JsonSerializer.Deserialize(property.Value.GetRawText()); + healthProbe = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property.NameEquals("networkInterfaceConfigurations"u8)) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/ProximityPlacementGroupData.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/ProximityPlacementGroupData.Serialization.cs index e65f0b6a25b..b7f9302fe9d 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/ProximityPlacementGroupData.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/ProximityPlacementGroupData.Serialization.cs @@ -9,6 +9,7 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Linq; +using System.Runtime.InteropServices; using System.Text; using System.Text.Json; using Azure.Core; @@ -44,7 +45,7 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri if (Optional.IsDefined(ExtendedLocation)) { writer.WritePropertyName("extendedLocation"u8); - JsonSerializer.Serialize(writer, ExtendedLocation); + ((IJsonModel)ExtendedLocation).Write(writer, options); } writer.WritePropertyName("properties"u8); writer.WriteStartObject(); @@ -133,7 +134,13 @@ internal static ProximityPlacementGroupData DeserializeProximityPlacementGroupDa { continue; } - extendedLocation = JsonSerializer.Deserialize(property.Value.GetRawText()); + extendedLocation = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property.NameEquals("tags"u8)) @@ -176,7 +183,13 @@ internal static ProximityPlacementGroupData DeserializeProximityPlacementGroupDa { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::AzureSample.ResourceManager.Sample.ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/SshPublicKeyData.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/SshPublicKeyData.Serialization.cs index 9ec7750acf7..4660162b32f 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/SshPublicKeyData.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/SshPublicKeyData.Serialization.cs @@ -9,6 +9,7 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Linq; +using System.Runtime.InteropServices; using System.Text; using System.Text.Json; using Azure.Core; @@ -120,7 +121,13 @@ internal static SshPublicKeyData DeserializeSshPublicKeyData(JsonElement element { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::AzureSample.ResourceManager.Sample.ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineData.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineData.Serialization.cs index ca3b9b65b41..54a7a3519d7 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineData.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineData.Serialization.cs @@ -9,6 +9,7 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Linq; +using System.Runtime.InteropServices; using System.Text; using System.Text.Json; using Azure.Core; @@ -59,7 +60,7 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri if (Optional.IsDefined(Identity)) { writer.WritePropertyName("identity"u8); - JsonSerializer.Serialize(writer, Identity); + ((IJsonModel)Identity).Write(writer, options); } if (Optional.IsCollectionDefined(Zones)) { @@ -111,17 +112,17 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri if (Optional.IsDefined(AvailabilitySet)) { writer.WritePropertyName("availabilitySet"u8); - JsonSerializer.Serialize(writer, AvailabilitySet); + ((IJsonModel)AvailabilitySet).Write(writer, options); } if (Optional.IsDefined(VirtualMachineScaleSet)) { writer.WritePropertyName("virtualMachineScaleSet"u8); - JsonSerializer.Serialize(writer, VirtualMachineScaleSet); + ((IJsonModel)VirtualMachineScaleSet).Write(writer, options); } if (Optional.IsDefined(ProximityPlacementGroup)) { writer.WritePropertyName("proximityPlacementGroup"u8); - JsonSerializer.Serialize(writer, ProximityPlacementGroup); + ((IJsonModel)ProximityPlacementGroup).Write(writer, options); } if (Optional.IsDefined(Priority)) { @@ -141,12 +142,12 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri if (Optional.IsDefined(Host)) { writer.WritePropertyName("host"u8); - JsonSerializer.Serialize(writer, Host); + ((IJsonModel)Host).Write(writer, options); } if (Optional.IsDefined(HostGroup)) { writer.WritePropertyName("hostGroup"u8); - JsonSerializer.Serialize(writer, HostGroup); + ((IJsonModel)HostGroup).Write(writer, options); } if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) { @@ -259,7 +260,13 @@ internal static VirtualMachineData DeserializeVirtualMachineData(JsonElement ele { continue; } - identity = JsonSerializer.Deserialize(property.Value.GetRawText()); + identity = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property.NameEquals("zones"u8)) @@ -316,7 +323,13 @@ internal static VirtualMachineData DeserializeVirtualMachineData(JsonElement ele { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::AzureSample.ResourceManager.Sample.ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) @@ -397,7 +410,13 @@ internal static VirtualMachineData DeserializeVirtualMachineData(JsonElement ele { continue; } - availabilitySet = JsonSerializer.Deserialize(property0.Value.GetRawText()); + availabilitySet = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property0.Value).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property0.NameEquals("virtualMachineScaleSet"u8)) @@ -406,7 +425,13 @@ internal static VirtualMachineData DeserializeVirtualMachineData(JsonElement ele { continue; } - virtualMachineScaleSet = JsonSerializer.Deserialize(property0.Value.GetRawText()); + virtualMachineScaleSet = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property0.Value).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property0.NameEquals("proximityPlacementGroup"u8)) @@ -415,7 +440,13 @@ internal static VirtualMachineData DeserializeVirtualMachineData(JsonElement ele { continue; } - proximityPlacementGroup = JsonSerializer.Deserialize(property0.Value.GetRawText()); + proximityPlacementGroup = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property0.Value).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property0.NameEquals("priority"u8)) @@ -451,7 +482,13 @@ internal static VirtualMachineData DeserializeVirtualMachineData(JsonElement ele { continue; } - host = JsonSerializer.Deserialize(property0.Value.GetRawText()); + host = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property0.Value).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property0.NameEquals("hostGroup"u8)) @@ -460,7 +497,13 @@ internal static VirtualMachineData DeserializeVirtualMachineData(JsonElement ele { continue; } - hostGroup = JsonSerializer.Deserialize(property0.Value.GetRawText()); + hostGroup = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property0.Value).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property0.NameEquals("provisioningState"u8)) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineExtensionData.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineExtensionData.Serialization.cs index e8e5419f616..98cc85f8369 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineExtensionData.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineExtensionData.Serialization.cs @@ -9,6 +9,7 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Linq; +using System.Runtime.InteropServices; using System.Text; using System.Text.Json; using Azure.Core; @@ -189,7 +190,13 @@ internal static VirtualMachineExtensionData DeserializeVirtualMachineExtensionDa { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::AzureSample.ResourceManager.Sample.ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineExtensionImageData.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineExtensionImageData.Serialization.cs index 4cce7d23e64..84882c969c5 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineExtensionImageData.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineExtensionImageData.Serialization.cs @@ -9,6 +9,7 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Linq; +using System.Runtime.InteropServices; using System.Text; using System.Text.Json; using Azure.Core; @@ -144,7 +145,13 @@ internal static VirtualMachineExtensionImageData DeserializeVirtualMachineExtens { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::AzureSample.ResourceManager.Sample.ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineScaleSetData.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineScaleSetData.Serialization.cs index 89316ed2560..db77a651f93 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineScaleSetData.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineScaleSetData.Serialization.cs @@ -9,6 +9,7 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Linq; +using System.Runtime.InteropServices; using System.Text; using System.Text.Json; using Azure.Core; @@ -54,7 +55,7 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri if (Optional.IsDefined(Identity)) { writer.WritePropertyName("identity"u8); - JsonSerializer.Serialize(writer, Identity); + ((IJsonModel)Identity).Write(writer, options); } if (Optional.IsCollectionDefined(Zones)) { @@ -121,12 +122,12 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri if (Optional.IsDefined(ProximityPlacementGroup)) { writer.WritePropertyName("proximityPlacementGroup"u8); - JsonSerializer.Serialize(writer, ProximityPlacementGroup); + ((IJsonModel)ProximityPlacementGroup).Write(writer, options); } if (Optional.IsDefined(HostGroup)) { writer.WritePropertyName("hostGroup"u8); - JsonSerializer.Serialize(writer, HostGroup); + ((IJsonModel)HostGroup).Write(writer, options); } if (Optional.IsDefined(AdditionalCapabilities)) { @@ -213,7 +214,13 @@ internal static VirtualMachineScaleSetData DeserializeVirtualMachineScaleSetData { continue; } - identity = JsonSerializer.Deserialize(property.Value.GetRawText()); + identity = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property.NameEquals("zones"u8)) @@ -270,7 +277,13 @@ internal static VirtualMachineScaleSetData DeserializeVirtualMachineScaleSetData { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::AzureSample.ResourceManager.Sample.ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) @@ -370,7 +383,13 @@ internal static VirtualMachineScaleSetData DeserializeVirtualMachineScaleSetData { continue; } - proximityPlacementGroup = JsonSerializer.Deserialize(property0.Value.GetRawText()); + proximityPlacementGroup = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property0.Value).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property0.NameEquals("hostGroup"u8)) @@ -379,7 +398,13 @@ internal static VirtualMachineScaleSetData DeserializeVirtualMachineScaleSetData { continue; } - hostGroup = JsonSerializer.Deserialize(property0.Value.GetRawText()); + hostGroup = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property0.Value).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property0.NameEquals("additionalCapabilities"u8)) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineScaleSetRollingUpgradeData.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineScaleSetRollingUpgradeData.Serialization.cs index e9c82c84513..e64ad427686 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineScaleSetRollingUpgradeData.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineScaleSetRollingUpgradeData.Serialization.cs @@ -9,6 +9,7 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Linq; +using System.Runtime.InteropServices; using System.Text; using System.Text.Json; using Azure.Core; @@ -139,7 +140,13 @@ internal static VirtualMachineScaleSetRollingUpgradeData DeserializeVirtualMachi { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::AzureSample.ResourceManager.Sample.ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) diff --git a/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineScaleSetVmData.Serialization.cs b/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineScaleSetVmData.Serialization.cs index 36529be14b7..be65b7132e1 100644 --- a/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineScaleSetVmData.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Sample/src/Generated/VirtualMachineScaleSetVmData.Serialization.cs @@ -9,6 +9,7 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Linq; +using System.Runtime.InteropServices; using System.Text; using System.Text.Json; using Azure.Core; @@ -136,7 +137,7 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri if (Optional.IsDefined(AvailabilitySet)) { writer.WritePropertyName("availabilitySet"u8); - JsonSerializer.Serialize(writer, AvailabilitySet); + ((IJsonModel)AvailabilitySet).Write(writer, options); } if (options.Format != "W" && Optional.IsDefined(ProvisioningState)) { @@ -303,7 +304,13 @@ internal static VirtualMachineScaleSetVmData DeserializeVirtualMachineScaleSetVm { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::AzureSample.ResourceManager.Sample.ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) @@ -416,7 +423,13 @@ internal static VirtualMachineScaleSetVmData DeserializeVirtualMachineScaleSetVm { continue; } - availabilitySet = JsonSerializer.Deserialize(property0.Value.GetRawText()); + availabilitySet = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property0.Value).ToArray()), options, AzureSampleResourceManagerSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), options, AzureSampleResourceManagerSampleContext.Default) +#endif +; continue; } if (property0.NameEquals("provisioningState"u8)) diff --git a/samples/AzureSample.ResourceManager.Storage/src/Generated/AzureSampleResourceManagerStoragePrivateEndpointConnectionData.Serialization.cs b/samples/AzureSample.ResourceManager.Storage/src/Generated/AzureSampleResourceManagerStoragePrivateEndpointConnectionData.Serialization.cs index 82a5f71c398..d30613e28f4 100644 --- a/samples/AzureSample.ResourceManager.Storage/src/Generated/AzureSampleResourceManagerStoragePrivateEndpointConnectionData.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Storage/src/Generated/AzureSampleResourceManagerStoragePrivateEndpointConnectionData.Serialization.cs @@ -5,6 +5,10 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -23,7 +27,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(PrivateEndpoint)) { writer.WritePropertyName("privateEndpoint"u8); - JsonSerializer.Serialize(writer, PrivateEndpoint); + ((IJsonModel)PrivateEndpoint).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsDefined(ConnectionState)) { @@ -70,7 +74,13 @@ internal static AzureSampleResourceManagerStoragePrivateEndpointConnectionData D { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::AzureSample.ResourceManager.Storage.ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerStorageContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerStorageContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) @@ -88,7 +98,13 @@ internal static AzureSampleResourceManagerStoragePrivateEndpointConnectionData D { continue; } - privateEndpoint = JsonSerializer.Deserialize(property0.Value.GetRawText()); + privateEndpoint = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property0.Value).ToArray()), global::AzureSample.ResourceManager.Storage.ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerStorageContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerStorageContext.Default) +#endif +; continue; } if (property0.NameEquals("privateLinkServiceConnectionState"u8)) diff --git a/samples/AzureSample.ResourceManager.Storage/src/Generated/BlobContainerData.Serialization.cs b/samples/AzureSample.ResourceManager.Storage/src/Generated/BlobContainerData.Serialization.cs index f776a0884d1..cf6cd2dc1a8 100644 --- a/samples/AzureSample.ResourceManager.Storage/src/Generated/BlobContainerData.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Storage/src/Generated/BlobContainerData.Serialization.cs @@ -6,7 +6,10 @@ #nullable disable using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure; using Azure.Core; @@ -129,7 +132,13 @@ internal static BlobContainerData DeserializeBlobContainerData(JsonElement eleme { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::AzureSample.ResourceManager.Storage.ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerStorageContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerStorageContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) diff --git a/samples/AzureSample.ResourceManager.Storage/src/Generated/BlobInventoryPolicyData.Serialization.cs b/samples/AzureSample.ResourceManager.Storage/src/Generated/BlobInventoryPolicyData.Serialization.cs index 877d151f282..6da7474f2bc 100644 --- a/samples/AzureSample.ResourceManager.Storage/src/Generated/BlobInventoryPolicyData.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Storage/src/Generated/BlobInventoryPolicyData.Serialization.cs @@ -6,6 +6,9 @@ #nullable disable using System; +using System.ClientModel.Primitives; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -64,7 +67,13 @@ internal static BlobInventoryPolicyData DeserializeBlobInventoryPolicyData(JsonE { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::AzureSample.ResourceManager.Storage.ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerStorageContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerStorageContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) diff --git a/samples/AzureSample.ResourceManager.Storage/src/Generated/BlobServiceData.Serialization.cs b/samples/AzureSample.ResourceManager.Storage/src/Generated/BlobServiceData.Serialization.cs index 02fadc6e745..e5768237e4d 100644 --- a/samples/AzureSample.ResourceManager.Storage/src/Generated/BlobServiceData.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Storage/src/Generated/BlobServiceData.Serialization.cs @@ -5,6 +5,10 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -120,7 +124,13 @@ internal static BlobServiceData DeserializeBlobServiceData(JsonElement element) { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::AzureSample.ResourceManager.Storage.ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerStorageContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerStorageContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) diff --git a/samples/AzureSample.ResourceManager.Storage/src/Generated/DeletedAccountData.Serialization.cs b/samples/AzureSample.ResourceManager.Storage/src/Generated/DeletedAccountData.Serialization.cs index 85e483c21f7..e2a96d4e9b5 100644 --- a/samples/AzureSample.ResourceManager.Storage/src/Generated/DeletedAccountData.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Storage/src/Generated/DeletedAccountData.Serialization.cs @@ -5,6 +5,10 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -60,7 +64,13 @@ internal static DeletedAccountData DeserializeDeletedAccountData(JsonElement ele { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::AzureSample.ResourceManager.Storage.ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerStorageContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerStorageContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) diff --git a/samples/AzureSample.ResourceManager.Storage/src/Generated/EncryptionScopeData.Serialization.cs b/samples/AzureSample.ResourceManager.Storage/src/Generated/EncryptionScopeData.Serialization.cs index 3e13600e31f..8055f76abaa 100644 --- a/samples/AzureSample.ResourceManager.Storage/src/Generated/EncryptionScopeData.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Storage/src/Generated/EncryptionScopeData.Serialization.cs @@ -6,6 +6,9 @@ #nullable disable using System; +using System.ClientModel.Primitives; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -83,7 +86,13 @@ internal static EncryptionScopeData DeserializeEncryptionScopeData(JsonElement e { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::AzureSample.ResourceManager.Storage.ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerStorageContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerStorageContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) diff --git a/samples/AzureSample.ResourceManager.Storage/src/Generated/FileServiceData.Serialization.cs b/samples/AzureSample.ResourceManager.Storage/src/Generated/FileServiceData.Serialization.cs index fd02fb8722f..e9495ddabe7 100644 --- a/samples/AzureSample.ResourceManager.Storage/src/Generated/FileServiceData.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Storage/src/Generated/FileServiceData.Serialization.cs @@ -5,6 +5,10 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -84,7 +88,13 @@ internal static FileServiceData DeserializeFileServiceData(JsonElement element) { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::AzureSample.ResourceManager.Storage.ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerStorageContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerStorageContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) diff --git a/samples/AzureSample.ResourceManager.Storage/src/Generated/FileShareData.Serialization.cs b/samples/AzureSample.ResourceManager.Storage/src/Generated/FileShareData.Serialization.cs index a8184bd69ff..74a36f620b8 100644 --- a/samples/AzureSample.ResourceManager.Storage/src/Generated/FileShareData.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Storage/src/Generated/FileShareData.Serialization.cs @@ -6,7 +6,10 @@ #nullable disable using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure; using Azure.Core; @@ -128,7 +131,13 @@ internal static FileShareData DeserializeFileShareData(JsonElement element) { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::AzureSample.ResourceManager.Storage.ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerStorageContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerStorageContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) diff --git a/samples/AzureSample.ResourceManager.Storage/src/Generated/ImmutabilityPolicyData.Serialization.cs b/samples/AzureSample.ResourceManager.Storage/src/Generated/ImmutabilityPolicyData.Serialization.cs index c37e9890c4a..77c55c57797 100644 --- a/samples/AzureSample.ResourceManager.Storage/src/Generated/ImmutabilityPolicyData.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Storage/src/Generated/ImmutabilityPolicyData.Serialization.cs @@ -5,6 +5,10 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure; using Azure.Core; @@ -86,7 +90,13 @@ internal static ImmutabilityPolicyData DeserializeImmutabilityPolicyData(JsonEle { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::AzureSample.ResourceManager.Storage.ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerStorageContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerStorageContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) diff --git a/samples/AzureSample.ResourceManager.Storage/src/Generated/LongRunningOperation/StorageArmOperation.cs b/samples/AzureSample.ResourceManager.Storage/src/Generated/LongRunningOperation/StorageArmOperation.cs index 70610b7d30d..0981b3e2587 100644 --- a/samples/AzureSample.ResourceManager.Storage/src/Generated/LongRunningOperation/StorageArmOperation.cs +++ b/samples/AzureSample.ResourceManager.Storage/src/Generated/LongRunningOperation/StorageArmOperation.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, AzureSampleResourceManagerStorageContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, AzureSampleResourceManagerStorageContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/samples/AzureSample.ResourceManager.Storage/src/Generated/LongRunningOperation/StorageArmOperationOfT.cs b/samples/AzureSample.ResourceManager.Storage/src/Generated/LongRunningOperation/StorageArmOperationOfT.cs index e182e606c55..5d472088a6f 100644 --- a/samples/AzureSample.ResourceManager.Storage/src/Generated/LongRunningOperation/StorageArmOperationOfT.cs +++ b/samples/AzureSample.ResourceManager.Storage/src/Generated/LongRunningOperation/StorageArmOperationOfT.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, AzureSampleResourceManagerStorageContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, AzureSampleResourceManagerStorageContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/samples/AzureSample.ResourceManager.Storage/src/Generated/ManagementPolicyData.Serialization.cs b/samples/AzureSample.ResourceManager.Storage/src/Generated/ManagementPolicyData.Serialization.cs index 12065207305..a39164ab86f 100644 --- a/samples/AzureSample.ResourceManager.Storage/src/Generated/ManagementPolicyData.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Storage/src/Generated/ManagementPolicyData.Serialization.cs @@ -6,6 +6,9 @@ #nullable disable using System; +using System.ClientModel.Primitives; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -64,7 +67,13 @@ internal static ManagementPolicyData DeserializeManagementPolicyData(JsonElement { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::AzureSample.ResourceManager.Storage.ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerStorageContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerStorageContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) diff --git a/samples/AzureSample.ResourceManager.Storage/src/Generated/Models/AzureSampleResourceManagerStoragePrivateLinkResource.Serialization.cs b/samples/AzureSample.ResourceManager.Storage/src/Generated/Models/AzureSampleResourceManagerStoragePrivateLinkResource.Serialization.cs index c97a39bcd70..371c06fa3ae 100644 --- a/samples/AzureSample.ResourceManager.Storage/src/Generated/Models/AzureSampleResourceManagerStoragePrivateLinkResource.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Storage/src/Generated/Models/AzureSampleResourceManagerStoragePrivateLinkResource.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -69,7 +73,13 @@ internal static AzureSampleResourceManagerStoragePrivateLinkResource Deserialize { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::AzureSample.ResourceManager.Storage.ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerStorageContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerStorageContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) diff --git a/samples/AzureSample.ResourceManager.Storage/src/Generated/Models/StorageAccountCreateOrUpdateContent.Serialization.cs b/samples/AzureSample.ResourceManager.Storage/src/Generated/Models/StorageAccountCreateOrUpdateContent.Serialization.cs index a44d215e6bd..dc32ef54117 100644 --- a/samples/AzureSample.ResourceManager.Storage/src/Generated/Models/StorageAccountCreateOrUpdateContent.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Storage/src/Generated/Models/StorageAccountCreateOrUpdateContent.Serialization.cs @@ -5,9 +5,11 @@ #nullable disable +using System.ClientModel.Primitives; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; +using Azure.ResourceManager.Resources.Models; namespace AzureSample.ResourceManager.Storage.Models { @@ -25,7 +27,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(ExtendedLocation)) { writer.WritePropertyName("extendedLocation"u8); - JsonSerializer.Serialize(writer, ExtendedLocation); + ((IJsonModel)ExtendedLocation).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsCollectionDefined(Tags)) { @@ -41,8 +43,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(Identity)) { writer.WritePropertyName("identity"u8); - var serializeOptions = new JsonSerializerOptions { Converters = { new ManagedServiceIdentityTypeV3Converter() } }; - JsonSerializer.Serialize(writer, Identity, serializeOptions); + ((IJsonModel)Identity).Write(writer, new ModelReaderWriterOptions("W|v3")); } writer.WritePropertyName("properties"u8); writer.WriteStartObject(); diff --git a/samples/AzureSample.ResourceManager.Storage/src/Generated/Models/StorageAccountPatch.Serialization.cs b/samples/AzureSample.ResourceManager.Storage/src/Generated/Models/StorageAccountPatch.Serialization.cs index 5ec2126324c..3b030c04264 100644 --- a/samples/AzureSample.ResourceManager.Storage/src/Generated/Models/StorageAccountPatch.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Storage/src/Generated/Models/StorageAccountPatch.Serialization.cs @@ -5,6 +5,7 @@ #nullable disable +using System.ClientModel.Primitives; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -35,8 +36,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(Identity)) { writer.WritePropertyName("identity"u8); - var serializeOptions = new JsonSerializerOptions { Converters = { new ManagedServiceIdentityTypeV3Converter() } }; - JsonSerializer.Serialize(writer, Identity, serializeOptions); + ((IJsonModel)Identity).Write(writer, new ModelReaderWriterOptions("W|v3")); } if (Optional.IsDefined(Kind)) { diff --git a/samples/AzureSample.ResourceManager.Storage/src/Generated/ObjectReplicationPolicyData.Serialization.cs b/samples/AzureSample.ResourceManager.Storage/src/Generated/ObjectReplicationPolicyData.Serialization.cs index 871b9f9a7b0..1b40fecaa0d 100644 --- a/samples/AzureSample.ResourceManager.Storage/src/Generated/ObjectReplicationPolicyData.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Storage/src/Generated/ObjectReplicationPolicyData.Serialization.cs @@ -6,7 +6,10 @@ #nullable disable using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -83,7 +86,13 @@ internal static ObjectReplicationPolicyData DeserializeObjectReplicationPolicyDa { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::AzureSample.ResourceManager.Storage.ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerStorageContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerStorageContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) diff --git a/samples/AzureSample.ResourceManager.Storage/src/Generated/StorageAccountData.Serialization.cs b/samples/AzureSample.ResourceManager.Storage/src/Generated/StorageAccountData.Serialization.cs index f942b4aec97..093ff8f32af 100644 --- a/samples/AzureSample.ResourceManager.Storage/src/Generated/StorageAccountData.Serialization.cs +++ b/samples/AzureSample.ResourceManager.Storage/src/Generated/StorageAccountData.Serialization.cs @@ -6,7 +6,10 @@ #nullable disable using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -23,13 +26,12 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(Identity)) { writer.WritePropertyName("identity"u8); - var serializeOptions = new JsonSerializerOptions { Converters = { new ManagedServiceIdentityTypeV3Converter() } }; - JsonSerializer.Serialize(writer, Identity, serializeOptions); + ((IJsonModel)Identity).Write(writer, new ModelReaderWriterOptions("W|v3")); } if (Optional.IsDefined(ExtendedLocation)) { writer.WritePropertyName("extendedLocation"u8); - JsonSerializer.Serialize(writer, ExtendedLocation); + ((IJsonModel)ExtendedLocation).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsCollectionDefined(Tags)) { @@ -190,8 +192,13 @@ internal static StorageAccountData DeserializeStorageAccountData(JsonElement ele { continue; } - var serializeOptions = new JsonSerializerOptions { Converters = { new ManagedServiceIdentityTypeV3Converter() } }; - identity = JsonSerializer.Deserialize(property.Value.GetRawText(), serializeOptions); + identity = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), new global::System.ClientModel.Primitives.ModelReaderWriterOptions("W|v3"), AzureSampleResourceManagerStorageContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), new ModelReaderWriterOptions("W|v3"), AzureSampleResourceManagerStorageContext.Default) +#endif +; continue; } if (property.NameEquals("extendedLocation"u8)) @@ -200,7 +207,13 @@ internal static StorageAccountData DeserializeStorageAccountData(JsonElement ele { continue; } - extendedLocation = JsonSerializer.Deserialize(property.Value.GetRawText()); + extendedLocation = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::AzureSample.ResourceManager.Storage.ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerStorageContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerStorageContext.Default) +#endif +; continue; } if (property.NameEquals("tags"u8)) @@ -243,7 +256,13 @@ internal static StorageAccountData DeserializeStorageAccountData(JsonElement ele { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::AzureSample.ResourceManager.Storage.ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerStorageContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, AzureSampleResourceManagerStorageContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) diff --git a/src/AutoRest.CSharp/Common/Output/Builders/JsonSerializationMethodsBuilder.cs b/src/AutoRest.CSharp/Common/Output/Builders/JsonSerializationMethodsBuilder.cs index f41b22b53c1..2c8585c2305 100644 --- a/src/AutoRest.CSharp/Common/Output/Builders/JsonSerializationMethodsBuilder.cs +++ b/src/AutoRest.CSharp/Common/Output/Builders/JsonSerializationMethodsBuilder.cs @@ -10,6 +10,7 @@ using System.Linq; using System.Net; using System.Reflection; +using System.Text; using System.Text.Json; using System.Text.Json.Serialization; using AutoRest.CSharp.Common.Input; @@ -32,6 +33,7 @@ using AutoRest.CSharp.Utilities; using Azure; using Azure.Core; +using Azure.ResourceManager.Models; using Azure.ResourceManager.Resources.Models; using Microsoft.CodeAnalysis; using static AutoRest.CSharp.Common.Output.Models.Snippets; @@ -434,22 +436,13 @@ private static MethodBodyStatement SerializeValue(Utf8JsonWriterExpression utf8J if (valueSerialization.Type.IsFrameworkType) { - return SerializeFrameworkTypeValue(utf8JsonWriter, valueSerialization, value, valueSerialization.Type.FrameworkType, options); + return SerializeFrameworkTypeValue(utf8JsonWriter, valueSerialization, value, valueSerialization.Type, options); } switch (valueSerialization.Type.Implementation) { case SystemObjectType systemObjectType when IsCustomJsonConverterAdded(systemObjectType.SystemType): - if (valueSerialization.Options == JsonSerializationOptions.UseManagedServiceIdentityV3) - { - return new[] - { - Var("serializeOptions", New.JsonSerializerOptions(), out var serializeOptions), - JsonSerializerExpression.Serialize(utf8JsonWriter, value, serializeOptions).ToStatement() - }; - } - - return JsonSerializerExpression.Serialize(utf8JsonWriter, value).ToStatement(); + return ModelReaderWriterExpression.Write(value, valueSerialization.Type, utf8JsonWriter, options, valueSerialization.Options == JsonSerializationOptions.UseManagedServiceIdentityV3); case ObjectType: return utf8JsonWriter.WriteObjectValue(value, options: options); @@ -468,55 +461,56 @@ private static MethodBodyStatement SerializeValue(Utf8JsonWriterExpression utf8J } } - private static MethodBodyStatement SerializeFrameworkTypeValue(Utf8JsonWriterExpression utf8JsonWriter, JsonValueSerialization valueSerialization, ValueExpression value, Type valueType, ModelReaderWriterOptionsExpression? options) + private static MethodBodyStatement SerializeFrameworkTypeValue(Utf8JsonWriterExpression utf8JsonWriter, JsonValueSerialization valueSerialization, ValueExpression value, CSharpType valueType, ModelReaderWriterOptionsExpression? options) { - if (valueType == typeof(JsonElement)) + var frameworkType = valueType.FrameworkType; + if (frameworkType == typeof(JsonElement)) { return new JsonElementExpression(value).WriteTo(utf8JsonWriter); } - if (valueType == typeof(Nullable<>)) + if (frameworkType == typeof(Nullable<>)) { - valueType = valueSerialization.Type.Arguments[0].FrameworkType; + frameworkType = valueSerialization.Type.Arguments[0].FrameworkType; } value = value.NullableStructValue(valueSerialization.Type); - if (valueType == typeof(decimal) || - valueType == typeof(double) || - valueType == typeof(float) || - IsIntType(valueType)) + if (frameworkType == typeof(decimal) || + frameworkType == typeof(double) || + frameworkType == typeof(float) || + IsIntType(frameworkType)) { if (valueSerialization.Format is SerializationFormat.Int_String && - IsIntType(valueType)) + IsIntType(frameworkType)) { return utf8JsonWriter.WriteStringValue(value.InvokeToString()); } return utf8JsonWriter.WriteNumberValue(value); } - if (valueType == typeof(object)) + if (frameworkType == typeof(object)) { return utf8JsonWriter.WriteObjectValue(new TypedValueExpression(valueType, value), options); } // These are string-like types that could implicitly convert to string type - if (valueType == typeof(string) || valueType == typeof(char) || valueType == typeof(Guid) || valueType == typeof(ResourceIdentifier) || valueType == typeof(ResourceType) || valueType == typeof(AzureLocation)) + if (frameworkType == typeof(string) || frameworkType == typeof(char) || frameworkType == typeof(Guid) || frameworkType == typeof(ResourceIdentifier) || frameworkType == typeof(ResourceType) || frameworkType == typeof(AzureLocation)) { return utf8JsonWriter.WriteStringValue(value); } - if (valueType == typeof(bool)) + if (frameworkType == typeof(bool)) { return utf8JsonWriter.WriteBooleanValue(value); } - if (valueType == typeof(byte[])) + if (frameworkType == typeof(byte[])) { return utf8JsonWriter.WriteBase64StringValue(value, valueSerialization.Format.ToFormatSpecifier()); } - if (valueType == typeof(DateTimeOffset) || valueType == typeof(DateTime) || valueType == typeof(TimeSpan)) + if (frameworkType == typeof(DateTimeOffset) || frameworkType == typeof(DateTime) || frameworkType == typeof(TimeSpan)) { var format = valueSerialization.Format.ToFormatSpecifier(); @@ -540,17 +534,17 @@ private static MethodBodyStatement SerializeFrameworkTypeValue(Utf8JsonWriterExp } // These are string-like types that cannot implicitly convert to string type, therefore we need to call ToString on them - if (valueType == typeof(ETag) || valueType == typeof(ContentType) || valueType == typeof(IPAddress) || valueType == typeof(RequestMethod) || valueType == typeof(ExtendedLocationType)) + if (frameworkType == typeof(ETag) || frameworkType == typeof(ContentType) || frameworkType == typeof(IPAddress) || frameworkType == typeof(RequestMethod) || frameworkType == typeof(ExtendedLocationType)) { return utf8JsonWriter.WriteStringValue(value.InvokeToString()); } - if (valueType == typeof(Uri)) + if (frameworkType == typeof(Uri)) { return utf8JsonWriter.WriteStringValue(new MemberExpression(value, nameof(Uri.AbsoluteUri))); } - if (valueType == typeof(BinaryData)) + if (frameworkType == typeof(BinaryData)) { var binaryDataValue = new BinaryDataExpression(value); if (valueSerialization.Format is SerializationFormat.Bytes_Base64 or SerializationFormat.Bytes_Base64Url) @@ -560,14 +554,15 @@ private static MethodBodyStatement SerializeFrameworkTypeValue(Utf8JsonWriterExp return utf8JsonWriter.WriteBinaryData(binaryDataValue); } - if (valueType == typeof(Stream)) + + if (frameworkType == typeof(Stream)) { return utf8JsonWriter.WriteBinaryData(BinaryDataExpression.FromStream(value, false)); } - if (IsCustomJsonConverterAdded(valueType)) + if (IsCustomJsonConverterAdded(frameworkType)) { - return JsonSerializerExpression.Serialize(utf8JsonWriter, value).ToStatement(); + return ModelReaderWriterExpression.Write(value, valueType, utf8JsonWriter, options); } throw new NotSupportedException($"Framework type {valueType} serialization not supported, please add `CodeGenMemberSerializationHooks` to specify the serialization of this type with the customized property"); @@ -1070,9 +1065,8 @@ public static MethodBodyStatement DeserializeValue(JsonSerialization serializati return deserializeDictionaryStatement; case JsonValueSerialization { Options: JsonSerializationOptions.UseManagedServiceIdentityV3 } valueSerialization: - var declareSerializeOptions = Var("serializeOptions", New.JsonSerializerOptions(), out var serializeOptions); - value = GetDeserializeValueExpression(element, valueSerialization.Type, options, valueSerialization.Format, serializeOptions); - return declareSerializeOptions; + value = GetDeserializeValueExpression(element, valueSerialization.Type, options, valueSerialization.Format, null, useManagedServiceIdentityV3: true); + return EmptyStatement; case JsonValueSerialization valueSerialization: value = GetDeserializeValueExpression(element, valueSerialization.Type, options, valueSerialization.Format); @@ -1123,11 +1117,11 @@ private static MethodBodyStatement DeserializeDictionaryValue(JsonSerialization return deserializeValueBlock; } - public static ValueExpression GetDeserializeValueExpression(JsonElementExpression element, CSharpType serializationType, ModelReaderWriterOptionsExpression? options, SerializationFormat serializationFormat = SerializationFormat.Default, ValueExpression? serializerOptions = null) + public static ValueExpression GetDeserializeValueExpression(JsonElementExpression element, CSharpType serializationType, ModelReaderWriterOptionsExpression? options, SerializationFormat serializationFormat = SerializationFormat.Default, ValueExpression? serializerOptions = null, bool useManagedServiceIdentityV3 = false) { if (serializationType.SerializeAs != null) { - return new CastExpression(GetFrameworkTypeValueExpression(serializationType.SerializeAs, element, serializationFormat, serializationType), serializationType); + return new CastExpression(GetFrameworkTypeValueExpression(serializationType.SerializeAs, element, serializationFormat), serializationType); } if (serializationType.IsFrameworkType) @@ -1138,30 +1132,29 @@ public static ValueExpression GetDeserializeValueExpression(JsonElementExpressio frameworkType = serializationType.Arguments[0].FrameworkType; } - return GetFrameworkTypeValueExpression(frameworkType, element, serializationFormat, serializationType); + return GetFrameworkTypeValueExpression(serializationType, element, serializationFormat); } - return GetDeserializeImplementation(serializationType.Implementation, element, options, serializerOptions); + return GetDeserializeImplementation(serializationType.Implementation, element, options, serializerOptions, useManagedServiceIdentityV3); } - private static ValueExpression GetDeserializeImplementation(TypeProvider implementation, JsonElementExpression element, ModelReaderWriterOptionsExpression? options, ValueExpression? serializerOptions) + private static ValueExpression GetDeserializeImplementation(TypeProvider implementation, JsonElementExpression element, ModelReaderWriterOptionsExpression? options, ValueExpression? serializerOptions, bool useManagedServiceIdentityV3 = false) { + var implementationType = implementation.Type; switch (implementation) { case SystemObjectType systemObjectType when IsCustomJsonConverterAdded(systemObjectType.SystemType): - return JsonSerializerExpression.Deserialize(element, implementation.Type, serializerOptions); + case MgmtObjectType mgmtObjectType when TypeReferenceTypeChooser.HasMatch(mgmtObjectType.InputModel): + return ModelReaderWriterExpression.Read(implementationType, element, options, useManagedServiceIdentityV3); case Resource { ResourceData: SerializableObjectType resourceDataType } resource: return New.Instance(resource.Type, new MemberExpression(null, "Client"), SerializableObjectTypeExpression.Deserialize(resourceDataType, element)); - case MgmtObjectType mgmtObjectType when TypeReferenceTypeChooser.HasMatch(mgmtObjectType.InputModel): - return JsonSerializerExpression.Deserialize(element, implementation.Type); - case SerializableObjectType type: return SerializableObjectTypeExpression.Deserialize(type, element, options); case EnumType clientEnum: - var value = GetFrameworkTypeValueExpression(clientEnum.ValueType.FrameworkType, element, SerializationFormat.Default, null); + var value = GetFrameworkTypeValueExpression(clientEnum.ValueType, element, SerializationFormat.Default, false); return EnumExpression.ToEnum(clientEnum, value); default: @@ -1184,76 +1177,76 @@ private static ValueExpression GetOptional(PropertySerialization jsonPropertySer return variable; } - public static ValueExpression GetFrameworkTypeValueExpression(Type frameworkType, JsonElementExpression element, SerializationFormat format, CSharpType? serializationType) + public static ValueExpression GetFrameworkTypeValueExpression(CSharpType serializationType, JsonElementExpression element, SerializationFormat format, bool shouldDeserialize = true) { - if (frameworkType == typeof(ETag) || - frameworkType == typeof(Uri) || - frameworkType == typeof(ResourceIdentifier) || - frameworkType == typeof(ResourceType) || - frameworkType == typeof(ContentType) || - frameworkType == typeof(RequestMethod) || - frameworkType == typeof(AzureLocation) || - frameworkType == typeof(ExtendedLocationType)) + if (serializationType.Equals(typeof(ETag)) || + serializationType.Equals(typeof(Uri)) || + serializationType.Equals(typeof(ResourceIdentifier)) || + serializationType.Equals(typeof(ResourceType)) || + serializationType.Equals(typeof(ContentType)) || + serializationType.Equals(typeof(RequestMethod)) || + serializationType.Equals(typeof(AzureLocation)) || + serializationType.Equals(typeof(ExtendedLocationType))) { - return New.Instance(frameworkType, element.GetString()); + return New.Instance(serializationType.WithNullable(false), element.GetString()); } - if (frameworkType == typeof(IPAddress)) + if (serializationType.Equals(typeof(IPAddress))) { return new InvokeStaticMethodExpression(typeof(IPAddress), nameof(IPAddress.Parse), new[] { element.GetString() }); } - if (frameworkType == typeof(BinaryData)) + if (serializationType.Equals(typeof(BinaryData))) { return format is SerializationFormat.Bytes_Base64 or SerializationFormat.Bytes_Base64Url ? BinaryDataExpression.FromBytes(element.GetBytesFromBase64(format.ToFormatSpecifier())) : BinaryDataExpression.FromString(element.GetRawText()); } - if (frameworkType == typeof(Stream)) + if (serializationType.Equals(typeof(Stream))) { /* BinaryData.FromString(property.Value).ToStream() */ return new BinaryDataExpression(BinaryDataExpression.FromString(element.GetRawText())).ToStream(); } - if (IsCustomJsonConverterAdded(frameworkType) && serializationType is not null) + if (IsCustomJsonConverterAdded(serializationType.FrameworkType) && serializationType is not null) { - return JsonSerializerExpression.Deserialize(element, serializationType); + return ModelReaderWriterExpression.Read(serializationType, element); } - if (frameworkType == typeof(JsonElement)) + if (serializationType!.Equals(typeof(JsonElement))) return element.InvokeClone(); - if (frameworkType == typeof(object)) - return element.GetObject(); - if (frameworkType == typeof(bool)) + if (serializationType.Equals(typeof(object))) + return element.GetObject(); // modified from == to Equals + if (serializationType.Equals(typeof(bool))) // modified from == to Equals return element.GetBoolean(); - if (frameworkType == typeof(char)) + if (serializationType.Equals(typeof(char))) // modified from == to Equals return element.GetChar(); - if (IsIntType(frameworkType)) - return GetIntTypeDeserializationValueExpression(element, frameworkType, format); - if (frameworkType == typeof(float)) + if (IsIntType(serializationType)) + return GetIntTypeDeserializationValueExpression(element, serializationType, format); + if (serializationType.Equals(typeof(float))) // modified from == to Equals return element.GetSingle(); - if (frameworkType == typeof(double)) + if (serializationType.Equals(typeof(double))) // modified from == to Equals return element.GetDouble(); - if (frameworkType == typeof(decimal)) + if (serializationType.Equals(typeof(decimal))) // modified from == to Equals return element.GetDecimal(); - if (frameworkType == typeof(string)) + if (serializationType.Equals(typeof(string))) // modified from == to Equals return element.GetString(); - if (frameworkType == typeof(Guid)) + if (serializationType.Equals(typeof(Guid))) // modified from == to Equals return element.GetGuid(); - if (frameworkType == typeof(byte[])) + if (serializationType.Equals(typeof(byte[]))) // modified from == to Equals return element.GetBytesFromBase64(format.ToFormatSpecifier()); - if (frameworkType == typeof(DateTimeOffset)) + if (serializationType.Equals(typeof(DateTimeOffset))) { return format == SerializationFormat.DateTime_Unix ? DateTimeOffsetExpression.FromUnixTimeSeconds(element.GetInt64()) : element.GetDateTimeOffset(format.ToFormatSpecifier()); } - if (frameworkType == typeof(DateTime)) + if (serializationType.Equals(typeof(DateTime))) return element.GetDateTime(); - if (frameworkType == typeof(TimeSpan)) + if (serializationType.Equals(typeof(TimeSpan))) { if (format is SerializationFormat.Duration_Seconds) { @@ -1268,29 +1261,29 @@ public static ValueExpression GetFrameworkTypeValueExpression(Type frameworkType return element.GetTimeSpan(format.ToFormatSpecifier()); } - throw new NotSupportedException($"Framework type {frameworkType} is not supported, please add `CodeGenMemberSerializationHooks` to specify the serialization of this type with the customized property"); + throw new NotSupportedException($"Framework type {serializationType} is not supported, please add `CodeGenMemberSerializationHooks` to specify the serialization of this type with the customized property"); } - private static ValueExpression GetIntTypeDeserializationValueExpression(JsonElementExpression element, Type type, SerializationFormat format) => format switch + private static ValueExpression GetIntTypeDeserializationValueExpression(JsonElementExpression element, CSharpType type, SerializationFormat format) => format switch { SerializationFormat.Int_String => new TypeReference(type).Invoke(nameof(int.Parse), new List { element.GetString() }), _ => type switch { - Type t when t == typeof(sbyte) => element.GetSByte(), - Type t when t == typeof(byte) => element.GetByte(), - Type t when t == typeof(short) => element.GetInt16(), - Type t when t == typeof(int) => element.GetInt32(), - Type t when t == typeof(long) => element.GetInt64(), + CSharpType t when t.Equals(typeof(sbyte)) => element.GetSByte(), + CSharpType t when t.Equals(typeof(byte)) => element.GetByte(), + CSharpType t when t.Equals(typeof(short)) => element.GetInt16(), + CSharpType t when t.Equals(typeof(int)) => element.GetInt32(), + CSharpType t when t.Equals(typeof(long)) => element.GetInt64(), _ => throw new NotSupportedException($"Framework type {type} is not int.") } }; - private static bool IsIntType(Type frameworkType) => - frameworkType == typeof(sbyte) || - frameworkType == typeof(byte) || - frameworkType == typeof(short) || - frameworkType == typeof(int) || - frameworkType == typeof(long); + private static bool IsIntType(CSharpType frameworkType) => + frameworkType.Equals(typeof(sbyte)) || + frameworkType.Equals(typeof(byte)) || + frameworkType.Equals(typeof(short)) || + frameworkType.Equals(typeof(int)) || + frameworkType.Equals(typeof(long)); private static MethodBodyStatement InvokeListAdd(ValueExpression list, ValueExpression value) => new InvokeInstanceMethodStatement(list, nameof(List.Add), value); diff --git a/src/AutoRest.CSharp/Common/Output/Builders/SerializationBuilder.cs b/src/AutoRest.CSharp/Common/Output/Builders/SerializationBuilder.cs index aa89ad6f0b8..40bd8527141 100644 --- a/src/AutoRest.CSharp/Common/Output/Builders/SerializationBuilder.cs +++ b/src/AutoRest.CSharp/Common/Output/Builders/SerializationBuilder.cs @@ -141,7 +141,7 @@ private static bool IsManagedServiceIdentityV3(InputType schema, CSharpType type { foreach (var property in m.Properties) { - if (property is { SerializedName: "type", Type: InputEnumType choice } && choice.Values.Any(c => c.Value.ToString() == ManagedServiceIdentityTypeV3Converter.SystemAssignedUserAssignedV3Value)) + if (property is { SerializedName: "type", Type: InputEnumType choice } && choice.Values.Any(c => c.Value.ToString() == "SystemAssigned,UserAssigned")) { return true; } diff --git a/src/AutoRest.CSharp/Common/Output/Expressions/KnownValueExpressions/ModelReaderWriterExpression.cs b/src/AutoRest.CSharp/Common/Output/Expressions/KnownValueExpressions/ModelReaderWriterExpression.cs new file mode 100644 index 00000000000..1773ae920e6 --- /dev/null +++ b/src/AutoRest.CSharp/Common/Output/Expressions/KnownValueExpressions/ModelReaderWriterExpression.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.ClientModel.Primitives; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; +using AutoRest.CSharp.Common.Output.Expressions.Statements; +using AutoRest.CSharp.Common.Output.Expressions.ValueExpressions; +using AutoRest.CSharp.Generation.Types; +using Azure.Core.Expressions.DataFactory; +using static AutoRest.CSharp.Common.Output.Models.Snippets; + +namespace AutoRest.CSharp.Common.Output.Expressions.KnownValueExpressions +{ + internal class ModelReaderWriterExpression + { + private static readonly HashSet _dataFactoryTypesNotImplementingIJsonModel = new() + { + typeof(DataFactoryLinkedServiceReference), + typeof(DataFactoryKeyVaultSecret), + typeof(DataFactorySecret), + typeof(DataFactorySecretString) + }; + + public static ValueExpression Read(CSharpType type, JsonElementExpression element, ModelReaderWriterOptionsExpression? options = null, bool useManagedServiceIdentityV3 = false) + { + if (IsDataFactoryType(type)) + { + return JsonSerializerExpression.Deserialize(element, type, options); + } + + return + new IfElsePreprocessorExpression( + "NET9_0_OR_GREATER", + new InvokeStaticMethodExpression( + typeof(ModelReaderWriter), + nameof(ModelReaderWriter.Read), + [ + New.Instance(typeof(BinaryData), [new InvokeStaticMethodExpression(typeof(JsonMarshal), nameof(JsonMarshal.GetRawUtf8Value), [element]).Invoke("ToArray")]), + useManagedServiceIdentityV3 ? ModelReaderWriterOptionsExpression.UsingSystemAssignedUserAssignedV3(options) : options ?? ModelReaderWriterOptionsExpression.Wire, + ModelReaderWriterContextExpression.Default + ], + TypeArguments: [type]), + new InvokeStaticMethodExpression( + typeof(ModelReaderWriter), + nameof(ModelReaderWriter.Read), + [ + New.Instance(typeof(BinaryData), [new MemberExpression(typeof(Encoding), nameof(Encoding.UTF8)).Invoke(nameof(UTF8Encoding.GetBytes), [element.GetRawText()])]), + useManagedServiceIdentityV3 ? ModelReaderWriterOptionsExpression.UsingSystemAssignedUserAssignedV3(options) : options ?? ModelReaderWriterOptionsExpression.Wire, + ModelReaderWriterContextExpression.Default + ], + TypeArguments: [type])); + } + + // MRW can't handle DataFactoryElement<> for now, so we use JsonSerializerExpression directly + // TODO: remove this when we have AOT-safe ready for DataFactoryElement related types + private static bool IsDataFactoryType(CSharpType type) + { + return (type.IsGenericType && type.GetGenericTypeDefinition().FrameworkType.Equals(typeof(DataFactoryElement<>))) + || (type.IsFrameworkType && _dataFactoryTypesNotImplementingIJsonModel.Contains(type.FrameworkType)); + } + + public static MethodBodyStatement Write(ValueExpression value, CSharpType type, Utf8JsonWriterExpression writer, ModelReaderWriterOptionsExpression? options = null, bool useManagedServiceIdentityV3 = false) + { + if (IsDataFactoryType(type)) + { + return JsonSerializerExpression.Serialize(writer, value).ToStatement(); + } + + return value.CastTo(new CSharpType(typeof(IJsonModel<>), type)).Invoke( + nameof(IJsonModel.Write), + [ + writer, + useManagedServiceIdentityV3 ? ModelReaderWriterOptionsExpression.UsingSystemAssignedUserAssignedV3(options) : options ?? ModelReaderWriterOptionsExpression.Wire + ]).ToStatement(); + } + } +} diff --git a/src/AutoRest.CSharp/Common/Output/Expressions/KnownValueExpressions/ModelReaderWriterOptionsExpression.cs b/src/AutoRest.CSharp/Common/Output/Expressions/KnownValueExpressions/ModelReaderWriterOptionsExpression.cs index 04be02b8f48..16f21adeda3 100644 --- a/src/AutoRest.CSharp/Common/Output/Expressions/KnownValueExpressions/ModelReaderWriterOptionsExpression.cs +++ b/src/AutoRest.CSharp/Common/Output/Expressions/KnownValueExpressions/ModelReaderWriterOptionsExpression.cs @@ -4,6 +4,7 @@ using System.ClientModel.Primitives; using AutoRest.CSharp.Common.Output.Expressions.ValueExpressions; using AutoRest.CSharp.Output.Models.Types; +using static AutoRest.CSharp.Common.Output.Models.Snippets; namespace AutoRest.CSharp.Common.Output.Expressions.KnownValueExpressions { @@ -13,6 +14,16 @@ internal record ModelReaderWriterOptionsExpression(ValueExpression Untyped) : Ty public static readonly ModelReaderWriterOptionsExpression Json = new(new MemberExpression(typeof(ModelReaderWriterOptions), "Json")); + public static ValueExpression UsingSystemAssignedUserAssignedV3(ModelReaderWriterOptionsExpression? options) + { + if (options == Json) + { + return New.Instance(typeof(ModelReaderWriterOptions), Literal("J|v3")); + } + + return New.Instance(typeof(ModelReaderWriterOptions), Literal("W|v3")); + } + public ValueExpression Format => new MemberExpression(this, nameof(ModelReaderWriterOptions.Format)); } } diff --git a/src/AutoRest.CSharp/Common/Output/Expressions/Snippets.New.cs b/src/AutoRest.CSharp/Common/Output/Expressions/Snippets.New.cs index 23b66376c62..226fcbd1817 100644 --- a/src/AutoRest.CSharp/Common/Output/Expressions/Snippets.New.cs +++ b/src/AutoRest.CSharp/Common/Output/Expressions/Snippets.New.cs @@ -55,8 +55,6 @@ public static DictionaryExpression Dictionary(CSharpType keyType, CSharpType val public static DictionaryExpression Dictionary(CSharpType keyType, CSharpType valueType, params (ValueExpression Key, ValueExpression Value)[] values) => new(keyType, valueType, new NewDictionaryExpression(new CSharpType(typeof(Dictionary<,>), keyType, valueType), new DictionaryInitializerExpression(values))); - public static TypedValueExpression JsonSerializerOptions() => new FrameworkTypeExpression(typeof(JsonSerializerOptions), new NewJsonSerializerOptionsExpression()); - public static ListExpression List(CSharpType elementType) => new(elementType, Instance(new CSharpType(typeof(List<>), elementType))); public static StreamReaderExpression StreamReader(ValueExpression stream) => new(Instance(typeof(StreamReader), stream)); diff --git a/src/AutoRest.CSharp/Common/Output/Expressions/Snippets.cs b/src/AutoRest.CSharp/Common/Output/Expressions/Snippets.cs index 96a9f090b92..ce54660ee06 100644 --- a/src/AutoRest.CSharp/Common/Output/Expressions/Snippets.cs +++ b/src/AutoRest.CSharp/Common/Output/Expressions/Snippets.cs @@ -39,6 +39,7 @@ internal static partial class Snippets public static ValueExpression Double(double value) => new FormattableStringToExpression($"{value}d"); public static ValueExpression Nameof(ValueExpression expression) => new InvokeInstanceMethodExpression(null, "nameof", new[] { expression }, null, false); + public static ValueExpression TypeOf(ValueExpression expression) => new InvokeInstanceMethodExpression(null, "typeof", new[] { expression }, null, false); public static ValueExpression ThrowExpression(ValueExpression expression) => new KeywordExpression("throw", expression); public static ValueExpression NullCoalescing(ValueExpression left, ValueExpression right) => new BinaryOperatorExpression("??", left, right); diff --git a/src/AutoRest.CSharp/Common/Output/Expressions/ValueExpressions/IfElsePreprocessorExpression.cs b/src/AutoRest.CSharp/Common/Output/Expressions/ValueExpressions/IfElsePreprocessorExpression.cs new file mode 100644 index 00000000000..d13251d18e4 --- /dev/null +++ b/src/AutoRest.CSharp/Common/Output/Expressions/ValueExpressions/IfElsePreprocessorExpression.cs @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using AutoRest.CSharp.Generation.Writers; + +namespace AutoRest.CSharp.Common.Output.Expressions.ValueExpressions +{ + internal record IfElsePreprocessorExpression(string Condition, ValueExpression If, ValueExpression Else) : ValueExpression + { + public sealed override void Write(CodeWriter writer) + { + writer.Line($"#if {Condition}"); + writer.AppendRaw("\t\t\t\t"); + If.Write(writer); + writer.Line(); + writer.LineRaw("#else"); + writer.AppendRaw("\t\t\t\t"); + Else.Write(writer); + writer.Line(); + writer.LineRaw("#endif"); + } + } +} diff --git a/src/AutoRest.CSharp/Common/Output/Expressions/ValueExpressions/NewJsonSerializerOptionsExpression.cs b/src/AutoRest.CSharp/Common/Output/Expressions/ValueExpressions/NewJsonSerializerOptionsExpression.cs deleted file mode 100644 index c3499fa5a64..00000000000 --- a/src/AutoRest.CSharp/Common/Output/Expressions/ValueExpressions/NewJsonSerializerOptionsExpression.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System.Text.Json; -using AutoRest.CSharp.Generation.Writers; -using Azure.ResourceManager.Models; - -namespace AutoRest.CSharp.Common.Output.Expressions.ValueExpressions -{ - internal sealed record NewJsonSerializerOptionsExpression : ValueExpression - { - public override void Write(CodeWriter writer) - { - writer.UseNamespace("Azure.ResourceManager.Models"); - writer.Append($"new {typeof(JsonSerializerOptions)} {{ Converters = {{ new {nameof(ManagedServiceIdentityTypeV3Converter)}() }} }}"); - } - } -} diff --git a/src/AutoRest.CSharp/Common/Output/Models/Types/HelperTypeProviders/ModelSerializationExtensionsProvider.cs b/src/AutoRest.CSharp/Common/Output/Models/Types/HelperTypeProviders/ModelSerializationExtensionsProvider.cs index 82d8644e994..e3864bf0717 100644 --- a/src/AutoRest.CSharp/Common/Output/Models/Types/HelperTypeProviders/ModelSerializationExtensionsProvider.cs +++ b/src/AutoRest.CSharp/Common/Output/Models/Types/HelperTypeProviders/ModelSerializationExtensionsProvider.cs @@ -5,7 +5,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using AutoRest.CSharp.Common.Input; @@ -16,7 +15,6 @@ using AutoRest.CSharp.Generation.Types; using AutoRest.CSharp.Output.Models.Shared; using Azure.Core; -using Azure.ResourceManager.Models; using static AutoRest.CSharp.Common.Output.Models.Snippets; namespace AutoRest.CSharp.Output.Models.Types @@ -65,38 +63,6 @@ public ModelSerializationExtensionsProvider() : base(Configuration.HelperNamespa new InvokeInstanceMethodExpression( LiteralU8("\"__EMPTY__\""), "ToArray", [], null, false)) }; - - _jsonSerializerOptionsField = new FieldDeclaration( - modifiers: FieldModifiers.Internal | FieldModifiers.Static | FieldModifiers.ReadOnly, - type: typeof(JsonSerializerOptions), - name: _jsonSerializerOptionsName) - { - InitializationValue = New.Instance( - typeof(JsonSerializerOptions), - new Dictionary - { - { "Converters", new ArrayInitializerExpression([New.Instance(typeof(JsonModelConverter), [new MemberExpression(null, _wireOptionsName), ModelReaderWriterContextExpression.Default])]) } - }) - }; - - _jsonSerializerOptionsUseManagedServiceIdentityV3Field = new FieldDeclaration( - modifiers: FieldModifiers.Internal | FieldModifiers.Static | FieldModifiers.ReadOnly, - type: typeof(JsonSerializerOptions), - name: _jsonSerializerOptionsUseManagedServiceIdentityV3Name) - { - InitializationValue = New.Instance( - typeof(JsonSerializerOptions), - new Dictionary - { - { - "Converters", - new ArrayInitializerExpression([ - New.Instance(typeof(JsonModelConverter), [new MemberExpression(null, _wireOptionsName), ModelReaderWriterContextExpression.Default]), - New.Instance(typeof(ManagedServiceIdentityTypeV3Converter)) - ]) - } - }) - }; } private const string _wireOptionsName = "WireOptions"; @@ -105,12 +71,6 @@ public ModelSerializationExtensionsProvider() : base(Configuration.HelperNamespa private readonly FieldDeclaration _jsonDocumentOptionsField; private const string _sentinelBinaryDataName = "SentinelValue"; private readonly FieldDeclaration? _sentinelBinaryDataField; - private readonly FieldDeclaration _jsonSerializerOptionsField; - private const string _jsonSerializerOptionsName = "Options"; - private readonly FieldDeclaration _jsonSerializerOptionsUseManagedServiceIdentityV3Field; - private const string _jsonSerializerOptionsUseManagedServiceIdentityV3Name = "OptionsUseManagedServiceIdentityV3"; - private const string _jsonDeserializeMethodName = "JsonDeserialize"; - private const string _jsonSerializeMethodName = "JsonSerialize"; private ModelReaderWriterOptionsExpression? _wireOptions; public ModelReaderWriterOptionsExpression WireOptions => _wireOptions ??= new ModelReaderWriterOptionsExpression(new MemberExpression(Type, _wireOptionsName)); @@ -129,15 +89,6 @@ protected override IEnumerable BuildFields() { yield return _sentinelBinaryDataField; } - if (Configuration.UseModelReaderWriter) - { - yield return _jsonSerializerOptionsField; - - if (Configuration.AzureArm) - { - yield return _jsonSerializerOptionsUseManagedServiceIdentityV3Field; - } - } } protected override IEnumerable BuildMethods() @@ -187,12 +138,6 @@ protected override IEnumerable BuildMethods() yield return new(signature, body); } #endregion - - if (Configuration.UseModelReaderWriter) - { - yield return BuildJsonDeserializeMethod(); - yield return BuildJsonSerializeMethod(); - } } private const string _isSentinelValueMethodName = "IsSentinelValue"; @@ -506,12 +451,6 @@ private Method BuildWriteBase64StringValueMethod() return new Method(signature, body); } - public static ValueExpression Deserialize(JsonElementExpression element, CSharpType type, bool useManagedServiceIdentityV3 = false) - => new InvokeStaticMethodExpression(Instance.Type, _jsonDeserializeMethodName, [element, new MemberExpression(null, useManagedServiceIdentityV3 ? _jsonSerializerOptionsUseManagedServiceIdentityV3Name : _jsonSerializerOptionsName)], TypeArguments: [type]); - - public static ValueExpression Serialize(ValueExpression data, CSharpType type, bool useManagedServiceIdentityV3 = false) - => new InvokeStaticMethodExpression(Instance.Type, _jsonSerializeMethodName, [data, new MemberExpression(null, useManagedServiceIdentityV3 ? _jsonSerializerOptionsUseManagedServiceIdentityV3Name : _jsonSerializerOptionsName)], TypeArguments: [type]); - public MethodBodyStatement WriteBase64StringValue(Utf8JsonWriterExpression writer, ValueExpression value, string? format) => new InvokeStaticMethodStatement(Type, _writeBase64StringValueMethodName, new[] { writer, value, Literal(format) }, CallAsExtension: true); @@ -744,70 +683,6 @@ public MethodBodyStatement WriteObjectValue(Utf8JsonWriterExpression writer, Typ } #endregion - private Method BuildJsonDeserializeMethod() - { - var jsonParameter = new Parameter("json", null, typeof(string), null, ValidationType.None, null); - var optionsParameter = new Parameter("options", null, typeof(JsonSerializerOptions), null, ValidationType.None, null); - var justificationExpression = new KeywordExpression("Justification =", Literal("By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")); - var signature = new MethodSignature( - _jsonDeserializeMethodName, - null, - null, - MethodSignatureModifiers.Static | MethodSignatureModifiers.Public, - _t, - null, - [jsonParameter, optionsParameter], - Attributes: Configuration.Flavor == "azure" - ? [ - new CSharpAttribute(typeof(UnconditionalSuppressMessageAttribute), Literal("Trimming"), Literal("IL2026"), justificationExpression), - new CSharpAttribute(typeof(UnconditionalSuppressMessageAttribute), Literal("Trimming"), Literal("IL3050"), justificationExpression) - ] - : [], - GenericArguments: [_t]); - return new Method(signature, new MethodBodyStatement[] - { - Return(new InvokeStaticMethodExpression( - typeof(JsonSerializer), - $"{nameof(JsonSerializer.Deserialize)}", - [jsonParameter, optionsParameter], - TypeArguments: [_t] - )) - }); - } - - private Method BuildJsonSerializeMethod() - { - var writerParameter = new Parameter("writer", null, typeof(Utf8JsonWriter), null, ValidationType.None, null); - var dataParameter = new Parameter("data", null, _t, null, ValidationType.None, null); - var optionsParameter = new Parameter("options", null, typeof(JsonSerializerOptions), null, ValidationType.None, null); - var justificationExpression = new KeywordExpression("Justification =", Literal("By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")); - var signature = new MethodSignature( - _jsonSerializeMethodName, - null, - null, - MethodSignatureModifiers.Static | MethodSignatureModifiers.Public, - null, - null, - [writerParameter, dataParameter, optionsParameter], - Attributes: Configuration.Flavor == "azure" - ? [ - new CSharpAttribute(typeof(UnconditionalSuppressMessageAttribute), Literal("Trimming"), Literal("IL2026"), justificationExpression), - new CSharpAttribute(typeof(UnconditionalSuppressMessageAttribute), Literal("Trimming"), Literal("IL3050"), justificationExpression) - ] - : [], - GenericArguments: [_t]); - return new Method(signature, new MethodBodyStatement[] - { - new InvokeStaticMethodExpression( - typeof(JsonSerializer), - $"{nameof(JsonSerializer.Serialize)}", - [writerParameter, dataParameter, optionsParameter], - TypeArguments: [_t] - ).ToStatement() - }); - } - - public BoolExpression IsSentinelValue(ValueExpression value) { return new(new InvokeStaticMethodExpression(Type, _isSentinelValueMethodName, new[] { value })); diff --git a/src/AutoRest.CSharp/Mgmt/Generation/MgmtLongRunningOperationWriter.cs b/src/AutoRest.CSharp/Mgmt/Generation/MgmtLongRunningOperationWriter.cs index 4b192ab4a7d..105c1d45593 100644 --- a/src/AutoRest.CSharp/Mgmt/Generation/MgmtLongRunningOperationWriter.cs +++ b/src/AutoRest.CSharp/Mgmt/Generation/MgmtLongRunningOperationWriter.cs @@ -3,8 +3,8 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; using System.Linq; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using AutoRest.CSharp.Common.Input; @@ -113,8 +113,10 @@ public void Write() { _writer.Line($"return null;"); } - _writer.Line($"var lroDetails = {typeof(ModelReaderWriter)}.{nameof(ModelReaderWriter.Write)}(rehydrationToken, ModelReaderWriterOptions.Json, {ModelReaderWriterContextExpression.Default}).ToObjectFromJson<{typeof(Dictionary)}>();"); - _writer.Line($"return lroDetails[\"id\"];"); + _writer.Line($"var data = {typeof(ModelReaderWriter)}.{nameof(ModelReaderWriter.Write)}(rehydrationToken, ModelReaderWriterOptions.Json, {ModelReaderWriterContextExpression.Default});"); + _writer.Line($"using var document = {typeof(JsonDocument)}.{nameof(JsonDocument.Parse)}(data);"); + _writer.Line($"var lroDetails = document.RootElement;"); + _writer.Line($"return lroDetails.{nameof(JsonElement.GetProperty)}(\"id\").{nameof(JsonElement.GetString)}();"); } _writer.WriteXmlDocumentationInheritDoc(); diff --git a/src/assets/Management.Shared/ManagedServiceIdentityTypeV3Converter.cs b/src/assets/Management.Shared/ManagedServiceIdentityTypeV3Converter.cs deleted file mode 100644 index b33c186e195..00000000000 --- a/src/assets/Management.Shared/ManagedServiceIdentityTypeV3Converter.cs +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#nullable disable - -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace Azure.ResourceManager.Models -{ - /// JsonConverter for managed service identity type v3. - internal class ManagedServiceIdentityTypeV3Converter : JsonConverter - { - internal const string SystemAssignedUserAssignedV3Value = "SystemAssigned,UserAssigned"; - - /// Serialize managed service identity type to v3 format. - /// The writer. - /// The ManagedServiceIdentityType model which is v4. - /// The options for JsonSerializer. - public override void Write(Utf8JsonWriter writer, ManagedServiceIdentityType model, JsonSerializerOptions options) - { - writer.WritePropertyName("type"); - if (model == ManagedServiceIdentityType.SystemAssignedUserAssigned) - { - writer.WriteStringValue(SystemAssignedUserAssignedV3Value); - } - else - { - writer.WriteStringValue(model.ToString()); - } - } - - /// Deserialize managed service identity type from v3 format. - /// The reader. - /// The type to convert - /// The options for JsonSerializer. - public override ManagedServiceIdentityType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - using var document = JsonDocument.ParseValue(ref reader); - foreach (var property in document.RootElement.EnumerateObject()) - { - var typeValue = property.Value.GetString(); - if (typeValue.Equals(SystemAssignedUserAssignedV3Value, StringComparison.OrdinalIgnoreCase)) - { - return ManagedServiceIdentityType.SystemAssignedUserAssigned; - } - return new ManagedServiceIdentityType(typeValue); - } - return null; - } - } -} diff --git a/test/CadlRanchProjects.Tests/CadlRanchProjects.Tests.csproj b/test/CadlRanchProjects.Tests/CadlRanchProjects.Tests.csproj index 640d860725b..2a935b33f42 100644 --- a/test/CadlRanchProjects.Tests/CadlRanchProjects.Tests.csproj +++ b/test/CadlRanchProjects.Tests/CadlRanchProjects.Tests.csproj @@ -37,7 +37,6 @@ - diff --git a/test/CadlRanchProjects/authentication/api-key/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/authentication/api-key/src/Generated/Internal/ModelSerializationExtensions.cs index 1f2156ac154..877072b3547 100644 --- a/test/CadlRanchProjects/authentication/api-key/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/authentication/api-key/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, AuthenticationApiKeyContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/azure/client-generator-core/access/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/azure/client-generator-core/access/src/Generated/Internal/ModelSerializationExtensions.cs index 280def9ed57..eeef467b7a2 100644 --- a/test/CadlRanchProjects/azure/client-generator-core/access/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/azure/client-generator-core/access/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, _Specs_AzureClientGeneratorCoreAccessContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/azure/client-generator-core/flatten-property/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/azure/client-generator-core/flatten-property/src/Generated/Internal/ModelSerializationExtensions.cs index ad6cfb368a1..f07e14f7e66 100644 --- a/test/CadlRanchProjects/azure/client-generator-core/flatten-property/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/azure/client-generator-core/flatten-property/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, _Specs_AzureClientGeneratorCoreFlattenPropertyContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/azure/client-generator-core/usage/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/azure/client-generator-core/usage/src/Generated/Internal/ModelSerializationExtensions.cs index 67417465790..312e9ee715d 100644 --- a/test/CadlRanchProjects/azure/client-generator-core/usage/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/azure/client-generator-core/usage/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, _Specs_AzureClientGeneratorCoreUsageContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/azure/core/basic/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/azure/core/basic/src/Generated/Internal/ModelSerializationExtensions.cs index 1f640ed15a1..a979830426c 100644 --- a/test/CadlRanchProjects/azure/core/basic/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/azure/core/basic/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, _Specs_AzureCoreBasicContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/azure/core/lro/rpc/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/azure/core/lro/rpc/src/Generated/Internal/ModelSerializationExtensions.cs index 65e47ab751a..8137d9727e7 100644 --- a/test/CadlRanchProjects/azure/core/lro/rpc/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/azure/core/lro/rpc/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, _AzureLroRpcContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/azure/core/lro/standard/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/azure/core/lro/standard/src/Generated/Internal/ModelSerializationExtensions.cs index 8964320e777..b2992737a19 100644 --- a/test/CadlRanchProjects/azure/core/lro/standard/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/azure/core/lro/standard/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, _AzureLroStandardContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/azure/core/model/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/azure/core/model/src/Generated/Internal/ModelSerializationExtensions.cs index 8ea1744f795..5d1cd4b7ecc 100644 --- a/test/CadlRanchProjects/azure/core/model/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/azure/core/model/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, _Specs_AzureCoreModelContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/azure/core/page/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/azure/core/page/src/Generated/Internal/ModelSerializationExtensions.cs index 147c48824f9..ed255c8aba4 100644 --- a/test/CadlRanchProjects/azure/core/page/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/azure/core/page/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, _Specs_AzureCorePageContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/azure/core/scalar/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/azure/core/scalar/src/Generated/Internal/ModelSerializationExtensions.cs index 4da4ac3b0d0..6e8a60f8755 100644 --- a/test/CadlRanchProjects/azure/core/scalar/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/azure/core/scalar/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, _Specs_AzureCoreScalarContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/azure/core/traits/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/azure/core/traits/src/Generated/Internal/ModelSerializationExtensions.cs index 895687249ed..0b8bde182a9 100644 --- a/test/CadlRanchProjects/azure/core/traits/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/azure/core/traits/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, _Specs_AzureCoreTraitsContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/azure/encode/duration/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/azure/encode/duration/src/Generated/Internal/ModelSerializationExtensions.cs index af5c562179d..408205038ec 100644 --- a/test/CadlRanchProjects/azure/encode/duration/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/azure/encode/duration/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, _Specs_AzureEncodeDurationContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/azure/example/basic/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/azure/example/basic/src/Generated/Internal/ModelSerializationExtensions.cs index 9cca2491bf9..8ba04fa3a8b 100644 --- a/test/CadlRanchProjects/azure/example/basic/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/azure/example/basic/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, _Specs_AzureExampleBasicContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/azure/resource-manager/common-properties/src/Generated/ConfidentialResourceData.Serialization.cs b/test/CadlRanchProjects/azure/resource-manager/common-properties/src/Generated/ConfidentialResourceData.Serialization.cs index b13e3e18f70..a881d122ebc 100644 --- a/test/CadlRanchProjects/azure/resource-manager/common-properties/src/Generated/ConfidentialResourceData.Serialization.cs +++ b/test/CadlRanchProjects/azure/resource-manager/common-properties/src/Generated/ConfidentialResourceData.Serialization.cs @@ -8,6 +8,8 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -124,7 +126,13 @@ internal static ConfidentialResourceData DeserializeConfidentialResourceData(Jso { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::_Azure.ResourceManager.CommonProperties.ModelSerializationExtensions.WireOptions, _AzureResourceManagerCommonPropertiesContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, _AzureResourceManagerCommonPropertiesContext.Default) +#endif +; continue; } if (options.Format != "W") diff --git a/test/CadlRanchProjects/azure/resource-manager/common-properties/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/azure/resource-manager/common-properties/src/Generated/Internal/ModelSerializationExtensions.cs index 4546f1628d5..4208a1b9961 100644 --- a/test/CadlRanchProjects/azure/resource-manager/common-properties/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/azure/resource-manager/common-properties/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,12 +9,10 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; using Azure.Core; -using Azure.ResourceManager.Models; namespace _Azure.ResourceManager.CommonProperties { @@ -23,8 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, _AzureResourceManagerCommonPropertiesContext.Default) } }; - internal static readonly JsonSerializerOptions OptionsUseManagedServiceIdentityV3 = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, _AzureResourceManagerCommonPropertiesContext.Default), new Azure.ResourceManager.Models.ManagedServiceIdentityTypeV3Converter() } }; public static object GetObject(this JsonElement element) { @@ -269,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/azure/resource-manager/common-properties/src/Generated/LongRunningOperation/CommonPropertiesArmOperationOfT.cs b/test/CadlRanchProjects/azure/resource-manager/common-properties/src/Generated/LongRunningOperation/CommonPropertiesArmOperationOfT.cs index 2c64fa557d1..80235bf560d 100644 --- a/test/CadlRanchProjects/azure/resource-manager/common-properties/src/Generated/LongRunningOperation/CommonPropertiesArmOperationOfT.cs +++ b/test/CadlRanchProjects/azure/resource-manager/common-properties/src/Generated/LongRunningOperation/CommonPropertiesArmOperationOfT.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, _AzureResourceManagerCommonPropertiesContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, _AzureResourceManagerCommonPropertiesContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/CadlRanchProjects/azure/resource-manager/common-properties/src/Generated/ManagedIdentityTrackedResourceData.Serialization.cs b/test/CadlRanchProjects/azure/resource-manager/common-properties/src/Generated/ManagedIdentityTrackedResourceData.Serialization.cs index bd86d64cbbe..541199d8f18 100644 --- a/test/CadlRanchProjects/azure/resource-manager/common-properties/src/Generated/ManagedIdentityTrackedResourceData.Serialization.cs +++ b/test/CadlRanchProjects/azure/resource-manager/common-properties/src/Generated/ManagedIdentityTrackedResourceData.Serialization.cs @@ -8,6 +8,8 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -45,8 +47,7 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri if (Optional.IsDefined(Identity)) { writer.WritePropertyName("identity"u8); - var serializeOptions = new JsonSerializerOptions { Converters = { new ManagedServiceIdentityTypeV3Converter() } }; - JsonSerializer.Serialize(writer, Identity, serializeOptions); + ((IJsonModel)Identity).Write(writer, new ModelReaderWriterOptions("W|v3")); } } @@ -97,8 +98,13 @@ internal static ManagedIdentityTrackedResourceData DeserializeManagedIdentityTra { continue; } - var serializeOptions = new JsonSerializerOptions { Converters = { new ManagedServiceIdentityTypeV3Converter() } }; - identity = JsonSerializer.Deserialize(property.Value.GetRawText(), serializeOptions); + identity = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), new global::System.ClientModel.Primitives.ModelReaderWriterOptions("W|v3"), _AzureResourceManagerCommonPropertiesContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), new ModelReaderWriterOptions("W|v3"), _AzureResourceManagerCommonPropertiesContext.Default) +#endif +; continue; } if (property.NameEquals("tags"u8)) @@ -141,7 +147,13 @@ internal static ManagedIdentityTrackedResourceData DeserializeManagedIdentityTra { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::_Azure.ResourceManager.CommonProperties.ModelSerializationExtensions.WireOptions, _AzureResourceManagerCommonPropertiesContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, _AzureResourceManagerCommonPropertiesContext.Default) +#endif +; continue; } if (options.Format != "W") diff --git a/test/CadlRanchProjects/azure/resource-manager/non-resource/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/azure/resource-manager/non-resource/src/Generated/Internal/ModelSerializationExtensions.cs index 3eb2bcb4124..121b5738cb1 100644 --- a/test/CadlRanchProjects/azure/resource-manager/non-resource/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/azure/resource-manager/non-resource/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,12 +9,10 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; using Azure.Core; -using Azure.ResourceManager.Models; namespace _Azure.ResourceManager.NonResources { @@ -23,8 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, _AzureResourceManagerNonResourcesContext.Default) } }; - internal static readonly JsonSerializerOptions OptionsUseManagedServiceIdentityV3 = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, _AzureResourceManagerNonResourcesContext.Default), new Azure.ResourceManager.Models.ManagedServiceIdentityTypeV3Converter() } }; public static object GetObject(this JsonElement element) { @@ -269,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/azure/resource-manager/resources/src/Generated/ExtensionsResourceData.Serialization.cs b/test/CadlRanchProjects/azure/resource-manager/resources/src/Generated/ExtensionsResourceData.Serialization.cs index 4d8d8e757ed..947daab7db6 100644 --- a/test/CadlRanchProjects/azure/resource-manager/resources/src/Generated/ExtensionsResourceData.Serialization.cs +++ b/test/CadlRanchProjects/azure/resource-manager/resources/src/Generated/ExtensionsResourceData.Serialization.cs @@ -8,6 +8,8 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -103,7 +105,13 @@ internal static ExtensionsResourceData DeserializeExtensionsResourceData(JsonEle { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::_Azure.ResourceManager.Resources.ModelSerializationExtensions.WireOptions, _AzureResourceManagerResourcesContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, _AzureResourceManagerResourcesContext.Default) +#endif +; continue; } if (options.Format != "W") diff --git a/test/CadlRanchProjects/azure/resource-manager/resources/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/azure/resource-manager/resources/src/Generated/Internal/ModelSerializationExtensions.cs index 319b981502e..70b628b2d99 100644 --- a/test/CadlRanchProjects/azure/resource-manager/resources/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/azure/resource-manager/resources/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,12 +9,10 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; using Azure.Core; -using Azure.ResourceManager.Models; namespace _Azure.ResourceManager.Resources { @@ -23,8 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, _AzureResourceManagerResourcesContext.Default) } }; - internal static readonly JsonSerializerOptions OptionsUseManagedServiceIdentityV3 = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, _AzureResourceManagerResourcesContext.Default), new Azure.ResourceManager.Models.ManagedServiceIdentityTypeV3Converter() } }; public static object GetObject(this JsonElement element) { @@ -269,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/azure/resource-manager/resources/src/Generated/LocationResourceData.Serialization.cs b/test/CadlRanchProjects/azure/resource-manager/resources/src/Generated/LocationResourceData.Serialization.cs index 14f8d72034c..27c448d7566 100644 --- a/test/CadlRanchProjects/azure/resource-manager/resources/src/Generated/LocationResourceData.Serialization.cs +++ b/test/CadlRanchProjects/azure/resource-manager/resources/src/Generated/LocationResourceData.Serialization.cs @@ -8,6 +8,8 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -103,7 +105,13 @@ internal static LocationResourceData DeserializeLocationResourceData(JsonElement { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::_Azure.ResourceManager.Resources.ModelSerializationExtensions.WireOptions, _AzureResourceManagerResourcesContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, _AzureResourceManagerResourcesContext.Default) +#endif +; continue; } if (options.Format != "W") diff --git a/test/CadlRanchProjects/azure/resource-manager/resources/src/Generated/LongRunningOperation/ResourcesArmOperation.cs b/test/CadlRanchProjects/azure/resource-manager/resources/src/Generated/LongRunningOperation/ResourcesArmOperation.cs index 2e349584c8a..ddfb1b7971d 100644 --- a/test/CadlRanchProjects/azure/resource-manager/resources/src/Generated/LongRunningOperation/ResourcesArmOperation.cs +++ b/test/CadlRanchProjects/azure/resource-manager/resources/src/Generated/LongRunningOperation/ResourcesArmOperation.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, _AzureResourceManagerResourcesContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, _AzureResourceManagerResourcesContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/CadlRanchProjects/azure/resource-manager/resources/src/Generated/LongRunningOperation/ResourcesArmOperationOfT.cs b/test/CadlRanchProjects/azure/resource-manager/resources/src/Generated/LongRunningOperation/ResourcesArmOperationOfT.cs index 05f5bcdd8e8..051c23cf416 100644 --- a/test/CadlRanchProjects/azure/resource-manager/resources/src/Generated/LongRunningOperation/ResourcesArmOperationOfT.cs +++ b/test/CadlRanchProjects/azure/resource-manager/resources/src/Generated/LongRunningOperation/ResourcesArmOperationOfT.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, _AzureResourceManagerResourcesContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, _AzureResourceManagerResourcesContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/CadlRanchProjects/azure/resource-manager/resources/src/Generated/NestedProxyResourceData.Serialization.cs b/test/CadlRanchProjects/azure/resource-manager/resources/src/Generated/NestedProxyResourceData.Serialization.cs index 4307caf7139..92146aa7d96 100644 --- a/test/CadlRanchProjects/azure/resource-manager/resources/src/Generated/NestedProxyResourceData.Serialization.cs +++ b/test/CadlRanchProjects/azure/resource-manager/resources/src/Generated/NestedProxyResourceData.Serialization.cs @@ -8,6 +8,8 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -103,7 +105,13 @@ internal static NestedProxyResourceData DeserializeNestedProxyResourceData(JsonE { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::_Azure.ResourceManager.Resources.ModelSerializationExtensions.WireOptions, _AzureResourceManagerResourcesContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, _AzureResourceManagerResourcesContext.Default) +#endif +; continue; } if (options.Format != "W") diff --git a/test/CadlRanchProjects/azure/resource-manager/resources/src/Generated/SingletonTrackedResourceData.Serialization.cs b/test/CadlRanchProjects/azure/resource-manager/resources/src/Generated/SingletonTrackedResourceData.Serialization.cs index 62dfe50e1c4..408f175a7d2 100644 --- a/test/CadlRanchProjects/azure/resource-manager/resources/src/Generated/SingletonTrackedResourceData.Serialization.cs +++ b/test/CadlRanchProjects/azure/resource-manager/resources/src/Generated/SingletonTrackedResourceData.Serialization.cs @@ -8,6 +8,8 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -124,7 +126,13 @@ internal static SingletonTrackedResourceData DeserializeSingletonTrackedResource { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::_Azure.ResourceManager.Resources.ModelSerializationExtensions.WireOptions, _AzureResourceManagerResourcesContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, _AzureResourceManagerResourcesContext.Default) +#endif +; continue; } if (options.Format != "W") diff --git a/test/CadlRanchProjects/azure/resource-manager/resources/src/Generated/TopLevelTrackedResourceData.Serialization.cs b/test/CadlRanchProjects/azure/resource-manager/resources/src/Generated/TopLevelTrackedResourceData.Serialization.cs index bb51f775bcf..cc1608217ad 100644 --- a/test/CadlRanchProjects/azure/resource-manager/resources/src/Generated/TopLevelTrackedResourceData.Serialization.cs +++ b/test/CadlRanchProjects/azure/resource-manager/resources/src/Generated/TopLevelTrackedResourceData.Serialization.cs @@ -8,6 +8,8 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -124,7 +126,13 @@ internal static TopLevelTrackedResourceData DeserializeTopLevelTrackedResourceDa { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::_Azure.ResourceManager.Resources.ModelSerializationExtensions.WireOptions, _AzureResourceManagerResourcesContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, _AzureResourceManagerResourcesContext.Default) +#endif +; continue; } if (options.Format != "W") diff --git a/test/CadlRanchProjects/client/naming/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/client/naming/src/Generated/Internal/ModelSerializationExtensions.cs index 6dd883cb209..96ebf7b42dc 100644 --- a/test/CadlRanchProjects/client/naming/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/client/naming/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, ClientNamingContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/encode/bytes/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/encode/bytes/src/Generated/Internal/ModelSerializationExtensions.cs index 7d94169ba33..9fd108b8629 100644 --- a/test/CadlRanchProjects/encode/bytes/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/encode/bytes/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, EncodeBytesContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/encode/datetime/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/encode/datetime/src/Generated/Internal/ModelSerializationExtensions.cs index 0e22c3fcd5f..2768246aecb 100644 --- a/test/CadlRanchProjects/encode/datetime/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/encode/datetime/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, EncodeDatetimeContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/encode/duration/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/encode/duration/src/Generated/Internal/ModelSerializationExtensions.cs index bf50141e448..81c9c00c717 100644 --- a/test/CadlRanchProjects/encode/duration/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/encode/duration/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, EncodeDurationContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/encode/numeric/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/encode/numeric/src/Generated/Internal/ModelSerializationExtensions.cs index 34ff061ef7d..5952479f047 100644 --- a/test/CadlRanchProjects/encode/numeric/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/encode/numeric/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, EncodeNumericContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/parameters/basic/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/parameters/basic/src/Generated/Internal/ModelSerializationExtensions.cs index 36dc1f2aa73..c7e865e21c9 100644 --- a/test/CadlRanchProjects/parameters/basic/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/parameters/basic/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, ParametersBasicContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/parameters/body-optionality/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/parameters/body-optionality/src/Generated/Internal/ModelSerializationExtensions.cs index 18a2098473f..e9df7f4874e 100644 --- a/test/CadlRanchProjects/parameters/body-optionality/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/parameters/body-optionality/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, ParametersBodyOptionalityContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/parameters/spread/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/parameters/spread/src/Generated/Internal/ModelSerializationExtensions.cs index 59bd58cd8ae..6f593c0da18 100644 --- a/test/CadlRanchProjects/parameters/spread/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/parameters/spread/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, ParametersSpreadContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/payload/content-negotiation/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/payload/content-negotiation/src/Generated/Internal/ModelSerializationExtensions.cs index 1a19e011e22..208d6b7c452 100644 --- a/test/CadlRanchProjects/payload/content-negotiation/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/payload/content-negotiation/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, PayloadContentNegotiationContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/payload/media-type/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/payload/media-type/src/Generated/Internal/ModelSerializationExtensions.cs index dcd5ec58f48..444c4d828bd 100644 --- a/test/CadlRanchProjects/payload/media-type/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/payload/media-type/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, PayloadMediaTypeContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/payload/multipart/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/payload/multipart/src/Generated/Internal/ModelSerializationExtensions.cs index b88472de9c2..06cf6438bf7 100644 --- a/test/CadlRanchProjects/payload/multipart/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/payload/multipart/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, PayloadMultiPartContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/serialization/encoded-name/json/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/serialization/encoded-name/json/src/Generated/Internal/ModelSerializationExtensions.cs index 3624f63f458..01948817643 100644 --- a/test/CadlRanchProjects/serialization/encoded-name/json/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/serialization/encoded-name/json/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, SerializationEncodedNameJsonContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/special-words/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/special-words/src/Generated/Internal/ModelSerializationExtensions.cs index f261bb70a93..9afb4d8d230 100644 --- a/test/CadlRanchProjects/special-words/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/special-words/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, SpecialWordsContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/type/array/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/type/array/src/Generated/Internal/ModelSerializationExtensions.cs index 87a81b3ee26..98bdf429ee9 100644 --- a/test/CadlRanchProjects/type/array/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/type/array/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, _Type_ArrayContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/type/dictionary/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/type/dictionary/src/Generated/Internal/ModelSerializationExtensions.cs index 90a91e5abc4..d661692873f 100644 --- a/test/CadlRanchProjects/type/dictionary/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/type/dictionary/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, _Type_DictionaryContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/type/model/empty/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/type/model/empty/src/Generated/Internal/ModelSerializationExtensions.cs index 376f6bed1f4..a87fc6d0422 100644 --- a/test/CadlRanchProjects/type/model/empty/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/type/model/empty/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, _TypeModelEmptyContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/type/model/inheritance/enum-discriminator/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/type/model/inheritance/enum-discriminator/src/Generated/Internal/ModelSerializationExtensions.cs index 7919a5527ad..d2a56b48c7c 100644 --- a/test/CadlRanchProjects/type/model/inheritance/enum-discriminator/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/type/model/inheritance/enum-discriminator/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, _TypeModelInheritanceEnumDiscriminatorContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/type/model/inheritance/not-discriminated/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/type/model/inheritance/not-discriminated/src/Generated/Internal/ModelSerializationExtensions.cs index 10ed4a2e584..3edb83b972c 100644 --- a/test/CadlRanchProjects/type/model/inheritance/not-discriminated/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/type/model/inheritance/not-discriminated/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, _TypeModelInheritanceNotDiscriminatedContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/type/model/inheritance/recursive/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/type/model/inheritance/recursive/src/Generated/Internal/ModelSerializationExtensions.cs index cb5dd69cb36..5680026d5b8 100644 --- a/test/CadlRanchProjects/type/model/inheritance/recursive/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/type/model/inheritance/recursive/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, _TypeModelInheritanceRecursiveContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/type/model/inheritance/single-discriminator/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/type/model/inheritance/single-discriminator/src/Generated/Internal/ModelSerializationExtensions.cs index e7e04c9bcb0..0fd8cd125f2 100644 --- a/test/CadlRanchProjects/type/model/inheritance/single-discriminator/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/type/model/inheritance/single-discriminator/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, _TypeModelInheritanceSingleDiscriminatorContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/type/model/usage/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/type/model/usage/src/Generated/Internal/ModelSerializationExtensions.cs index 3f3e6ba47cd..f3dacbf42c5 100644 --- a/test/CadlRanchProjects/type/model/usage/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/type/model/usage/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, _TypeModelUsageContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/type/model/visibility/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/type/model/visibility/src/Generated/Internal/ModelSerializationExtensions.cs index 9f1e3af06ba..10b6313a79a 100644 --- a/test/CadlRanchProjects/type/model/visibility/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/type/model/visibility/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, _TypeModelVisibilityContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/type/property/additional-properties/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/type/property/additional-properties/src/Generated/Internal/ModelSerializationExtensions.cs index 64fdb0cf5d4..9df9f29fd18 100644 --- a/test/CadlRanchProjects/type/property/additional-properties/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/type/property/additional-properties/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, _TypePropertyAdditionalPropertiesContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/type/property/nullable/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/type/property/nullable/src/Generated/Internal/ModelSerializationExtensions.cs index f0404fe4030..860220d7bea 100644 --- a/test/CadlRanchProjects/type/property/nullable/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/type/property/nullable/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, _TypePropertyNullableContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/type/property/optionality/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/type/property/optionality/src/Generated/Internal/ModelSerializationExtensions.cs index f76f7bccbc8..81ec13e20c0 100644 --- a/test/CadlRanchProjects/type/property/optionality/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/type/property/optionality/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, _TypePropertyOptionalityContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/type/property/value-types/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/type/property/value-types/src/Generated/Internal/ModelSerializationExtensions.cs index 9afb0cf227c..eb97a16a0c4 100644 --- a/test/CadlRanchProjects/type/property/value-types/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/type/property/value-types/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, _TypePropertyValueTypesContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/type/scalar/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/type/scalar/src/Generated/Internal/ModelSerializationExtensions.cs index 990b2da1f74..e5637135fa0 100644 --- a/test/CadlRanchProjects/type/scalar/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/type/scalar/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, _TypeScalarContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/type/union/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/type/union/src/Generated/Internal/ModelSerializationExtensions.cs index 79d0a8c8c65..7ebb3e52157 100644 --- a/test/CadlRanchProjects/type/union/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/type/union/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, _TypeUnionContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/versioning/added/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/versioning/added/src/Generated/Internal/ModelSerializationExtensions.cs index ffedff855f1..1daa09fb253 100644 --- a/test/CadlRanchProjects/versioning/added/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/versioning/added/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, VersioningAddedContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/versioning/madeOptional/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/versioning/madeOptional/src/Generated/Internal/ModelSerializationExtensions.cs index ac9c9b20bd6..4f7df4046e1 100644 --- a/test/CadlRanchProjects/versioning/madeOptional/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/versioning/madeOptional/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, VersioningMadeOptionalContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/versioning/removed-betaversion/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/versioning/removed-betaversion/src/Generated/Internal/ModelSerializationExtensions.cs index f5a9fb94af2..0b7f5c473d6 100644 --- a/test/CadlRanchProjects/versioning/removed-betaversion/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/versioning/removed-betaversion/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, VersioningRemovedBetaVersionContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/versioning/removed-oldversion/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/versioning/removed-oldversion/src/Generated/Internal/ModelSerializationExtensions.cs index ba781d871e3..779679e5c76 100644 --- a/test/CadlRanchProjects/versioning/removed-oldversion/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/versioning/removed-oldversion/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, VersioningRemovedOldVersionContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/versioning/removed/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/versioning/removed/src/Generated/Internal/ModelSerializationExtensions.cs index 3204847a8d8..59b2fb6109c 100644 --- a/test/CadlRanchProjects/versioning/removed/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/versioning/removed/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, VersioningRemovedLatestVersionContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/versioning/renamedFrom/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/versioning/renamedFrom/src/Generated/Internal/ModelSerializationExtensions.cs index cb2d052944e..33a7c2bde65 100644 --- a/test/CadlRanchProjects/versioning/renamedFrom/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/versioning/renamedFrom/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, VersioningRenamedFromContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/versioning/returnTypeChangedFrom/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/versioning/returnTypeChangedFrom/src/Generated/Internal/ModelSerializationExtensions.cs index cf1eb064fb9..051f5da727a 100644 --- a/test/CadlRanchProjects/versioning/returnTypeChangedFrom/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/versioning/returnTypeChangedFrom/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, VersioningReturnTypeChangedFromContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjects/versioning/typeChangedFrom/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjects/versioning/typeChangedFrom/src/Generated/Internal/ModelSerializationExtensions.cs index 1e5793957c0..bce178ea15e 100644 --- a/test/CadlRanchProjects/versioning/typeChangedFrom/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjects/versioning/typeChangedFrom/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, VersioningTypeChangedFromContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjectsNonAzure/authentication/api-key/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjectsNonAzure/authentication/api-key/src/Generated/Internal/ModelSerializationExtensions.cs index a28e744eec3..23b51b19655 100644 --- a/test/CadlRanchProjectsNonAzure/authentication/api-key/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjectsNonAzure/authentication/api-key/src/Generated/Internal/ModelSerializationExtensions.cs @@ -17,7 +17,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, ScmAuthenticationApiKeyContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -259,16 +258,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjectsNonAzure/authentication/http/custom/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjectsNonAzure/authentication/http/custom/src/Generated/Internal/ModelSerializationExtensions.cs index 322b3f2f206..5fd69b5975f 100644 --- a/test/CadlRanchProjectsNonAzure/authentication/http/custom/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjectsNonAzure/authentication/http/custom/src/Generated/Internal/ModelSerializationExtensions.cs @@ -17,7 +17,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, ScmAuthenticationHttpCustomContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -259,16 +258,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjectsNonAzure/client/naming/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjectsNonAzure/client/naming/src/Generated/Internal/ModelSerializationExtensions.cs index f4bdc0a4ea2..1b2c8d5b6d7 100644 --- a/test/CadlRanchProjectsNonAzure/client/naming/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjectsNonAzure/client/naming/src/Generated/Internal/ModelSerializationExtensions.cs @@ -17,7 +17,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, ScmClientNamingContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -259,16 +258,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjectsNonAzure/parameters/body-optionality/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjectsNonAzure/parameters/body-optionality/src/Generated/Internal/ModelSerializationExtensions.cs index ce52cb0ee14..835ab35ef34 100644 --- a/test/CadlRanchProjectsNonAzure/parameters/body-optionality/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjectsNonAzure/parameters/body-optionality/src/Generated/Internal/ModelSerializationExtensions.cs @@ -17,7 +17,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, ScmParametersBodyOptionalityContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -259,16 +258,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjectsNonAzure/parameters/spread/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjectsNonAzure/parameters/spread/src/Generated/Internal/ModelSerializationExtensions.cs index f2cefb68b97..ee03718df0a 100644 --- a/test/CadlRanchProjectsNonAzure/parameters/spread/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjectsNonAzure/parameters/spread/src/Generated/Internal/ModelSerializationExtensions.cs @@ -17,7 +17,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, ScmParametersSpreadContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -259,16 +258,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjectsNonAzure/payload/content-negotiation/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjectsNonAzure/payload/content-negotiation/src/Generated/Internal/ModelSerializationExtensions.cs index 9c74561d877..ba3e28f794b 100644 --- a/test/CadlRanchProjectsNonAzure/payload/content-negotiation/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjectsNonAzure/payload/content-negotiation/src/Generated/Internal/ModelSerializationExtensions.cs @@ -17,7 +17,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, ScmPayloadContentNegotiationContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -259,16 +258,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjectsNonAzure/payload/multipart/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjectsNonAzure/payload/multipart/src/Generated/Internal/ModelSerializationExtensions.cs index 59420b57a5b..be3cd3e2ca7 100644 --- a/test/CadlRanchProjectsNonAzure/payload/multipart/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjectsNonAzure/payload/multipart/src/Generated/Internal/ModelSerializationExtensions.cs @@ -17,7 +17,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, ScmPayloadMultipartContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -259,16 +258,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjectsNonAzure/serialization/encoded-name/json/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjectsNonAzure/serialization/encoded-name/json/src/Generated/Internal/ModelSerializationExtensions.cs index acd0b01feaa..fe3985eff51 100644 --- a/test/CadlRanchProjectsNonAzure/serialization/encoded-name/json/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjectsNonAzure/serialization/encoded-name/json/src/Generated/Internal/ModelSerializationExtensions.cs @@ -17,7 +17,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, ScmSerializationEncodedNameJsonContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -259,16 +258,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjectsNonAzure/server/endpoint/not-defined/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjectsNonAzure/server/endpoint/not-defined/src/Generated/Internal/ModelSerializationExtensions.cs index 75be9f416dc..8d58a750b23 100644 --- a/test/CadlRanchProjectsNonAzure/server/endpoint/not-defined/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjectsNonAzure/server/endpoint/not-defined/src/Generated/Internal/ModelSerializationExtensions.cs @@ -17,7 +17,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, ScmServerEndpointNotDefinedContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -259,16 +258,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjectsNonAzure/special-words/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjectsNonAzure/special-words/src/Generated/Internal/ModelSerializationExtensions.cs index d9cf4b8d23c..bc1a4634618 100644 --- a/test/CadlRanchProjectsNonAzure/special-words/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjectsNonAzure/special-words/src/Generated/Internal/ModelSerializationExtensions.cs @@ -17,7 +17,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, ScmSpecialWordsContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -259,16 +258,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjectsNonAzure/type/array/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjectsNonAzure/type/array/src/Generated/Internal/ModelSerializationExtensions.cs index 695baf190be..ea018742c02 100644 --- a/test/CadlRanchProjectsNonAzure/type/array/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjectsNonAzure/type/array/src/Generated/Internal/ModelSerializationExtensions.cs @@ -17,7 +17,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, Scm_Type_ArrayContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -259,16 +258,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjectsNonAzure/type/dictionary/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjectsNonAzure/type/dictionary/src/Generated/Internal/ModelSerializationExtensions.cs index bb0ca39d836..5efac71e35a 100644 --- a/test/CadlRanchProjectsNonAzure/type/dictionary/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjectsNonAzure/type/dictionary/src/Generated/Internal/ModelSerializationExtensions.cs @@ -17,7 +17,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, Scm_Type_DictionaryContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -259,16 +258,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjectsNonAzure/type/enum/extensible/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjectsNonAzure/type/enum/extensible/src/Generated/Internal/ModelSerializationExtensions.cs index 4379bd533a0..6070edd4f0a 100644 --- a/test/CadlRanchProjectsNonAzure/type/enum/extensible/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjectsNonAzure/type/enum/extensible/src/Generated/Internal/ModelSerializationExtensions.cs @@ -17,7 +17,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, Scm_Type_EnumExtensibleContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -259,16 +258,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjectsNonAzure/type/enum/fixed/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjectsNonAzure/type/enum/fixed/src/Generated/Internal/ModelSerializationExtensions.cs index 1ab950d9377..e44c22f4d77 100644 --- a/test/CadlRanchProjectsNonAzure/type/enum/fixed/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjectsNonAzure/type/enum/fixed/src/Generated/Internal/ModelSerializationExtensions.cs @@ -17,7 +17,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, Scm_Type_EnumFixedContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -259,16 +258,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjectsNonAzure/type/model/empty/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjectsNonAzure/type/model/empty/src/Generated/Internal/ModelSerializationExtensions.cs index 6afb0de491e..2f793942393 100644 --- a/test/CadlRanchProjectsNonAzure/type/model/empty/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjectsNonAzure/type/model/empty/src/Generated/Internal/ModelSerializationExtensions.cs @@ -17,7 +17,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, Scm_TypeModelEmptyContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -259,16 +258,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjectsNonAzure/type/model/inheritance/enum-discriminator/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjectsNonAzure/type/model/inheritance/enum-discriminator/src/Generated/Internal/ModelSerializationExtensions.cs index b784d9851b6..38187bf2ee1 100644 --- a/test/CadlRanchProjectsNonAzure/type/model/inheritance/enum-discriminator/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjectsNonAzure/type/model/inheritance/enum-discriminator/src/Generated/Internal/ModelSerializationExtensions.cs @@ -17,7 +17,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, Scm_TypeModelInheritanceEnumDiscriminatorContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -259,16 +258,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjectsNonAzure/type/model/inheritance/not-discriminated/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjectsNonAzure/type/model/inheritance/not-discriminated/src/Generated/Internal/ModelSerializationExtensions.cs index bb385cc340b..c974321bf83 100644 --- a/test/CadlRanchProjectsNonAzure/type/model/inheritance/not-discriminated/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjectsNonAzure/type/model/inheritance/not-discriminated/src/Generated/Internal/ModelSerializationExtensions.cs @@ -17,7 +17,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, Scm_TypeModelInheritanceNotDiscriminatedContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -259,16 +258,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjectsNonAzure/type/model/inheritance/recursive/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjectsNonAzure/type/model/inheritance/recursive/src/Generated/Internal/ModelSerializationExtensions.cs index 9a24722cd64..81151aac85f 100644 --- a/test/CadlRanchProjectsNonAzure/type/model/inheritance/recursive/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjectsNonAzure/type/model/inheritance/recursive/src/Generated/Internal/ModelSerializationExtensions.cs @@ -17,7 +17,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, Scm_TypeModelInheritanceRecursiveContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -259,16 +258,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjectsNonAzure/type/model/inheritance/single-discriminator/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjectsNonAzure/type/model/inheritance/single-discriminator/src/Generated/Internal/ModelSerializationExtensions.cs index 2c57c7fa857..bd8519a3f63 100644 --- a/test/CadlRanchProjectsNonAzure/type/model/inheritance/single-discriminator/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjectsNonAzure/type/model/inheritance/single-discriminator/src/Generated/Internal/ModelSerializationExtensions.cs @@ -17,7 +17,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, Scm_TypeModelInheritanceSingleDiscriminatorContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -259,16 +258,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjectsNonAzure/type/model/usage/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjectsNonAzure/type/model/usage/src/Generated/Internal/ModelSerializationExtensions.cs index 60e5abb1dbf..9870d8b53d5 100644 --- a/test/CadlRanchProjectsNonAzure/type/model/usage/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjectsNonAzure/type/model/usage/src/Generated/Internal/ModelSerializationExtensions.cs @@ -17,7 +17,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, Scm_TypeModelUsageContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -259,16 +258,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjectsNonAzure/type/property/additional-properties/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjectsNonAzure/type/property/additional-properties/src/Generated/Internal/ModelSerializationExtensions.cs index 0fafceb1427..768d8a24d8f 100644 --- a/test/CadlRanchProjectsNonAzure/type/property/additional-properties/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjectsNonAzure/type/property/additional-properties/src/Generated/Internal/ModelSerializationExtensions.cs @@ -17,7 +17,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, Scm_TypePropertyAdditionalPropertiesContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -259,16 +258,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjectsNonAzure/type/property/nullable/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjectsNonAzure/type/property/nullable/src/Generated/Internal/ModelSerializationExtensions.cs index 6dec91b2574..4858ab74565 100644 --- a/test/CadlRanchProjectsNonAzure/type/property/nullable/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjectsNonAzure/type/property/nullable/src/Generated/Internal/ModelSerializationExtensions.cs @@ -17,7 +17,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, Scm_TypePropertyNullableContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -259,16 +258,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjectsNonAzure/type/property/optionality/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjectsNonAzure/type/property/optionality/src/Generated/Internal/ModelSerializationExtensions.cs index 78bb34feeed..ec8e6ee4d9d 100644 --- a/test/CadlRanchProjectsNonAzure/type/property/optionality/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjectsNonAzure/type/property/optionality/src/Generated/Internal/ModelSerializationExtensions.cs @@ -17,7 +17,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, Scm_TypePropertyOptionalityContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -259,16 +258,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjectsNonAzure/type/property/value-types/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjectsNonAzure/type/property/value-types/src/Generated/Internal/ModelSerializationExtensions.cs index 250a5468a7a..85fc82c5453 100644 --- a/test/CadlRanchProjectsNonAzure/type/property/value-types/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjectsNonAzure/type/property/value-types/src/Generated/Internal/ModelSerializationExtensions.cs @@ -17,7 +17,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, Scm_TypePropertyValueTypesContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -259,16 +258,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjectsNonAzure/type/scalar/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjectsNonAzure/type/scalar/src/Generated/Internal/ModelSerializationExtensions.cs index 0f970355ea7..4ec7e8aed1b 100644 --- a/test/CadlRanchProjectsNonAzure/type/scalar/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjectsNonAzure/type/scalar/src/Generated/Internal/ModelSerializationExtensions.cs @@ -17,7 +17,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, Scm_TypeScalarContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -259,16 +258,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/CadlRanchProjectsNonAzure/type/union/src/Generated/Internal/ModelSerializationExtensions.cs b/test/CadlRanchProjectsNonAzure/type/union/src/Generated/Internal/ModelSerializationExtensions.cs index d21aee277e9..aefea647572 100644 --- a/test/CadlRanchProjectsNonAzure/type/union/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/CadlRanchProjectsNonAzure/type/union/src/Generated/Internal/ModelSerializationExtensions.cs @@ -17,7 +17,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, Scm_TypeUnionContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -259,16 +258,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestProjects/AdditionalPropertiesEx/Generated/Internal/ModelSerializationExtensions.cs b/test/TestProjects/AdditionalPropertiesEx/Generated/Internal/ModelSerializationExtensions.cs index b9779e4a4a5..d9a59c9c434 100644 --- a/test/TestProjects/AdditionalPropertiesEx/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestProjects/AdditionalPropertiesEx/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, AdditionalPropertiesExContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestProjects/Authoring-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs b/test/TestProjects/Authoring-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs index 5a2ee5f751c..5e30c3cbd50 100644 --- a/test/TestProjects/Authoring-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestProjects/Authoring-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, AuthoringTypeSpecContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestProjects/Authoring-TypeSpec/src/Generated/Models/DeploymentJob.Serialization.cs b/test/TestProjects/Authoring-TypeSpec/src/Generated/Models/DeploymentJob.Serialization.cs index 41e996d2fb4..58c0707b0a3 100644 --- a/test/TestProjects/Authoring-TypeSpec/src/Generated/Models/DeploymentJob.Serialization.cs +++ b/test/TestProjects/Authoring-TypeSpec/src/Generated/Models/DeploymentJob.Serialization.cs @@ -8,6 +8,8 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure; using Azure.Core; @@ -62,7 +64,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } writer.WriteEndArray(); writer.WritePropertyName("errors"u8); - JsonSerializer.Serialize(writer, Errors); + ((IJsonModel)Errors).Write(writer, options); if (options.Format != "W") { writer.WritePropertyName("id"u8); @@ -154,7 +156,13 @@ internal static DeploymentJob DeserializeDeploymentJob(JsonElement element, Mode } if (property.NameEquals("errors"u8)) { - errors = JsonSerializer.Deserialize(property.Value.GetRawText()); + errors = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), options, AuthoringTypeSpecContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, AuthoringTypeSpecContext.Default) +#endif +; continue; } if (property.NameEquals("id"u8)) diff --git a/test/TestProjects/Authoring-TypeSpec/src/Generated/Models/SwapDeploymentsJob.Serialization.cs b/test/TestProjects/Authoring-TypeSpec/src/Generated/Models/SwapDeploymentsJob.Serialization.cs index 584abc9b810..7e0cc4c85e6 100644 --- a/test/TestProjects/Authoring-TypeSpec/src/Generated/Models/SwapDeploymentsJob.Serialization.cs +++ b/test/TestProjects/Authoring-TypeSpec/src/Generated/Models/SwapDeploymentsJob.Serialization.cs @@ -8,6 +8,8 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure; using Azure.Core; @@ -62,7 +64,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit } writer.WriteEndArray(); writer.WritePropertyName("errors"u8); - JsonSerializer.Serialize(writer, Errors); + ((IJsonModel)Errors).Write(writer, options); if (options.Format != "W") { writer.WritePropertyName("id"u8); @@ -154,7 +156,13 @@ internal static SwapDeploymentsJob DeserializeSwapDeploymentsJob(JsonElement ele } if (property.NameEquals("errors"u8)) { - errors = JsonSerializer.Deserialize(property.Value.GetRawText()); + errors = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), options, AuthoringTypeSpecContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, AuthoringTypeSpecContext.Default) +#endif +; continue; } if (property.NameEquals("id"u8)) diff --git a/test/TestProjects/ConvenienceUpdate-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs b/test/TestProjects/ConvenienceUpdate-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs index 4eca2e65a14..63fb2ac3aac 100644 --- a/test/TestProjects/ConvenienceUpdate-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestProjects/ConvenienceUpdate-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, ConvenienceInCadlContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestProjects/Customizations-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs b/test/TestProjects/Customizations-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs index 68af7ca7261..47c55e77df8 100644 --- a/test/TestProjects/Customizations-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestProjects/Customizations-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, CustomizationsInTspContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestProjects/FirstTest-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs b/test/TestProjects/FirstTest-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs index 9127315c90c..77831c1305a 100644 --- a/test/TestProjects/FirstTest-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestProjects/FirstTest-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, FirstTestTypeSpecContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestProjects/MediaTypes-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs b/test/TestProjects/MediaTypes-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs index 095fe573723..1e949198c1a 100644 --- a/test/TestProjects/MediaTypes-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestProjects/MediaTypes-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, MultipleMediaTypesContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestProjects/MgmtAcronymMapping/src/Generated/ImageData.Serialization.cs b/test/TestProjects/MgmtAcronymMapping/src/Generated/ImageData.Serialization.cs index c72c92b2185..9e6df2ebce0 100644 --- a/test/TestProjects/MgmtAcronymMapping/src/Generated/ImageData.Serialization.cs +++ b/test/TestProjects/MgmtAcronymMapping/src/Generated/ImageData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -37,7 +41,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(SourceVirtualMachine)) { writer.WritePropertyName("sourceVirtualMachine"u8); - JsonSerializer.Serialize(writer, SourceVirtualMachine); + ((IJsonModel)SourceVirtualMachine).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsDefined(StorageProfile)) { @@ -111,7 +115,13 @@ internal static ImageData DeserializeImageData(JsonElement element) { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtAcronymMapping.ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) @@ -129,7 +139,13 @@ internal static ImageData DeserializeImageData(JsonElement element) { continue; } - sourceVirtualMachine = JsonSerializer.Deserialize(property0.Value.GetRawText()); + sourceVirtualMachine = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property0.Value).ToArray()), global::MgmtAcronymMapping.ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#endif +; continue; } if (property0.NameEquals("storageProfile"u8)) diff --git a/test/TestProjects/MgmtAcronymMapping/src/Generated/LongRunningOperation/MgmtAcronymMappingArmOperation.cs b/test/TestProjects/MgmtAcronymMapping/src/Generated/LongRunningOperation/MgmtAcronymMappingArmOperation.cs index f5d97e32350..253f63eca03 100644 --- a/test/TestProjects/MgmtAcronymMapping/src/Generated/LongRunningOperation/MgmtAcronymMappingArmOperation.cs +++ b/test/TestProjects/MgmtAcronymMapping/src/Generated/LongRunningOperation/MgmtAcronymMappingArmOperation.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtAcronymMappingContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtAcronymMappingContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtAcronymMapping/src/Generated/LongRunningOperation/MgmtAcronymMappingArmOperationOfT.cs b/test/TestProjects/MgmtAcronymMapping/src/Generated/LongRunningOperation/MgmtAcronymMappingArmOperationOfT.cs index 5502b4ae9a5..155ced5fa5e 100644 --- a/test/TestProjects/MgmtAcronymMapping/src/Generated/LongRunningOperation/MgmtAcronymMappingArmOperationOfT.cs +++ b/test/TestProjects/MgmtAcronymMapping/src/Generated/LongRunningOperation/MgmtAcronymMappingArmOperationOfT.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtAcronymMappingContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtAcronymMappingContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/ImageDataDisk.Serialization.cs b/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/ImageDataDisk.Serialization.cs index 225171be2d3..706a5055c41 100644 --- a/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/ImageDataDisk.Serialization.cs +++ b/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/ImageDataDisk.Serialization.cs @@ -6,6 +6,9 @@ #nullable disable using System; +using System.ClientModel.Primitives; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Resources.Models; @@ -22,12 +25,12 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(Snapshot)) { writer.WritePropertyName("snapshot"u8); - JsonSerializer.Serialize(writer, Snapshot); + ((IJsonModel)Snapshot).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsDefined(ManagedDisk)) { writer.WritePropertyName("managedDisk"u8); - JsonSerializer.Serialize(writer, ManagedDisk); + ((IJsonModel)ManagedDisk).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsDefined(BlobUri)) { @@ -52,7 +55,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(DiskEncryptionSet)) { writer.WritePropertyName("diskEncryptionSet"u8); - JsonSerializer.Serialize(writer, DiskEncryptionSet); + ((IJsonModel)DiskEncryptionSet).Write(writer, ModelSerializationExtensions.WireOptions); } writer.WriteEndObject(); } @@ -84,7 +87,13 @@ internal static ImageDataDisk DeserializeImageDataDisk(JsonElement element) { continue; } - snapshot = JsonSerializer.Deserialize(property.Value.GetRawText()); + snapshot = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtAcronymMapping.ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#endif +; continue; } if (property.NameEquals("managedDisk"u8)) @@ -93,7 +102,13 @@ internal static ImageDataDisk DeserializeImageDataDisk(JsonElement element) { continue; } - managedDisk = JsonSerializer.Deserialize(property.Value.GetRawText()); + managedDisk = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtAcronymMapping.ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#endif +; continue; } if (property.NameEquals("blobUri"u8)) @@ -138,7 +153,13 @@ internal static ImageDataDisk DeserializeImageDataDisk(JsonElement element) { continue; } - diskEncryptionSet = JsonSerializer.Deserialize(property.Value.GetRawText()); + diskEncryptionSet = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtAcronymMapping.ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/ImageDisk.Serialization.cs b/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/ImageDisk.Serialization.cs index a915c9fef0a..1aba7954cf5 100644 --- a/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/ImageDisk.Serialization.cs +++ b/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/ImageDisk.Serialization.cs @@ -6,6 +6,9 @@ #nullable disable using System; +using System.ClientModel.Primitives; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Resources.Models; @@ -20,12 +23,12 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(Snapshot)) { writer.WritePropertyName("snapshot"u8); - JsonSerializer.Serialize(writer, Snapshot); + ((IJsonModel)Snapshot).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsDefined(ManagedDisk)) { writer.WritePropertyName("managedDisk"u8); - JsonSerializer.Serialize(writer, ManagedDisk); + ((IJsonModel)ManagedDisk).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsDefined(BlobUri)) { @@ -50,7 +53,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(DiskEncryptionSet)) { writer.WritePropertyName("diskEncryptionSet"u8); - JsonSerializer.Serialize(writer, DiskEncryptionSet); + ((IJsonModel)DiskEncryptionSet).Write(writer, ModelSerializationExtensions.WireOptions); } writer.WriteEndObject(); } @@ -76,7 +79,13 @@ internal static ImageDisk DeserializeImageDisk(JsonElement element) { continue; } - snapshot = JsonSerializer.Deserialize(property.Value.GetRawText()); + snapshot = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtAcronymMapping.ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#endif +; continue; } if (property.NameEquals("managedDisk"u8)) @@ -85,7 +94,13 @@ internal static ImageDisk DeserializeImageDisk(JsonElement element) { continue; } - managedDisk = JsonSerializer.Deserialize(property.Value.GetRawText()); + managedDisk = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtAcronymMapping.ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#endif +; continue; } if (property.NameEquals("blobUri"u8)) @@ -130,7 +145,13 @@ internal static ImageDisk DeserializeImageDisk(JsonElement element) { continue; } - diskEncryptionSet = JsonSerializer.Deserialize(property.Value.GetRawText()); + diskEncryptionSet = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtAcronymMapping.ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/ImageOSDisk.Serialization.cs b/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/ImageOSDisk.Serialization.cs index 202133db9fe..31ac736ef96 100644 --- a/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/ImageOSDisk.Serialization.cs +++ b/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/ImageOSDisk.Serialization.cs @@ -6,6 +6,9 @@ #nullable disable using System; +using System.ClientModel.Primitives; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Resources.Models; @@ -24,12 +27,12 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(Snapshot)) { writer.WritePropertyName("snapshot"u8); - JsonSerializer.Serialize(writer, Snapshot); + ((IJsonModel)Snapshot).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsDefined(ManagedDisk)) { writer.WritePropertyName("managedDisk"u8); - JsonSerializer.Serialize(writer, ManagedDisk); + ((IJsonModel)ManagedDisk).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsDefined(BlobUri)) { @@ -54,7 +57,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(DiskEncryptionSet)) { writer.WritePropertyName("diskEncryptionSet"u8); - JsonSerializer.Serialize(writer, DiskEncryptionSet); + ((IJsonModel)DiskEncryptionSet).Write(writer, ModelSerializationExtensions.WireOptions); } writer.WriteEndObject(); } @@ -92,7 +95,13 @@ internal static ImageOSDisk DeserializeImageOSDisk(JsonElement element) { continue; } - snapshot = JsonSerializer.Deserialize(property.Value.GetRawText()); + snapshot = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtAcronymMapping.ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#endif +; continue; } if (property.NameEquals("managedDisk"u8)) @@ -101,7 +110,13 @@ internal static ImageOSDisk DeserializeImageOSDisk(JsonElement element) { continue; } - managedDisk = JsonSerializer.Deserialize(property.Value.GetRawText()); + managedDisk = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtAcronymMapping.ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#endif +; continue; } if (property.NameEquals("blobUri"u8)) @@ -146,7 +161,13 @@ internal static ImageOSDisk DeserializeImageOSDisk(JsonElement element) { continue; } - diskEncryptionSet = JsonSerializer.Deserialize(property.Value.GetRawText()); + diskEncryptionSet = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtAcronymMapping.ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/ImagePatch.Serialization.cs b/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/ImagePatch.Serialization.cs index 2c7242d665f..1c648458b70 100644 --- a/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/ImagePatch.Serialization.cs +++ b/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/ImagePatch.Serialization.cs @@ -5,8 +5,10 @@ #nullable disable +using System.ClientModel.Primitives; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.Resources.Models; namespace MgmtAcronymMapping.Models { @@ -31,7 +33,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(SourceVirtualMachine)) { writer.WritePropertyName("sourceVirtualMachine"u8); - JsonSerializer.Serialize(writer, SourceVirtualMachine); + ((IJsonModel)SourceVirtualMachine).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsDefined(StorageProfile)) { diff --git a/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/KeyVaultKeyReference.Serialization.cs b/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/KeyVaultKeyReference.Serialization.cs index 01d1d9a8416..3ba83999968 100644 --- a/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/KeyVaultKeyReference.Serialization.cs +++ b/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/KeyVaultKeyReference.Serialization.cs @@ -6,6 +6,9 @@ #nullable disable using System; +using System.ClientModel.Primitives; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Resources.Models; @@ -20,7 +23,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("keyUrl"u8); writer.WriteStringValue(KeyUri.AbsoluteUri); writer.WritePropertyName("sourceVault"u8); - JsonSerializer.Serialize(writer, SourceVault); + ((IJsonModel)SourceVault).Write(writer, ModelSerializationExtensions.WireOptions); writer.WriteEndObject(); } @@ -41,7 +44,13 @@ internal static KeyVaultKeyReference DeserializeKeyVaultKeyReference(JsonElement } if (property.NameEquals("sourceVault"u8)) { - sourceVault = JsonSerializer.Deserialize(property.Value.GetRawText()); + sourceVault = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtAcronymMapping.ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/KeyVaultSecretReference.Serialization.cs b/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/KeyVaultSecretReference.Serialization.cs index 14ef316039a..281a24ea13d 100644 --- a/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/KeyVaultSecretReference.Serialization.cs +++ b/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/KeyVaultSecretReference.Serialization.cs @@ -6,6 +6,9 @@ #nullable disable using System; +using System.ClientModel.Primitives; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Resources.Models; @@ -20,7 +23,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WritePropertyName("secretUrl"u8); writer.WriteStringValue(SecretUri.AbsoluteUri); writer.WritePropertyName("sourceVault"u8); - JsonSerializer.Serialize(writer, SourceVault); + ((IJsonModel)SourceVault).Write(writer, ModelSerializationExtensions.WireOptions); writer.WriteEndObject(); } @@ -41,7 +44,13 @@ internal static KeyVaultSecretReference DeserializeKeyVaultSecretReference(JsonE } if (property.NameEquals("sourceVault"u8)) { - sourceVault = JsonSerializer.Deserialize(property.Value.GetRawText()); + sourceVault = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtAcronymMapping.ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/ManagedDiskParameters.Serialization.cs b/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/ManagedDiskParameters.Serialization.cs index 03b9115e4d7..096fe553cb6 100644 --- a/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/ManagedDiskParameters.Serialization.cs +++ b/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/ManagedDiskParameters.Serialization.cs @@ -5,6 +5,10 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Resources.Models; @@ -24,7 +28,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(DiskEncryptionSet)) { writer.WritePropertyName("diskEncryptionSet"u8); - JsonSerializer.Serialize(writer, DiskEncryptionSet); + ((IJsonModel)DiskEncryptionSet).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsDefined(Id)) { @@ -60,7 +64,13 @@ internal static ManagedDiskParameters DeserializeManagedDiskParameters(JsonEleme { continue; } - diskEncryptionSet = JsonSerializer.Deserialize(property.Value.GetRawText()); + diskEncryptionSet = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtAcronymMapping.ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#endif +; continue; } if (property.NameEquals("id"u8)) diff --git a/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/VaultSecretGroup.Serialization.cs b/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/VaultSecretGroup.Serialization.cs index 3c241f2f75f..1f529a6e557 100644 --- a/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/VaultSecretGroup.Serialization.cs +++ b/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/VaultSecretGroup.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Resources.Models; @@ -20,7 +24,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(SourceVault)) { writer.WritePropertyName("sourceVault"u8); - JsonSerializer.Serialize(writer, SourceVault); + ((IJsonModel)SourceVault).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsCollectionDefined(VaultCertificates)) { @@ -51,7 +55,13 @@ internal static VaultSecretGroup DeserializeVaultSecretGroup(JsonElement element { continue; } - sourceVault = JsonSerializer.Deserialize(property.Value.GetRawText()); + sourceVault = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtAcronymMapping.ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#endif +; continue; } if (property.NameEquals("vaultCertificates"u8)) diff --git a/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/VirtualMachinePatch.Serialization.cs b/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/VirtualMachinePatch.Serialization.cs index 14a3159388c..d6275f521da 100644 --- a/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/VirtualMachinePatch.Serialization.cs +++ b/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/VirtualMachinePatch.Serialization.cs @@ -5,8 +5,11 @@ #nullable disable +using System.ClientModel.Primitives; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Resources.Models; namespace MgmtAcronymMapping.Models { @@ -23,7 +26,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(Identity)) { writer.WritePropertyName("identity"u8); - JsonSerializer.Serialize(writer, Identity); + ((IJsonModel)Identity).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsCollectionDefined(Zones)) { @@ -86,17 +89,17 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(AvailabilitySet)) { writer.WritePropertyName("availabilitySet"u8); - JsonSerializer.Serialize(writer, AvailabilitySet); + ((IJsonModel)AvailabilitySet).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsDefined(VirtualMachineScaleSet)) { writer.WritePropertyName("virtualMachineScaleSet"u8); - JsonSerializer.Serialize(writer, VirtualMachineScaleSet); + ((IJsonModel)VirtualMachineScaleSet).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsDefined(ProximityPlacementGroup)) { writer.WritePropertyName("proximityPlacementGroup"u8); - JsonSerializer.Serialize(writer, ProximityPlacementGroup); + ((IJsonModel)ProximityPlacementGroup).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsDefined(Priority)) { @@ -116,12 +119,12 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(Host)) { writer.WritePropertyName("host"u8); - JsonSerializer.Serialize(writer, Host); + ((IJsonModel)Host).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsDefined(HostGroup)) { writer.WritePropertyName("hostGroup"u8); - JsonSerializer.Serialize(writer, HostGroup); + ((IJsonModel)HostGroup).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsDefined(LicenseType)) { diff --git a/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/VirtualMachineScaleSetExtensionPatch.Serialization.cs b/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/VirtualMachineScaleSetExtensionPatch.Serialization.cs index 9aa99119798..a774491061b 100644 --- a/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/VirtualMachineScaleSetExtensionPatch.Serialization.cs +++ b/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/VirtualMachineScaleSetExtensionPatch.Serialization.cs @@ -6,7 +6,10 @@ #nullable disable using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -131,7 +134,13 @@ internal static VirtualMachineScaleSetExtensionPatch DeserializeVirtualMachineSc { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtAcronymMapping.ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) diff --git a/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/VirtualMachineScaleSetIPConfiguration.Serialization.cs b/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/VirtualMachineScaleSetIPConfiguration.Serialization.cs index d7a29ed71d8..d6421e68b8b 100644 --- a/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/VirtualMachineScaleSetIPConfiguration.Serialization.cs +++ b/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/VirtualMachineScaleSetIPConfiguration.Serialization.cs @@ -5,8 +5,12 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Net; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Resources.Models; @@ -30,7 +34,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(Subnet)) { writer.WritePropertyName("subnet"u8); - JsonSerializer.Serialize(writer, Subnet); + ((IJsonModel)Subnet).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsDefined(Primary)) { @@ -68,7 +72,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStartArray(); foreach (var item in ApplicationGatewayBackendAddressPools) { - JsonSerializer.Serialize(writer, item); + ((IJsonModel)item).Write(writer, ModelSerializationExtensions.WireOptions); } writer.WriteEndArray(); } @@ -78,7 +82,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStartArray(); foreach (var item in ApplicationSecurityGroups) { - JsonSerializer.Serialize(writer, item); + ((IJsonModel)item).Write(writer, ModelSerializationExtensions.WireOptions); } writer.WriteEndArray(); } @@ -88,7 +92,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStartArray(); foreach (var item in LoadBalancerBackendAddressPools) { - JsonSerializer.Serialize(writer, item); + ((IJsonModel)item).Write(writer, ModelSerializationExtensions.WireOptions); } writer.WriteEndArray(); } @@ -98,7 +102,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStartArray(); foreach (var item in LoadBalancerInboundNatPools) { - JsonSerializer.Serialize(writer, item); + ((IJsonModel)item).Write(writer, ModelSerializationExtensions.WireOptions); } writer.WriteEndArray(); } @@ -150,7 +154,13 @@ internal static VirtualMachineScaleSetIPConfiguration DeserializeVirtualMachineS { continue; } - subnet = JsonSerializer.Deserialize(property0.Value.GetRawText()); + subnet = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property0.Value).ToArray()), global::MgmtAcronymMapping.ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#endif +; continue; } if (property0.NameEquals("primary"u8)) @@ -210,7 +220,13 @@ internal static VirtualMachineScaleSetIPConfiguration DeserializeVirtualMachineS List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(JsonSerializer.Deserialize(item.GetRawText())); + array.Add( +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(item).ToArray()), global::MgmtAcronymMapping.ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(item.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#endif +); } applicationGatewayBackendAddressPools = array; continue; @@ -224,7 +240,13 @@ internal static VirtualMachineScaleSetIPConfiguration DeserializeVirtualMachineS List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(JsonSerializer.Deserialize(item.GetRawText())); + array.Add( +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(item).ToArray()), global::MgmtAcronymMapping.ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(item.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#endif +); } applicationSecurityGroups = array; continue; @@ -238,7 +260,13 @@ internal static VirtualMachineScaleSetIPConfiguration DeserializeVirtualMachineS List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(JsonSerializer.Deserialize(item.GetRawText())); + array.Add( +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(item).ToArray()), global::MgmtAcronymMapping.ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(item.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#endif +); } loadBalancerBackendAddressPools = array; continue; @@ -252,7 +280,13 @@ internal static VirtualMachineScaleSetIPConfiguration DeserializeVirtualMachineS List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(JsonSerializer.Deserialize(item.GetRawText())); + array.Add( +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(item).ToArray()), global::MgmtAcronymMapping.ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(item.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#endif +); } loadBalancerInboundNatPools = array; continue; diff --git a/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/VirtualMachineScaleSetManagedDiskParameters.Serialization.cs b/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/VirtualMachineScaleSetManagedDiskParameters.Serialization.cs index f2b64bea3dc..87e2483f585 100644 --- a/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/VirtualMachineScaleSetManagedDiskParameters.Serialization.cs +++ b/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/VirtualMachineScaleSetManagedDiskParameters.Serialization.cs @@ -5,6 +5,10 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Resources.Models; @@ -24,7 +28,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(DiskEncryptionSet)) { writer.WritePropertyName("diskEncryptionSet"u8); - JsonSerializer.Serialize(writer, DiskEncryptionSet); + ((IJsonModel)DiskEncryptionSet).Write(writer, ModelSerializationExtensions.WireOptions); } writer.WriteEndObject(); } @@ -54,7 +58,13 @@ internal static VirtualMachineScaleSetManagedDiskParameters DeserializeVirtualMa { continue; } - diskEncryptionSet = JsonSerializer.Deserialize(property.Value.GetRawText()); + diskEncryptionSet = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtAcronymMapping.ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/VirtualMachineScaleSetNetworkConfiguration.Serialization.cs b/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/VirtualMachineScaleSetNetworkConfiguration.Serialization.cs index 5771f4569c7..8b3bdb46b57 100644 --- a/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/VirtualMachineScaleSetNetworkConfiguration.Serialization.cs +++ b/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/VirtualMachineScaleSetNetworkConfiguration.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Resources.Models; @@ -39,7 +43,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(NetworkSecurityGroup)) { writer.WritePropertyName("networkSecurityGroup"u8); - JsonSerializer.Serialize(writer, NetworkSecurityGroup); + ((IJsonModel)NetworkSecurityGroup).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsDefined(DnsSettings)) { @@ -124,7 +128,13 @@ internal static VirtualMachineScaleSetNetworkConfiguration DeserializeVirtualMac { continue; } - networkSecurityGroup = JsonSerializer.Deserialize(property0.Value.GetRawText()); + networkSecurityGroup = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property0.Value).ToArray()), global::MgmtAcronymMapping.ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#endif +; continue; } if (property0.NameEquals("dnsSettings"u8)) diff --git a/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/VirtualMachineScaleSetNetworkProfile.Serialization.cs b/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/VirtualMachineScaleSetNetworkProfile.Serialization.cs index df9c2b5e9f9..70081da7abc 100644 --- a/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/VirtualMachineScaleSetNetworkProfile.Serialization.cs +++ b/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/VirtualMachineScaleSetNetworkProfile.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Resources.Models; @@ -20,7 +24,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(HealthProbe)) { writer.WritePropertyName("healthProbe"u8); - JsonSerializer.Serialize(writer, HealthProbe); + ((IJsonModel)HealthProbe).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsCollectionDefined(NetworkInterfaceConfigurations)) { @@ -51,7 +55,13 @@ internal static VirtualMachineScaleSetNetworkProfile DeserializeVirtualMachineSc { continue; } - healthProbe = JsonSerializer.Deserialize(property.Value.GetRawText()); + healthProbe = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtAcronymMapping.ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#endif +; continue; } if (property.NameEquals("networkInterfaceConfigurations"u8)) diff --git a/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/VirtualMachineScaleSetPatch.Serialization.cs b/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/VirtualMachineScaleSetPatch.Serialization.cs index 884dd295e34..b1e6b39b672 100644 --- a/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/VirtualMachineScaleSetPatch.Serialization.cs +++ b/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/VirtualMachineScaleSetPatch.Serialization.cs @@ -5,8 +5,11 @@ #nullable disable +using System.ClientModel.Primitives; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.Models; +using Azure.ResourceManager.Resources.Models; namespace MgmtAcronymMapping.Models { @@ -28,7 +31,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(Identity)) { writer.WritePropertyName("identity"u8); - JsonSerializer.Serialize(writer, Identity); + ((IJsonModel)Identity).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsCollectionDefined(Tags)) { @@ -86,7 +89,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(ProximityPlacementGroup)) { writer.WritePropertyName("proximityPlacementGroup"u8); - JsonSerializer.Serialize(writer, ProximityPlacementGroup); + ((IJsonModel)ProximityPlacementGroup).Write(writer, ModelSerializationExtensions.WireOptions); } writer.WriteEndObject(); writer.WriteEndObject(); diff --git a/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/VirtualMachineScaleSetPublicIPAddressConfiguration.Serialization.cs b/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/VirtualMachineScaleSetPublicIPAddressConfiguration.Serialization.cs index b1b53dff6be..04922c14430 100644 --- a/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/VirtualMachineScaleSetPublicIPAddressConfiguration.Serialization.cs +++ b/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/VirtualMachineScaleSetPublicIPAddressConfiguration.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Resources.Models; @@ -44,7 +48,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(PublicIPPrefix)) { writer.WritePropertyName("publicIPPrefix"u8); - JsonSerializer.Serialize(writer, PublicIPPrefix); + ((IJsonModel)PublicIPPrefix).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsDefined(PublicIPAddressVersion)) { @@ -121,7 +125,13 @@ internal static VirtualMachineScaleSetPublicIPAddressConfiguration DeserializeVi { continue; } - publicIPPrefix = JsonSerializer.Deserialize(property0.Value.GetRawText()); + publicIPPrefix = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property0.Value).ToArray()), global::MgmtAcronymMapping.ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#endif +; continue; } if (property0.NameEquals("publicIPAddressVersion"u8)) diff --git a/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/VirtualMachineScaleSetUpdateIPConfiguration.Serialization.cs b/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/VirtualMachineScaleSetUpdateIPConfiguration.Serialization.cs index a1a68d4218c..10009aa6400 100644 --- a/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/VirtualMachineScaleSetUpdateIPConfiguration.Serialization.cs +++ b/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/VirtualMachineScaleSetUpdateIPConfiguration.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Resources.Models; @@ -32,7 +36,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(Subnet)) { writer.WritePropertyName("subnet"u8); - JsonSerializer.Serialize(writer, Subnet); + ((IJsonModel)Subnet).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsDefined(Primary)) { @@ -55,7 +59,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStartArray(); foreach (var item in ApplicationGatewayBackendAddressPools) { - JsonSerializer.Serialize(writer, item); + ((IJsonModel)item).Write(writer, ModelSerializationExtensions.WireOptions); } writer.WriteEndArray(); } @@ -65,7 +69,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStartArray(); foreach (var item in ApplicationSecurityGroups) { - JsonSerializer.Serialize(writer, item); + ((IJsonModel)item).Write(writer, ModelSerializationExtensions.WireOptions); } writer.WriteEndArray(); } @@ -75,7 +79,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStartArray(); foreach (var item in LoadBalancerBackendAddressPools) { - JsonSerializer.Serialize(writer, item); + ((IJsonModel)item).Write(writer, ModelSerializationExtensions.WireOptions); } writer.WriteEndArray(); } @@ -85,7 +89,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStartArray(); foreach (var item in LoadBalancerInboundNatPools) { - JsonSerializer.Serialize(writer, item); + ((IJsonModel)item).Write(writer, ModelSerializationExtensions.WireOptions); } writer.WriteEndArray(); } @@ -136,7 +140,13 @@ internal static VirtualMachineScaleSetUpdateIPConfiguration DeserializeVirtualMa { continue; } - subnet = JsonSerializer.Deserialize(property0.Value.GetRawText()); + subnet = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property0.Value).ToArray()), global::MgmtAcronymMapping.ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#endif +; continue; } if (property0.NameEquals("primary"u8)) @@ -175,7 +185,13 @@ internal static VirtualMachineScaleSetUpdateIPConfiguration DeserializeVirtualMa List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(JsonSerializer.Deserialize(item.GetRawText())); + array.Add( +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(item).ToArray()), global::MgmtAcronymMapping.ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(item.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#endif +); } applicationGatewayBackendAddressPools = array; continue; @@ -189,7 +205,13 @@ internal static VirtualMachineScaleSetUpdateIPConfiguration DeserializeVirtualMa List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(JsonSerializer.Deserialize(item.GetRawText())); + array.Add( +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(item).ToArray()), global::MgmtAcronymMapping.ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(item.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#endif +); } applicationSecurityGroups = array; continue; @@ -203,7 +225,13 @@ internal static VirtualMachineScaleSetUpdateIPConfiguration DeserializeVirtualMa List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(JsonSerializer.Deserialize(item.GetRawText())); + array.Add( +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(item).ToArray()), global::MgmtAcronymMapping.ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(item.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#endif +); } loadBalancerBackendAddressPools = array; continue; @@ -217,7 +245,13 @@ internal static VirtualMachineScaleSetUpdateIPConfiguration DeserializeVirtualMa List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(JsonSerializer.Deserialize(item.GetRawText())); + array.Add( +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(item).ToArray()), global::MgmtAcronymMapping.ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(item.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#endif +); } loadBalancerInboundNatPools = array; continue; diff --git a/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/VirtualMachineScaleSetUpdateNetworkConfiguration.Serialization.cs b/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/VirtualMachineScaleSetUpdateNetworkConfiguration.Serialization.cs index a2eedf213d3..86075edc468 100644 --- a/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/VirtualMachineScaleSetUpdateNetworkConfiguration.Serialization.cs +++ b/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/VirtualMachineScaleSetUpdateNetworkConfiguration.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Resources.Models; @@ -42,7 +46,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(NetworkSecurityGroup)) { writer.WritePropertyName("networkSecurityGroup"u8); - JsonSerializer.Serialize(writer, NetworkSecurityGroup); + ((IJsonModel)NetworkSecurityGroup).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsDefined(DnsSettings)) { @@ -127,7 +131,13 @@ internal static VirtualMachineScaleSetUpdateNetworkConfiguration DeserializeVirt { continue; } - networkSecurityGroup = JsonSerializer.Deserialize(property0.Value.GetRawText()); + networkSecurityGroup = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property0.Value).ToArray()), global::MgmtAcronymMapping.ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#endif +; continue; } if (property0.NameEquals("dnsSettings"u8)) diff --git a/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/VirtualMachineScaleSetUpdateNetworkProfile.Serialization.cs b/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/VirtualMachineScaleSetUpdateNetworkProfile.Serialization.cs index 369971d1738..d8b48ea7247 100644 --- a/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/VirtualMachineScaleSetUpdateNetworkProfile.Serialization.cs +++ b/test/TestProjects/MgmtAcronymMapping/src/Generated/Models/VirtualMachineScaleSetUpdateNetworkProfile.Serialization.cs @@ -5,8 +5,10 @@ #nullable disable +using System.ClientModel.Primitives; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.Resources.Models; namespace MgmtAcronymMapping.Models { @@ -18,7 +20,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(HealthProbe)) { writer.WritePropertyName("healthProbe"u8); - JsonSerializer.Serialize(writer, HealthProbe); + ((IJsonModel)HealthProbe).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsCollectionDefined(NetworkInterfaceConfigurations)) { diff --git a/test/TestProjects/MgmtAcronymMapping/src/Generated/VirtualMachineData.Serialization.cs b/test/TestProjects/MgmtAcronymMapping/src/Generated/VirtualMachineData.Serialization.cs index 5c291f64a8b..d34aa8d339a 100644 --- a/test/TestProjects/MgmtAcronymMapping/src/Generated/VirtualMachineData.Serialization.cs +++ b/test/TestProjects/MgmtAcronymMapping/src/Generated/VirtualMachineData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -27,7 +31,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(Identity)) { writer.WritePropertyName("identity"u8); - JsonSerializer.Serialize(writer, Identity); + ((IJsonModel)Identity).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsCollectionDefined(Zones)) { @@ -92,17 +96,17 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(AvailabilitySet)) { writer.WritePropertyName("availabilitySet"u8); - JsonSerializer.Serialize(writer, AvailabilitySet); + ((IJsonModel)AvailabilitySet).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsDefined(VirtualMachineScaleSet)) { writer.WritePropertyName("virtualMachineScaleSet"u8); - JsonSerializer.Serialize(writer, VirtualMachineScaleSet); + ((IJsonModel)VirtualMachineScaleSet).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsDefined(ProximityPlacementGroup)) { writer.WritePropertyName("proximityPlacementGroup"u8); - JsonSerializer.Serialize(writer, ProximityPlacementGroup); + ((IJsonModel)ProximityPlacementGroup).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsDefined(Priority)) { @@ -122,12 +126,12 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(Host)) { writer.WritePropertyName("host"u8); - JsonSerializer.Serialize(writer, Host); + ((IJsonModel)Host).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsDefined(HostGroup)) { writer.WritePropertyName("hostGroup"u8); - JsonSerializer.Serialize(writer, HostGroup); + ((IJsonModel)HostGroup).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsDefined(LicenseType)) { @@ -195,7 +199,13 @@ internal static VirtualMachineData DeserializeVirtualMachineData(JsonElement ele { continue; } - identity = JsonSerializer.Deserialize(property.Value.GetRawText()); + identity = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtAcronymMapping.ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#endif +; continue; } if (property.NameEquals("zones"u8)) @@ -252,7 +262,13 @@ internal static VirtualMachineData DeserializeVirtualMachineData(JsonElement ele { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtAcronymMapping.ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) @@ -333,7 +349,13 @@ internal static VirtualMachineData DeserializeVirtualMachineData(JsonElement ele { continue; } - availabilitySet = JsonSerializer.Deserialize(property0.Value.GetRawText()); + availabilitySet = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property0.Value).ToArray()), global::MgmtAcronymMapping.ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#endif +; continue; } if (property0.NameEquals("virtualMachineScaleSet"u8)) @@ -342,7 +364,13 @@ internal static VirtualMachineData DeserializeVirtualMachineData(JsonElement ele { continue; } - virtualMachineScaleSet = JsonSerializer.Deserialize(property0.Value.GetRawText()); + virtualMachineScaleSet = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property0.Value).ToArray()), global::MgmtAcronymMapping.ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#endif +; continue; } if (property0.NameEquals("proximityPlacementGroup"u8)) @@ -351,7 +379,13 @@ internal static VirtualMachineData DeserializeVirtualMachineData(JsonElement ele { continue; } - proximityPlacementGroup = JsonSerializer.Deserialize(property0.Value.GetRawText()); + proximityPlacementGroup = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property0.Value).ToArray()), global::MgmtAcronymMapping.ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#endif +; continue; } if (property0.NameEquals("priority"u8)) @@ -387,7 +421,13 @@ internal static VirtualMachineData DeserializeVirtualMachineData(JsonElement ele { continue; } - host = JsonSerializer.Deserialize(property0.Value.GetRawText()); + host = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property0.Value).ToArray()), global::MgmtAcronymMapping.ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#endif +; continue; } if (property0.NameEquals("hostGroup"u8)) @@ -396,7 +436,13 @@ internal static VirtualMachineData DeserializeVirtualMachineData(JsonElement ele { continue; } - hostGroup = JsonSerializer.Deserialize(property0.Value.GetRawText()); + hostGroup = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property0.Value).ToArray()), global::MgmtAcronymMapping.ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#endif +; continue; } if (property0.NameEquals("provisioningState"u8)) diff --git a/test/TestProjects/MgmtAcronymMapping/src/Generated/VirtualMachineScaleSetData.Serialization.cs b/test/TestProjects/MgmtAcronymMapping/src/Generated/VirtualMachineScaleSetData.Serialization.cs index 4d17f713663..f7ae64c9936 100644 --- a/test/TestProjects/MgmtAcronymMapping/src/Generated/VirtualMachineScaleSetData.Serialization.cs +++ b/test/TestProjects/MgmtAcronymMapping/src/Generated/VirtualMachineScaleSetData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -32,7 +36,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(Identity)) { writer.WritePropertyName("identity"u8); - JsonSerializer.Serialize(writer, Identity); + ((IJsonModel)Identity).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsCollectionDefined(Zones)) { @@ -117,12 +121,12 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(ProximityPlacementGroup)) { writer.WritePropertyName("proximityPlacementGroup"u8); - JsonSerializer.Serialize(writer, ProximityPlacementGroup); + ((IJsonModel)ProximityPlacementGroup).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsDefined(HostGroup)) { writer.WritePropertyName("hostGroup"u8); - JsonSerializer.Serialize(writer, HostGroup); + ((IJsonModel)HostGroup).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsDefined(AdditionalCapabilities)) { @@ -197,7 +201,13 @@ internal static VirtualMachineScaleSetData DeserializeVirtualMachineScaleSetData { continue; } - identity = JsonSerializer.Deserialize(property.Value.GetRawText()); + identity = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtAcronymMapping.ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#endif +; continue; } if (property.NameEquals("zones"u8)) @@ -254,7 +264,13 @@ internal static VirtualMachineScaleSetData DeserializeVirtualMachineScaleSetData { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtAcronymMapping.ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) @@ -369,7 +385,13 @@ internal static VirtualMachineScaleSetData DeserializeVirtualMachineScaleSetData { continue; } - proximityPlacementGroup = JsonSerializer.Deserialize(property0.Value.GetRawText()); + proximityPlacementGroup = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property0.Value).ToArray()), global::MgmtAcronymMapping.ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#endif +; continue; } if (property0.NameEquals("hostGroup"u8)) @@ -378,7 +400,13 @@ internal static VirtualMachineScaleSetData DeserializeVirtualMachineScaleSetData { continue; } - hostGroup = JsonSerializer.Deserialize(property0.Value.GetRawText()); + hostGroup = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property0.Value).ToArray()), global::MgmtAcronymMapping.ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#endif +; continue; } if (property0.NameEquals("additionalCapabilities"u8)) diff --git a/test/TestProjects/MgmtAcronymMapping/src/Generated/VirtualMachineScaleSetRollingUpgradeData.Serialization.cs b/test/TestProjects/MgmtAcronymMapping/src/Generated/VirtualMachineScaleSetRollingUpgradeData.Serialization.cs index 0816ab044e9..1fbd37915b8 100644 --- a/test/TestProjects/MgmtAcronymMapping/src/Generated/VirtualMachineScaleSetRollingUpgradeData.Serialization.cs +++ b/test/TestProjects/MgmtAcronymMapping/src/Generated/VirtualMachineScaleSetRollingUpgradeData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -95,7 +99,13 @@ internal static VirtualMachineScaleSetRollingUpgradeData DeserializeVirtualMachi { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtAcronymMapping.ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) diff --git a/test/TestProjects/MgmtAcronymMapping/src/Generated/VirtualMachineScaleSetVmData.Serialization.cs b/test/TestProjects/MgmtAcronymMapping/src/Generated/VirtualMachineScaleSetVmData.Serialization.cs index ea599dceb72..13e92f71a93 100644 --- a/test/TestProjects/MgmtAcronymMapping/src/Generated/VirtualMachineScaleSetVmData.Serialization.cs +++ b/test/TestProjects/MgmtAcronymMapping/src/Generated/VirtualMachineScaleSetVmData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -82,7 +86,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(AvailabilitySet)) { writer.WritePropertyName("availabilitySet"u8); - JsonSerializer.Serialize(writer, AvailabilitySet); + ((IJsonModel)AvailabilitySet).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsDefined(LicenseType)) { @@ -209,7 +213,13 @@ internal static VirtualMachineScaleSetVmData DeserializeVirtualMachineScaleSetVm { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtAcronymMapping.ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) @@ -322,7 +332,13 @@ internal static VirtualMachineScaleSetVmData DeserializeVirtualMachineScaleSetVm { continue; } - availabilitySet = JsonSerializer.Deserialize(property0.Value.GetRawText()); + availabilitySet = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property0.Value).ToArray()), global::MgmtAcronymMapping.ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtAcronymMappingContext.Default) +#endif +; continue; } if (property0.NameEquals("provisioningState"u8)) diff --git a/test/TestProjects/MgmtCollectionParent/src/Generated/OrderResourceData.Serialization.cs b/test/TestProjects/MgmtCollectionParent/src/Generated/OrderResourceData.Serialization.cs index b10826b0abc..479c7b5411b 100644 --- a/test/TestProjects/MgmtCollectionParent/src/Generated/OrderResourceData.Serialization.cs +++ b/test/TestProjects/MgmtCollectionParent/src/Generated/OrderResourceData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -51,7 +55,13 @@ internal static OrderResourceData DeserializeOrderResourceData(JsonElement eleme { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtCollectionParent.ModelSerializationExtensions.WireOptions, MgmtCollectionParentContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtCollectionParentContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) diff --git a/test/TestProjects/MgmtConstants/src/Generated/LongRunningOperation/MgmtConstantsArmOperation.cs b/test/TestProjects/MgmtConstants/src/Generated/LongRunningOperation/MgmtConstantsArmOperation.cs index bf9f9b53c62..8859131ff56 100644 --- a/test/TestProjects/MgmtConstants/src/Generated/LongRunningOperation/MgmtConstantsArmOperation.cs +++ b/test/TestProjects/MgmtConstants/src/Generated/LongRunningOperation/MgmtConstantsArmOperation.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtConstantsContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtConstantsContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtConstants/src/Generated/LongRunningOperation/MgmtConstantsArmOperationOfT.cs b/test/TestProjects/MgmtConstants/src/Generated/LongRunningOperation/MgmtConstantsArmOperationOfT.cs index 771a559c767..c81796bd466 100644 --- a/test/TestProjects/MgmtConstants/src/Generated/LongRunningOperation/MgmtConstantsArmOperationOfT.cs +++ b/test/TestProjects/MgmtConstants/src/Generated/LongRunningOperation/MgmtConstantsArmOperationOfT.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtConstantsContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtConstantsContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtConstants/src/Generated/OptionalMachineData.Serialization.cs b/test/TestProjects/MgmtConstants/src/Generated/OptionalMachineData.Serialization.cs index 7d313dd999f..aa186011423 100644 --- a/test/TestProjects/MgmtConstants/src/Generated/OptionalMachineData.Serialization.cs +++ b/test/TestProjects/MgmtConstants/src/Generated/OptionalMachineData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -103,7 +107,13 @@ internal static OptionalMachineData DeserializeOptionalMachineData(JsonElement e { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtConstants.ModelSerializationExtensions.WireOptions, MgmtConstantsContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtConstantsContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) diff --git a/test/TestProjects/MgmtCustomizations/src/Generated/Internal/ModelSerializationExtensions.cs b/test/TestProjects/MgmtCustomizations/src/Generated/Internal/ModelSerializationExtensions.cs index a2708393b18..02cc9006a3a 100644 --- a/test/TestProjects/MgmtCustomizations/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestProjects/MgmtCustomizations/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,12 +9,10 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; using Azure.Core; -using Azure.ResourceManager.Models; namespace MgmtCustomizations { @@ -23,8 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, MgmtCustomizationsContext.Default) } }; - internal static readonly JsonSerializerOptions OptionsUseManagedServiceIdentityV3 = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, MgmtCustomizationsContext.Default), new Azure.ResourceManager.Models.ManagedServiceIdentityTypeV3Converter() } }; public static object GetObject(this JsonElement element) { @@ -269,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestProjects/MgmtCustomizations/src/Generated/LongRunningOperation/MgmtCustomizationsArmOperation.cs b/test/TestProjects/MgmtCustomizations/src/Generated/LongRunningOperation/MgmtCustomizationsArmOperation.cs index 0cfc2b843e8..a3637421224 100644 --- a/test/TestProjects/MgmtCustomizations/src/Generated/LongRunningOperation/MgmtCustomizationsArmOperation.cs +++ b/test/TestProjects/MgmtCustomizations/src/Generated/LongRunningOperation/MgmtCustomizationsArmOperation.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtCustomizationsContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtCustomizationsContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtCustomizations/src/Generated/LongRunningOperation/MgmtCustomizationsArmOperationOfT.cs b/test/TestProjects/MgmtCustomizations/src/Generated/LongRunningOperation/MgmtCustomizationsArmOperationOfT.cs index dacb0755363..8efc304363e 100644 --- a/test/TestProjects/MgmtCustomizations/src/Generated/LongRunningOperation/MgmtCustomizationsArmOperationOfT.cs +++ b/test/TestProjects/MgmtCustomizations/src/Generated/LongRunningOperation/MgmtCustomizationsArmOperationOfT.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtCustomizationsContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtCustomizationsContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtCustomizations/src/Generated/PetStoreData.Serialization.cs b/test/TestProjects/MgmtCustomizations/src/Generated/PetStoreData.Serialization.cs index 652f585bb9a..d8f13331176 100644 --- a/test/TestProjects/MgmtCustomizations/src/Generated/PetStoreData.Serialization.cs +++ b/test/TestProjects/MgmtCustomizations/src/Generated/PetStoreData.Serialization.cs @@ -8,6 +8,8 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -103,7 +105,13 @@ internal static PetStoreData DeserializePetStoreData(JsonElement element, ModelR { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtCustomizations.ModelSerializationExtensions.WireOptions, MgmtCustomizationsContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtCustomizationsContext.Default) +#endif +; continue; } if (options.Format != "W") diff --git a/test/TestProjects/MgmtCustomizations/tests/MgmtCustomizations.Tests.csproj b/test/TestProjects/MgmtCustomizations/tests/MgmtCustomizations.Tests.csproj index 5bc42599edd..09a9d75b20e 100644 --- a/test/TestProjects/MgmtCustomizations/tests/MgmtCustomizations.Tests.csproj +++ b/test/TestProjects/MgmtCustomizations/tests/MgmtCustomizations.Tests.csproj @@ -1,12 +1,7 @@ - - $(RequiredTargetFrameworks) - - $(NoWarn);CS1591 - + - diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/DeliveryRuleData.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/DeliveryRuleData.Serialization.cs index 175c21430e4..ebe6de26959 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/DeliveryRuleData.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/DeliveryRuleData.Serialization.cs @@ -8,6 +8,7 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; using System.Text; using System.Text.Json; using Azure.Core; @@ -262,7 +263,13 @@ internal static DeliveryRuleData DeserializeDeliveryRuleData(JsonElement element { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtDiscriminator.ModelSerializationExtensions.WireOptions, MgmtDiscriminatorContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtDiscriminatorContext.Default) +#endif +; continue; } if (property.Value.ValueKind == JsonValueKind.String || property.Value.ValueKind == JsonValueKind.Null) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Internal/ModelSerializationExtensions.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Internal/ModelSerializationExtensions.cs index ec53119f4ba..4e5bbb5dc9f 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,12 +9,10 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; using Azure.Core; -using Azure.ResourceManager.Models; namespace MgmtDiscriminator { @@ -23,8 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, MgmtDiscriminatorContext.Default) } }; - internal static readonly JsonSerializerOptions OptionsUseManagedServiceIdentityV3 = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, MgmtDiscriminatorContext.Default), new Azure.ResourceManager.Models.ManagedServiceIdentityTypeV3Converter() } }; public static object GetObject(this JsonElement element) { @@ -269,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/LongRunningOperation/MgmtDiscriminatorArmOperation.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/LongRunningOperation/MgmtDiscriminatorArmOperation.cs index a5e4b1f5d52..b0c3b0ce6ec 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/LongRunningOperation/MgmtDiscriminatorArmOperation.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/LongRunningOperation/MgmtDiscriminatorArmOperation.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtDiscriminatorContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtDiscriminatorContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/LongRunningOperation/MgmtDiscriminatorArmOperationOfT.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/LongRunningOperation/MgmtDiscriminatorArmOperationOfT.cs index cdec88285b0..cc24d941649 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/LongRunningOperation/MgmtDiscriminatorArmOperationOfT.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/LongRunningOperation/MgmtDiscriminatorArmOperationOfT.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtDiscriminatorContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtDiscriminatorContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/OriginGroupOverride.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/OriginGroupOverride.Serialization.cs index fd06c2787c2..ffc27c07489 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/OriginGroupOverride.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/OriginGroupOverride.Serialization.cs @@ -8,6 +8,7 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; using System.Text; using System.Text.Json; using Azure.Core; @@ -40,7 +41,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit if (Optional.IsDefined(OriginGroup)) { writer.WritePropertyName("originGroup"u8); - JsonSerializer.Serialize(writer, OriginGroup); + ((IJsonModel)OriginGroup).Write(writer, options); } if (Optional.IsDefined(ForwardingProtocol)) { @@ -96,7 +97,13 @@ internal static OriginGroupOverride DeserializeOriginGroupOverride(JsonElement e { continue; } - originGroup = JsonSerializer.Deserialize(property.Value.GetRawText()); + originGroup = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), options, MgmtDiscriminatorContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, MgmtDiscriminatorContext.Default) +#endif +; continue; } if (property.NameEquals("forwardingProtocol"u8)) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/OriginGroupOverrideActionParameters.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/OriginGroupOverrideActionParameters.Serialization.cs index ee89948c680..a043342461b 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/OriginGroupOverrideActionParameters.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/OriginGroupOverrideActionParameters.Serialization.cs @@ -8,6 +8,7 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; using System.Text; using System.Text.Json; using Azure.Core; @@ -40,7 +41,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit writer.WritePropertyName("typeName"u8); writer.WriteStringValue(TypeName.ToString()); writer.WritePropertyName("originGroup"u8); - JsonSerializer.Serialize(writer, OriginGroup); + ((IJsonModel)OriginGroup).Write(writer, options); if (options.Format != "W" && _serializedAdditionalRawData != null) { foreach (var item in _serializedAdditionalRawData) @@ -91,7 +92,13 @@ internal static OriginGroupOverrideActionParameters DeserializeOriginGroupOverri } if (property.NameEquals("originGroup"u8)) { - originGroup = JsonSerializer.Deserialize(property.Value.GetRawText()); + originGroup = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), options, MgmtDiscriminatorContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, MgmtDiscriminatorContext.Default) +#endif +; continue; } if (options.Format != "W") diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/RoleAssignmentArtifact.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/RoleAssignmentArtifact.Serialization.cs index 42b48a22d40..72df76a4385 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/RoleAssignmentArtifact.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/RoleAssignmentArtifact.Serialization.cs @@ -8,6 +8,7 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; using System.Text; using System.Text.Json; using Azure.Core; @@ -117,7 +118,13 @@ internal static RoleAssignmentArtifact DeserializeRoleAssignmentArtifact(JsonEle { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtDiscriminator.ModelSerializationExtensions.WireOptions, MgmtDiscriminatorContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtDiscriminatorContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/TemplateArtifact.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/TemplateArtifact.Serialization.cs index 653292a8879..f1bba6a1356 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/TemplateArtifact.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/TemplateArtifact.Serialization.cs @@ -9,6 +9,7 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Linq; +using System.Runtime.InteropServices; using System.Text; using System.Text.Json; using Azure.Core; @@ -136,7 +137,13 @@ internal static TemplateArtifact DeserializeTemplateArtifact(JsonElement element { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtDiscriminator.ModelSerializationExtensions.WireOptions, MgmtDiscriminatorContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtDiscriminatorContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) diff --git a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/UnknownArtifact.Serialization.cs b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/UnknownArtifact.Serialization.cs index 8b4138de112..d5b17c5c3a0 100644 --- a/test/TestProjects/MgmtDiscriminator/src/Generated/Models/UnknownArtifact.Serialization.cs +++ b/test/TestProjects/MgmtDiscriminator/src/Generated/Models/UnknownArtifact.Serialization.cs @@ -8,6 +8,7 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; using System.Text; using System.Text.Json; using Azure.Core; @@ -95,7 +96,13 @@ internal static UnknownArtifact DeserializeUnknownArtifact(JsonElement element, { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtDiscriminator.ModelSerializationExtensions.WireOptions, MgmtDiscriminatorContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtDiscriminatorContext.Default) +#endif +; continue; } if (options.Format != "W") diff --git a/test/TestProjects/MgmtExactMatchFlattenInheritance/src/Generated/AzureResourceFlattenModel1Data.Serialization.cs b/test/TestProjects/MgmtExactMatchFlattenInheritance/src/Generated/AzureResourceFlattenModel1Data.Serialization.cs index 01b9862be80..8fb081dc6ad 100644 --- a/test/TestProjects/MgmtExactMatchFlattenInheritance/src/Generated/AzureResourceFlattenModel1Data.Serialization.cs +++ b/test/TestProjects/MgmtExactMatchFlattenInheritance/src/Generated/AzureResourceFlattenModel1Data.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -117,7 +121,13 @@ internal static AzureResourceFlattenModel1Data DeserializeAzureResourceFlattenMo { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtExactMatchFlattenInheritance.ModelSerializationExtensions.WireOptions, MgmtExactMatchFlattenInheritanceContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtExactMatchFlattenInheritanceContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) diff --git a/test/TestProjects/MgmtExactMatchFlattenInheritance/src/Generated/CustomModel2Data.Serialization.cs b/test/TestProjects/MgmtExactMatchFlattenInheritance/src/Generated/CustomModel2Data.Serialization.cs index ba79e75929b..7f1e3dadacc 100644 --- a/test/TestProjects/MgmtExactMatchFlattenInheritance/src/Generated/CustomModel2Data.Serialization.cs +++ b/test/TestProjects/MgmtExactMatchFlattenInheritance/src/Generated/CustomModel2Data.Serialization.cs @@ -5,6 +5,10 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -63,7 +67,13 @@ internal static CustomModel2Data DeserializeCustomModel2Data(JsonElement element { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtExactMatchFlattenInheritance.ModelSerializationExtensions.WireOptions, MgmtExactMatchFlattenInheritanceContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtExactMatchFlattenInheritanceContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtExactMatchFlattenInheritance/src/Generated/LongRunningOperation/MgmtExactMatchFlattenInheritanceArmOperationOfT.cs b/test/TestProjects/MgmtExactMatchFlattenInheritance/src/Generated/LongRunningOperation/MgmtExactMatchFlattenInheritanceArmOperationOfT.cs index ab805aaea3e..d392d69b31e 100644 --- a/test/TestProjects/MgmtExactMatchFlattenInheritance/src/Generated/LongRunningOperation/MgmtExactMatchFlattenInheritanceArmOperationOfT.cs +++ b/test/TestProjects/MgmtExactMatchFlattenInheritance/src/Generated/LongRunningOperation/MgmtExactMatchFlattenInheritanceArmOperationOfT.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtExactMatchFlattenInheritanceContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtExactMatchFlattenInheritanceContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtExactMatchFlattenInheritance/src/Generated/Models/AzureResourceFlattenModel2.Serialization.cs b/test/TestProjects/MgmtExactMatchFlattenInheritance/src/Generated/Models/AzureResourceFlattenModel2.Serialization.cs index 8a56cc46765..9c3c103d723 100644 --- a/test/TestProjects/MgmtExactMatchFlattenInheritance/src/Generated/Models/AzureResourceFlattenModel2.Serialization.cs +++ b/test/TestProjects/MgmtExactMatchFlattenInheritance/src/Generated/Models/AzureResourceFlattenModel2.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -102,7 +106,13 @@ internal static AzureResourceFlattenModel2 DeserializeAzureResourceFlattenModel2 { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtExactMatchFlattenInheritance.ModelSerializationExtensions.WireOptions, MgmtExactMatchFlattenInheritanceContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtExactMatchFlattenInheritanceContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtExactMatchFlattenInheritance/src/Generated/Models/AzureResourceFlattenModel3.Serialization.cs b/test/TestProjects/MgmtExactMatchFlattenInheritance/src/Generated/Models/AzureResourceFlattenModel3.Serialization.cs index 5d386121389..e11168014b8 100644 --- a/test/TestProjects/MgmtExactMatchFlattenInheritance/src/Generated/Models/AzureResourceFlattenModel3.Serialization.cs +++ b/test/TestProjects/MgmtExactMatchFlattenInheritance/src/Generated/Models/AzureResourceFlattenModel3.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -102,7 +106,13 @@ internal static AzureResourceFlattenModel3 DeserializeAzureResourceFlattenModel3 { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtExactMatchFlattenInheritance.ModelSerializationExtensions.WireOptions, MgmtExactMatchFlattenInheritanceContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtExactMatchFlattenInheritanceContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtExactMatchFlattenInheritance/src/Generated/Models/AzureResourceFlattenModel5.Serialization.cs b/test/TestProjects/MgmtExactMatchFlattenInheritance/src/Generated/Models/AzureResourceFlattenModel5.Serialization.cs index 822a9d60c78..d8f6e4df88c 100644 --- a/test/TestProjects/MgmtExactMatchFlattenInheritance/src/Generated/Models/AzureResourceFlattenModel5.Serialization.cs +++ b/test/TestProjects/MgmtExactMatchFlattenInheritance/src/Generated/Models/AzureResourceFlattenModel5.Serialization.cs @@ -5,6 +5,10 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -67,7 +71,13 @@ internal static AzureResourceFlattenModel5 DeserializeAzureResourceFlattenModel5 { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtExactMatchFlattenInheritance.ModelSerializationExtensions.WireOptions, MgmtExactMatchFlattenInheritanceContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtExactMatchFlattenInheritanceContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtExactMatchInheritance/src/Generated/ExactMatchModel1Data.Serialization.cs b/test/TestProjects/MgmtExactMatchInheritance/src/Generated/ExactMatchModel1Data.Serialization.cs index 4df91d11c6b..58310fd7eb4 100644 --- a/test/TestProjects/MgmtExactMatchInheritance/src/Generated/ExactMatchModel1Data.Serialization.cs +++ b/test/TestProjects/MgmtExactMatchInheritance/src/Generated/ExactMatchModel1Data.Serialization.cs @@ -6,8 +6,11 @@ #nullable disable using System; +using System.ClientModel.Primitives; using System.Collections.Generic; using System.Net; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.Core.Expressions.DataFactory; @@ -124,17 +127,17 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(Type17)) { writer.WritePropertyName("type17"u8); - JsonSerializer.Serialize(writer, Type17); + ((IJsonModel)Type17).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsDefined(Type18)) { writer.WritePropertyName("type18"u8); - JsonSerializer.Serialize(writer, Type18); + ((IJsonModel)Type18).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsDefined(Type19)) { writer.WritePropertyName("type19"u8); - JsonSerializer.Serialize(writer, Type19); + ((IJsonModel)Type19).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsDefined(Type20)) { @@ -354,7 +357,13 @@ internal static ExactMatchModel1Data DeserializeExactMatchModel1Data(JsonElement { continue; } - type17 = JsonSerializer.Deserialize(property.Value.GetRawText()); + type17 = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtExactMatchInheritance.ModelSerializationExtensions.WireOptions, MgmtExactMatchInheritanceContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtExactMatchInheritanceContext.Default) +#endif +; continue; } if (property.NameEquals("type18"u8)) @@ -363,7 +372,13 @@ internal static ExactMatchModel1Data DeserializeExactMatchModel1Data(JsonElement { continue; } - type18 = JsonSerializer.Deserialize(property.Value.GetRawText()); + type18 = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtExactMatchInheritance.ModelSerializationExtensions.WireOptions, MgmtExactMatchInheritanceContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtExactMatchInheritanceContext.Default) +#endif +; continue; } if (property.NameEquals("type19"u8)) @@ -372,7 +387,13 @@ internal static ExactMatchModel1Data DeserializeExactMatchModel1Data(JsonElement { continue; } - type19 = JsonSerializer.Deserialize(property.Value.GetRawText()); + type19 = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtExactMatchInheritance.ModelSerializationExtensions.WireOptions, MgmtExactMatchInheritanceContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtExactMatchInheritanceContext.Default) +#endif +; continue; } if (property.NameEquals("type20"u8)) @@ -405,7 +426,13 @@ internal static ExactMatchModel1Data DeserializeExactMatchModel1Data(JsonElement { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtExactMatchInheritance.ModelSerializationExtensions.WireOptions, MgmtExactMatchInheritanceContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtExactMatchInheritanceContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtExactMatchInheritance/src/Generated/ExactMatchModel5Data.Serialization.cs b/test/TestProjects/MgmtExactMatchInheritance/src/Generated/ExactMatchModel5Data.Serialization.cs index dc79d3bc0d6..6caf617e66c 100644 --- a/test/TestProjects/MgmtExactMatchInheritance/src/Generated/ExactMatchModel5Data.Serialization.cs +++ b/test/TestProjects/MgmtExactMatchInheritance/src/Generated/ExactMatchModel5Data.Serialization.cs @@ -6,7 +6,10 @@ #nullable disable using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using System.Text.Json.Serialization; using Azure.Core; @@ -101,7 +104,13 @@ internal static ExactMatchModel5Data DeserializeExactMatchModel5Data(JsonElement { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtExactMatchInheritance.ModelSerializationExtensions.WireOptions, MgmtExactMatchInheritanceContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtExactMatchInheritanceContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtExactMatchInheritance/src/Generated/LongRunningOperation/MgmtExactMatchInheritanceArmOperationOfT.cs b/test/TestProjects/MgmtExactMatchInheritance/src/Generated/LongRunningOperation/MgmtExactMatchInheritanceArmOperationOfT.cs index e333bfeffc4..2bcaa9c97d2 100644 --- a/test/TestProjects/MgmtExactMatchInheritance/src/Generated/LongRunningOperation/MgmtExactMatchInheritanceArmOperationOfT.cs +++ b/test/TestProjects/MgmtExactMatchInheritance/src/Generated/LongRunningOperation/MgmtExactMatchInheritanceArmOperationOfT.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtExactMatchInheritanceContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtExactMatchInheritanceContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtExactMatchInheritance/src/Generated/Models/ExactMatchModel10.Serialization.cs b/test/TestProjects/MgmtExactMatchInheritance/src/Generated/Models/ExactMatchModel10.Serialization.cs index f06cdfcd453..1ade1955d7a 100644 --- a/test/TestProjects/MgmtExactMatchInheritance/src/Generated/Models/ExactMatchModel10.Serialization.cs +++ b/test/TestProjects/MgmtExactMatchInheritance/src/Generated/Models/ExactMatchModel10.Serialization.cs @@ -6,7 +6,10 @@ #nullable disable using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using System.Text.Json.Serialization; using Azure.Core; @@ -97,7 +100,13 @@ internal static ExactMatchModel10 DeserializeExactMatchModel10(JsonElement eleme { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtExactMatchInheritance.ModelSerializationExtensions.WireOptions, MgmtExactMatchInheritanceContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtExactMatchInheritanceContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtExpandResourceTypes/src/Generated/LongRunningOperation/MgmtExpandResourceTypesArmOperation.cs b/test/TestProjects/MgmtExpandResourceTypes/src/Generated/LongRunningOperation/MgmtExpandResourceTypesArmOperation.cs index ce451d31add..0e3f5d46432 100644 --- a/test/TestProjects/MgmtExpandResourceTypes/src/Generated/LongRunningOperation/MgmtExpandResourceTypesArmOperation.cs +++ b/test/TestProjects/MgmtExpandResourceTypes/src/Generated/LongRunningOperation/MgmtExpandResourceTypesArmOperation.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtExpandResourceTypesContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtExpandResourceTypesContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtExpandResourceTypes/src/Generated/LongRunningOperation/MgmtExpandResourceTypesArmOperationOfT.cs b/test/TestProjects/MgmtExpandResourceTypes/src/Generated/LongRunningOperation/MgmtExpandResourceTypesArmOperationOfT.cs index 7c01c902f29..082c0bfd743 100644 --- a/test/TestProjects/MgmtExpandResourceTypes/src/Generated/LongRunningOperation/MgmtExpandResourceTypesArmOperationOfT.cs +++ b/test/TestProjects/MgmtExpandResourceTypes/src/Generated/LongRunningOperation/MgmtExpandResourceTypesArmOperationOfT.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtExpandResourceTypesContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtExpandResourceTypesContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtExpandResourceTypes/src/Generated/Models/DnsResourceReference.Serialization.cs b/test/TestProjects/MgmtExpandResourceTypes/src/Generated/Models/DnsResourceReference.Serialization.cs index 0880aace69d..d6e9f4191e4 100644 --- a/test/TestProjects/MgmtExpandResourceTypes/src/Generated/Models/DnsResourceReference.Serialization.cs +++ b/test/TestProjects/MgmtExpandResourceTypes/src/Generated/Models/DnsResourceReference.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.ResourceManager.Resources.Models; @@ -32,7 +36,13 @@ internal static DnsResourceReference DeserializeDnsResourceReference(JsonElement List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(JsonSerializer.Deserialize(item.GetRawText())); + array.Add( +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(item).ToArray()), global::MgmtExpandResourceTypes.ModelSerializationExtensions.WireOptions, MgmtExpandResourceTypesContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(item.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtExpandResourceTypesContext.Default) +#endif +); } dnsResources = array; continue; @@ -43,7 +53,13 @@ internal static DnsResourceReference DeserializeDnsResourceReference(JsonElement { continue; } - targetResource = JsonSerializer.Deserialize(property.Value.GetRawText()); + targetResource = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtExpandResourceTypes.ModelSerializationExtensions.WireOptions, MgmtExpandResourceTypesContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtExpandResourceTypesContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtExpandResourceTypes/src/Generated/Models/DnsResourceReferenceContent.Serialization.cs b/test/TestProjects/MgmtExpandResourceTypes/src/Generated/Models/DnsResourceReferenceContent.Serialization.cs index c005145e7af..7204c141001 100644 --- a/test/TestProjects/MgmtExpandResourceTypes/src/Generated/Models/DnsResourceReferenceContent.Serialization.cs +++ b/test/TestProjects/MgmtExpandResourceTypes/src/Generated/Models/DnsResourceReferenceContent.Serialization.cs @@ -5,8 +5,10 @@ #nullable disable +using System.ClientModel.Primitives; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.Resources.Models; namespace MgmtExpandResourceTypes.Models { @@ -23,7 +25,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStartArray(); foreach (var item in TargetResources) { - JsonSerializer.Serialize(writer, item); + ((IJsonModel)item).Write(writer, ModelSerializationExtensions.WireOptions); } writer.WriteEndArray(); } diff --git a/test/TestProjects/MgmtExpandResourceTypes/src/Generated/RecordSetData.Serialization.cs b/test/TestProjects/MgmtExpandResourceTypes/src/Generated/RecordSetData.Serialization.cs index d90310327bc..e15ad6efd84 100644 --- a/test/TestProjects/MgmtExpandResourceTypes/src/Generated/RecordSetData.Serialization.cs +++ b/test/TestProjects/MgmtExpandResourceTypes/src/Generated/RecordSetData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -45,7 +49,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(TargetResource)) { writer.WritePropertyName("targetResource"u8); - JsonSerializer.Serialize(writer, TargetResource); + ((IJsonModel)TargetResource).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsCollectionDefined(ARecords)) { @@ -195,7 +199,13 @@ internal static RecordSetData DeserializeRecordSetData(JsonElement element) { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtExpandResourceTypes.ModelSerializationExtensions.WireOptions, MgmtExpandResourceTypesContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtExpandResourceTypesContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) @@ -246,7 +256,13 @@ internal static RecordSetData DeserializeRecordSetData(JsonElement element) { continue; } - targetResource = JsonSerializer.Deserialize(property0.Value.GetRawText()); + targetResource = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property0.Value).ToArray()), global::MgmtExpandResourceTypes.ModelSerializationExtensions.WireOptions, MgmtExpandResourceTypesContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtExpandResourceTypesContext.Default) +#endif +; continue; } if (property0.NameEquals("ARecords"u8)) diff --git a/test/TestProjects/MgmtExpandResourceTypes/src/Generated/ZoneData.Serialization.cs b/test/TestProjects/MgmtExpandResourceTypes/src/Generated/ZoneData.Serialization.cs index 56c55416e7f..1756286d166 100644 --- a/test/TestProjects/MgmtExpandResourceTypes/src/Generated/ZoneData.Serialization.cs +++ b/test/TestProjects/MgmtExpandResourceTypes/src/Generated/ZoneData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -65,7 +69,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStartArray(); foreach (var item in RegistrationVirtualNetworks) { - JsonSerializer.Serialize(writer, item); + ((IJsonModel)item).Write(writer, ModelSerializationExtensions.WireOptions); } writer.WriteEndArray(); } @@ -75,7 +79,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStartArray(); foreach (var item in ResolutionVirtualNetworks) { - JsonSerializer.Serialize(writer, item); + ((IJsonModel)item).Write(writer, ModelSerializationExtensions.WireOptions); } writer.WriteEndArray(); } @@ -153,7 +157,13 @@ internal static ZoneData DeserializeZoneData(JsonElement element) { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtExpandResourceTypes.ModelSerializationExtensions.WireOptions, MgmtExpandResourceTypesContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtExpandResourceTypesContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) @@ -251,7 +261,13 @@ internal static ZoneData DeserializeZoneData(JsonElement element) List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(JsonSerializer.Deserialize(item.GetRawText())); + array.Add( +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(item).ToArray()), global::MgmtExpandResourceTypes.ModelSerializationExtensions.WireOptions, MgmtExpandResourceTypesContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(item.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtExpandResourceTypesContext.Default) +#endif +); } registrationVirtualNetworks = array; continue; @@ -265,7 +281,13 @@ internal static ZoneData DeserializeZoneData(JsonElement element) List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(JsonSerializer.Deserialize(item.GetRawText())); + array.Add( +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(item).ToArray()), global::MgmtExpandResourceTypes.ModelSerializationExtensions.WireOptions, MgmtExpandResourceTypesContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(item.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtExpandResourceTypesContext.Default) +#endif +); } resolutionVirtualNetworks = array; continue; diff --git a/test/TestProjects/MgmtExtensionCommonRestOperation/src/Generated/LongRunningOperation/MgmtExtensionCommonRestOperationArmOperationOfT.cs b/test/TestProjects/MgmtExtensionCommonRestOperation/src/Generated/LongRunningOperation/MgmtExtensionCommonRestOperationArmOperationOfT.cs index 7839c2b7c0d..e3ade4fce03 100644 --- a/test/TestProjects/MgmtExtensionCommonRestOperation/src/Generated/LongRunningOperation/MgmtExtensionCommonRestOperationArmOperationOfT.cs +++ b/test/TestProjects/MgmtExtensionCommonRestOperation/src/Generated/LongRunningOperation/MgmtExtensionCommonRestOperationArmOperationOfT.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtExtensionCommonRestOperationContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtExtensionCommonRestOperationContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtExtensionCommonRestOperation/src/Generated/TypeOneData.Serialization.cs b/test/TestProjects/MgmtExtensionCommonRestOperation/src/Generated/TypeOneData.Serialization.cs index c31aa860365..e0d62760243 100644 --- a/test/TestProjects/MgmtExtensionCommonRestOperation/src/Generated/TypeOneData.Serialization.cs +++ b/test/TestProjects/MgmtExtensionCommonRestOperation/src/Generated/TypeOneData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -98,7 +102,13 @@ internal static TypeOneData DeserializeTypeOneData(JsonElement element) { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtExtensionCommonRestOperation.ModelSerializationExtensions.WireOptions, MgmtExtensionCommonRestOperationContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtExtensionCommonRestOperationContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtExtensionCommonRestOperation/src/Generated/TypeTwoData.Serialization.cs b/test/TestProjects/MgmtExtensionCommonRestOperation/src/Generated/TypeTwoData.Serialization.cs index 4141e64bc08..1719a2b4229 100644 --- a/test/TestProjects/MgmtExtensionCommonRestOperation/src/Generated/TypeTwoData.Serialization.cs +++ b/test/TestProjects/MgmtExtensionCommonRestOperation/src/Generated/TypeTwoData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -98,7 +102,13 @@ internal static TypeTwoData DeserializeTypeTwoData(JsonElement element) { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtExtensionCommonRestOperation.ModelSerializationExtensions.WireOptions, MgmtExtensionCommonRestOperationContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtExtensionCommonRestOperationContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtExtensionResource/src/Generated/LongRunningOperation/MgmtExtensionResourceArmOperation.cs b/test/TestProjects/MgmtExtensionResource/src/Generated/LongRunningOperation/MgmtExtensionResourceArmOperation.cs index 1f21af57be2..be3a5bb8a86 100644 --- a/test/TestProjects/MgmtExtensionResource/src/Generated/LongRunningOperation/MgmtExtensionResourceArmOperation.cs +++ b/test/TestProjects/MgmtExtensionResource/src/Generated/LongRunningOperation/MgmtExtensionResourceArmOperation.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtExtensionResourceContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtExtensionResourceContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtExtensionResource/src/Generated/LongRunningOperation/MgmtExtensionResourceArmOperationOfT.cs b/test/TestProjects/MgmtExtensionResource/src/Generated/LongRunningOperation/MgmtExtensionResourceArmOperationOfT.cs index c7730a196ee..db9eec1b9e0 100644 --- a/test/TestProjects/MgmtExtensionResource/src/Generated/LongRunningOperation/MgmtExtensionResourceArmOperationOfT.cs +++ b/test/TestProjects/MgmtExtensionResource/src/Generated/LongRunningOperation/MgmtExtensionResourceArmOperationOfT.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtExtensionResourceContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtExtensionResourceContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtExtensionResource/src/Generated/PolicyDefinitionData.Serialization.cs b/test/TestProjects/MgmtExtensionResource/src/Generated/PolicyDefinitionData.Serialization.cs index 91171db7dcc..01c752fcb77 100644 --- a/test/TestProjects/MgmtExtensionResource/src/Generated/PolicyDefinitionData.Serialization.cs +++ b/test/TestProjects/MgmtExtensionResource/src/Generated/PolicyDefinitionData.Serialization.cs @@ -6,7 +6,10 @@ #nullable disable using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -120,7 +123,13 @@ internal static PolicyDefinitionData DeserializePolicyDefinitionData(JsonElement { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtExtensionResource.ModelSerializationExtensions.WireOptions, MgmtExtensionResourceContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtExtensionResourceContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) diff --git a/test/TestProjects/MgmtExtensionResource/src/Generated/SubSingletonData.Serialization.cs b/test/TestProjects/MgmtExtensionResource/src/Generated/SubSingletonData.Serialization.cs index 403f421f165..861ab23cbda 100644 --- a/test/TestProjects/MgmtExtensionResource/src/Generated/SubSingletonData.Serialization.cs +++ b/test/TestProjects/MgmtExtensionResource/src/Generated/SubSingletonData.Serialization.cs @@ -5,6 +5,10 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -52,7 +56,13 @@ internal static SubSingletonData DeserializeSubSingletonData(JsonElement element { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtExtensionResource.ModelSerializationExtensions.WireOptions, MgmtExtensionResourceContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtExtensionResourceContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtLRO/src/Generated/BarData.Serialization.cs b/test/TestProjects/MgmtLRO/src/Generated/BarData.Serialization.cs index fa2faee611c..188c38de75d 100644 --- a/test/TestProjects/MgmtLRO/src/Generated/BarData.Serialization.cs +++ b/test/TestProjects/MgmtLRO/src/Generated/BarData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -103,7 +107,13 @@ internal static BarData DeserializeBarData(JsonElement element) { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtLRO.ModelSerializationExtensions.WireOptions, MgmtLROContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtLROContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtLRO/src/Generated/FakeData.Serialization.cs b/test/TestProjects/MgmtLRO/src/Generated/FakeData.Serialization.cs index d4d96296053..403bda0653d 100644 --- a/test/TestProjects/MgmtLRO/src/Generated/FakeData.Serialization.cs +++ b/test/TestProjects/MgmtLRO/src/Generated/FakeData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -103,7 +107,13 @@ internal static FakeData DeserializeFakeData(JsonElement element) { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtLRO.ModelSerializationExtensions.WireOptions, MgmtLROContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtLROContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtLRO/src/Generated/LongRunningOperation/MgmtLROArmOperation.cs b/test/TestProjects/MgmtLRO/src/Generated/LongRunningOperation/MgmtLROArmOperation.cs index 4acd99524c6..f948d498e30 100644 --- a/test/TestProjects/MgmtLRO/src/Generated/LongRunningOperation/MgmtLROArmOperation.cs +++ b/test/TestProjects/MgmtLRO/src/Generated/LongRunningOperation/MgmtLROArmOperation.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtLROContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtLROContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtLRO/src/Generated/LongRunningOperation/MgmtLROArmOperationOfT.cs b/test/TestProjects/MgmtLRO/src/Generated/LongRunningOperation/MgmtLROArmOperationOfT.cs index c69357c418a..ae25c63adb5 100644 --- a/test/TestProjects/MgmtLRO/src/Generated/LongRunningOperation/MgmtLROArmOperationOfT.cs +++ b/test/TestProjects/MgmtLRO/src/Generated/LongRunningOperation/MgmtLROArmOperationOfT.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtLROContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtLROContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtListMethods/src/Generated/FakeConfigurationData.Serialization.cs b/test/TestProjects/MgmtListMethods/src/Generated/FakeConfigurationData.Serialization.cs index 4bc95aba363..da71fde294d 100644 --- a/test/TestProjects/MgmtListMethods/src/Generated/FakeConfigurationData.Serialization.cs +++ b/test/TestProjects/MgmtListMethods/src/Generated/FakeConfigurationData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -98,7 +102,13 @@ internal static FakeConfigurationData DeserializeFakeConfigurationData(JsonEleme { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtListMethods.ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtListMethods/src/Generated/FakeData.Serialization.cs b/test/TestProjects/MgmtListMethods/src/Generated/FakeData.Serialization.cs index 82825e6dfca..62a6668ec90 100644 --- a/test/TestProjects/MgmtListMethods/src/Generated/FakeData.Serialization.cs +++ b/test/TestProjects/MgmtListMethods/src/Generated/FakeData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -98,7 +102,13 @@ internal static FakeData DeserializeFakeData(JsonElement element) { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtListMethods.ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtListMethods/src/Generated/FakeParentData.Serialization.cs b/test/TestProjects/MgmtListMethods/src/Generated/FakeParentData.Serialization.cs index 11043602e2b..f63328dead8 100644 --- a/test/TestProjects/MgmtListMethods/src/Generated/FakeParentData.Serialization.cs +++ b/test/TestProjects/MgmtListMethods/src/Generated/FakeParentData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -98,7 +102,13 @@ internal static FakeParentData DeserializeFakeParentData(JsonElement element) { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtListMethods.ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtListMethods/src/Generated/FakeParentWithAncestorData.Serialization.cs b/test/TestProjects/MgmtListMethods/src/Generated/FakeParentWithAncestorData.Serialization.cs index f14adf655ff..0eece823874 100644 --- a/test/TestProjects/MgmtListMethods/src/Generated/FakeParentWithAncestorData.Serialization.cs +++ b/test/TestProjects/MgmtListMethods/src/Generated/FakeParentWithAncestorData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -98,7 +102,13 @@ internal static FakeParentWithAncestorData DeserializeFakeParentWithAncestorData { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtListMethods.ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtListMethods/src/Generated/FakeParentWithAncestorWithLocData.Serialization.cs b/test/TestProjects/MgmtListMethods/src/Generated/FakeParentWithAncestorWithLocData.Serialization.cs index ccf5fc6c0cd..cda91e47869 100644 --- a/test/TestProjects/MgmtListMethods/src/Generated/FakeParentWithAncestorWithLocData.Serialization.cs +++ b/test/TestProjects/MgmtListMethods/src/Generated/FakeParentWithAncestorWithLocData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -98,7 +102,13 @@ internal static FakeParentWithAncestorWithLocData DeserializeFakeParentWithAnces { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtListMethods.ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtListMethods/src/Generated/FakeParentWithAncestorWithNonResChData.Serialization.cs b/test/TestProjects/MgmtListMethods/src/Generated/FakeParentWithAncestorWithNonResChData.Serialization.cs index 54e46a59fb9..31b064bd45a 100644 --- a/test/TestProjects/MgmtListMethods/src/Generated/FakeParentWithAncestorWithNonResChData.Serialization.cs +++ b/test/TestProjects/MgmtListMethods/src/Generated/FakeParentWithAncestorWithNonResChData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -98,7 +102,13 @@ internal static FakeParentWithAncestorWithNonResChData DeserializeFakeParentWith { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtListMethods.ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtListMethods/src/Generated/FakeParentWithAncestorWithNonResChWithLocData.Serialization.cs b/test/TestProjects/MgmtListMethods/src/Generated/FakeParentWithAncestorWithNonResChWithLocData.Serialization.cs index cf183c3a8d2..0a95797b9a3 100644 --- a/test/TestProjects/MgmtListMethods/src/Generated/FakeParentWithAncestorWithNonResChWithLocData.Serialization.cs +++ b/test/TestProjects/MgmtListMethods/src/Generated/FakeParentWithAncestorWithNonResChWithLocData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -98,7 +102,13 @@ internal static FakeParentWithAncestorWithNonResChWithLocData DeserializeFakePar { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtListMethods.ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtListMethods/src/Generated/FakeParentWithNonResChData.Serialization.cs b/test/TestProjects/MgmtListMethods/src/Generated/FakeParentWithNonResChData.Serialization.cs index 84dbb6188b3..cbcc9d09075 100644 --- a/test/TestProjects/MgmtListMethods/src/Generated/FakeParentWithNonResChData.Serialization.cs +++ b/test/TestProjects/MgmtListMethods/src/Generated/FakeParentWithNonResChData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -98,7 +102,13 @@ internal static FakeParentWithNonResChData DeserializeFakeParentWithNonResChData { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtListMethods.ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtListMethods/src/Generated/LongRunningOperation/MgmtListMethodsArmOperationOfT.cs b/test/TestProjects/MgmtListMethods/src/Generated/LongRunningOperation/MgmtListMethodsArmOperationOfT.cs index a29ad3c3e79..26148c35a40 100644 --- a/test/TestProjects/MgmtListMethods/src/Generated/LongRunningOperation/MgmtListMethodsArmOperationOfT.cs +++ b/test/TestProjects/MgmtListMethods/src/Generated/LongRunningOperation/MgmtListMethodsArmOperationOfT.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtListMethodsContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtListMethodsContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtListMethods/src/Generated/MgmtGroupParentData.Serialization.cs b/test/TestProjects/MgmtListMethods/src/Generated/MgmtGroupParentData.Serialization.cs index 2d56eecffc6..643661cf4f6 100644 --- a/test/TestProjects/MgmtListMethods/src/Generated/MgmtGroupParentData.Serialization.cs +++ b/test/TestProjects/MgmtListMethods/src/Generated/MgmtGroupParentData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -98,7 +102,13 @@ internal static MgmtGroupParentData DeserializeMgmtGroupParentData(JsonElement e { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtListMethods.ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtListMethods/src/Generated/MgmtGrpParentWithLocData.Serialization.cs b/test/TestProjects/MgmtListMethods/src/Generated/MgmtGrpParentWithLocData.Serialization.cs index ed5120e4a55..4d70baebbe5 100644 --- a/test/TestProjects/MgmtListMethods/src/Generated/MgmtGrpParentWithLocData.Serialization.cs +++ b/test/TestProjects/MgmtListMethods/src/Generated/MgmtGrpParentWithLocData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -98,7 +102,13 @@ internal static MgmtGrpParentWithLocData DeserializeMgmtGrpParentWithLocData(Jso { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtListMethods.ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtListMethods/src/Generated/MgmtGrpParentWithNonResChData.Serialization.cs b/test/TestProjects/MgmtListMethods/src/Generated/MgmtGrpParentWithNonResChData.Serialization.cs index 1a208ebde13..645fed2c45d 100644 --- a/test/TestProjects/MgmtListMethods/src/Generated/MgmtGrpParentWithNonResChData.Serialization.cs +++ b/test/TestProjects/MgmtListMethods/src/Generated/MgmtGrpParentWithNonResChData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -98,7 +102,13 @@ internal static MgmtGrpParentWithNonResChData DeserializeMgmtGrpParentWithNonRes { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtListMethods.ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtListMethods/src/Generated/MgmtGrpParentWithNonResChWithLocData.Serialization.cs b/test/TestProjects/MgmtListMethods/src/Generated/MgmtGrpParentWithNonResChWithLocData.Serialization.cs index a2ad523857d..b2b444cc0d9 100644 --- a/test/TestProjects/MgmtListMethods/src/Generated/MgmtGrpParentWithNonResChWithLocData.Serialization.cs +++ b/test/TestProjects/MgmtListMethods/src/Generated/MgmtGrpParentWithNonResChWithLocData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -98,7 +102,13 @@ internal static MgmtGrpParentWithNonResChWithLocData DeserializeMgmtGrpParentWit { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtListMethods.ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtListMethods/src/Generated/ResGrpParentData.Serialization.cs b/test/TestProjects/MgmtListMethods/src/Generated/ResGrpParentData.Serialization.cs index a16970244f9..232d5118696 100644 --- a/test/TestProjects/MgmtListMethods/src/Generated/ResGrpParentData.Serialization.cs +++ b/test/TestProjects/MgmtListMethods/src/Generated/ResGrpParentData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -98,7 +102,13 @@ internal static ResGrpParentData DeserializeResGrpParentData(JsonElement element { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtListMethods.ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtListMethods/src/Generated/ResGrpParentWithAncestorData.Serialization.cs b/test/TestProjects/MgmtListMethods/src/Generated/ResGrpParentWithAncestorData.Serialization.cs index c6e1825c88b..629ba03c175 100644 --- a/test/TestProjects/MgmtListMethods/src/Generated/ResGrpParentWithAncestorData.Serialization.cs +++ b/test/TestProjects/MgmtListMethods/src/Generated/ResGrpParentWithAncestorData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -98,7 +102,13 @@ internal static ResGrpParentWithAncestorData DeserializeResGrpParentWithAncestor { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtListMethods.ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtListMethods/src/Generated/ResGrpParentWithAncestorWithLocData.Serialization.cs b/test/TestProjects/MgmtListMethods/src/Generated/ResGrpParentWithAncestorWithLocData.Serialization.cs index d57551ba0cd..9b79428ca79 100644 --- a/test/TestProjects/MgmtListMethods/src/Generated/ResGrpParentWithAncestorWithLocData.Serialization.cs +++ b/test/TestProjects/MgmtListMethods/src/Generated/ResGrpParentWithAncestorWithLocData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -98,7 +102,13 @@ internal static ResGrpParentWithAncestorWithLocData DeserializeResGrpParentWithA { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtListMethods.ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtListMethods/src/Generated/ResGrpParentWithAncestorWithNonResChData.Serialization.cs b/test/TestProjects/MgmtListMethods/src/Generated/ResGrpParentWithAncestorWithNonResChData.Serialization.cs index 7617626c177..2e1938ecdd0 100644 --- a/test/TestProjects/MgmtListMethods/src/Generated/ResGrpParentWithAncestorWithNonResChData.Serialization.cs +++ b/test/TestProjects/MgmtListMethods/src/Generated/ResGrpParentWithAncestorWithNonResChData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -98,7 +102,13 @@ internal static ResGrpParentWithAncestorWithNonResChData DeserializeResGrpParent { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtListMethods.ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtListMethods/src/Generated/ResGrpParentWithAncestorWithNonResChWithLocData.Serialization.cs b/test/TestProjects/MgmtListMethods/src/Generated/ResGrpParentWithAncestorWithNonResChWithLocData.Serialization.cs index 01f14f401f8..e33e8912020 100644 --- a/test/TestProjects/MgmtListMethods/src/Generated/ResGrpParentWithAncestorWithNonResChWithLocData.Serialization.cs +++ b/test/TestProjects/MgmtListMethods/src/Generated/ResGrpParentWithAncestorWithNonResChWithLocData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -98,7 +102,13 @@ internal static ResGrpParentWithAncestorWithNonResChWithLocData DeserializeResGr { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtListMethods.ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtListMethods/src/Generated/ResGrpParentWithNonResChData.Serialization.cs b/test/TestProjects/MgmtListMethods/src/Generated/ResGrpParentWithNonResChData.Serialization.cs index 1524c620f0a..14767c12dc2 100644 --- a/test/TestProjects/MgmtListMethods/src/Generated/ResGrpParentWithNonResChData.Serialization.cs +++ b/test/TestProjects/MgmtListMethods/src/Generated/ResGrpParentWithNonResChData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -98,7 +102,13 @@ internal static ResGrpParentWithNonResChData DeserializeResGrpParentWithNonResCh { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtListMethods.ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtListMethods/src/Generated/SubParentData.Serialization.cs b/test/TestProjects/MgmtListMethods/src/Generated/SubParentData.Serialization.cs index 4fa2a8c18f5..2e038baf736 100644 --- a/test/TestProjects/MgmtListMethods/src/Generated/SubParentData.Serialization.cs +++ b/test/TestProjects/MgmtListMethods/src/Generated/SubParentData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -98,7 +102,13 @@ internal static SubParentData DeserializeSubParentData(JsonElement element) { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtListMethods.ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtListMethods/src/Generated/SubParentWithLocData.Serialization.cs b/test/TestProjects/MgmtListMethods/src/Generated/SubParentWithLocData.Serialization.cs index 49a0ebabd83..18ad7844e15 100644 --- a/test/TestProjects/MgmtListMethods/src/Generated/SubParentWithLocData.Serialization.cs +++ b/test/TestProjects/MgmtListMethods/src/Generated/SubParentWithLocData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -98,7 +102,13 @@ internal static SubParentWithLocData DeserializeSubParentWithLocData(JsonElement { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtListMethods.ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtListMethods/src/Generated/SubParentWithNonResChData.Serialization.cs b/test/TestProjects/MgmtListMethods/src/Generated/SubParentWithNonResChData.Serialization.cs index 5d367d56776..d27126573e7 100644 --- a/test/TestProjects/MgmtListMethods/src/Generated/SubParentWithNonResChData.Serialization.cs +++ b/test/TestProjects/MgmtListMethods/src/Generated/SubParentWithNonResChData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -98,7 +102,13 @@ internal static SubParentWithNonResChData DeserializeSubParentWithNonResChData(J { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtListMethods.ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtListMethods/src/Generated/SubParentWithNonResChWithLocData.Serialization.cs b/test/TestProjects/MgmtListMethods/src/Generated/SubParentWithNonResChWithLocData.Serialization.cs index 04ea8abef3a..39d249ceac0 100644 --- a/test/TestProjects/MgmtListMethods/src/Generated/SubParentWithNonResChWithLocData.Serialization.cs +++ b/test/TestProjects/MgmtListMethods/src/Generated/SubParentWithNonResChWithLocData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -98,7 +102,13 @@ internal static SubParentWithNonResChWithLocData DeserializeSubParentWithNonResC { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtListMethods.ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtListMethods/src/Generated/TenantParentData.Serialization.cs b/test/TestProjects/MgmtListMethods/src/Generated/TenantParentData.Serialization.cs index 2b627c3101e..edcf0a1db01 100644 --- a/test/TestProjects/MgmtListMethods/src/Generated/TenantParentData.Serialization.cs +++ b/test/TestProjects/MgmtListMethods/src/Generated/TenantParentData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -98,7 +102,13 @@ internal static TenantParentData DeserializeTenantParentData(JsonElement element { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtListMethods.ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtListMethods/src/Generated/TenantParentWithLocData.Serialization.cs b/test/TestProjects/MgmtListMethods/src/Generated/TenantParentWithLocData.Serialization.cs index a2ce998d25f..f18e257657c 100644 --- a/test/TestProjects/MgmtListMethods/src/Generated/TenantParentWithLocData.Serialization.cs +++ b/test/TestProjects/MgmtListMethods/src/Generated/TenantParentWithLocData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -98,7 +102,13 @@ internal static TenantParentWithLocData DeserializeTenantParentWithLocData(JsonE { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtListMethods.ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtListMethods/src/Generated/TenantParentWithNonResChData.Serialization.cs b/test/TestProjects/MgmtListMethods/src/Generated/TenantParentWithNonResChData.Serialization.cs index 97ccf8f01d0..9c134665545 100644 --- a/test/TestProjects/MgmtListMethods/src/Generated/TenantParentWithNonResChData.Serialization.cs +++ b/test/TestProjects/MgmtListMethods/src/Generated/TenantParentWithNonResChData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -98,7 +102,13 @@ internal static TenantParentWithNonResChData DeserializeTenantParentWithNonResCh { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtListMethods.ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtListMethods/src/Generated/TenantParentWithNonResChWithLocData.Serialization.cs b/test/TestProjects/MgmtListMethods/src/Generated/TenantParentWithNonResChWithLocData.Serialization.cs index 41c5cce0d78..da7c8b7c774 100644 --- a/test/TestProjects/MgmtListMethods/src/Generated/TenantParentWithNonResChWithLocData.Serialization.cs +++ b/test/TestProjects/MgmtListMethods/src/Generated/TenantParentWithNonResChWithLocData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -98,7 +102,13 @@ internal static TenantParentWithNonResChWithLocData DeserializeTenantParentWithN { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtListMethods.ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtListMethods/src/Generated/TenantTestData.Serialization.cs b/test/TestProjects/MgmtListMethods/src/Generated/TenantTestData.Serialization.cs index 2d4e4d00ba0..cd0141092ce 100644 --- a/test/TestProjects/MgmtListMethods/src/Generated/TenantTestData.Serialization.cs +++ b/test/TestProjects/MgmtListMethods/src/Generated/TenantTestData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -98,7 +102,13 @@ internal static TenantTestData DeserializeTenantTestData(JsonElement element) { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtListMethods.ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtListMethodsContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtMockAndSample/src/Generated/DeletedManagedHsmData.Serialization.cs b/test/TestProjects/MgmtMockAndSample/src/Generated/DeletedManagedHsmData.Serialization.cs index 329e3df909d..eb726baea1a 100644 --- a/test/TestProjects/MgmtMockAndSample/src/Generated/DeletedManagedHsmData.Serialization.cs +++ b/test/TestProjects/MgmtMockAndSample/src/Generated/DeletedManagedHsmData.Serialization.cs @@ -5,6 +5,10 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -57,7 +61,13 @@ internal static DeletedManagedHsmData DeserializeDeletedManagedHsmData(JsonEleme { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtMockAndSample.ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtMockAndSample/src/Generated/DeletedVaultData.Serialization.cs b/test/TestProjects/MgmtMockAndSample/src/Generated/DeletedVaultData.Serialization.cs index 3e495aa1cac..31f043c6287 100644 --- a/test/TestProjects/MgmtMockAndSample/src/Generated/DeletedVaultData.Serialization.cs +++ b/test/TestProjects/MgmtMockAndSample/src/Generated/DeletedVaultData.Serialization.cs @@ -5,6 +5,10 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -57,7 +61,13 @@ internal static DeletedVaultData DeserializeDeletedVaultData(JsonElement element { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtMockAndSample.ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtMockAndSample/src/Generated/DiskEncryptionSetData.Serialization.cs b/test/TestProjects/MgmtMockAndSample/src/Generated/DiskEncryptionSetData.Serialization.cs index a645f680149..361d6cc65fe 100644 --- a/test/TestProjects/MgmtMockAndSample/src/Generated/DiskEncryptionSetData.Serialization.cs +++ b/test/TestProjects/MgmtMockAndSample/src/Generated/DiskEncryptionSetData.Serialization.cs @@ -6,7 +6,10 @@ #nullable disable using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -22,8 +25,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(Identity)) { writer.WritePropertyName("identity"u8); - var serializeOptions = new JsonSerializerOptions { Converters = { new ManagedServiceIdentityTypeV3Converter() } }; - JsonSerializer.Serialize(writer, Identity, serializeOptions); + ((IJsonModel)Identity).Write(writer, new ModelReaderWriterOptions("W|v3")); } writer.WritePropertyName("properties"u8); writer.WriteStartObject(); @@ -85,8 +87,13 @@ internal static DiskEncryptionSetData DeserializeDiskEncryptionSetData(JsonEleme { continue; } - var serializeOptions = new JsonSerializerOptions { Converters = { new ManagedServiceIdentityTypeV3Converter() } }; - identity = JsonSerializer.Deserialize(property.Value.GetRawText(), serializeOptions); + identity = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), new global::System.ClientModel.Primitives.ModelReaderWriterOptions("W|v3"), MgmtMockAndSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), new ModelReaderWriterOptions("W|v3"), MgmtMockAndSampleContext.Default) +#endif +; continue; } if (property.NameEquals("location"u8)) @@ -133,7 +140,13 @@ internal static DiskEncryptionSetData DeserializeDiskEncryptionSetData(JsonEleme { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtMockAndSample.ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) diff --git a/test/TestProjects/MgmtMockAndSample/src/Generated/FirewallPolicyData.Serialization.cs b/test/TestProjects/MgmtMockAndSample/src/Generated/FirewallPolicyData.Serialization.cs index b59f5ed23fc..2efa840cb07 100644 --- a/test/TestProjects/MgmtMockAndSample/src/Generated/FirewallPolicyData.Serialization.cs +++ b/test/TestProjects/MgmtMockAndSample/src/Generated/FirewallPolicyData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -22,8 +26,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(Identity)) { writer.WritePropertyName("identity"u8); - var serializeOptions = new JsonSerializerOptions { Converters = { new ManagedServiceIdentityTypeV3Converter() } }; - JsonSerializer.Serialize(writer, Identity, serializeOptions); + ((IJsonModel)Identity).Write(writer, new ModelReaderWriterOptions("W|v3")); } if (Optional.IsCollectionDefined(Tags)) { @@ -58,7 +61,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(BasePolicy)) { writer.WritePropertyName("basePolicy"u8); - JsonSerializer.Serialize(writer, BasePolicy); + ((IJsonModel)BasePolicy).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsDefined(ThreatIntelWhitelist)) { @@ -163,8 +166,13 @@ internal static FirewallPolicyData DeserializeFirewallPolicyData(JsonElement ele { continue; } - var serializeOptions = new JsonSerializerOptions { Converters = { new ManagedServiceIdentityTypeV3Converter() } }; - identity = JsonSerializer.Deserialize(property.Value.GetRawText(), serializeOptions); + identity = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), new global::System.ClientModel.Primitives.ModelReaderWriterOptions("W|v3"), MgmtMockAndSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), new ModelReaderWriterOptions("W|v3"), MgmtMockAndSampleContext.Default) +#endif +; continue; } if (property.NameEquals("tags"u8)) @@ -207,7 +215,13 @@ internal static FirewallPolicyData DeserializeFirewallPolicyData(JsonElement ele { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtMockAndSample.ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) @@ -255,7 +269,13 @@ internal static FirewallPolicyData DeserializeFirewallPolicyData(JsonElement ele List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(JsonSerializer.Deserialize(item.GetRawText())); + array.Add( +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(item).ToArray()), global::MgmtMockAndSample.ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(item.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#endif +); } ruleCollectionGroups = array; continue; @@ -275,7 +295,13 @@ internal static FirewallPolicyData DeserializeFirewallPolicyData(JsonElement ele { continue; } - basePolicy = JsonSerializer.Deserialize(property0.Value.GetRawText()); + basePolicy = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property0.Value).ToArray()), global::MgmtMockAndSample.ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#endif +; continue; } if (property0.NameEquals("firewalls"u8)) @@ -287,7 +313,13 @@ internal static FirewallPolicyData DeserializeFirewallPolicyData(JsonElement ele List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(JsonSerializer.Deserialize(item.GetRawText())); + array.Add( +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(item).ToArray()), global::MgmtMockAndSample.ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(item.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#endif +); } firewalls = array; continue; @@ -301,7 +333,13 @@ internal static FirewallPolicyData DeserializeFirewallPolicyData(JsonElement ele List array = new List(); foreach (var item in property0.Value.EnumerateArray()) { - array.Add(JsonSerializer.Deserialize(item.GetRawText())); + array.Add( +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(item).ToArray()), global::MgmtMockAndSample.ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(item.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#endif +); } childPolicies = array; continue; diff --git a/test/TestProjects/MgmtMockAndSample/src/Generated/LongRunningOperation/MgmtMockAndSampleArmOperation.cs b/test/TestProjects/MgmtMockAndSample/src/Generated/LongRunningOperation/MgmtMockAndSampleArmOperation.cs index b130604d8b6..db778991242 100644 --- a/test/TestProjects/MgmtMockAndSample/src/Generated/LongRunningOperation/MgmtMockAndSampleArmOperation.cs +++ b/test/TestProjects/MgmtMockAndSample/src/Generated/LongRunningOperation/MgmtMockAndSampleArmOperation.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtMockAndSampleContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtMockAndSampleContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtMockAndSample/src/Generated/LongRunningOperation/MgmtMockAndSampleArmOperationOfT.cs b/test/TestProjects/MgmtMockAndSample/src/Generated/LongRunningOperation/MgmtMockAndSampleArmOperationOfT.cs index 5b185566893..81d88dacaca 100644 --- a/test/TestProjects/MgmtMockAndSample/src/Generated/LongRunningOperation/MgmtMockAndSampleArmOperationOfT.cs +++ b/test/TestProjects/MgmtMockAndSample/src/Generated/LongRunningOperation/MgmtMockAndSampleArmOperationOfT.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtMockAndSampleContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtMockAndSampleContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtMockAndSample/src/Generated/ManagedHsmData.Serialization.cs b/test/TestProjects/MgmtMockAndSample/src/Generated/ManagedHsmData.Serialization.cs index 190575d9141..dcbcfb32570 100644 --- a/test/TestProjects/MgmtMockAndSample/src/Generated/ManagedHsmData.Serialization.cs +++ b/test/TestProjects/MgmtMockAndSample/src/Generated/ManagedHsmData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -118,7 +122,13 @@ internal static ManagedHsmData DeserializeManagedHsmData(JsonElement element) { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtMockAndSample.ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtMockAndSample/src/Generated/MgmtMockAndSamplePrivateEndpointConnectionData.Serialization.cs b/test/TestProjects/MgmtMockAndSample/src/Generated/MgmtMockAndSamplePrivateEndpointConnectionData.Serialization.cs index 8b911afe3fb..f69461dd037 100644 --- a/test/TestProjects/MgmtMockAndSample/src/Generated/MgmtMockAndSamplePrivateEndpointConnectionData.Serialization.cs +++ b/test/TestProjects/MgmtMockAndSample/src/Generated/MgmtMockAndSamplePrivateEndpointConnectionData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -29,7 +33,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(PrivateEndpoint)) { writer.WritePropertyName("privateEndpoint"u8); - JsonSerializer.Serialize(writer, PrivateEndpoint); + ((IJsonModel)PrivateEndpoint).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsDefined(ConnectionState)) { @@ -112,7 +116,13 @@ internal static MgmtMockAndSamplePrivateEndpointConnectionData DeserializeMgmtMo { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtMockAndSample.ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) @@ -130,7 +140,13 @@ internal static MgmtMockAndSamplePrivateEndpointConnectionData DeserializeMgmtMo { continue; } - privateEndpoint = JsonSerializer.Deserialize(property0.Value.GetRawText()); + privateEndpoint = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property0.Value).ToArray()), global::MgmtMockAndSample.ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#endif +; continue; } if (property0.NameEquals("privateLinkServiceConnectionState"u8)) diff --git a/test/TestProjects/MgmtMockAndSample/src/Generated/MhsmPrivateEndpointConnectionData.Serialization.cs b/test/TestProjects/MgmtMockAndSample/src/Generated/MhsmPrivateEndpointConnectionData.Serialization.cs index 668b849c995..f12c23abde1 100644 --- a/test/TestProjects/MgmtMockAndSample/src/Generated/MhsmPrivateEndpointConnectionData.Serialization.cs +++ b/test/TestProjects/MgmtMockAndSample/src/Generated/MhsmPrivateEndpointConnectionData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -47,7 +51,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(PrivateEndpoint)) { writer.WritePropertyName("privateEndpoint"u8); - JsonSerializer.Serialize(writer, PrivateEndpoint); + ((IJsonModel)PrivateEndpoint).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsDefined(PrivateLinkServiceConnectionState)) { @@ -136,7 +140,13 @@ internal static MhsmPrivateEndpointConnectionData DeserializeMhsmPrivateEndpoint { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtMockAndSample.ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) @@ -154,7 +164,13 @@ internal static MhsmPrivateEndpointConnectionData DeserializeMhsmPrivateEndpoint { continue; } - privateEndpoint = JsonSerializer.Deserialize(property0.Value.GetRawText()); + privateEndpoint = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property0.Value).ToArray()), global::MgmtMockAndSample.ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#endif +; continue; } if (property0.NameEquals("privateLinkServiceConnectionState"u8)) diff --git a/test/TestProjects/MgmtMockAndSample/src/Generated/Models/DiskEncryptionSetPatch.Serialization.cs b/test/TestProjects/MgmtMockAndSample/src/Generated/Models/DiskEncryptionSetPatch.Serialization.cs index b2db5c2050d..da7cd6554f8 100644 --- a/test/TestProjects/MgmtMockAndSample/src/Generated/Models/DiskEncryptionSetPatch.Serialization.cs +++ b/test/TestProjects/MgmtMockAndSample/src/Generated/Models/DiskEncryptionSetPatch.Serialization.cs @@ -5,6 +5,7 @@ #nullable disable +using System.ClientModel.Primitives; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -30,8 +31,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(Identity)) { writer.WritePropertyName("identity"u8); - var serializeOptions = new JsonSerializerOptions { Converters = { new ManagedServiceIdentityTypeV3Converter() } }; - JsonSerializer.Serialize(writer, Identity, serializeOptions); + ((IJsonModel)Identity).Write(writer, new ModelReaderWriterOptions("W|v3")); } writer.WritePropertyName("properties"u8); writer.WriteStartObject(); diff --git a/test/TestProjects/MgmtMockAndSample/src/Generated/Models/FirewallPolicyLogAnalyticsResources.Serialization.cs b/test/TestProjects/MgmtMockAndSample/src/Generated/Models/FirewallPolicyLogAnalyticsResources.Serialization.cs index 736051ff9c5..8f6389aeb07 100644 --- a/test/TestProjects/MgmtMockAndSample/src/Generated/Models/FirewallPolicyLogAnalyticsResources.Serialization.cs +++ b/test/TestProjects/MgmtMockAndSample/src/Generated/Models/FirewallPolicyLogAnalyticsResources.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Resources.Models; @@ -30,7 +34,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(DefaultWorkspaceId)) { writer.WritePropertyName("defaultWorkspaceId"u8); - JsonSerializer.Serialize(writer, DefaultWorkspaceId); + ((IJsonModel)DefaultWorkspaceId).Write(writer, ModelSerializationExtensions.WireOptions); } writer.WriteEndObject(); } @@ -65,7 +69,13 @@ internal static FirewallPolicyLogAnalyticsResources DeserializeFirewallPolicyLog { continue; } - defaultWorkspaceId = JsonSerializer.Deserialize(property.Value.GetRawText()); + defaultWorkspaceId = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtMockAndSample.ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtMockAndSample/src/Generated/Models/FirewallPolicyLogAnalyticsWorkspace.Serialization.cs b/test/TestProjects/MgmtMockAndSample/src/Generated/Models/FirewallPolicyLogAnalyticsWorkspace.Serialization.cs index d38b345ed2e..58adec27e71 100644 --- a/test/TestProjects/MgmtMockAndSample/src/Generated/Models/FirewallPolicyLogAnalyticsWorkspace.Serialization.cs +++ b/test/TestProjects/MgmtMockAndSample/src/Generated/Models/FirewallPolicyLogAnalyticsWorkspace.Serialization.cs @@ -5,6 +5,10 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Resources.Models; @@ -24,7 +28,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(WorkspaceId)) { writer.WritePropertyName("workspaceId"u8); - JsonSerializer.Serialize(writer, WorkspaceId); + ((IJsonModel)WorkspaceId).Write(writer, ModelSerializationExtensions.WireOptions); } writer.WriteEndObject(); } @@ -50,7 +54,13 @@ internal static FirewallPolicyLogAnalyticsWorkspace DeserializeFirewallPolicyLog { continue; } - workspaceId = JsonSerializer.Deserialize(property.Value.GetRawText()); + workspaceId = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtMockAndSample.ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtMockAndSample/src/Generated/Models/KeyForDiskEncryptionSet.Serialization.cs b/test/TestProjects/MgmtMockAndSample/src/Generated/Models/KeyForDiskEncryptionSet.Serialization.cs index f54f0b2b31a..1a111574b55 100644 --- a/test/TestProjects/MgmtMockAndSample/src/Generated/Models/KeyForDiskEncryptionSet.Serialization.cs +++ b/test/TestProjects/MgmtMockAndSample/src/Generated/Models/KeyForDiskEncryptionSet.Serialization.cs @@ -6,7 +6,10 @@ #nullable disable using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Resources.Models; @@ -21,7 +24,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(SourceVault)) { writer.WritePropertyName("sourceVault"u8); - JsonSerializer.Serialize(writer, SourceVault); + ((IJsonModel)SourceVault).Write(writer, ModelSerializationExtensions.WireOptions); } writer.WritePropertyName("keyUrl"u8); writer.WriteStringValue(KeyUri.AbsoluteUri); @@ -62,7 +65,13 @@ internal static KeyForDiskEncryptionSet DeserializeKeyForDiskEncryptionSet(JsonE { continue; } - sourceVault = JsonSerializer.Deserialize(property.Value.GetRawText()); + sourceVault = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtMockAndSample.ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#endif +; continue; } if (property.NameEquals("keyUrl"u8)) diff --git a/test/TestProjects/MgmtMockAndSample/src/Generated/Models/MgmtMockAndSamplePrivateLinkResource.Serialization.cs b/test/TestProjects/MgmtMockAndSample/src/Generated/Models/MgmtMockAndSamplePrivateLinkResource.Serialization.cs index c495b8e805b..69a2fead965 100644 --- a/test/TestProjects/MgmtMockAndSample/src/Generated/Models/MgmtMockAndSamplePrivateLinkResource.Serialization.cs +++ b/test/TestProjects/MgmtMockAndSample/src/Generated/Models/MgmtMockAndSamplePrivateLinkResource.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -94,7 +98,13 @@ internal static MgmtMockAndSamplePrivateLinkResource DeserializeMgmtMockAndSampl { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtMockAndSample.ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) diff --git a/test/TestProjects/MgmtMockAndSample/src/Generated/Models/MhsmNetworkRuleSet.Serialization.cs b/test/TestProjects/MgmtMockAndSample/src/Generated/Models/MhsmNetworkRuleSet.Serialization.cs index c89eb2415ec..0a076bdb775 100644 --- a/test/TestProjects/MgmtMockAndSample/src/Generated/Models/MhsmNetworkRuleSet.Serialization.cs +++ b/test/TestProjects/MgmtMockAndSample/src/Generated/Models/MhsmNetworkRuleSet.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Resources.Models; @@ -43,7 +47,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) writer.WriteStartArray(); foreach (var item in VirtualNetworkRules) { - JsonSerializer.Serialize(writer, item); + ((IJsonModel)item).Write(writer, ModelSerializationExtensions.WireOptions); } writer.WriteEndArray(); } @@ -103,7 +107,13 @@ internal static MhsmNetworkRuleSet DeserializeMhsmNetworkRuleSet(JsonElement ele List array = new List(); foreach (var item in property.Value.EnumerateArray()) { - array.Add(JsonSerializer.Deserialize(item.GetRawText())); + array.Add( +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(item).ToArray()), global::MgmtMockAndSample.ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(item.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#endif +); } virtualNetworkRules = array; continue; diff --git a/test/TestProjects/MgmtMockAndSample/src/Generated/Models/MhsmPrivateEndpointConnectionItem.Serialization.cs b/test/TestProjects/MgmtMockAndSample/src/Generated/Models/MhsmPrivateEndpointConnectionItem.Serialization.cs index 1b8d5f4e3fd..bfa90cca9c9 100644 --- a/test/TestProjects/MgmtMockAndSample/src/Generated/Models/MhsmPrivateEndpointConnectionItem.Serialization.cs +++ b/test/TestProjects/MgmtMockAndSample/src/Generated/Models/MhsmPrivateEndpointConnectionItem.Serialization.cs @@ -5,6 +5,10 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.ResourceManager.Resources.Models; @@ -38,7 +42,13 @@ internal static MhsmPrivateEndpointConnectionItem DeserializeMhsmPrivateEndpoint { continue; } - privateEndpoint = JsonSerializer.Deserialize(property0.Value.GetRawText()); + privateEndpoint = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property0.Value).ToArray()), global::MgmtMockAndSample.ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#endif +; continue; } if (property0.NameEquals("privateLinkServiceConnectionState"u8)) diff --git a/test/TestProjects/MgmtMockAndSample/src/Generated/Models/MhsmPrivateLinkResource.Serialization.cs b/test/TestProjects/MgmtMockAndSample/src/Generated/Models/MhsmPrivateLinkResource.Serialization.cs index cdf6d5efbd2..555f8d6c945 100644 --- a/test/TestProjects/MgmtMockAndSample/src/Generated/Models/MhsmPrivateLinkResource.Serialization.cs +++ b/test/TestProjects/MgmtMockAndSample/src/Generated/Models/MhsmPrivateLinkResource.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -118,7 +122,13 @@ internal static MhsmPrivateLinkResource DeserializeMhsmPrivateLinkResource(JsonE { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtMockAndSample.ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) diff --git a/test/TestProjects/MgmtMockAndSample/src/Generated/Models/PrivateEndpointConnectionItem.Serialization.cs b/test/TestProjects/MgmtMockAndSample/src/Generated/Models/PrivateEndpointConnectionItem.Serialization.cs index 2f9e3f93d40..ec1ef12d0d7 100644 --- a/test/TestProjects/MgmtMockAndSample/src/Generated/Models/PrivateEndpointConnectionItem.Serialization.cs +++ b/test/TestProjects/MgmtMockAndSample/src/Generated/Models/PrivateEndpointConnectionItem.Serialization.cs @@ -5,6 +5,10 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.ResourceManager.Resources.Models; @@ -50,7 +54,13 @@ internal static PrivateEndpointConnectionItem DeserializePrivateEndpointConnecti { continue; } - privateEndpoint = JsonSerializer.Deserialize(property0.Value.GetRawText()); + privateEndpoint = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property0.Value).ToArray()), global::MgmtMockAndSample.ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#endif +; continue; } if (property0.NameEquals("privateLinkServiceConnectionState"u8)) diff --git a/test/TestProjects/MgmtMockAndSample/src/Generated/Models/VaultAccessPolicyParameters.Serialization.cs b/test/TestProjects/MgmtMockAndSample/src/Generated/Models/VaultAccessPolicyParameters.Serialization.cs index 3f3d436121f..22876245bd0 100644 --- a/test/TestProjects/MgmtMockAndSample/src/Generated/Models/VaultAccessPolicyParameters.Serialization.cs +++ b/test/TestProjects/MgmtMockAndSample/src/Generated/Models/VaultAccessPolicyParameters.Serialization.cs @@ -5,6 +5,10 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -70,7 +74,13 @@ internal static VaultAccessPolicyParameters DeserializeVaultAccessPolicyParamete { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtMockAndSample.ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtMockAndSample/src/Generated/Models/VaultCreateOrUpdateContent.Serialization.cs b/test/TestProjects/MgmtMockAndSample/src/Generated/Models/VaultCreateOrUpdateContent.Serialization.cs index aa272d0463a..911198be547 100644 --- a/test/TestProjects/MgmtMockAndSample/src/Generated/Models/VaultCreateOrUpdateContent.Serialization.cs +++ b/test/TestProjects/MgmtMockAndSample/src/Generated/Models/VaultCreateOrUpdateContent.Serialization.cs @@ -5,6 +5,7 @@ #nullable disable +using System.ClientModel.Primitives; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -34,8 +35,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(Identity)) { writer.WritePropertyName("identity"u8); - var serializeOptions = new JsonSerializerOptions { Converters = { new ManagedServiceIdentityTypeV3Converter() } }; - JsonSerializer.Serialize(writer, Identity, serializeOptions); + ((IJsonModel)Identity).Write(writer, new ModelReaderWriterOptions("W|v3")); } writer.WriteEndObject(); } diff --git a/test/TestProjects/MgmtMockAndSample/src/Generated/RoleAssignmentData.Serialization.cs b/test/TestProjects/MgmtMockAndSample/src/Generated/RoleAssignmentData.Serialization.cs index 966e1263941..9c6022c35df 100644 --- a/test/TestProjects/MgmtMockAndSample/src/Generated/RoleAssignmentData.Serialization.cs +++ b/test/TestProjects/MgmtMockAndSample/src/Generated/RoleAssignmentData.Serialization.cs @@ -5,6 +5,10 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -50,7 +54,13 @@ internal static RoleAssignmentData DeserializeRoleAssignmentData(JsonElement ele { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtMockAndSample.ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) diff --git a/test/TestProjects/MgmtMockAndSample/src/Generated/VaultData.Serialization.cs b/test/TestProjects/MgmtMockAndSample/src/Generated/VaultData.Serialization.cs index 73e28964b9a..e990f799f0c 100644 --- a/test/TestProjects/MgmtMockAndSample/src/Generated/VaultData.Serialization.cs +++ b/test/TestProjects/MgmtMockAndSample/src/Generated/VaultData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -65,8 +69,13 @@ internal static VaultData DeserializeVaultData(JsonElement element) { continue; } - var serializeOptions = new JsonSerializerOptions { Converters = { new ManagedServiceIdentityTypeV3Converter() } }; - identity = JsonSerializer.Deserialize(property.Value.GetRawText(), serializeOptions); + identity = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), new global::System.ClientModel.Primitives.ModelReaderWriterOptions("W|v3"), MgmtMockAndSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), new ModelReaderWriterOptions("W|v3"), MgmtMockAndSampleContext.Default) +#endif +; continue; } if (property.NameEquals("id"u8)) @@ -90,7 +99,13 @@ internal static VaultData DeserializeVaultData(JsonElement element) { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtMockAndSample.ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtMockAndSample/src/Generated/VirtualMachineExtensionImageData.Serialization.cs b/test/TestProjects/MgmtMockAndSample/src/Generated/VirtualMachineExtensionImageData.Serialization.cs index a2621f66339..08903991fe8 100644 --- a/test/TestProjects/MgmtMockAndSample/src/Generated/VirtualMachineExtensionImageData.Serialization.cs +++ b/test/TestProjects/MgmtMockAndSample/src/Generated/VirtualMachineExtensionImageData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -111,7 +115,13 @@ internal static VirtualMachineExtensionImageData DeserializeVirtualMachineExtens { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtMockAndSample.ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtMockAndSampleContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) diff --git a/test/TestProjects/MgmtMultipleParentResource/src/Generated/AnotherParentData.Serialization.cs b/test/TestProjects/MgmtMultipleParentResource/src/Generated/AnotherParentData.Serialization.cs index c99fd772b78..480822ad7e9 100644 --- a/test/TestProjects/MgmtMultipleParentResource/src/Generated/AnotherParentData.Serialization.cs +++ b/test/TestProjects/MgmtMultipleParentResource/src/Generated/AnotherParentData.Serialization.cs @@ -6,7 +6,10 @@ #nullable disable using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -128,7 +131,13 @@ internal static AnotherParentData DeserializeAnotherParentData(JsonElement eleme { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtMultipleParentResource.ModelSerializationExtensions.WireOptions, MgmtMultipleParentResourceContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtMultipleParentResourceContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) diff --git a/test/TestProjects/MgmtMultipleParentResource/src/Generated/ChildBodyData.Serialization.cs b/test/TestProjects/MgmtMultipleParentResource/src/Generated/ChildBodyData.Serialization.cs index cc61e0dc710..da46524b4b4 100644 --- a/test/TestProjects/MgmtMultipleParentResource/src/Generated/ChildBodyData.Serialization.cs +++ b/test/TestProjects/MgmtMultipleParentResource/src/Generated/ChildBodyData.Serialization.cs @@ -6,7 +6,10 @@ #nullable disable using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -128,7 +131,13 @@ internal static ChildBodyData DeserializeChildBodyData(JsonElement element) { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtMultipleParentResource.ModelSerializationExtensions.WireOptions, MgmtMultipleParentResourceContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtMultipleParentResourceContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) diff --git a/test/TestProjects/MgmtMultipleParentResource/src/Generated/LongRunningOperation/MgmtMultipleParentResourceArmOperation.cs b/test/TestProjects/MgmtMultipleParentResource/src/Generated/LongRunningOperation/MgmtMultipleParentResourceArmOperation.cs index d6ad718a923..ccb2edb42ba 100644 --- a/test/TestProjects/MgmtMultipleParentResource/src/Generated/LongRunningOperation/MgmtMultipleParentResourceArmOperation.cs +++ b/test/TestProjects/MgmtMultipleParentResource/src/Generated/LongRunningOperation/MgmtMultipleParentResourceArmOperation.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtMultipleParentResourceContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtMultipleParentResourceContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtMultipleParentResource/src/Generated/LongRunningOperation/MgmtMultipleParentResourceArmOperationOfT.cs b/test/TestProjects/MgmtMultipleParentResource/src/Generated/LongRunningOperation/MgmtMultipleParentResourceArmOperationOfT.cs index eb7629c4b72..62bd23c829c 100644 --- a/test/TestProjects/MgmtMultipleParentResource/src/Generated/LongRunningOperation/MgmtMultipleParentResourceArmOperationOfT.cs +++ b/test/TestProjects/MgmtMultipleParentResource/src/Generated/LongRunningOperation/MgmtMultipleParentResourceArmOperationOfT.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtMultipleParentResourceContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtMultipleParentResourceContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtMultipleParentResource/src/Generated/SubParentData.Serialization.cs b/test/TestProjects/MgmtMultipleParentResource/src/Generated/SubParentData.Serialization.cs index 3ee332004bc..e3cfd6310ac 100644 --- a/test/TestProjects/MgmtMultipleParentResource/src/Generated/SubParentData.Serialization.cs +++ b/test/TestProjects/MgmtMultipleParentResource/src/Generated/SubParentData.Serialization.cs @@ -6,7 +6,10 @@ #nullable disable using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -128,7 +131,13 @@ internal static SubParentData DeserializeSubParentData(JsonElement element) { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtMultipleParentResource.ModelSerializationExtensions.WireOptions, MgmtMultipleParentResourceContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtMultipleParentResourceContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) diff --git a/test/TestProjects/MgmtMultipleParentResource/src/Generated/TheParentData.Serialization.cs b/test/TestProjects/MgmtMultipleParentResource/src/Generated/TheParentData.Serialization.cs index 0fd499b207e..2cf68b74d43 100644 --- a/test/TestProjects/MgmtMultipleParentResource/src/Generated/TheParentData.Serialization.cs +++ b/test/TestProjects/MgmtMultipleParentResource/src/Generated/TheParentData.Serialization.cs @@ -6,7 +6,10 @@ #nullable disable using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -128,7 +131,13 @@ internal static TheParentData DeserializeTheParentData(JsonElement element) { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtMultipleParentResource.ModelSerializationExtensions.WireOptions, MgmtMultipleParentResourceContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtMultipleParentResourceContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) diff --git a/test/TestProjects/MgmtNoTypeReplacement/src/Generated/LongRunningOperation/MgmtNoTypeReplacementArmOperationOfT.cs b/test/TestProjects/MgmtNoTypeReplacement/src/Generated/LongRunningOperation/MgmtNoTypeReplacementArmOperationOfT.cs index abfa95c0b1e..139e6d477d0 100644 --- a/test/TestProjects/MgmtNoTypeReplacement/src/Generated/LongRunningOperation/MgmtNoTypeReplacementArmOperationOfT.cs +++ b/test/TestProjects/MgmtNoTypeReplacement/src/Generated/LongRunningOperation/MgmtNoTypeReplacementArmOperationOfT.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtNoTypeReplacementContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtNoTypeReplacementContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtNoTypeReplacement/src/Generated/NoTypeReplacementModel1Data.Serialization.cs b/test/TestProjects/MgmtNoTypeReplacement/src/Generated/NoTypeReplacementModel1Data.Serialization.cs index ba7cf1a172a..6692a78f270 100644 --- a/test/TestProjects/MgmtNoTypeReplacement/src/Generated/NoTypeReplacementModel1Data.Serialization.cs +++ b/test/TestProjects/MgmtNoTypeReplacement/src/Generated/NoTypeReplacementModel1Data.Serialization.cs @@ -5,6 +5,10 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -20,7 +24,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(Foo)) { writer.WritePropertyName("foo"u8); - JsonSerializer.Serialize(writer, Foo); + ((IJsonModel)Foo).Write(writer, ModelSerializationExtensions.WireOptions); } writer.WriteEndObject(); } @@ -44,7 +48,13 @@ internal static NoTypeReplacementModel1Data DeserializeNoTypeReplacementModel1Da { continue; } - foo = JsonSerializer.Deserialize(property.Value.GetRawText()); + foo = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtNoTypeReplacement.ModelSerializationExtensions.WireOptions, MgmtNoTypeReplacementContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtNoTypeReplacementContext.Default) +#endif +; continue; } if (property.NameEquals("id"u8)) @@ -68,7 +78,13 @@ internal static NoTypeReplacementModel1Data DeserializeNoTypeReplacementModel1Da { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtNoTypeReplacement.ModelSerializationExtensions.WireOptions, MgmtNoTypeReplacementContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtNoTypeReplacementContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtNoTypeReplacement/src/Generated/NoTypeReplacementModel2Data.Serialization.cs b/test/TestProjects/MgmtNoTypeReplacement/src/Generated/NoTypeReplacementModel2Data.Serialization.cs index a4c29d97169..937ee4fc73b 100644 --- a/test/TestProjects/MgmtNoTypeReplacement/src/Generated/NoTypeReplacementModel2Data.Serialization.cs +++ b/test/TestProjects/MgmtNoTypeReplacement/src/Generated/NoTypeReplacementModel2Data.Serialization.cs @@ -5,6 +5,10 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -68,7 +72,13 @@ internal static NoTypeReplacementModel2Data DeserializeNoTypeReplacementModel2Da { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtNoTypeReplacement.ModelSerializationExtensions.WireOptions, MgmtNoTypeReplacementContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtNoTypeReplacementContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtNoTypeReplacement/src/Generated/NoTypeReplacementModel3Data.Serialization.cs b/test/TestProjects/MgmtNoTypeReplacement/src/Generated/NoTypeReplacementModel3Data.Serialization.cs index 0d0ad7fdf9f..ac5b3f3cc56 100644 --- a/test/TestProjects/MgmtNoTypeReplacement/src/Generated/NoTypeReplacementModel3Data.Serialization.cs +++ b/test/TestProjects/MgmtNoTypeReplacement/src/Generated/NoTypeReplacementModel3Data.Serialization.cs @@ -5,6 +5,10 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -68,7 +72,13 @@ internal static NoTypeReplacementModel3Data DeserializeNoTypeReplacementModel3Da { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtNoTypeReplacement.ModelSerializationExtensions.WireOptions, MgmtNoTypeReplacementContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtNoTypeReplacementContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtNonStringPathVariable/src/Generated/BarData.Serialization.cs b/test/TestProjects/MgmtNonStringPathVariable/src/Generated/BarData.Serialization.cs index a0e5e8b9c7b..34b90236e93 100644 --- a/test/TestProjects/MgmtNonStringPathVariable/src/Generated/BarData.Serialization.cs +++ b/test/TestProjects/MgmtNonStringPathVariable/src/Generated/BarData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -103,7 +107,13 @@ internal static BarData DeserializeBarData(JsonElement element) { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtNonStringPathVariable.ModelSerializationExtensions.WireOptions, MgmtNonStringPathVariableContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtNonStringPathVariableContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtNonStringPathVariable/src/Generated/FakeData.Serialization.cs b/test/TestProjects/MgmtNonStringPathVariable/src/Generated/FakeData.Serialization.cs index f3b591da924..31e1a8c4b45 100644 --- a/test/TestProjects/MgmtNonStringPathVariable/src/Generated/FakeData.Serialization.cs +++ b/test/TestProjects/MgmtNonStringPathVariable/src/Generated/FakeData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -103,7 +107,13 @@ internal static FakeData DeserializeFakeData(JsonElement element) { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtNonStringPathVariable.ModelSerializationExtensions.WireOptions, MgmtNonStringPathVariableContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtNonStringPathVariableContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtNonStringPathVariable/src/Generated/LongRunningOperation/MgmtNonStringPathVariableArmOperation.cs b/test/TestProjects/MgmtNonStringPathVariable/src/Generated/LongRunningOperation/MgmtNonStringPathVariableArmOperation.cs index 74a4113df53..68cb9027987 100644 --- a/test/TestProjects/MgmtNonStringPathVariable/src/Generated/LongRunningOperation/MgmtNonStringPathVariableArmOperation.cs +++ b/test/TestProjects/MgmtNonStringPathVariable/src/Generated/LongRunningOperation/MgmtNonStringPathVariableArmOperation.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtNonStringPathVariableContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtNonStringPathVariableContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtNonStringPathVariable/src/Generated/LongRunningOperation/MgmtNonStringPathVariableArmOperationOfT.cs b/test/TestProjects/MgmtNonStringPathVariable/src/Generated/LongRunningOperation/MgmtNonStringPathVariableArmOperationOfT.cs index 8bfd70cde22..204a150d185 100644 --- a/test/TestProjects/MgmtNonStringPathVariable/src/Generated/LongRunningOperation/MgmtNonStringPathVariableArmOperationOfT.cs +++ b/test/TestProjects/MgmtNonStringPathVariable/src/Generated/LongRunningOperation/MgmtNonStringPathVariableArmOperationOfT.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtNonStringPathVariableContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtNonStringPathVariableContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtOmitOperationGroups/src/Generated/LongRunningOperation/MgmtOmitOperationGroupsArmOperationOfT.cs b/test/TestProjects/MgmtOmitOperationGroups/src/Generated/LongRunningOperation/MgmtOmitOperationGroupsArmOperationOfT.cs index b11542c4fe4..dfe2bf31330 100644 --- a/test/TestProjects/MgmtOmitOperationGroups/src/Generated/LongRunningOperation/MgmtOmitOperationGroupsArmOperationOfT.cs +++ b/test/TestProjects/MgmtOmitOperationGroups/src/Generated/LongRunningOperation/MgmtOmitOperationGroupsArmOperationOfT.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtOmitOperationGroupsContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtOmitOperationGroupsContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtOmitOperationGroups/src/Generated/Model2Data.Serialization.cs b/test/TestProjects/MgmtOmitOperationGroups/src/Generated/Model2Data.Serialization.cs index 3a595d00089..bcaad76ab1d 100644 --- a/test/TestProjects/MgmtOmitOperationGroups/src/Generated/Model2Data.Serialization.cs +++ b/test/TestProjects/MgmtOmitOperationGroups/src/Generated/Model2Data.Serialization.cs @@ -5,6 +5,10 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -91,7 +95,13 @@ internal static Model2Data DeserializeModel2Data(JsonElement element) { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtOmitOperationGroups.ModelSerializationExtensions.WireOptions, MgmtOmitOperationGroupsContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtOmitOperationGroupsContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtOmitOperationGroups/src/Generated/Models/ModelQ.Serialization.cs b/test/TestProjects/MgmtOmitOperationGroups/src/Generated/Models/ModelQ.Serialization.cs index af6735d07af..377b7b704cb 100644 --- a/test/TestProjects/MgmtOmitOperationGroups/src/Generated/Models/ModelQ.Serialization.cs +++ b/test/TestProjects/MgmtOmitOperationGroups/src/Generated/Models/ModelQ.Serialization.cs @@ -5,6 +5,10 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -63,7 +67,13 @@ internal static ModelQ DeserializeModelQ(JsonElement element) { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtOmitOperationGroups.ModelSerializationExtensions.WireOptions, MgmtOmitOperationGroupsContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtOmitOperationGroupsContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtOperations/src/Generated/AvailabilitySetChildData.Serialization.cs b/test/TestProjects/MgmtOperations/src/Generated/AvailabilitySetChildData.Serialization.cs index bd77a0c7eb0..24c9dbb93d3 100644 --- a/test/TestProjects/MgmtOperations/src/Generated/AvailabilitySetChildData.Serialization.cs +++ b/test/TestProjects/MgmtOperations/src/Generated/AvailabilitySetChildData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -98,7 +102,13 @@ internal static AvailabilitySetChildData DeserializeAvailabilitySetChildData(Jso { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtOperations.ModelSerializationExtensions.WireOptions, MgmtOperationsContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtOperationsContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtOperations/src/Generated/AvailabilitySetData.Serialization.cs b/test/TestProjects/MgmtOperations/src/Generated/AvailabilitySetData.Serialization.cs index 235d617c7cf..cdd09178169 100644 --- a/test/TestProjects/MgmtOperations/src/Generated/AvailabilitySetData.Serialization.cs +++ b/test/TestProjects/MgmtOperations/src/Generated/AvailabilitySetData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -98,7 +102,13 @@ internal static AvailabilitySetData DeserializeAvailabilitySetData(JsonElement e { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtOperations.ModelSerializationExtensions.WireOptions, MgmtOperationsContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtOperationsContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtOperations/src/Generated/AvailabilitySetGrandChildData.Serialization.cs b/test/TestProjects/MgmtOperations/src/Generated/AvailabilitySetGrandChildData.Serialization.cs index 229f5811f88..6a8ef068c60 100644 --- a/test/TestProjects/MgmtOperations/src/Generated/AvailabilitySetGrandChildData.Serialization.cs +++ b/test/TestProjects/MgmtOperations/src/Generated/AvailabilitySetGrandChildData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -98,7 +102,13 @@ internal static AvailabilitySetGrandChildData DeserializeAvailabilitySetGrandChi { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtOperations.ModelSerializationExtensions.WireOptions, MgmtOperationsContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtOperationsContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtOperations/src/Generated/LongRunningOperation/MgmtOperationsArmOperation.cs b/test/TestProjects/MgmtOperations/src/Generated/LongRunningOperation/MgmtOperationsArmOperation.cs index bb8ebbb41aa..d020f123a91 100644 --- a/test/TestProjects/MgmtOperations/src/Generated/LongRunningOperation/MgmtOperationsArmOperation.cs +++ b/test/TestProjects/MgmtOperations/src/Generated/LongRunningOperation/MgmtOperationsArmOperation.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtOperationsContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtOperationsContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtOperations/src/Generated/LongRunningOperation/MgmtOperationsArmOperationOfT.cs b/test/TestProjects/MgmtOperations/src/Generated/LongRunningOperation/MgmtOperationsArmOperationOfT.cs index 3d70df2b896..20e6eae3c49 100644 --- a/test/TestProjects/MgmtOperations/src/Generated/LongRunningOperation/MgmtOperationsArmOperationOfT.cs +++ b/test/TestProjects/MgmtOperations/src/Generated/LongRunningOperation/MgmtOperationsArmOperationOfT.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtOperationsContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtOperationsContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtOperations/src/Generated/Models/ConnectionSharedKey.Serialization.cs b/test/TestProjects/MgmtOperations/src/Generated/Models/ConnectionSharedKey.Serialization.cs index b9b609e1d61..8510828df1c 100644 --- a/test/TestProjects/MgmtOperations/src/Generated/Models/ConnectionSharedKey.Serialization.cs +++ b/test/TestProjects/MgmtOperations/src/Generated/Models/ConnectionSharedKey.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -95,7 +99,13 @@ internal static ConnectionSharedKey DeserializeConnectionSharedKey(JsonElement e { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtOperations.ModelSerializationExtensions.WireOptions, MgmtOperationsContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtOperationsContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtOperations/src/Generated/UnpatchableResourceData.Serialization.cs b/test/TestProjects/MgmtOperations/src/Generated/UnpatchableResourceData.Serialization.cs index b13ed00a884..ecbe6d49c08 100644 --- a/test/TestProjects/MgmtOperations/src/Generated/UnpatchableResourceData.Serialization.cs +++ b/test/TestProjects/MgmtOperations/src/Generated/UnpatchableResourceData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -98,7 +102,13 @@ internal static UnpatchableResourceData DeserializeUnpatchableResourceData(JsonE { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtOperations.ModelSerializationExtensions.WireOptions, MgmtOperationsContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtOperationsContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtPagination/src/Generated/LongRunningOperation/MgmtPaginationArmOperationOfT.cs b/test/TestProjects/MgmtPagination/src/Generated/LongRunningOperation/MgmtPaginationArmOperationOfT.cs index d3f6d982a26..11000ccbed3 100644 --- a/test/TestProjects/MgmtPagination/src/Generated/LongRunningOperation/MgmtPaginationArmOperationOfT.cs +++ b/test/TestProjects/MgmtPagination/src/Generated/LongRunningOperation/MgmtPaginationArmOperationOfT.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtPaginationContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtPaginationContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtParamOrdering/src/Generated/AvailabilitySetData.Serialization.cs b/test/TestProjects/MgmtParamOrdering/src/Generated/AvailabilitySetData.Serialization.cs index 5ab7d5ed644..faa9bfb797c 100644 --- a/test/TestProjects/MgmtParamOrdering/src/Generated/AvailabilitySetData.Serialization.cs +++ b/test/TestProjects/MgmtParamOrdering/src/Generated/AvailabilitySetData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -98,7 +102,13 @@ internal static AvailabilitySetData DeserializeAvailabilitySetData(JsonElement e { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtParamOrdering.ModelSerializationExtensions.WireOptions, MgmtParamOrderingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtParamOrderingContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtParamOrdering/src/Generated/DedicatedHostData.Serialization.cs b/test/TestProjects/MgmtParamOrdering/src/Generated/DedicatedHostData.Serialization.cs index 9c6f9f1e7fd..4f1128c7536 100644 --- a/test/TestProjects/MgmtParamOrdering/src/Generated/DedicatedHostData.Serialization.cs +++ b/test/TestProjects/MgmtParamOrdering/src/Generated/DedicatedHostData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -98,7 +102,13 @@ internal static DedicatedHostData DeserializeDedicatedHostData(JsonElement eleme { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtParamOrdering.ModelSerializationExtensions.WireOptions, MgmtParamOrderingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtParamOrderingContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtParamOrdering/src/Generated/DedicatedHostGroupData.Serialization.cs b/test/TestProjects/MgmtParamOrdering/src/Generated/DedicatedHostGroupData.Serialization.cs index 13bf0f653c2..971646be3b9 100644 --- a/test/TestProjects/MgmtParamOrdering/src/Generated/DedicatedHostGroupData.Serialization.cs +++ b/test/TestProjects/MgmtParamOrdering/src/Generated/DedicatedHostGroupData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -98,7 +102,13 @@ internal static DedicatedHostGroupData DeserializeDedicatedHostGroupData(JsonEle { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtParamOrdering.ModelSerializationExtensions.WireOptions, MgmtParamOrderingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtParamOrderingContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtParamOrdering/src/Generated/EnvironmentContainerResourceData.Serialization.cs b/test/TestProjects/MgmtParamOrdering/src/Generated/EnvironmentContainerResourceData.Serialization.cs index 7bc164e721f..c2bc9020bab 100644 --- a/test/TestProjects/MgmtParamOrdering/src/Generated/EnvironmentContainerResourceData.Serialization.cs +++ b/test/TestProjects/MgmtParamOrdering/src/Generated/EnvironmentContainerResourceData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -96,7 +100,13 @@ internal static EnvironmentContainerResourceData DeserializeEnvironmentContainer { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtParamOrdering.ModelSerializationExtensions.WireOptions, MgmtParamOrderingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtParamOrderingContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtParamOrdering/src/Generated/LongRunningOperation/MgmtParamOrderingArmOperation.cs b/test/TestProjects/MgmtParamOrdering/src/Generated/LongRunningOperation/MgmtParamOrderingArmOperation.cs index fb904107258..f7e56875728 100644 --- a/test/TestProjects/MgmtParamOrdering/src/Generated/LongRunningOperation/MgmtParamOrderingArmOperation.cs +++ b/test/TestProjects/MgmtParamOrdering/src/Generated/LongRunningOperation/MgmtParamOrderingArmOperation.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtParamOrderingContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtParamOrderingContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtParamOrdering/src/Generated/LongRunningOperation/MgmtParamOrderingArmOperationOfT.cs b/test/TestProjects/MgmtParamOrdering/src/Generated/LongRunningOperation/MgmtParamOrderingArmOperationOfT.cs index d83aa30a92d..6ff243839f8 100644 --- a/test/TestProjects/MgmtParamOrdering/src/Generated/LongRunningOperation/MgmtParamOrderingArmOperationOfT.cs +++ b/test/TestProjects/MgmtParamOrdering/src/Generated/LongRunningOperation/MgmtParamOrderingArmOperationOfT.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtParamOrderingContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtParamOrderingContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtParamOrdering/src/Generated/VirtualMachineExtensionImageData.Serialization.cs b/test/TestProjects/MgmtParamOrdering/src/Generated/VirtualMachineExtensionImageData.Serialization.cs index d46036a8e59..3824443b297 100644 --- a/test/TestProjects/MgmtParamOrdering/src/Generated/VirtualMachineExtensionImageData.Serialization.cs +++ b/test/TestProjects/MgmtParamOrdering/src/Generated/VirtualMachineExtensionImageData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -98,7 +102,13 @@ internal static VirtualMachineExtensionImageData DeserializeVirtualMachineExtens { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtParamOrdering.ModelSerializationExtensions.WireOptions, MgmtParamOrderingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtParamOrderingContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtParamOrdering/src/Generated/VirtualMachineScaleSetData.Serialization.cs b/test/TestProjects/MgmtParamOrdering/src/Generated/VirtualMachineScaleSetData.Serialization.cs index 688e090d4ef..5d7354a96f8 100644 --- a/test/TestProjects/MgmtParamOrdering/src/Generated/VirtualMachineScaleSetData.Serialization.cs +++ b/test/TestProjects/MgmtParamOrdering/src/Generated/VirtualMachineScaleSetData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -112,7 +116,13 @@ internal static VirtualMachineScaleSetData DeserializeVirtualMachineScaleSetData { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtParamOrdering.ModelSerializationExtensions.WireOptions, MgmtParamOrderingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtParamOrderingContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtParamOrdering/src/Generated/WorkspaceData.Serialization.cs b/test/TestProjects/MgmtParamOrdering/src/Generated/WorkspaceData.Serialization.cs index 4f993a1a2f4..72a0cfd7178 100644 --- a/test/TestProjects/MgmtParamOrdering/src/Generated/WorkspaceData.Serialization.cs +++ b/test/TestProjects/MgmtParamOrdering/src/Generated/WorkspaceData.Serialization.cs @@ -6,7 +6,10 @@ #nullable disable using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -170,7 +173,13 @@ internal static WorkspaceData DeserializeWorkspaceData(JsonElement element) { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtParamOrdering.ModelSerializationExtensions.WireOptions, MgmtParamOrderingContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtParamOrderingContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) diff --git a/test/TestProjects/MgmtParent/src/Generated/AvailabilitySetData.Serialization.cs b/test/TestProjects/MgmtParent/src/Generated/AvailabilitySetData.Serialization.cs index c6463d1c306..840e82959cd 100644 --- a/test/TestProjects/MgmtParent/src/Generated/AvailabilitySetData.Serialization.cs +++ b/test/TestProjects/MgmtParent/src/Generated/AvailabilitySetData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -98,7 +102,13 @@ internal static AvailabilitySetData DeserializeAvailabilitySetData(JsonElement e { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtParent.ModelSerializationExtensions.WireOptions, MgmtParentContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtParentContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtParent/src/Generated/DedicatedHostData.Serialization.cs b/test/TestProjects/MgmtParent/src/Generated/DedicatedHostData.Serialization.cs index 0c1c91c561f..430f8aa1c80 100644 --- a/test/TestProjects/MgmtParent/src/Generated/DedicatedHostData.Serialization.cs +++ b/test/TestProjects/MgmtParent/src/Generated/DedicatedHostData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -98,7 +102,13 @@ internal static DedicatedHostData DeserializeDedicatedHostData(JsonElement eleme { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtParent.ModelSerializationExtensions.WireOptions, MgmtParentContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtParentContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtParent/src/Generated/DedicatedHostGroupData.Serialization.cs b/test/TestProjects/MgmtParent/src/Generated/DedicatedHostGroupData.Serialization.cs index 1f394693125..11ba44d6a8b 100644 --- a/test/TestProjects/MgmtParent/src/Generated/DedicatedHostGroupData.Serialization.cs +++ b/test/TestProjects/MgmtParent/src/Generated/DedicatedHostGroupData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -98,7 +102,13 @@ internal static DedicatedHostGroupData DeserializeDedicatedHostGroupData(JsonEle { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtParent.ModelSerializationExtensions.WireOptions, MgmtParentContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtParentContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtParent/src/Generated/LongRunningOperation/MgmtParentArmOperation.cs b/test/TestProjects/MgmtParent/src/Generated/LongRunningOperation/MgmtParentArmOperation.cs index ca12c6debdd..bb6afcf8adf 100644 --- a/test/TestProjects/MgmtParent/src/Generated/LongRunningOperation/MgmtParentArmOperation.cs +++ b/test/TestProjects/MgmtParent/src/Generated/LongRunningOperation/MgmtParentArmOperation.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtParentContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtParentContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtParent/src/Generated/LongRunningOperation/MgmtParentArmOperationOfT.cs b/test/TestProjects/MgmtParent/src/Generated/LongRunningOperation/MgmtParentArmOperationOfT.cs index 16d73853aba..757ca00998a 100644 --- a/test/TestProjects/MgmtParent/src/Generated/LongRunningOperation/MgmtParentArmOperationOfT.cs +++ b/test/TestProjects/MgmtParent/src/Generated/LongRunningOperation/MgmtParentArmOperationOfT.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtParentContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtParentContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtParent/src/Generated/VirtualMachineExtensionImageData.Serialization.cs b/test/TestProjects/MgmtParent/src/Generated/VirtualMachineExtensionImageData.Serialization.cs index 2e9a89b09d3..bcf32dfe7bf 100644 --- a/test/TestProjects/MgmtParent/src/Generated/VirtualMachineExtensionImageData.Serialization.cs +++ b/test/TestProjects/MgmtParent/src/Generated/VirtualMachineExtensionImageData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -98,7 +102,13 @@ internal static VirtualMachineExtensionImageData DeserializeVirtualMachineExtens { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtParent.ModelSerializationExtensions.WireOptions, MgmtParentContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtParentContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtPartialResource/src/Generated/ConfigurationProfileAssignmentData.Serialization.cs b/test/TestProjects/MgmtPartialResource/src/Generated/ConfigurationProfileAssignmentData.Serialization.cs index 67afedb956c..9ab7dbaeaa3 100644 --- a/test/TestProjects/MgmtPartialResource/src/Generated/ConfigurationProfileAssignmentData.Serialization.cs +++ b/test/TestProjects/MgmtPartialResource/src/Generated/ConfigurationProfileAssignmentData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -103,7 +107,13 @@ internal static ConfigurationProfileAssignmentData DeserializeConfigurationProfi { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtPartialResource.ModelSerializationExtensions.WireOptions, MgmtPartialResourceContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtPartialResourceContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtPartialResource/src/Generated/LongRunningOperation/MgmtPartialResourceArmOperation.cs b/test/TestProjects/MgmtPartialResource/src/Generated/LongRunningOperation/MgmtPartialResourceArmOperation.cs index 6ab82fa9333..dec9e69bbe7 100644 --- a/test/TestProjects/MgmtPartialResource/src/Generated/LongRunningOperation/MgmtPartialResourceArmOperation.cs +++ b/test/TestProjects/MgmtPartialResource/src/Generated/LongRunningOperation/MgmtPartialResourceArmOperation.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtPartialResourceContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtPartialResourceContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtPartialResource/src/Generated/LongRunningOperation/MgmtPartialResourceArmOperationOfT.cs b/test/TestProjects/MgmtPartialResource/src/Generated/LongRunningOperation/MgmtPartialResourceArmOperationOfT.cs index bddb74c9418..77704d425f5 100644 --- a/test/TestProjects/MgmtPartialResource/src/Generated/LongRunningOperation/MgmtPartialResourceArmOperationOfT.cs +++ b/test/TestProjects/MgmtPartialResource/src/Generated/LongRunningOperation/MgmtPartialResourceArmOperationOfT.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtPartialResourceContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtPartialResourceContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtPartialResource/src/Generated/PublicIPAddressData.Serialization.cs b/test/TestProjects/MgmtPartialResource/src/Generated/PublicIPAddressData.Serialization.cs index f47cd36dc1b..7a416fd8e1e 100644 --- a/test/TestProjects/MgmtPartialResource/src/Generated/PublicIPAddressData.Serialization.cs +++ b/test/TestProjects/MgmtPartialResource/src/Generated/PublicIPAddressData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -152,7 +156,13 @@ internal static PublicIPAddressData DeserializePublicIPAddressData(JsonElement e { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtPartialResource.ModelSerializationExtensions.WireOptions, MgmtPartialResourceContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtPartialResourceContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) diff --git a/test/TestProjects/MgmtPropertyBag/src/Generated/BarData.Serialization.cs b/test/TestProjects/MgmtPropertyBag/src/Generated/BarData.Serialization.cs index 6c6497d45e4..555941e6cb8 100644 --- a/test/TestProjects/MgmtPropertyBag/src/Generated/BarData.Serialization.cs +++ b/test/TestProjects/MgmtPropertyBag/src/Generated/BarData.Serialization.cs @@ -5,6 +5,10 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -63,7 +67,13 @@ internal static BarData DeserializeBarData(JsonElement element) { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtPropertyBag.ModelSerializationExtensions.WireOptions, MgmtPropertyBagContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtPropertyBagContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtPropertyBag/src/Generated/FooData.Serialization.cs b/test/TestProjects/MgmtPropertyBag/src/Generated/FooData.Serialization.cs index f46737daf33..3a164b3030d 100644 --- a/test/TestProjects/MgmtPropertyBag/src/Generated/FooData.Serialization.cs +++ b/test/TestProjects/MgmtPropertyBag/src/Generated/FooData.Serialization.cs @@ -5,6 +5,10 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -63,7 +67,13 @@ internal static FooData DeserializeFooData(JsonElement element) { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtPropertyBag.ModelSerializationExtensions.WireOptions, MgmtPropertyBagContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtPropertyBagContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtPropertyBag/src/Generated/LongRunningOperation/MgmtPropertyBagArmOperationOfT.cs b/test/TestProjects/MgmtPropertyBag/src/Generated/LongRunningOperation/MgmtPropertyBagArmOperationOfT.cs index 1a0c1c91c0c..aeaf66d8970 100644 --- a/test/TestProjects/MgmtPropertyBag/src/Generated/LongRunningOperation/MgmtPropertyBagArmOperationOfT.cs +++ b/test/TestProjects/MgmtPropertyBag/src/Generated/LongRunningOperation/MgmtPropertyBagArmOperationOfT.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtPropertyBagContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtPropertyBagContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtPropertyChooser/src/Generated/LongRunningOperation/MgmtPropertyChooserArmOperation.cs b/test/TestProjects/MgmtPropertyChooser/src/Generated/LongRunningOperation/MgmtPropertyChooserArmOperation.cs index ba37e3fec14..d2fc76a1e82 100644 --- a/test/TestProjects/MgmtPropertyChooser/src/Generated/LongRunningOperation/MgmtPropertyChooserArmOperation.cs +++ b/test/TestProjects/MgmtPropertyChooser/src/Generated/LongRunningOperation/MgmtPropertyChooserArmOperation.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtPropertyChooserContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtPropertyChooserContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtPropertyChooser/src/Generated/LongRunningOperation/MgmtPropertyChooserArmOperationOfT.cs b/test/TestProjects/MgmtPropertyChooser/src/Generated/LongRunningOperation/MgmtPropertyChooserArmOperationOfT.cs index 5899f08f5a0..4dbb5332c91 100644 --- a/test/TestProjects/MgmtPropertyChooser/src/Generated/LongRunningOperation/MgmtPropertyChooserArmOperationOfT.cs +++ b/test/TestProjects/MgmtPropertyChooser/src/Generated/LongRunningOperation/MgmtPropertyChooserArmOperationOfT.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtPropertyChooserContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtPropertyChooserContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtPropertyChooser/src/Generated/Models/IdentityWithDifferentPropertyType.Serialization.cs b/test/TestProjects/MgmtPropertyChooser/src/Generated/Models/IdentityWithDifferentPropertyType.Serialization.cs index a7ec8ea822b..1d6f6238a47 100644 --- a/test/TestProjects/MgmtPropertyChooser/src/Generated/Models/IdentityWithDifferentPropertyType.Serialization.cs +++ b/test/TestProjects/MgmtPropertyChooser/src/Generated/Models/IdentityWithDifferentPropertyType.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -29,7 +33,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) foreach (var item in UserAssignedIdentities) { writer.WritePropertyName(item.Key); - JsonSerializer.Serialize(writer, item.Value); + ((IJsonModel)item.Value).Write(writer, ModelSerializationExtensions.WireOptions); } writer.WriteEndObject(); } @@ -80,7 +84,13 @@ internal static IdentityWithDifferentPropertyType DeserializeIdentityWithDiffere Dictionary dictionary = new Dictionary(); foreach (var property0 in property.Value.EnumerateObject()) { - dictionary.Add(property0.Name, JsonSerializer.Deserialize(property0.Value.GetRawText())); + dictionary.Add(property0.Name, +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property0.Value).ToArray()), global::MgmtPropertyChooser.ModelSerializationExtensions.WireOptions, MgmtPropertyChooserContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtPropertyChooserContext.Default) +#endif +); } userAssignedIdentities = dictionary; continue; diff --git a/test/TestProjects/MgmtPropertyChooser/src/Generated/Models/IdentityWithNoSystemIdentity.Serialization.cs b/test/TestProjects/MgmtPropertyChooser/src/Generated/Models/IdentityWithNoSystemIdentity.Serialization.cs index 952966101f4..79bdc39ed93 100644 --- a/test/TestProjects/MgmtPropertyChooser/src/Generated/Models/IdentityWithNoSystemIdentity.Serialization.cs +++ b/test/TestProjects/MgmtPropertyChooser/src/Generated/Models/IdentityWithNoSystemIdentity.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -29,7 +33,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) foreach (var item in UserAssignedIdentities) { writer.WritePropertyName(item.Key); - JsonSerializer.Serialize(writer, item.Value); + ((IJsonModel)item.Value).Write(writer, ModelSerializationExtensions.WireOptions); } writer.WriteEndObject(); } @@ -64,7 +68,13 @@ internal static IdentityWithNoSystemIdentity DeserializeIdentityWithNoSystemIden Dictionary dictionary = new Dictionary(); foreach (var property0 in property.Value.EnumerateObject()) { - dictionary.Add(property0.Name, JsonSerializer.Deserialize(property0.Value.GetRawText())); + dictionary.Add(property0.Name, +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property0.Value).ToArray()), global::MgmtPropertyChooser.ModelSerializationExtensions.WireOptions, MgmtPropertyChooserContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtPropertyChooserContext.Default) +#endif +); } userAssignedIdentities = dictionary; continue; diff --git a/test/TestProjects/MgmtPropertyChooser/src/Generated/Models/IdentityWithRenamedProperty.Serialization.cs b/test/TestProjects/MgmtPropertyChooser/src/Generated/Models/IdentityWithRenamedProperty.Serialization.cs index 70d912827ff..175c9d964a5 100644 --- a/test/TestProjects/MgmtPropertyChooser/src/Generated/Models/IdentityWithRenamedProperty.Serialization.cs +++ b/test/TestProjects/MgmtPropertyChooser/src/Generated/Models/IdentityWithRenamedProperty.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -29,7 +33,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) foreach (var item in UserAssignedIdentities) { writer.WritePropertyName(item.Key); - JsonSerializer.Serialize(writer, item.Value); + ((IJsonModel)item.Value).Write(writer, ModelSerializationExtensions.WireOptions); } writer.WriteEndObject(); } @@ -76,7 +80,13 @@ internal static IdentityWithRenamedProperty DeserializeIdentityWithRenamedProper Dictionary dictionary = new Dictionary(); foreach (var property0 in property.Value.EnumerateObject()) { - dictionary.Add(property0.Name, JsonSerializer.Deserialize(property0.Value.GetRawText())); + dictionary.Add(property0.Name, +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property0.Value).ToArray()), global::MgmtPropertyChooser.ModelSerializationExtensions.WireOptions, MgmtPropertyChooserContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property0.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtPropertyChooserContext.Default) +#endif +); } userAssignedIdentities = dictionary; continue; diff --git a/test/TestProjects/MgmtPropertyChooser/src/Generated/Models/MgmtPropertyChooserResourceData.Serialization.cs b/test/TestProjects/MgmtPropertyChooser/src/Generated/Models/MgmtPropertyChooserResourceData.Serialization.cs index 9156b88835c..cb7df473f93 100644 --- a/test/TestProjects/MgmtPropertyChooser/src/Generated/Models/MgmtPropertyChooserResourceData.Serialization.cs +++ b/test/TestProjects/MgmtPropertyChooser/src/Generated/Models/MgmtPropertyChooserResourceData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -87,7 +91,13 @@ internal static MgmtPropertyChooserResourceData DeserializeMgmtPropertyChooserRe { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtPropertyChooser.ModelSerializationExtensions.WireOptions, MgmtPropertyChooserContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtPropertyChooserContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtPropertyChooser/src/Generated/Models/VirtualMachineExtension.Serialization.cs b/test/TestProjects/MgmtPropertyChooser/src/Generated/Models/VirtualMachineExtension.Serialization.cs index e4747172a5d..e414943beeb 100644 --- a/test/TestProjects/MgmtPropertyChooser/src/Generated/Models/VirtualMachineExtension.Serialization.cs +++ b/test/TestProjects/MgmtPropertyChooser/src/Generated/Models/VirtualMachineExtension.Serialization.cs @@ -6,7 +6,10 @@ #nullable disable using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -154,7 +157,13 @@ internal static VirtualMachineExtension DeserializeVirtualMachineExtension(JsonE { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtPropertyChooser.ModelSerializationExtensions.WireOptions, MgmtPropertyChooserContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtPropertyChooserContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) diff --git a/test/TestProjects/MgmtPropertyChooser/src/Generated/Models/VirtualMachinePatch.Serialization.cs b/test/TestProjects/MgmtPropertyChooser/src/Generated/Models/VirtualMachinePatch.Serialization.cs index b07941c03e5..cee360220f3 100644 --- a/test/TestProjects/MgmtPropertyChooser/src/Generated/Models/VirtualMachinePatch.Serialization.cs +++ b/test/TestProjects/MgmtPropertyChooser/src/Generated/Models/VirtualMachinePatch.Serialization.cs @@ -5,8 +5,10 @@ #nullable disable +using System.ClientModel.Primitives; using System.Text.Json; using Azure.Core; +using Azure.ResourceManager.Models; namespace MgmtPropertyChooser.Models { @@ -18,12 +20,12 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(Plan)) { writer.WritePropertyName("plan"u8); - JsonSerializer.Serialize(writer, Plan); + ((IJsonModel)Plan).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsDefined(Identity)) { writer.WritePropertyName("identity"u8); - JsonSerializer.Serialize(writer, Identity); + ((IJsonModel)Identity).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsCollectionDefined(Zones)) { diff --git a/test/TestProjects/MgmtPropertyChooser/src/Generated/VirtualMachineData.Serialization.cs b/test/TestProjects/MgmtPropertyChooser/src/Generated/VirtualMachineData.Serialization.cs index 54e37f28e57..aa7e941c9da 100644 --- a/test/TestProjects/MgmtPropertyChooser/src/Generated/VirtualMachineData.Serialization.cs +++ b/test/TestProjects/MgmtPropertyChooser/src/Generated/VirtualMachineData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -22,12 +26,12 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(Plan)) { writer.WritePropertyName("plan"u8); - JsonSerializer.Serialize(writer, Plan); + ((IJsonModel)Plan).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsDefined(Identity)) { writer.WritePropertyName("identity"u8); - JsonSerializer.Serialize(writer, Identity); + ((IJsonModel)Identity).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsDefined(IdentityWithRenamedProperty)) { @@ -42,7 +46,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(IdentityWithNoUserIdentity)) { writer.WritePropertyName("identityWithNoUserIdentity"u8); - JsonSerializer.Serialize(writer, IdentityWithNoUserIdentity); + ((IJsonModel)IdentityWithNoUserIdentity).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsDefined(IdentityWithNoSystemIdentity)) { @@ -52,8 +56,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(IdentityV3)) { writer.WritePropertyName("identityV3"u8); - var serializeOptions = new JsonSerializerOptions { Converters = { new ManagedServiceIdentityTypeV3Converter() } }; - JsonSerializer.Serialize(writer, IdentityV3, serializeOptions); + ((IJsonModel)IdentityV3).Write(writer, new ModelReaderWriterOptions("W|v3")); } if (Optional.IsCollectionDefined(Zones)) { @@ -68,12 +71,12 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(FakeSubResource)) { writer.WritePropertyName("fakeSubResource"u8); - JsonSerializer.Serialize(writer, FakeSubResource); + ((IJsonModel)FakeSubResource).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsDefined(FakeWritableSubResource)) { writer.WritePropertyName("fakeWritableSubResource"u8); - JsonSerializer.Serialize(writer, FakeWritableSubResource); + ((IJsonModel)FakeWritableSubResource).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsCollectionDefined(Tags)) { @@ -140,7 +143,13 @@ internal static VirtualMachineData DeserializeVirtualMachineData(JsonElement ele { continue; } - plan = JsonSerializer.Deserialize(property.Value.GetRawText()); + plan = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtPropertyChooser.ModelSerializationExtensions.WireOptions, MgmtPropertyChooserContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtPropertyChooserContext.Default) +#endif +; continue; } if (property.NameEquals("resources"u8)) @@ -163,7 +172,13 @@ internal static VirtualMachineData DeserializeVirtualMachineData(JsonElement ele { continue; } - identity = JsonSerializer.Deserialize(property.Value.GetRawText()); + identity = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtPropertyChooser.ModelSerializationExtensions.WireOptions, MgmtPropertyChooserContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtPropertyChooserContext.Default) +#endif +; continue; } if (property.NameEquals("identityWithRenamedProperty"u8)) @@ -190,7 +205,13 @@ internal static VirtualMachineData DeserializeVirtualMachineData(JsonElement ele { continue; } - identityWithNoUserIdentity = JsonSerializer.Deserialize(property.Value.GetRawText()); + identityWithNoUserIdentity = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtPropertyChooser.ModelSerializationExtensions.WireOptions, MgmtPropertyChooserContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtPropertyChooserContext.Default) +#endif +; continue; } if (property.NameEquals("identityWithNoSystemIdentity"u8)) @@ -208,8 +229,13 @@ internal static VirtualMachineData DeserializeVirtualMachineData(JsonElement ele { continue; } - var serializeOptions = new JsonSerializerOptions { Converters = { new ManagedServiceIdentityTypeV3Converter() } }; - identityV3 = JsonSerializer.Deserialize(property.Value.GetRawText(), serializeOptions); + identityV3 = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), new global::System.ClientModel.Primitives.ModelReaderWriterOptions("W|v3"), MgmtPropertyChooserContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), new ModelReaderWriterOptions("W|v3"), MgmtPropertyChooserContext.Default) +#endif +; continue; } if (property.NameEquals("zones"u8)) @@ -246,7 +272,13 @@ internal static VirtualMachineData DeserializeVirtualMachineData(JsonElement ele { continue; } - fakeSubResource = JsonSerializer.Deserialize(property.Value.GetRawText()); + fakeSubResource = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtPropertyChooser.ModelSerializationExtensions.WireOptions, MgmtPropertyChooserContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtPropertyChooserContext.Default) +#endif +; continue; } if (property.NameEquals("fakeWritableSubResource"u8)) @@ -255,7 +287,13 @@ internal static VirtualMachineData DeserializeVirtualMachineData(JsonElement ele { continue; } - fakeWritableSubResource = JsonSerializer.Deserialize(property.Value.GetRawText()); + fakeWritableSubResource = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtPropertyChooser.ModelSerializationExtensions.WireOptions, MgmtPropertyChooserContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtPropertyChooserContext.Default) +#endif +; continue; } if (property.NameEquals("tags"u8)) @@ -298,7 +336,13 @@ internal static VirtualMachineData DeserializeVirtualMachineData(JsonElement ele { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtPropertyChooser.ModelSerializationExtensions.WireOptions, MgmtPropertyChooserContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtPropertyChooserContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) diff --git a/test/TestProjects/MgmtResourceName/src/Generated/DiskData.Serialization.cs b/test/TestProjects/MgmtResourceName/src/Generated/DiskData.Serialization.cs index b4979f07b9e..7454724563d 100644 --- a/test/TestProjects/MgmtResourceName/src/Generated/DiskData.Serialization.cs +++ b/test/TestProjects/MgmtResourceName/src/Generated/DiskData.Serialization.cs @@ -5,6 +5,10 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -63,7 +67,13 @@ internal static DiskData DeserializeDiskData(JsonElement element) { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtResourceName.ModelSerializationExtensions.WireOptions, MgmtResourceNameContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtResourceNameContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtResourceName/src/Generated/DisplayResourceData.Serialization.cs b/test/TestProjects/MgmtResourceName/src/Generated/DisplayResourceData.Serialization.cs index 548f3c018d1..78d523c67d9 100644 --- a/test/TestProjects/MgmtResourceName/src/Generated/DisplayResourceData.Serialization.cs +++ b/test/TestProjects/MgmtResourceName/src/Generated/DisplayResourceData.Serialization.cs @@ -5,6 +5,10 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -63,7 +67,13 @@ internal static DisplayResourceData DeserializeDisplayResourceData(JsonElement e { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtResourceName.ModelSerializationExtensions.WireOptions, MgmtResourceNameContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtResourceNameContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtResourceName/src/Generated/LongRunningOperation/MgmtResourceNameArmOperationOfT.cs b/test/TestProjects/MgmtResourceName/src/Generated/LongRunningOperation/MgmtResourceNameArmOperationOfT.cs index 93755b6f0b4..29cd2ac4601 100644 --- a/test/TestProjects/MgmtResourceName/src/Generated/LongRunningOperation/MgmtResourceNameArmOperationOfT.cs +++ b/test/TestProjects/MgmtResourceName/src/Generated/LongRunningOperation/MgmtResourceNameArmOperationOfT.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtResourceNameContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtResourceNameContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtResourceName/src/Generated/MachineData.Serialization.cs b/test/TestProjects/MgmtResourceName/src/Generated/MachineData.Serialization.cs index 9183652606e..7f411bfa087 100644 --- a/test/TestProjects/MgmtResourceName/src/Generated/MachineData.Serialization.cs +++ b/test/TestProjects/MgmtResourceName/src/Generated/MachineData.Serialization.cs @@ -5,6 +5,10 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -63,7 +67,13 @@ internal static MachineData DeserializeMachineData(JsonElement element) { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtResourceName.ModelSerializationExtensions.WireOptions, MgmtResourceNameContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtResourceNameContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtResourceName/src/Generated/MemoryData.Serialization.cs b/test/TestProjects/MgmtResourceName/src/Generated/MemoryData.Serialization.cs index b38123c7857..d167541286b 100644 --- a/test/TestProjects/MgmtResourceName/src/Generated/MemoryData.Serialization.cs +++ b/test/TestProjects/MgmtResourceName/src/Generated/MemoryData.Serialization.cs @@ -5,6 +5,10 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -63,7 +67,13 @@ internal static MemoryData DeserializeMemoryData(JsonElement element) { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtResourceName.ModelSerializationExtensions.WireOptions, MgmtResourceNameContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtResourceNameContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtResourceName/src/Generated/NetworkData.Serialization.cs b/test/TestProjects/MgmtResourceName/src/Generated/NetworkData.Serialization.cs index 8fa7a32a60c..5de16032b2f 100644 --- a/test/TestProjects/MgmtResourceName/src/Generated/NetworkData.Serialization.cs +++ b/test/TestProjects/MgmtResourceName/src/Generated/NetworkData.Serialization.cs @@ -5,6 +5,10 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -63,7 +67,13 @@ internal static NetworkData DeserializeNetworkData(JsonElement element) { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtResourceName.ModelSerializationExtensions.WireOptions, MgmtResourceNameContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtResourceNameContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtResourceName/src/Generated/ProviderOperationData.Serialization.cs b/test/TestProjects/MgmtResourceName/src/Generated/ProviderOperationData.Serialization.cs index f3aa9cdbeb9..ff2f8577c86 100644 --- a/test/TestProjects/MgmtResourceName/src/Generated/ProviderOperationData.Serialization.cs +++ b/test/TestProjects/MgmtResourceName/src/Generated/ProviderOperationData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -84,7 +88,13 @@ internal static ProviderOperationData DeserializeProviderOperationData(JsonEleme { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtResourceName.ModelSerializationExtensions.WireOptions, MgmtResourceNameContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtResourceNameContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtSafeFlatten/src/Generated/LongRunningOperation/MgmtSafeFlattenArmOperationOfT.cs b/test/TestProjects/MgmtSafeFlatten/src/Generated/LongRunningOperation/MgmtSafeFlattenArmOperationOfT.cs index d7575400e10..ef9c8857b81 100644 --- a/test/TestProjects/MgmtSafeFlatten/src/Generated/LongRunningOperation/MgmtSafeFlattenArmOperationOfT.cs +++ b/test/TestProjects/MgmtSafeFlatten/src/Generated/LongRunningOperation/MgmtSafeFlattenArmOperationOfT.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtSafeFlattenContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtSafeFlattenContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtSafeFlatten/src/Generated/TypeOneData.Serialization.cs b/test/TestProjects/MgmtSafeFlatten/src/Generated/TypeOneData.Serialization.cs index 126c17cb1d6..5b4cc67fed3 100644 --- a/test/TestProjects/MgmtSafeFlatten/src/Generated/TypeOneData.Serialization.cs +++ b/test/TestProjects/MgmtSafeFlatten/src/Generated/TypeOneData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -37,7 +41,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(LayerOneConflict)) { writer.WritePropertyName("layerOneConflict"u8); - JsonSerializer.Serialize(writer, LayerOneConflict); + ((IJsonModel)LayerOneConflict).Write(writer, ModelSerializationExtensions.WireOptions); } if (Optional.IsCollectionDefined(Tags)) { @@ -102,7 +106,13 @@ internal static TypeOneData DeserializeTypeOneData(JsonElement element) { continue; } - layerOneConflict = JsonSerializer.Deserialize(property.Value.GetRawText()); + layerOneConflict = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtSafeFlatten.ModelSerializationExtensions.WireOptions, MgmtSafeFlattenContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtSafeFlattenContext.Default) +#endif +; continue; } if (property.NameEquals("tags"u8)) @@ -145,7 +155,13 @@ internal static TypeOneData DeserializeTypeOneData(JsonElement element) { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtSafeFlatten.ModelSerializationExtensions.WireOptions, MgmtSafeFlattenContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtSafeFlattenContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtSafeFlatten/src/Generated/TypeTwoData.Serialization.cs b/test/TestProjects/MgmtSafeFlatten/src/Generated/TypeTwoData.Serialization.cs index f5837e59e1a..ea128aee4d5 100644 --- a/test/TestProjects/MgmtSafeFlatten/src/Generated/TypeTwoData.Serialization.cs +++ b/test/TestProjects/MgmtSafeFlatten/src/Generated/TypeTwoData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -114,7 +118,13 @@ internal static TypeTwoData DeserializeTypeTwoData(JsonElement element) { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtSafeFlatten.ModelSerializationExtensions.WireOptions, MgmtSafeFlattenContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtSafeFlattenContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtScopeResource/src/Generated/DeploymentExtendedData.Serialization.cs b/test/TestProjects/MgmtScopeResource/src/Generated/DeploymentExtendedData.Serialization.cs index 5b572931701..af71abc9683 100644 --- a/test/TestProjects/MgmtScopeResource/src/Generated/DeploymentExtendedData.Serialization.cs +++ b/test/TestProjects/MgmtScopeResource/src/Generated/DeploymentExtendedData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -79,7 +83,13 @@ internal static DeploymentExtendedData DeserializeDeploymentExtendedData(JsonEle { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtScopeResource.ModelSerializationExtensions.WireOptions, MgmtScopeResourceContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtScopeResourceContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtScopeResource/src/Generated/FakePolicyAssignmentData.Serialization.cs b/test/TestProjects/MgmtScopeResource/src/Generated/FakePolicyAssignmentData.Serialization.cs index 2a682ee667a..6a0a3f14ee9 100644 --- a/test/TestProjects/MgmtScopeResource/src/Generated/FakePolicyAssignmentData.Serialization.cs +++ b/test/TestProjects/MgmtScopeResource/src/Generated/FakePolicyAssignmentData.Serialization.cs @@ -6,7 +6,10 @@ #nullable disable using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -27,7 +30,7 @@ void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) if (Optional.IsDefined(Identity)) { writer.WritePropertyName("identity"u8); - JsonSerializer.Serialize(writer, Identity); + ((IJsonModel)Identity).Write(writer, ModelSerializationExtensions.WireOptions); } writer.WritePropertyName("properties"u8); writer.WriteStartObject(); @@ -132,7 +135,13 @@ internal static FakePolicyAssignmentData DeserializeFakePolicyAssignmentData(Jso { continue; } - identity = JsonSerializer.Deserialize(property.Value.GetRawText()); + identity = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtScopeResource.ModelSerializationExtensions.WireOptions, MgmtScopeResourceContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtScopeResourceContext.Default) +#endif +; continue; } if (property.NameEquals("id"u8)) @@ -156,7 +165,13 @@ internal static FakePolicyAssignmentData DeserializeFakePolicyAssignmentData(Jso { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtScopeResource.ModelSerializationExtensions.WireOptions, MgmtScopeResourceContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtScopeResourceContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) diff --git a/test/TestProjects/MgmtScopeResource/src/Generated/LongRunningOperation/MgmtScopeResourceArmOperation.cs b/test/TestProjects/MgmtScopeResource/src/Generated/LongRunningOperation/MgmtScopeResourceArmOperation.cs index 2edd6fea60d..a9b19d42694 100644 --- a/test/TestProjects/MgmtScopeResource/src/Generated/LongRunningOperation/MgmtScopeResourceArmOperation.cs +++ b/test/TestProjects/MgmtScopeResource/src/Generated/LongRunningOperation/MgmtScopeResourceArmOperation.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtScopeResourceContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtScopeResourceContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtScopeResource/src/Generated/LongRunningOperation/MgmtScopeResourceArmOperationOfT.cs b/test/TestProjects/MgmtScopeResource/src/Generated/LongRunningOperation/MgmtScopeResourceArmOperationOfT.cs index d81cfe6a88f..bbbeb833f31 100644 --- a/test/TestProjects/MgmtScopeResource/src/Generated/LongRunningOperation/MgmtScopeResourceArmOperationOfT.cs +++ b/test/TestProjects/MgmtScopeResource/src/Generated/LongRunningOperation/MgmtScopeResourceArmOperationOfT.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtScopeResourceContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtScopeResourceContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtScopeResource/src/Generated/Models/Marketplace.Serialization.cs b/test/TestProjects/MgmtScopeResource/src/Generated/Models/Marketplace.Serialization.cs index 053d526a830..607bf284430 100644 --- a/test/TestProjects/MgmtScopeResource/src/Generated/Models/Marketplace.Serialization.cs +++ b/test/TestProjects/MgmtScopeResource/src/Generated/Models/Marketplace.Serialization.cs @@ -6,7 +6,10 @@ #nullable disable using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -95,7 +98,13 @@ internal static Marketplace DeserializeMarketplace(JsonElement element) { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtScopeResource.ModelSerializationExtensions.WireOptions, MgmtScopeResourceContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtScopeResourceContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) diff --git a/test/TestProjects/MgmtScopeResource/src/Generated/ResourceLinkData.Serialization.cs b/test/TestProjects/MgmtScopeResource/src/Generated/ResourceLinkData.Serialization.cs index e98d25b8343..60eb6910903 100644 --- a/test/TestProjects/MgmtScopeResource/src/Generated/ResourceLinkData.Serialization.cs +++ b/test/TestProjects/MgmtScopeResource/src/Generated/ResourceLinkData.Serialization.cs @@ -5,6 +5,10 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -68,7 +72,13 @@ internal static ResourceLinkData DeserializeResourceLinkData(JsonElement element { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtScopeResource.ModelSerializationExtensions.WireOptions, MgmtScopeResourceContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtScopeResourceContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtScopeResource/src/Generated/VMInsightsOnboardingStatusData.Serialization.cs b/test/TestProjects/MgmtScopeResource/src/Generated/VMInsightsOnboardingStatusData.Serialization.cs index 9924d8927b9..ab714038b2a 100644 --- a/test/TestProjects/MgmtScopeResource/src/Generated/VMInsightsOnboardingStatusData.Serialization.cs +++ b/test/TestProjects/MgmtScopeResource/src/Generated/VMInsightsOnboardingStatusData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -52,7 +56,13 @@ internal static VMInsightsOnboardingStatusData DeserializeVMInsightsOnboardingSt { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtScopeResource.ModelSerializationExtensions.WireOptions, MgmtScopeResourceContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtScopeResourceContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) diff --git a/test/TestProjects/MgmtSingletonResource/src/Generated/BrakeData.Serialization.cs b/test/TestProjects/MgmtSingletonResource/src/Generated/BrakeData.Serialization.cs index a6c3a7683f1..3d140f30df4 100644 --- a/test/TestProjects/MgmtSingletonResource/src/Generated/BrakeData.Serialization.cs +++ b/test/TestProjects/MgmtSingletonResource/src/Generated/BrakeData.Serialization.cs @@ -5,6 +5,10 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -56,7 +60,13 @@ internal static BrakeData DeserializeBrakeData(JsonElement element) { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtSingletonResource.ModelSerializationExtensions.WireOptions, MgmtSingletonResourceContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtSingletonResourceContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtSingletonResource/src/Generated/CarData.Serialization.cs b/test/TestProjects/MgmtSingletonResource/src/Generated/CarData.Serialization.cs index dc75e842db6..349e03781a9 100644 --- a/test/TestProjects/MgmtSingletonResource/src/Generated/CarData.Serialization.cs +++ b/test/TestProjects/MgmtSingletonResource/src/Generated/CarData.Serialization.cs @@ -5,6 +5,10 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -63,7 +67,13 @@ internal static CarData DeserializeCarData(JsonElement element) { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtSingletonResource.ModelSerializationExtensions.WireOptions, MgmtSingletonResourceContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtSingletonResourceContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtSingletonResource/src/Generated/IgnitionData.Serialization.cs b/test/TestProjects/MgmtSingletonResource/src/Generated/IgnitionData.Serialization.cs index f85eeddf8ec..7566c9f51be 100644 --- a/test/TestProjects/MgmtSingletonResource/src/Generated/IgnitionData.Serialization.cs +++ b/test/TestProjects/MgmtSingletonResource/src/Generated/IgnitionData.Serialization.cs @@ -5,6 +5,10 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -56,7 +60,13 @@ internal static IgnitionData DeserializeIgnitionData(JsonElement element) { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtSingletonResource.ModelSerializationExtensions.WireOptions, MgmtSingletonResourceContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtSingletonResourceContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtSingletonResource/src/Generated/LongRunningOperation/MgmtSingletonResourceArmOperationOfT.cs b/test/TestProjects/MgmtSingletonResource/src/Generated/LongRunningOperation/MgmtSingletonResourceArmOperationOfT.cs index 451c7131c74..5ef116cfff4 100644 --- a/test/TestProjects/MgmtSingletonResource/src/Generated/LongRunningOperation/MgmtSingletonResourceArmOperationOfT.cs +++ b/test/TestProjects/MgmtSingletonResource/src/Generated/LongRunningOperation/MgmtSingletonResourceArmOperationOfT.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtSingletonResourceContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtSingletonResourceContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtSingletonResource/src/Generated/ParentResourceData.Serialization.cs b/test/TestProjects/MgmtSingletonResource/src/Generated/ParentResourceData.Serialization.cs index c407be62e0c..c4b778502c2 100644 --- a/test/TestProjects/MgmtSingletonResource/src/Generated/ParentResourceData.Serialization.cs +++ b/test/TestProjects/MgmtSingletonResource/src/Generated/ParentResourceData.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -98,7 +102,13 @@ internal static ParentResourceData DeserializeParentResourceData(JsonElement ele { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtSingletonResource.ModelSerializationExtensions.WireOptions, MgmtSingletonResourceContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtSingletonResourceContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtSingletonResource/src/Generated/SingletonResourceData.Serialization.cs b/test/TestProjects/MgmtSingletonResource/src/Generated/SingletonResourceData.Serialization.cs index c94371a50a8..1389f4a4d1c 100644 --- a/test/TestProjects/MgmtSingletonResource/src/Generated/SingletonResourceData.Serialization.cs +++ b/test/TestProjects/MgmtSingletonResource/src/Generated/SingletonResourceData.Serialization.cs @@ -5,6 +5,10 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -63,7 +67,13 @@ internal static SingletonResourceData DeserializeSingletonResourceData(JsonEleme { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtSingletonResource.ModelSerializationExtensions.WireOptions, MgmtSingletonResourceContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtSingletonResourceContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtSubscriptionNameParameter/src/Generated/LongRunningOperation/MgmtSubscriptionNameParameterArmOperation.cs b/test/TestProjects/MgmtSubscriptionNameParameter/src/Generated/LongRunningOperation/MgmtSubscriptionNameParameterArmOperation.cs index 520f6e99787..0c2ff26fd79 100644 --- a/test/TestProjects/MgmtSubscriptionNameParameter/src/Generated/LongRunningOperation/MgmtSubscriptionNameParameterArmOperation.cs +++ b/test/TestProjects/MgmtSubscriptionNameParameter/src/Generated/LongRunningOperation/MgmtSubscriptionNameParameterArmOperation.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtSubscriptionNameParameterContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtSubscriptionNameParameterContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtSubscriptionNameParameter/src/Generated/LongRunningOperation/MgmtSubscriptionNameParameterArmOperationOfT.cs b/test/TestProjects/MgmtSubscriptionNameParameter/src/Generated/LongRunningOperation/MgmtSubscriptionNameParameterArmOperationOfT.cs index d81b862018e..a0932ec2af9 100644 --- a/test/TestProjects/MgmtSubscriptionNameParameter/src/Generated/LongRunningOperation/MgmtSubscriptionNameParameterArmOperationOfT.cs +++ b/test/TestProjects/MgmtSubscriptionNameParameter/src/Generated/LongRunningOperation/MgmtSubscriptionNameParameterArmOperationOfT.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtSubscriptionNameParameterContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtSubscriptionNameParameterContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtSubscriptionNameParameter/src/Generated/SBSubscriptionData.Serialization.cs b/test/TestProjects/MgmtSubscriptionNameParameter/src/Generated/SBSubscriptionData.Serialization.cs index 0efc44789d7..1cf0f7c19f0 100644 --- a/test/TestProjects/MgmtSubscriptionNameParameter/src/Generated/SBSubscriptionData.Serialization.cs +++ b/test/TestProjects/MgmtSubscriptionNameParameter/src/Generated/SBSubscriptionData.Serialization.cs @@ -6,6 +6,9 @@ #nullable disable using System; +using System.ClientModel.Primitives; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -139,7 +142,13 @@ internal static SBSubscriptionData DeserializeSBSubscriptionData(JsonElement ele { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtSubscriptionNameParameter.ModelSerializationExtensions.WireOptions, MgmtSubscriptionNameParameterContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtSubscriptionNameParameterContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) diff --git a/test/TestProjects/MgmtSupersetFlattenInheritance/src/Generated/LongRunningOperation/MgmtSupersetFlattenInheritanceArmOperationOfT.cs b/test/TestProjects/MgmtSupersetFlattenInheritance/src/Generated/LongRunningOperation/MgmtSupersetFlattenInheritanceArmOperationOfT.cs index d4151bbd092..fc84a3e6e98 100644 --- a/test/TestProjects/MgmtSupersetFlattenInheritance/src/Generated/LongRunningOperation/MgmtSupersetFlattenInheritanceArmOperationOfT.cs +++ b/test/TestProjects/MgmtSupersetFlattenInheritance/src/Generated/LongRunningOperation/MgmtSupersetFlattenInheritanceArmOperationOfT.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtSupersetFlattenInheritanceContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtSupersetFlattenInheritanceContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtSupersetFlattenInheritance/src/Generated/Models/ResourceModel2.Serialization.cs b/test/TestProjects/MgmtSupersetFlattenInheritance/src/Generated/Models/ResourceModel2.Serialization.cs index e86470db481..2fa404a10be 100644 --- a/test/TestProjects/MgmtSupersetFlattenInheritance/src/Generated/Models/ResourceModel2.Serialization.cs +++ b/test/TestProjects/MgmtSupersetFlattenInheritance/src/Generated/Models/ResourceModel2.Serialization.cs @@ -5,6 +5,10 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -61,7 +65,13 @@ internal static ResourceModel2 DeserializeResourceModel2(JsonElement element) { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtSupersetFlattenInheritance.ModelSerializationExtensions.WireOptions, MgmtSupersetFlattenInheritanceContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtSupersetFlattenInheritanceContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) diff --git a/test/TestProjects/MgmtSupersetFlattenInheritance/src/Generated/Models/TrackedResourceModel2.Serialization.cs b/test/TestProjects/MgmtSupersetFlattenInheritance/src/Generated/Models/TrackedResourceModel2.Serialization.cs index edd3b7f1ba5..41d9e3a2868 100644 --- a/test/TestProjects/MgmtSupersetFlattenInheritance/src/Generated/Models/TrackedResourceModel2.Serialization.cs +++ b/test/TestProjects/MgmtSupersetFlattenInheritance/src/Generated/Models/TrackedResourceModel2.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -118,7 +122,13 @@ internal static TrackedResourceModel2 DeserializeTrackedResourceModel2(JsonEleme { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtSupersetFlattenInheritance.ModelSerializationExtensions.WireOptions, MgmtSupersetFlattenInheritanceContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtSupersetFlattenInheritanceContext.Default) +#endif +; continue; } if (property.NameEquals("properties"u8)) diff --git a/test/TestProjects/MgmtSupersetFlattenInheritance/src/Generated/ResourceModel1Data.Serialization.cs b/test/TestProjects/MgmtSupersetFlattenInheritance/src/Generated/ResourceModel1Data.Serialization.cs index 386149f8afb..a961449052e 100644 --- a/test/TestProjects/MgmtSupersetFlattenInheritance/src/Generated/ResourceModel1Data.Serialization.cs +++ b/test/TestProjects/MgmtSupersetFlattenInheritance/src/Generated/ResourceModel1Data.Serialization.cs @@ -5,6 +5,10 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -63,7 +67,13 @@ internal static ResourceModel1Data DeserializeResourceModel1Data(JsonElement ele { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtSupersetFlattenInheritance.ModelSerializationExtensions.WireOptions, MgmtSupersetFlattenInheritanceContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtSupersetFlattenInheritanceContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtSupersetFlattenInheritance/src/Generated/TrackedResourceModel1Data.Serialization.cs b/test/TestProjects/MgmtSupersetFlattenInheritance/src/Generated/TrackedResourceModel1Data.Serialization.cs index 1044626cf14..39afff6de7b 100644 --- a/test/TestProjects/MgmtSupersetFlattenInheritance/src/Generated/TrackedResourceModel1Data.Serialization.cs +++ b/test/TestProjects/MgmtSupersetFlattenInheritance/src/Generated/TrackedResourceModel1Data.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -98,7 +102,13 @@ internal static TrackedResourceModel1Data DeserializeTrackedResourceModel1Data(J { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtSupersetFlattenInheritance.ModelSerializationExtensions.WireOptions, MgmtSupersetFlattenInheritanceContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtSupersetFlattenInheritanceContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtSupersetInheritance/src/Generated/LongRunningOperation/MgmtSupersetInheritanceArmOperationOfT.cs b/test/TestProjects/MgmtSupersetInheritance/src/Generated/LongRunningOperation/MgmtSupersetInheritanceArmOperationOfT.cs index 8fc42d891da..0d29c9b9035 100644 --- a/test/TestProjects/MgmtSupersetInheritance/src/Generated/LongRunningOperation/MgmtSupersetInheritanceArmOperationOfT.cs +++ b/test/TestProjects/MgmtSupersetInheritance/src/Generated/LongRunningOperation/MgmtSupersetInheritanceArmOperationOfT.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtSupersetInheritanceContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtSupersetInheritanceContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtSupersetInheritance/src/Generated/Models/SupersetModel5.Serialization.cs b/test/TestProjects/MgmtSupersetInheritance/src/Generated/Models/SupersetModel5.Serialization.cs index d6d6c3ffe75..1761d3100b4 100644 --- a/test/TestProjects/MgmtSupersetInheritance/src/Generated/Models/SupersetModel5.Serialization.cs +++ b/test/TestProjects/MgmtSupersetInheritance/src/Generated/Models/SupersetModel5.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -109,7 +113,13 @@ internal static SupersetModel5 DeserializeSupersetModel5(JsonElement element) { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtSupersetInheritance.ModelSerializationExtensions.WireOptions, MgmtSupersetInheritanceContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtSupersetInheritanceContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtSupersetInheritance/src/Generated/SupersetModel1Data.Serialization.cs b/test/TestProjects/MgmtSupersetInheritance/src/Generated/SupersetModel1Data.Serialization.cs index 2ea5005da66..85bc8694667 100644 --- a/test/TestProjects/MgmtSupersetInheritance/src/Generated/SupersetModel1Data.Serialization.cs +++ b/test/TestProjects/MgmtSupersetInheritance/src/Generated/SupersetModel1Data.Serialization.cs @@ -5,6 +5,10 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -63,7 +67,13 @@ internal static SupersetModel1Data DeserializeSupersetModel1Data(JsonElement ele { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtSupersetInheritance.ModelSerializationExtensions.WireOptions, MgmtSupersetInheritanceContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtSupersetInheritanceContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtSupersetInheritance/src/Generated/SupersetModel4Data.Serialization.cs b/test/TestProjects/MgmtSupersetInheritance/src/Generated/SupersetModel4Data.Serialization.cs index 2b52149ee3d..8e09e3d47f3 100644 --- a/test/TestProjects/MgmtSupersetInheritance/src/Generated/SupersetModel4Data.Serialization.cs +++ b/test/TestProjects/MgmtSupersetInheritance/src/Generated/SupersetModel4Data.Serialization.cs @@ -5,7 +5,11 @@ #nullable disable +using System; +using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -98,7 +102,13 @@ internal static SupersetModel4Data DeserializeSupersetModel4Data(JsonElement ele { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtSupersetInheritance.ModelSerializationExtensions.WireOptions, MgmtSupersetInheritanceContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtSupersetInheritanceContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtSupersetInheritance/src/Generated/SupersetModel6Data.Serialization.cs b/test/TestProjects/MgmtSupersetInheritance/src/Generated/SupersetModel6Data.Serialization.cs index ca57ef65452..18eb4ac3aff 100644 --- a/test/TestProjects/MgmtSupersetInheritance/src/Generated/SupersetModel6Data.Serialization.cs +++ b/test/TestProjects/MgmtSupersetInheritance/src/Generated/SupersetModel6Data.Serialization.cs @@ -5,6 +5,10 @@ #nullable disable +using System; +using System.ClientModel.Primitives; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using Azure.Core; using Azure.ResourceManager.Models; @@ -63,7 +67,13 @@ internal static SupersetModel6Data DeserializeSupersetModel6Data(JsonElement ele { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtSupersetInheritance.ModelSerializationExtensions.WireOptions, MgmtSupersetInheritanceContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtSupersetInheritanceContext.Default) +#endif +; continue; } } diff --git a/test/TestProjects/MgmtTypeSpec/src/Generated/FooData.Serialization.cs b/test/TestProjects/MgmtTypeSpec/src/Generated/FooData.Serialization.cs index b549a0c326a..9a024aaa8fc 100644 --- a/test/TestProjects/MgmtTypeSpec/src/Generated/FooData.Serialization.cs +++ b/test/TestProjects/MgmtTypeSpec/src/Generated/FooData.Serialization.cs @@ -9,6 +9,7 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Linq; +using System.Runtime.InteropServices; using System.Text; using System.Text.Json; using Azure.Core; @@ -49,7 +50,7 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri if (Optional.IsDefined(ExtendedLocation)) { writer.WritePropertyName("extendedLocation"u8); - JsonSerializer.Serialize(writer, ExtendedLocation); + ((IJsonModel)ExtendedLocation).Write(writer, options); } } @@ -100,7 +101,13 @@ internal static FooData DeserializeFooData(JsonElement element, ModelReaderWrite { continue; } - extendedLocation = JsonSerializer.Deserialize(property.Value.GetRawText()); + extendedLocation = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), options, MgmtTypeSpecContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, MgmtTypeSpecContext.Default) +#endif +; continue; } if (property.NameEquals("tags"u8)) @@ -143,7 +150,13 @@ internal static FooData DeserializeFooData(JsonElement element, ModelReaderWrite { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtTypeSpec.ModelSerializationExtensions.WireOptions, MgmtTypeSpecContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtTypeSpecContext.Default) +#endif +; continue; } if (options.Format != "W") diff --git a/test/TestProjects/MgmtTypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs b/test/TestProjects/MgmtTypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs index 792a875f311..398b2aecc80 100644 --- a/test/TestProjects/MgmtTypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestProjects/MgmtTypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,12 +9,10 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; using Azure.Core; -using Azure.ResourceManager.Models; namespace MgmtTypeSpec { @@ -23,8 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, MgmtTypeSpecContext.Default) } }; - internal static readonly JsonSerializerOptions OptionsUseManagedServiceIdentityV3 = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, MgmtTypeSpecContext.Default), new Azure.ResourceManager.Models.ManagedServiceIdentityTypeV3Converter() } }; public static object GetObject(this JsonElement element) { @@ -269,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestProjects/MgmtTypeSpec/src/Generated/LongRunningOperation/MgmtTypeSpecArmOperation.cs b/test/TestProjects/MgmtTypeSpec/src/Generated/LongRunningOperation/MgmtTypeSpecArmOperation.cs index 54bb236e265..ba24c5b0f17 100644 --- a/test/TestProjects/MgmtTypeSpec/src/Generated/LongRunningOperation/MgmtTypeSpecArmOperation.cs +++ b/test/TestProjects/MgmtTypeSpec/src/Generated/LongRunningOperation/MgmtTypeSpecArmOperation.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtTypeSpecContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtTypeSpecContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtTypeSpec/src/Generated/LongRunningOperation/MgmtTypeSpecArmOperationOfT.cs b/test/TestProjects/MgmtTypeSpec/src/Generated/LongRunningOperation/MgmtTypeSpecArmOperationOfT.cs index c9c3f00926b..a1cdc2696ef 100644 --- a/test/TestProjects/MgmtTypeSpec/src/Generated/LongRunningOperation/MgmtTypeSpecArmOperationOfT.cs +++ b/test/TestProjects/MgmtTypeSpec/src/Generated/LongRunningOperation/MgmtTypeSpecArmOperationOfT.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtTypeSpecContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtTypeSpecContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtTypeSpec/src/Generated/Models/MgmtTypeSpecPrivateLinkResourceData.Serialization.cs b/test/TestProjects/MgmtTypeSpec/src/Generated/Models/MgmtTypeSpecPrivateLinkResourceData.Serialization.cs index 4bf16b1e1f5..66efff2a7be 100644 --- a/test/TestProjects/MgmtTypeSpec/src/Generated/Models/MgmtTypeSpecPrivateLinkResourceData.Serialization.cs +++ b/test/TestProjects/MgmtTypeSpec/src/Generated/Models/MgmtTypeSpecPrivateLinkResourceData.Serialization.cs @@ -8,6 +8,7 @@ using System; using System.ClientModel.Primitives; using System.Collections.Generic; +using System.Runtime.InteropServices; using System.Text; using System.Text.Json; using Azure.Core; @@ -46,8 +47,7 @@ protected override void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWri if (Optional.IsDefined(Identity)) { writer.WritePropertyName("identity"u8); - var serializeOptions = new JsonSerializerOptions { Converters = { new ManagedServiceIdentityTypeV3Converter() } }; - JsonSerializer.Serialize(writer, Identity, serializeOptions); + ((IJsonModel)Identity).Write(writer, new ModelReaderWriterOptions("W|v3")); } } @@ -96,8 +96,13 @@ internal static MgmtTypeSpecPrivateLinkResourceData DeserializeMgmtTypeSpecPriva { continue; } - var serializeOptions = new JsonSerializerOptions { Converters = { new ManagedServiceIdentityTypeV3Converter() } }; - identity = JsonSerializer.Deserialize(property.Value.GetRawText(), serializeOptions); + identity = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), new global::System.ClientModel.Primitives.ModelReaderWriterOptions("W|v3"), MgmtTypeSpecContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), new ModelReaderWriterOptions("W|v3"), MgmtTypeSpecContext.Default) +#endif +; continue; } if (property.NameEquals("id"u8)) @@ -121,7 +126,13 @@ internal static MgmtTypeSpecPrivateLinkResourceData DeserializeMgmtTypeSpecPriva { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtTypeSpec.ModelSerializationExtensions.WireOptions, MgmtTypeSpecContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtTypeSpecContext.Default) +#endif +; continue; } if (options.Format != "W") diff --git a/test/TestProjects/MgmtTypeSpec/src/Generated/Models/OperationStatusResult.Serialization.cs b/test/TestProjects/MgmtTypeSpec/src/Generated/Models/OperationStatusResult.Serialization.cs index 175bb44e666..7d482e98343 100644 --- a/test/TestProjects/MgmtTypeSpec/src/Generated/Models/OperationStatusResult.Serialization.cs +++ b/test/TestProjects/MgmtTypeSpec/src/Generated/Models/OperationStatusResult.Serialization.cs @@ -9,6 +9,7 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Linq; +using System.Runtime.InteropServices; using System.Text; using System.Text.Json; using Azure; @@ -78,7 +79,7 @@ protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWrit if (Optional.IsDefined(Error)) { writer.WritePropertyName("error"u8); - JsonSerializer.Serialize(writer, Error); + ((IJsonModel)Error).Write(writer, options); } if (options.Format != "W" && Optional.IsDefined(ResourceId)) { @@ -201,7 +202,13 @@ internal static OperationStatusResult DeserializeOperationStatusResult(JsonEleme { continue; } - error = JsonSerializer.Deserialize(property.Value.GetRawText()); + error = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), options, MgmtTypeSpecContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), options, MgmtTypeSpecContext.Default) +#endif +; continue; } if (property.NameEquals("resourceId"u8)) diff --git a/test/TestProjects/MgmtXmlDeserialization/src/Generated/Internal/ModelSerializationExtensions.cs b/test/TestProjects/MgmtXmlDeserialization/src/Generated/Internal/ModelSerializationExtensions.cs index 0c306e83bff..ec698f52027 100644 --- a/test/TestProjects/MgmtXmlDeserialization/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestProjects/MgmtXmlDeserialization/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,12 +9,10 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; using Azure.Core; -using Azure.ResourceManager.Models; namespace MgmtXmlDeserialization { @@ -23,8 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, MgmtXmlDeserializationContext.Default) } }; - internal static readonly JsonSerializerOptions OptionsUseManagedServiceIdentityV3 = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, MgmtXmlDeserializationContext.Default), new Azure.ResourceManager.Models.ManagedServiceIdentityTypeV3Converter() } }; public static object GetObject(this JsonElement element) { @@ -269,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestProjects/MgmtXmlDeserialization/src/Generated/LongRunningOperation/MgmtXmlDeserializationArmOperation.cs b/test/TestProjects/MgmtXmlDeserialization/src/Generated/LongRunningOperation/MgmtXmlDeserializationArmOperation.cs index b08048ec1ab..fc8808f552b 100644 --- a/test/TestProjects/MgmtXmlDeserialization/src/Generated/LongRunningOperation/MgmtXmlDeserializationArmOperation.cs +++ b/test/TestProjects/MgmtXmlDeserialization/src/Generated/LongRunningOperation/MgmtXmlDeserializationArmOperation.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtXmlDeserializationContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtXmlDeserializationContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtXmlDeserialization/src/Generated/LongRunningOperation/MgmtXmlDeserializationArmOperationOfT.cs b/test/TestProjects/MgmtXmlDeserialization/src/Generated/LongRunningOperation/MgmtXmlDeserializationArmOperationOfT.cs index b3b4a04cdd9..654dda363fb 100644 --- a/test/TestProjects/MgmtXmlDeserialization/src/Generated/LongRunningOperation/MgmtXmlDeserializationArmOperationOfT.cs +++ b/test/TestProjects/MgmtXmlDeserialization/src/Generated/LongRunningOperation/MgmtXmlDeserializationArmOperationOfT.cs @@ -7,7 +7,7 @@ using System; using System.ClientModel.Primitives; -using System.Collections.Generic; +using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure; @@ -60,8 +60,10 @@ private string GetOperationId(RehydrationToken? rehydrationToken) { return null; } - var lroDetails = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtXmlDeserializationContext.Default).ToObjectFromJson>(); - return lroDetails["id"]; + var data = ModelReaderWriter.Write(rehydrationToken, ModelReaderWriterOptions.Json, MgmtXmlDeserializationContext.Default); + using var document = JsonDocument.Parse(data); + var lroDetails = document.RootElement; + return lroDetails.GetProperty("id").GetString(); } /// public override string Id => _operationId ?? NextLinkOperationImplementation.NotSet; diff --git a/test/TestProjects/MgmtXmlDeserialization/src/Generated/XmlInstanceData.Serialization.cs b/test/TestProjects/MgmtXmlDeserialization/src/Generated/XmlInstanceData.Serialization.cs index 94b62d0d0f8..aea6a46be1c 100644 --- a/test/TestProjects/MgmtXmlDeserialization/src/Generated/XmlInstanceData.Serialization.cs +++ b/test/TestProjects/MgmtXmlDeserialization/src/Generated/XmlInstanceData.Serialization.cs @@ -9,6 +9,8 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.IO; +using System.Runtime.InteropServices; +using System.Text; using System.Text.Json; using System.Xml; using System.Xml.Linq; @@ -149,7 +151,13 @@ internal static XmlInstanceData DeserializeXmlInstanceData(JsonElement element, { continue; } - systemData = JsonSerializer.Deserialize(property.Value.GetRawText()); + systemData = +#if NET9_0_OR_GREATER + global::System.ClientModel.Primitives.ModelReaderWriter.Read(new global::System.BinaryData(global::System.Runtime.InteropServices.JsonMarshal.GetRawUtf8Value(property.Value).ToArray()), global::MgmtXmlDeserialization.ModelSerializationExtensions.WireOptions, MgmtXmlDeserializationContext.Default) +#else + ModelReaderWriter.Read(new BinaryData(Encoding.UTF8.GetBytes(property.Value.GetRawText())), ModelSerializationExtensions.WireOptions, MgmtXmlDeserializationContext.Default) +#endif +; continue; } if (options.Format != "W") diff --git a/test/TestProjects/ModelReaderWriterValidation-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs b/test/TestProjects/ModelReaderWriterValidation-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs index ae001e9b2b5..435171c4d24 100644 --- a/test/TestProjects/ModelReaderWriterValidation-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestProjects/ModelReaderWriterValidation-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, ModelReaderWriterValidationTypeSpecContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestProjects/ModelShapes/Generated/Internal/ModelSerializationExtensions.cs b/test/TestProjects/ModelShapes/Generated/Internal/ModelSerializationExtensions.cs index b3b030c8951..3827d95fa07 100644 --- a/test/TestProjects/ModelShapes/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestProjects/ModelShapes/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, ModelShapesContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestProjects/ModelWithConverterUsage/Generated/Internal/ModelSerializationExtensions.cs b/test/TestProjects/ModelWithConverterUsage/Generated/Internal/ModelSerializationExtensions.cs index 679ff1c411e..31933a7ad2b 100644 --- a/test/TestProjects/ModelWithConverterUsage/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestProjects/ModelWithConverterUsage/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, ModelWithConverterUsageContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestProjects/NoDocs-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs b/test/TestProjects/NoDocs-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs index 9506e854fcd..4dfeea5590d 100644 --- a/test/TestProjects/NoDocs-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestProjects/NoDocs-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, NoDocsTypeSpecContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestProjects/Parameters-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs b/test/TestProjects/Parameters-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs index 04204cab6d4..246e3bba131 100644 --- a/test/TestProjects/Parameters-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestProjects/Parameters-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, ParametersTypeSpecContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestProjects/TypeSchemaMapping/SomeFolder/Generated/Internal/ModelSerializationExtensions.cs b/test/TestProjects/TypeSchemaMapping/SomeFolder/Generated/Internal/ModelSerializationExtensions.cs index 9c1dedb0be7..5921b77aee4 100644 --- a/test/TestProjects/TypeSchemaMapping/SomeFolder/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestProjects/TypeSchemaMapping/SomeFolder/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, TypeSchemaMappingContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestProjects/sdk/newprojecttypespec/Azure.NewProject.TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs b/test/TestProjects/sdk/newprojecttypespec/Azure.NewProject.TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs index 5595788efcb..ed33c90874c 100644 --- a/test/TestProjects/sdk/newprojecttypespec/Azure.NewProject.TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestProjects/sdk/newprojecttypespec/Azure.NewProject.TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, AzureNewProjectTypeSpecContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestServerProjects/additionalProperties/Generated/Internal/ModelSerializationExtensions.cs b/test/TestServerProjects/additionalProperties/Generated/Internal/ModelSerializationExtensions.cs index 28c07558756..eaf56db8e61 100644 --- a/test/TestServerProjects/additionalProperties/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestServerProjects/additionalProperties/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, additionalPropertiesContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestServerProjects/azure-parameter-grouping/Generated/Internal/ModelSerializationExtensions.cs b/test/TestServerProjects/azure-parameter-grouping/Generated/Internal/ModelSerializationExtensions.cs index a6208161245..2b24cbb7ddb 100644 --- a/test/TestServerProjects/azure-parameter-grouping/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestServerProjects/azure-parameter-grouping/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, azure_parameter_groupingContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestServerProjects/azure-special-properties/Generated/Internal/ModelSerializationExtensions.cs b/test/TestServerProjects/azure-special-properties/Generated/Internal/ModelSerializationExtensions.cs index bd2154fc866..946f33f0090 100644 --- a/test/TestServerProjects/azure-special-properties/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestServerProjects/azure-special-properties/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, azure_special_propertiesContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestServerProjects/body-array/Generated/Internal/ModelSerializationExtensions.cs b/test/TestServerProjects/body-array/Generated/Internal/ModelSerializationExtensions.cs index dfdbf1ae5e9..742299567e8 100644 --- a/test/TestServerProjects/body-array/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestServerProjects/body-array/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, body_arrayContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestServerProjects/body-boolean/Generated/Internal/ModelSerializationExtensions.cs b/test/TestServerProjects/body-boolean/Generated/Internal/ModelSerializationExtensions.cs index 976a2c747cc..b255ec78450 100644 --- a/test/TestServerProjects/body-boolean/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestServerProjects/body-boolean/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, body_booleanContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestServerProjects/body-byte/Generated/Internal/ModelSerializationExtensions.cs b/test/TestServerProjects/body-byte/Generated/Internal/ModelSerializationExtensions.cs index 12cc9f47212..35387da9a3d 100644 --- a/test/TestServerProjects/body-byte/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestServerProjects/body-byte/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, body_byteContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestServerProjects/body-complex/Generated/Internal/ModelSerializationExtensions.cs b/test/TestServerProjects/body-complex/Generated/Internal/ModelSerializationExtensions.cs index 4cc2e2f795d..4ca0e39bd15 100644 --- a/test/TestServerProjects/body-complex/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestServerProjects/body-complex/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, body_complexContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestServerProjects/body-date/Generated/Internal/ModelSerializationExtensions.cs b/test/TestServerProjects/body-date/Generated/Internal/ModelSerializationExtensions.cs index 2c9417ed210..8d8fc4bb67b 100644 --- a/test/TestServerProjects/body-date/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestServerProjects/body-date/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, body_dateContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestServerProjects/body-datetime-rfc1123/Generated/Internal/ModelSerializationExtensions.cs b/test/TestServerProjects/body-datetime-rfc1123/Generated/Internal/ModelSerializationExtensions.cs index 4bb86edd795..094db5545dc 100644 --- a/test/TestServerProjects/body-datetime-rfc1123/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestServerProjects/body-datetime-rfc1123/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, body_datetime_rfc1123Context.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestServerProjects/body-datetime/Generated/Internal/ModelSerializationExtensions.cs b/test/TestServerProjects/body-datetime/Generated/Internal/ModelSerializationExtensions.cs index 82f50f3841f..0f4602e45ff 100644 --- a/test/TestServerProjects/body-datetime/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestServerProjects/body-datetime/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, body_datetimeContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestServerProjects/body-dictionary/Generated/Internal/ModelSerializationExtensions.cs b/test/TestServerProjects/body-dictionary/Generated/Internal/ModelSerializationExtensions.cs index 3e173b53025..cea594e85c6 100644 --- a/test/TestServerProjects/body-dictionary/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestServerProjects/body-dictionary/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, body_dictionaryContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestServerProjects/body-duration/Generated/Internal/ModelSerializationExtensions.cs b/test/TestServerProjects/body-duration/Generated/Internal/ModelSerializationExtensions.cs index 4c62dbcbbfe..efb4a57d909 100644 --- a/test/TestServerProjects/body-duration/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestServerProjects/body-duration/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, body_durationContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestServerProjects/body-file/Generated/Internal/ModelSerializationExtensions.cs b/test/TestServerProjects/body-file/Generated/Internal/ModelSerializationExtensions.cs index f883d55c3d7..a62638854e3 100644 --- a/test/TestServerProjects/body-file/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestServerProjects/body-file/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, body_fileContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestServerProjects/body-formdata-urlencoded/Generated/Internal/ModelSerializationExtensions.cs b/test/TestServerProjects/body-formdata-urlencoded/Generated/Internal/ModelSerializationExtensions.cs index e272525036d..cf0e1b26dff 100644 --- a/test/TestServerProjects/body-formdata-urlencoded/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestServerProjects/body-formdata-urlencoded/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, body_formdata_urlencodedContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestServerProjects/body-formdata/Generated/Internal/ModelSerializationExtensions.cs b/test/TestServerProjects/body-formdata/Generated/Internal/ModelSerializationExtensions.cs index 8d2ca471a18..b5426610dfc 100644 --- a/test/TestServerProjects/body-formdata/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestServerProjects/body-formdata/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, body_formdataContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestServerProjects/body-integer/Generated/Internal/ModelSerializationExtensions.cs b/test/TestServerProjects/body-integer/Generated/Internal/ModelSerializationExtensions.cs index 5d57e50fee0..de47ceb5b52 100644 --- a/test/TestServerProjects/body-integer/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestServerProjects/body-integer/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, body_integerContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestServerProjects/body-number/Generated/Internal/ModelSerializationExtensions.cs b/test/TestServerProjects/body-number/Generated/Internal/ModelSerializationExtensions.cs index df47bf16abc..5371e521251 100644 --- a/test/TestServerProjects/body-number/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestServerProjects/body-number/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, body_numberContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestServerProjects/body-string/Generated/Internal/ModelSerializationExtensions.cs b/test/TestServerProjects/body-string/Generated/Internal/ModelSerializationExtensions.cs index 1acf0fcef2e..67c5b76b5d6 100644 --- a/test/TestServerProjects/body-string/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestServerProjects/body-string/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, body_stringContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestServerProjects/body-time/Generated/Internal/ModelSerializationExtensions.cs b/test/TestServerProjects/body-time/Generated/Internal/ModelSerializationExtensions.cs index f41ed3557a6..259a7b6fbbf 100644 --- a/test/TestServerProjects/body-time/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestServerProjects/body-time/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, body_timeContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestServerProjects/constants/Generated/Internal/ModelSerializationExtensions.cs b/test/TestServerProjects/constants/Generated/Internal/ModelSerializationExtensions.cs index 48594e5b3dc..ad3622496fc 100644 --- a/test/TestServerProjects/constants/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestServerProjects/constants/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, constantsContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestServerProjects/custom-baseUrl-more-options/Generated/Internal/ModelSerializationExtensions.cs b/test/TestServerProjects/custom-baseUrl-more-options/Generated/Internal/ModelSerializationExtensions.cs index e60f1a1fca3..b85dd808424 100644 --- a/test/TestServerProjects/custom-baseUrl-more-options/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestServerProjects/custom-baseUrl-more-options/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, custom_baseUrl_more_optionsContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestServerProjects/custom-baseUrl-paging/Generated/Internal/ModelSerializationExtensions.cs b/test/TestServerProjects/custom-baseUrl-paging/Generated/Internal/ModelSerializationExtensions.cs index e919257747a..befe744c4ae 100644 --- a/test/TestServerProjects/custom-baseUrl-paging/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestServerProjects/custom-baseUrl-paging/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, custom_baseUrl_pagingContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestServerProjects/custom-baseUrl/Generated/Internal/ModelSerializationExtensions.cs b/test/TestServerProjects/custom-baseUrl/Generated/Internal/ModelSerializationExtensions.cs index aacb7f6fa69..752ab95cdb8 100644 --- a/test/TestServerProjects/custom-baseUrl/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestServerProjects/custom-baseUrl/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, custom_baseUrlContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestServerProjects/extensible-enums-swagger/Generated/Internal/ModelSerializationExtensions.cs b/test/TestServerProjects/extensible-enums-swagger/Generated/Internal/ModelSerializationExtensions.cs index d84763589a0..dea5fc5f0c6 100644 --- a/test/TestServerProjects/extensible-enums-swagger/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestServerProjects/extensible-enums-swagger/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, extensible_enums_swaggerContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestServerProjects/head/Generated/Internal/ModelSerializationExtensions.cs b/test/TestServerProjects/head/Generated/Internal/ModelSerializationExtensions.cs index 8d7d3ef2cab..fe430b070aa 100644 --- a/test/TestServerProjects/head/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestServerProjects/head/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, headContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestServerProjects/header/Generated/Internal/ModelSerializationExtensions.cs b/test/TestServerProjects/header/Generated/Internal/ModelSerializationExtensions.cs index bad2604a571..646a5b5f200 100644 --- a/test/TestServerProjects/header/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestServerProjects/header/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, headerContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestServerProjects/httpInfrastructure/Generated/Internal/ModelSerializationExtensions.cs b/test/TestServerProjects/httpInfrastructure/Generated/Internal/ModelSerializationExtensions.cs index 26d7a472cb3..76ea5dc63f6 100644 --- a/test/TestServerProjects/httpInfrastructure/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestServerProjects/httpInfrastructure/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, httpInfrastructureContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestServerProjects/lro-parameterized-endpoints/Generated/Internal/ModelSerializationExtensions.cs b/test/TestServerProjects/lro-parameterized-endpoints/Generated/Internal/ModelSerializationExtensions.cs index d9dcdebf9ed..828252ebe66 100644 --- a/test/TestServerProjects/lro-parameterized-endpoints/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestServerProjects/lro-parameterized-endpoints/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, lro_parameterized_endpointsContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestServerProjects/lro/Generated/Internal/ModelSerializationExtensions.cs b/test/TestServerProjects/lro/Generated/Internal/ModelSerializationExtensions.cs index 4f567f500ff..dca03f2a41a 100644 --- a/test/TestServerProjects/lro/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestServerProjects/lro/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, lroContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestServerProjects/media_types/Generated/Internal/ModelSerializationExtensions.cs b/test/TestServerProjects/media_types/Generated/Internal/ModelSerializationExtensions.cs index f12d9529bb3..d986086e2e6 100644 --- a/test/TestServerProjects/media_types/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestServerProjects/media_types/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, media_typesContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestServerProjects/model-flattening/Generated/Internal/ModelSerializationExtensions.cs b/test/TestServerProjects/model-flattening/Generated/Internal/ModelSerializationExtensions.cs index cac8d580908..02ed04a8e10 100644 --- a/test/TestServerProjects/model-flattening/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestServerProjects/model-flattening/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, model_flatteningContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestServerProjects/multiple-inheritance/Generated/Internal/ModelSerializationExtensions.cs b/test/TestServerProjects/multiple-inheritance/Generated/Internal/ModelSerializationExtensions.cs index 079693e202b..ec4755cf505 100644 --- a/test/TestServerProjects/multiple-inheritance/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestServerProjects/multiple-inheritance/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, multiple_inheritanceContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestServerProjects/non-string-enum/Generated/Internal/ModelSerializationExtensions.cs b/test/TestServerProjects/non-string-enum/Generated/Internal/ModelSerializationExtensions.cs index eaf5a32dc13..edd7b8e8a8f 100644 --- a/test/TestServerProjects/non-string-enum/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestServerProjects/non-string-enum/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, non_string_enumContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestServerProjects/object-type/Generated/Internal/ModelSerializationExtensions.cs b/test/TestServerProjects/object-type/Generated/Internal/ModelSerializationExtensions.cs index c2efc1b6acd..6754702ea10 100644 --- a/test/TestServerProjects/object-type/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestServerProjects/object-type/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, object_typeContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestServerProjects/paging/Generated/Internal/ModelSerializationExtensions.cs b/test/TestServerProjects/paging/Generated/Internal/ModelSerializationExtensions.cs index 9c6e91d051e..43ab0aa7cb9 100644 --- a/test/TestServerProjects/paging/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestServerProjects/paging/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, pagingContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestServerProjects/required-optional/Generated/Internal/ModelSerializationExtensions.cs b/test/TestServerProjects/required-optional/Generated/Internal/ModelSerializationExtensions.cs index 236a913438e..6e4c2a6a606 100644 --- a/test/TestServerProjects/required-optional/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestServerProjects/required-optional/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, required_optionalContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestServerProjects/subscriptionId-apiVersion/Generated/Internal/ModelSerializationExtensions.cs b/test/TestServerProjects/subscriptionId-apiVersion/Generated/Internal/ModelSerializationExtensions.cs index 04e3104613a..29f7e124bdc 100644 --- a/test/TestServerProjects/subscriptionId-apiVersion/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestServerProjects/subscriptionId-apiVersion/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, subscriptionId_apiVersionContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestServerProjects/url-multi-collectionFormat/Generated/Internal/ModelSerializationExtensions.cs b/test/TestServerProjects/url-multi-collectionFormat/Generated/Internal/ModelSerializationExtensions.cs index 17254517a10..f743bee156d 100644 --- a/test/TestServerProjects/url-multi-collectionFormat/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestServerProjects/url-multi-collectionFormat/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, url_multi_collectionFormatContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestServerProjects/url/Generated/Internal/ModelSerializationExtensions.cs b/test/TestServerProjects/url/Generated/Internal/ModelSerializationExtensions.cs index 86704a10050..f16f3190481 100644 --- a/test/TestServerProjects/url/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestServerProjects/url/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, urlContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestServerProjects/validation/Generated/Internal/ModelSerializationExtensions.cs b/test/TestServerProjects/validation/Generated/Internal/ModelSerializationExtensions.cs index 75ae63aef98..7c08138bc4b 100644 --- a/test/TestServerProjects/validation/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestServerProjects/validation/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, validationContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestServerProjects/xml-service/Generated/Internal/ModelSerializationExtensions.cs b/test/TestServerProjects/xml-service/Generated/Internal/ModelSerializationExtensions.cs index 1a1fed81d6a..a28d2210200 100644 --- a/test/TestServerProjects/xml-service/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestServerProjects/xml-service/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, xml_serviceContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestServerProjects/xms-error-responses/Generated/Internal/ModelSerializationExtensions.cs b/test/TestServerProjects/xms-error-responses/Generated/Internal/ModelSerializationExtensions.cs index a8d841b35f2..834debaa149 100644 --- a/test/TestServerProjects/xms-error-responses/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestServerProjects/xms-error-responses/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, xms_error_responsesContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/TestServerProjectsLowLevel/dpg-customization/src/Generated/Internal/ModelSerializationExtensions.cs b/test/TestServerProjectsLowLevel/dpg-customization/src/Generated/Internal/ModelSerializationExtensions.cs index 5c58cab7356..5fba0e3d660 100644 --- a/test/TestServerProjectsLowLevel/dpg-customization/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/TestServerProjectsLowLevel/dpg-customization/src/Generated/Internal/ModelSerializationExtensions.cs @@ -9,7 +9,6 @@ using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text.Json; using System.Xml; @@ -22,7 +21,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, dpg_customization_LowLevelContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -267,20 +265,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - [UnconditionalSuppressMessage("Trimming", "IL3050", Justification = "By passing in the JsonSerializerOptions with a reference to AzureResourceManagerCosmosDBContext.Default we are certain there is no AOT compat issue.")] - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/UnbrandedProjects/Customized-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs b/test/UnbrandedProjects/Customized-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs index aaebd5d9e42..f5f2eb724ed 100644 --- a/test/UnbrandedProjects/Customized-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/UnbrandedProjects/Customized-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs @@ -17,7 +17,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, CustomizedTypeSpecContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -259,16 +258,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/UnbrandedProjects/NoDocsUnbranded-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs b/test/UnbrandedProjects/NoDocsUnbranded-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs index fce884c4ad6..7db31f241cd 100644 --- a/test/UnbrandedProjects/NoDocsUnbranded-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/UnbrandedProjects/NoDocsUnbranded-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs @@ -17,7 +17,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, NoDocsUnbrandedTypeSpecContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -259,16 +258,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/UnbrandedProjects/NoTest-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs b/test/UnbrandedProjects/NoTest-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs index 945e65bd419..4759b9a70de 100644 --- a/test/UnbrandedProjects/NoTest-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/UnbrandedProjects/NoTest-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs @@ -17,7 +17,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, NoTestTypeSpecContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -259,16 +258,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ"; diff --git a/test/UnbrandedProjects/Unbranded-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs b/test/UnbrandedProjects/Unbranded-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs index 9626a88b073..91ce1b61c07 100644 --- a/test/UnbrandedProjects/Unbranded-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs +++ b/test/UnbrandedProjects/Unbranded-TypeSpec/src/Generated/Internal/ModelSerializationExtensions.cs @@ -17,7 +17,6 @@ internal static class ModelSerializationExtensions internal static readonly JsonDocumentOptions JsonDocumentOptions = new JsonDocumentOptions { MaxDepth = 256 }; internal static readonly ModelReaderWriterOptions WireOptions = new ModelReaderWriterOptions("W"); internal static readonly BinaryData SentinelValue = BinaryData.FromBytes("\"__EMPTY__\""u8.ToArray()); - internal static readonly JsonSerializerOptions Options = new JsonSerializerOptions { Converters = { new JsonModelConverter(WireOptions, UnbrandedTypeSpecContext.Default) } }; public static object GetObject(this JsonElement element) { @@ -259,16 +258,6 @@ internal static bool IsSentinelValue(BinaryData value) return sentinelSpan.SequenceEqual(valueSpan); } - public static T JsonDeserialize(string json, JsonSerializerOptions options) - { - return JsonSerializer.Deserialize(json, options); - } - - public static void JsonSerialize(Utf8JsonWriter writer, T data, JsonSerializerOptions options) - { - JsonSerializer.Serialize(writer, data, options); - } - internal static class TypeFormatters { private const string RoundtripZFormat = "yyyy-MM-ddTHH:mm:ss.fffffffZ";