diff --git a/src/core/AutoRest.Core/Model/CodeModel.cs b/src/core/AutoRest.Core/Model/CodeModel.cs index 0b947d81ab..f47d7d1535 100644 --- a/src/core/AutoRest.Core/Model/CodeModel.cs +++ b/src/core/AutoRest.Core/Model/CodeModel.cs @@ -182,5 +182,10 @@ public virtual IEnumerable MyReservedNames } public virtual HashSet LocallyUsedNames => null; + + public bool ShouldGenerateXmlSerialization => + Methods.Any(method => + method.RequestContentType == "application/xml" || + (method.ResponseContentTypes?.Any(rct => rct.StartsWith("application/xml")) ?? false)); } } \ No newline at end of file diff --git a/src/core/AutoRest.Core/Model/IModelType.cs b/src/core/AutoRest.Core/Model/IModelType.cs index 7f317895c8..0c621c8732 100644 --- a/src/core/AutoRest.Core/Model/IModelType.cs +++ b/src/core/AutoRest.Core/Model/IModelType.cs @@ -51,6 +51,19 @@ public interface IModelType : IParent, IChild /// The object to compare with this object. /// true if the specified object is functionally equal to this object; otherwise, false. bool StructurallyEquals(IModelType other); + + XmlProperties XmlProperties { get; set; } + + [JsonIgnore] + string XmlName { get; } + [JsonIgnore] + string XmlNamespace { get; } + [JsonIgnore] + string XmlPrefix { get; } + [JsonIgnore] + bool XmlIsWrapped { get; } + [JsonIgnore] + bool XmlIsAttribute { get; } } /// @@ -179,7 +192,19 @@ public virtual bool StructurallyEquals(IModelType other) public virtual IEnumerable IdentifiersInScope => this.SingleItemConcat(Parent?.IdentifiersInScope); [JsonIgnore] public virtual IEnumerable Children => Enumerable.Empty(); + + public XmlProperties XmlProperties { get; set; } + [JsonIgnore] + public virtual string XmlName => XmlProperties?.Name ?? Name.RawValue; + [JsonIgnore] + public string XmlNamespace => XmlProperties?.Namespace; + [JsonIgnore] + public string XmlPrefix => XmlProperties?.Prefix; + [JsonIgnore] + public bool XmlIsWrapped => XmlProperties?.Wrapped ?? false; + [JsonIgnore] + public bool XmlIsAttribute => XmlProperties?.Attribute ?? false; } } \ No newline at end of file diff --git a/src/core/AutoRest.Core/Model/Method.cs b/src/core/AutoRest.Core/Model/Method.cs index d8bfbe1848..b0316b3685 100644 --- a/src/core/AutoRest.Core/Model/Method.cs +++ b/src/core/AutoRest.Core/Model/Method.cs @@ -225,6 +225,11 @@ public string Summary /// public string RequestContentType { get; set; } + /// + /// The potential response content types. + /// + public string[] ResponseContentTypes { get; set;} + /// /// Gets vendor extensions dictionary. /// diff --git a/src/core/AutoRest.Core/Model/Property.cs b/src/core/AutoRest.Core/Model/Property.cs index a8824d5a5d..efae28fdc3 100644 --- a/src/core/AutoRest.Core/Model/Property.cs +++ b/src/core/AutoRest.Core/Model/Property.cs @@ -91,5 +91,46 @@ public Fixable Summary } public virtual bool IsPolymorphicDiscriminator => true == (Parent as CompositeType)?.BasePolymorphicDiscriminator?.EqualsIgnoreCase(Name.RawValue); + + /// + /// Represents the path for getting to this property when holding the JSON node of the parent object in your hand. + /// + public IEnumerable RealPath { get; set; } + + /// + /// Represents the path for getting to this property when holding the XML node of the parent object in your hand. + /// + public IEnumerable RealXmlPath + { + get + { + // special case: sequence types are usually inlined into parent + if (ModelType is SequenceType && !XmlIsWrapped) + { + yield break; + } + + // special case: inline property (like additional properties and such) + if (RealPath?.Any() != true) + { + yield break; + } + + yield return XmlName; + } + } + + public XmlProperties XmlProperties { get; set; } + + [JsonIgnore] + public string XmlName => XmlProperties?.Name ?? RealPath.FirstOrDefault() ?? Name; + [JsonIgnore] + public string XmlNamespace => XmlProperties?.Namespace ?? ModelType.XmlNamespace; + [JsonIgnore] + public string XmlPrefix => XmlProperties?.Prefix ?? ModelType.XmlPrefix; + [JsonIgnore] + public bool XmlIsWrapped => XmlProperties?.Wrapped ?? ModelType.XmlIsWrapped; + [JsonIgnore] + public bool XmlIsAttribute => XmlProperties?.Attribute ?? ModelType.XmlIsAttribute; } } \ No newline at end of file diff --git a/src/core/AutoRest.Core/Model/SequenceType.cs b/src/core/AutoRest.Core/Model/SequenceType.cs index 6b742dfd15..193d04b068 100644 --- a/src/core/AutoRest.Core/Model/SequenceType.cs +++ b/src/core/AutoRest.Core/Model/SequenceType.cs @@ -3,6 +3,7 @@ using System.Globalization; using Newtonsoft.Json; +using AutoRest.Core.Utilities; namespace AutoRest.Core.Model { @@ -28,5 +29,22 @@ public override void Disambiguate() /// Gets or sets the element type of the collection. /// public virtual IModelType ElementType { get; set; } + + /// + /// Xml Properties... + /// + public XmlProperties ElementXmlProperties { get; set; } + + [JsonIgnore] + public override string XmlName => base.XmlName.Else(ElementType.XmlName); + + [JsonIgnore] + public string ElementXmlName => ElementXmlProperties?.Name ?? XmlName; + [JsonIgnore] + public string ElementXmlNamespace => ElementXmlProperties?.Namespace ?? ElementType.XmlNamespace; + [JsonIgnore] + public string ElementXmlPrefix => ElementXmlProperties?.Prefix ?? ElementType.XmlPrefix; + [JsonIgnore] + public bool ElementXmlIsWrapped => ElementXmlProperties?.Wrapped ?? ElementType.XmlIsWrapped; } } \ No newline at end of file diff --git a/src/core/AutoRest.Core/Model/XmlProperties.cs b/src/core/AutoRest.Core/Model/XmlProperties.cs new file mode 100644 index 0000000000..c6aaee5085 --- /dev/null +++ b/src/core/AutoRest.Core/Model/XmlProperties.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace AutoRest.Core.Model +{ + public class XmlProperties + { + /// + /// Replaces the name of the element/attribute used for the described schema property. + /// When defined within the Items Object (items), it will affect the name of the individual XML elements within the list. + /// When defined alongside type being array (outside the items), it will affect the wrapping element and only if wrapped is true. + /// If wrapped is false, it will be ignored. + /// + public string Name { get; set; } + + /// + /// The URL of the namespace definition. + /// Value SHOULD be in the form of a URL. + /// + public string Namespace { get; set; } + + /// + /// The prefix to be used for the name. + /// + public string Prefix { get; set; } + + /// + /// Declares whether the property definition translates to an attribute instead of an element. + /// + public bool Attribute { get; set; } + + /// + /// MAY be used only for an array definition. + /// Signifies whether the array is wrapped (for example, ``) or unwrapped (``). + /// The definition takes effect only when defined alongside type being array (outside the items). + /// + public bool Wrapped { get; set; } + } +} diff --git a/src/core/AutoRest.Extensions/SwaggerExtensions.cs b/src/core/AutoRest.Extensions/SwaggerExtensions.cs index e16b669359..8372a94245 100644 --- a/src/core/AutoRest.Extensions/SwaggerExtensions.cs +++ b/src/core/AutoRest.Extensions/SwaggerExtensions.cs @@ -37,6 +37,7 @@ public abstract class SwaggerExtensions public const string PositionInOperation = "positionInOperation"; public const string ParameterLocationExtension = "x-ms-parameter-location"; public const string ExternalExtension = "x-ms-external"; + public const string HeaderCollectionPrefix = "x-ms-header-collection-prefix"; private static bool hostChecked = false; diff --git a/src/core/AutoRest/Simplify/CSharpSimplifier.cs b/src/core/AutoRest/Simplify/CSharpSimplifier.cs index 46fac377df..ed94b0737d 100644 --- a/src/core/AutoRest/Simplify/CSharpSimplifier.cs +++ b/src/core/AutoRest/Simplify/CSharpSimplifier.cs @@ -18,18 +18,21 @@ namespace AutoRest.Simplify public class CSharpSimplifier { private static MetadataReference mscorlib; + private static MetadataReference newtonsoft; + private static MetadataReference xml; private static MetadataReference Mscorlib { - get - { - if (mscorlib == null) - { - mscorlib = MetadataReference.CreateFromFile(typeof(object).Assembly.Location); - } + get {return mscorlib ?? (mscorlib = MetadataReference.CreateFromFile(typeof(object).Assembly.Location));} + } - return mscorlib; - } + private static MetadataReference Xml { + get {return xml ?? (xml = MetadataReference.CreateFromFile($"{Path.GetDirectoryName(typeof(object).Assembly.Location)}\\System.Xml.Linq.dll"));} + } + + private static MetadataReference Newtonsoft + { + get {return newtonsoft ?? (newtonsoft = MetadataReference.CreateFromFile(typeof(Newtonsoft.Json.JsonObjectAttribute).Assembly.Location));} } public async Task Run() @@ -45,17 +48,13 @@ public async Task Run() var solution = new AdhocWorkspace().CurrentSolution .AddProject(projectId, "MyProject", "MyProject", LanguageNames.CSharp) .AddMetadataReference(projectId, Mscorlib) + .AddMetadataReference(projectId, Xml) + .AddMetadataReference(projectId, Newtonsoft) .AddMetadataReference(projectId, AppDomain.CurrentDomain.GetAssemblies() - .Where( - a => - string.Compare(a.GetName().Name, "Microsoft.Rest.ClientRuntime.Azure", - StringComparison.OrdinalIgnoreCase) == 0) + .Where(a =>string.Compare(a.GetName().Name, "Microsoft.Rest.ClientRuntime.Azure",StringComparison.OrdinalIgnoreCase) == 0) .Select(a => MetadataReference.CreateFromFile(a.Location)).Single()) .AddMetadataReference(projectId, AppDomain.CurrentDomain.GetAssemblies() - .Where( - a => - string.Compare(a.GetName().Name, "Microsoft.Rest.ClientRuntime", - StringComparison.OrdinalIgnoreCase) == 0) + .Where(a =>string.Compare(a.GetName().Name, "Microsoft.Rest.ClientRuntime",StringComparison.OrdinalIgnoreCase) == 0) .Select(a => MetadataReference.CreateFromFile(a.Location)).Single()) .AddMetadataReference(projectId, AppDomain.CurrentDomain.GetAssemblies() .Where(a => string.Compare(a.GetName().Name, "System", StringComparison.OrdinalIgnoreCase) == 0) diff --git a/src/core/AutoRest/project.json b/src/core/AutoRest/project.json index b2c8a9084d..b06381fcb3 100644 --- a/src/core/AutoRest/project.json +++ b/src/core/AutoRest/project.json @@ -41,6 +41,7 @@ }, "dependencies": { + "System.Xml.XDocument" : "4.0.0", "Newtonsoft.Json": {"version": "[9.0.1,10.0)", "type":"build"}, "AutoRest.Core": { "target": "project" ,"type":"build"}, "AutoRest.Swagger": { "target": "project", "type": "build" }, diff --git a/src/dev/AutoRest.Preview/Linting.cs b/src/dev/AutoRest.Preview/Linting.cs index 01a650e076..84abcd5e4f 100644 --- a/src/dev/AutoRest.Preview/Linting.cs +++ b/src/dev/AutoRest.Preview/Linting.cs @@ -91,17 +91,20 @@ public void ProcessMessages(string swagger, IEnumerable messages) { foreach (var message in messages.Where(m => m.Path != null)) { - scintilla.IndicatorCurrent = INDICATOR_BASE + (int)message.Severity; - var node = message.Path.SelectNode(doc); - var start = node.Start.Index; - var len = Math.Max(1, node.End.Index - start); - scintilla.IndicatorFillRange(start, len); - highlights.Add(new Highlight - { - Start = start, - End = start + len, - Message = $"{message.Severity}: [{message.Path.XPath}] {message.Message}" - }); + try { + scintilla.IndicatorCurrent = INDICATOR_BASE + (int)message.Severity; + var node = message.Path.SelectNode(doc); + var start = node.Start.Index; + var len = Math.Max(1, node.End.Index - start); + scintilla.IndicatorFillRange(start, len); + highlights.Add(new Highlight { + Start = start, + End = start + len, + Message = $"{message.Severity}: [{message.Path.XPath}] {message.Message}" + }); + } catch { + + } } } } diff --git a/src/dev/AutoRest.Preview/default.yaml b/src/dev/AutoRest.Preview/default.yaml index 9b10360d1b..104299fb03 100644 --- a/src/dev/AutoRest.Preview/default.yaml +++ b/src/dev/AutoRest.Preview/default.yaml @@ -1,69 +1,2561 @@ -swagger: '2.0' -info: - version: 1.0.0 - title: Simple API -paths: - /operationInteger: - get: - operationId: test_integer - responses: - 200: - description: OK - schema: - $ref: '#/definitions/ResultInteger' - parameters: - - name: param000 - in: query - type: integer - required: true - - name: param001 - in: query - type: integer - x-nullable: false - - name: paramObj - in: query - schema: - $ref: '#/definitions/ResultInteger' - -definitions: - ResultInteger: - required: - - Member100 - - Member110 - properties: - MemberInteger: - type: integer - readOnly: false - default: 42 - x-nullable: true - MemberGuid: - type: string - format: uuid - readOnly: false - default: 42 - x-nullable: true - MemberList: - type: array - items: - x-nullable: true - type: integer - readOnly: false - default: 42 - MemberDictionary: - type: object - additionalProperties: - x-nullable: true - type: integer - readOnly: false - default: 42 - MemberDictionaryX: - type: object - properties: - nested: - type: integer - x-nullable: false - additionalProperties: - x-nullable: false - type: integer - readOnly: false - default: 42 \ No newline at end of file +{ + "swagger": 2.0, + "info": { + "title": "Azure Storage", + "version": "1.0.0", + "x-ms-code-generation-settings": { + "header": "MIT", + "strictSpecAdherence": false + } + }, + "x-ms-parameterized-host": "{accountName}.blob.core.windows.net", + "schemes": ["http"], + "consumes": [ + "application/xml", + "application/json", + "application/octet-stream", + "text/plain" + ], + "produces": [ + "application/xml", + "application/json", + "application/octet-stream", + "text/plain" + ], + "paths" : { + "/{container}/{blob}": { + "get": { + "tags": ["blobs"], + "operationId": "Blobs_Get", + "parameters": [ + { + "$ref": "#/parameters/BlobContainer" + }, + { + "$ref": "#/parameters/Blob" + }, + { + "$ref": "#/parameters/Snapshot" + }, + { + "$ref": "#/parameters/Range" + }, + { + "$ref": "#/parameters/LeaseId" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/ClientRequestId" + } + ], + "responses": { + "200": { + "description": "Returns the content of the entire blob.", + "headers": { + "x-ms-request-id" : { + "type": "string", + "description": "This header uniquely identifies the request that was made and can be used for troubleshooting the request." + }, + "x-ms-version" : { + "type": "string", + "description": "Indicates the version of the Blob service used to execute the request. This header is returned for requests made against version 2009-09-19 and above." + } + }, + "schema": { + "type": "file" + } + }, + "206": { + "description": "Returns the content of a specified range of the blob.", + "headers": { + "x-ms-request-id" : { + "type": "string", + "description": "This header uniquely identifies the request that was made and can be used for troubleshooting the request." + }, + "x-ms-version" : { + "type": "string", + "description": "Indicates the version of the Blob service used to execute the request. This header is returned for requests made against version 2009-09-19 and above." + } + }, + "schema": { + "type": "file" + } + }, + "default": { + "$ref": "#/responses/Default" + } + } + }, + "head": { + "tags": ["blobs"], + "operationId": "Blobs_GetProperties", + "parameters": [ + { + "$ref": "#/parameters/BlobContainer" + }, + { + "$ref": "#/parameters/Blob" + }, + { + "$ref": "#/parameters/Snapshot" + }, + { + "$ref": "#/parameters/LeaseId" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/ClientRequestId" + } + ], + "responses": { + "200": { + "description": "Returns the properties of the blob.", + "headers": { + "x-ms-request-id" : { + "type": "string", + "description": "This header uniquely identifies the request that was made and can be used for troubleshooting the request." + }, + "x-ms-version" : { + "type": "string", + "description": "Indicates the version of the Blob service used to execute the request. This header is returned for requests made against version 2009-09-19 and above." + }, + "metadata": { + "type": "string", + "x-ms-header-collection-prefix": "x-ms-meta-" + }, + "x-ms-lease-duration" : { + "type": "string", + "x-ms-client-name": "leaseDuration", + "enum": ["pending","success","aborted","failed"], + "x-ms-enum": { + "name": "LeaseDuration", + "modelAsString": false + } + }, + "x-ms-lease-state" : { + "type": "string", + "x-ms-client-name": "leaseState", + "enum": ["available","leased","expired","breaking","broken"], + "x-ms-enum": { + "name": "LeaseState", + "modelAsString": false + } + }, + "x-ms-lease-status" : { + "type": "string", + "x-ms-client-name": "leaseStatus", + "enum": ["locked","unlocked"], + "x-ms-enum": { + "name": "LeaseStatus", + "modelAsString": false + } + }, + "ETag" : { + "type": "string", + "description": "The entity tag for the container." + }, + "Last-Modified" : { + "type": "string", + "description": "Returns the date and time the container was last modified." + }, + "x-ms-blob-type" : { + "type": "string", + "description": "Lease status of the container.", + "enum": [ "BlockBlob", "PageBlob", "AppendBlob" ] + }, + "x-ms-copy-completion-time" : { + "type": "string", + "format": "datetime", + "description": "Conclusion time of the last attempted Copy Blob operation where this blob was the destination blob." + }, + "x-ms-copy-status-description" : { + "type": "string", + "description": "Describes cause of fatal or non-fatal copy operation failure." + }, + "x-ms-copy-id" : { + "type": "string", + "description": "String identifier for the last attempted Copy Blob operation where this blob was the destination blob." + }, + "x-ms-copy-progress" : { + "type": "integer", + "description": "Contains the number of bytes copied and the total bytes in the source in the last attempted Copy Blob operation where this blob was the destination blob." + }, + "x-ms-copy-source" : { + "type": "string", + "format": "datetime", + "description": "URL up to 2 KB in length that specifies the source blob used in the last attempted Copy Blob operation where this blob was the destination blob." + }, + "x-ms-copy-status" : { + "type": "string", + "format": "datetime", + "description": "State of the copy operation identified by x-ms-copy-id.", + "enum": [ "pending", "success", "aborted", "failed" ] + }, + "x-ms-blob-sequence-number" : { + "type": "integer", + "description": "The current sequence number for a page blob." + }, + "x-ms-blob-committed-block-count" : { + "type": "integer", + "description": "The number of committed blocks present in the blob. This header is returned only for append blobs." + } + } + } + } + }, + "delete": { + "tags": ["blobs"], + "operationId": "Blobs_Remove", + "parameters": [ + { + "$ref": "#/parameters/BlobContainer" + }, + { + "$ref": "#/parameters/Blob" + }, + { + "$ref": "#/parameters/Snapshot" + }, + { + "$ref": "#/parameters/LeaseId" + }, + { + "name": "x-ms-delete-snapshots", + "x-ms-client-name": "deleteSnapshots", + "in": "header", + "required": false, + "type": "string", + "enum": ["include", "only"], + "description": "Required if the blob has associated snapshots. Specify one of the following two options: include: Delete the base blob and all of its snapshots. only: Delete only the blob's snapshots and not the blob itself." + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/ClientRequestId" + } + ], + "responses": { + "202": { + "description": "The delete request was accepted and the blob will be deleted.", + "headers": { + "x-ms-request-id" : { + "type": "string", + "description": "This header uniquely identifies the request that was made and can be used for troubleshooting the request." + }, + "x-ms-version" : { + "type": "string", + "description": "Indicates the version of the Blob service used to execute the request. This header is returned for requests made against version 2009-09-19 and above." + } + } + }, + "default": { + "$ref": "#/responses/Default" + } + } + } + } + }, + "x-ms-paths": { + "/?restype=service&comp=properties": { + "get": { + "tags": ["service"], + "operationId": "Service_GetServiceProperties", + "parameters": [ + { + "name": "restype", + "in": "query", + "required": true, + "type": "string", + "enum": ["service"] + }, + { + "name": "comp", + "in": "query", + "required": true, + "type": "string", + "enum": ["properties"] + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/ClientRequestId" + } + ], + "responses": { + "200": { + "description": "Success.", + "headers": { + "x-ms-request-id" : { + "type": "string", + "description": "This header uniquely identifies the request that was made and can be used for troubleshooting the request." + }, + "x-ms-version" : { + "type": "string", + "description": "Indicates the version of the Blob service used to execute the request. This header is returned for requests made against version 2009-09-19 and above." + } + }, + "schema": { + "$ref": "#/definitions/ServiceProperties" + } + }, + "default": { + "$ref": "#/responses/Default" + } + } + } + }, + "/?restype=service&comp=stats": { + "get": { + "tags": ["service"], + "operationId": "Service_GetServiceStats", + "parameters": [ + { + "name": "restype", + "in": "query", + "required": true, + "type": "string", + "enum": ["service"] + }, + { + "name": "comp", + "in": "query", + "required": true, + "type": "string", + "enum": ["stats"] + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/ClientRequestId" + } + ], + "responses": { + "200": { + "description": "Success.", + "headers": { + "x-ms-request-id" : { + "type": "string", + "description": "This header uniquely identifies the request that was made and can be used for troubleshooting the request." + }, + "x-ms-version" : { + "type": "string", + "description": "Indicates the version of the Blob service used to execute the request. This header is returned for requests made against version 2009-09-19 and above." + } + }, + "schema": { + "$ref": "#/definitions/ServiceStats" + } + }, + "default": { + "$ref": "#/responses/Default" + } + } + } + }, + "/?comp=list": { + "get": { + "tags": ["service"], + "operationId": "Service_ListContainers", + "parameters": [ + { + "name": "comp", + "in": "query", + "required": true, + "type": "string", + "enum": ["list"] + }, + { + "name": "prefix", + "in": "query", + "required": false, + "type": "string", + "description": "Filters the results to return only containers whose name begins with the specified prefix." + }, + { + "name": "marker", + "in": "query", + "required": false, + "type": "string", + "description": "A string value that identifies the portion of the list to be returned with the next list operation." + }, + { + "name": "maxresults", + "in": "query", + "required": false, + "type": "integer", + "description": "Specifies the maximum number of containers to return." + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/ClientRequestId" + } + ], + "responses": { + "200": { + "description": "Success.", + "headers": { + "x-ms-request-id" : { + "type": "string", + "description": "This header uniquely identifies the request that was made and can be used for troubleshooting the request." + }, + "x-ms-version" : { + "type": "string", + "description": "Indicates the version of the Blob service used to execute the request. This header is returned for requests made against version 2009-09-19 and above." + } + }, + "schema": { + "$ref": "#/definitions/ContainerEnumerationResults" + } + }, + "default": { + "$ref": "#/responses/Default" + } + } + } + }, + "/{container}?restype=container": { + "get": { + "tags": ["containers"], + "operationId": "Containers_GetProperties", + "parameters": [ + { + "name": "restype", + "in": "query", + "required": true, + "type": "string", + "enum": ["container"] + }, + { + "$ref": "#/parameters/Container" + }, + { + "name": "x-ms-lease-id", + "in": "header", + "required": false, + "type": "string", + "description": "If specified, the operation only succeeds if the container’s lease is active and matches this ID." + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/ClientRequestId" + } + ], + "responses": { + "200": { + "description": "Success.", + "headers": { + "ETag" : { + "type": "string", + "description": "The entity tag for the container." + }, + "Last-Modified" : { + "type": "string", + "description": "Returns the date and time the container was last modified." + }, + "x-ms-lease-status" : { + "type": "string", + "description": "Lease status of the container." + }, + "x-ms-lease-state" : { + "type": "string", + "description": "Lease state of the container." + }, + "x-ms-lease-duration" : { + "type": "string", + "description": "Specifies whether the lease on a container is of infinite or fixed duration" + }, + "x-ms-request-id" : { + "type": "string", + "description": "This header uniquely identifies the request that was made and can be used for troubleshooting the request." + }, + "x-ms-version" : { + "type": "string", + "description": "Indicates the version of the Blob service used to execute the request. This header is returned for requests made against version 2009-09-19 and above." + } + } + }, + "default": { + "$ref": "#/responses/Default" + } + } + }, + "head": { + "tags": ["containers"], + "operationId": "Containers_Exists", + "parameters": [ + { + "name": "restype", + "in": "query", + "required": true, + "type": "string", + "enum": ["container"] + }, + { + "$ref": "#/parameters/Container" + }, + { + "name": "x-ms-lease-id", + "in": "header", + "required": false, + "type": "string", + "description": "If specified, the operation only succeeds if the container’s lease is active and matches this ID." + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/ClientRequestId" + } + ], + "responses": { + "200": { + "description": "The container exists.", + "headers": { + "x-ms-request-id" : { + "type": "string", + "description": "This header uniquely identifies the request that was made and can be used for troubleshooting the request." + }, + "x-ms-version" : { + "type": "string", + "description": "Indicates the version of the Blob service used to execute the request. This header is returned for requests made against version 2009-09-19 and above." + } + }, + "x-ms-response-value": { "type": "boolean", "value": true } + }, + "404": { + "description": "The container does not exist", + "headers": { + "x-ms-request-id" : { + "type": "string", + "description": "This header uniquely identifies the request that was made and can be used for troubleshooting the request." + }, + "x-ms-version" : { + "type": "string", + "description": "Indicates the version of the Blob service used to execute the request. This header is returned for requests made against version 2009-09-19 and above." + } + }, + "x-ms-response-value": { "type": "boolean", "value": false } + } + } + }, + "put": { + "tags": ["containers"], + "operationId": "Containers_Create", + "parameters": [ + { + "name": "restype", + "in": "query", + "required": true, + "type": "string", + "enum": ["container"] + }, + { + "$ref": "#/parameters/Container" + }, + { + "name": "x-ms-blob-public-access", + "in": "header", + "required": false, + "type": "string", + "enum": [ + "container", + "blob" + ], + "description": "Specifies whether data in the container may be accessed publicly and the level of access." + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/ClientRequestId" + } + ], + "responses": { + "201": { + "description": "Success.", + "headers": { + "x-ms-request-id" : { + "type": "string", + "description": "This header uniquely identifies the request that was made and can be used for troubleshooting the request." + }, + "x-ms-version" : { + "type": "string", + "description": "Indicates the version of the Blob service used to execute the request. This header is returned for requests made against version 2009-09-19 and above." + } + } + }, + "default": { + "$ref": "#/responses/Default" + } + } + }, + "delete": { + "tags": ["containers"], + "operationId": "Containers_Remove", + "parameters": [ + { + "name": "restype", + "in": "query", + "required": true, + "type": "string", + "enum": ["container"] + }, + { + "$ref": "#/parameters/Container" + }, + { + "$ref": "#/parameters/LeaseId" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/ClientRequestId" + } + ], + "responses": { + "202": { + "description": "Success.", + "headers": { + "x-ms-request-id" : { + "type": "string", + "description": "This header uniquely identifies the request that was made and can be used for troubleshooting the request." + }, + "x-ms-version" : { + "type": "string", + "description": "Indicates the version of the Blob service used to execute the request. This header is returned for requests made against version 2009-09-19 and above." + } + } + }, + "default": { + "$ref": "#/responses/Default" + } + } + } + }, + "/{container}?restype=container&comp=list": { + "get": { + "tags": ["containers"], + "operationId": "Containers_ListBlobs", + "parameters": [ + { + "name": "restype", + "in": "query", + "required": true, + "type": "string", + "enum": ["container"] + }, + { + "name": "comp", + "in": "query", + "required": true, + "type": "string", + "enum": ["list"] + }, + { + "$ref": "#/parameters/Container" + }, + { + "name": "prefix", + "in": "query", + "required": false, + "type": "string", + "description": "Filters the results to return only containers whose name begins with the specified prefix." + }, + { + "name": "delimiter", + "in": "query", + "required": false, + "type": "string", + "description": "Optional. When the request includes this parameter, the operation returns a BlobPrefix element in the response body that acts as a placeholder for all blobs whose names begin with the same substring up to the appearance of the delimiter character. The delimiter may be a single character or a string." + }, + { + "name": "marker", + "in": "query", + "required": false, + "type": "string", + "description": "A string value that identifies the portion of the list to be returned with the next list operation." + }, + { + "name": "maxresults", + "in": "query", + "required": false, + "type": "integer", + "description": "Specifies the maximum number of containers to return." + }, + { + "name": "include", + "in": "query", + "required": false, + "type": "string", + "enum": ["snapshots","metadata","uncommittedblobs","copy"], + "description": "Optional. Specifies one or more datasets to include in the response: - snapshots: Specifies that snapshots should be included in the enumeration. Snapshots are listed from oldest to newest in the response. - metadata: Specifies that blob metadata be returned in the response. - uncommittedblobs: Specifies that blobs for which blocks have been uploaded, but which have not been committed using Put Block List, be included in the response. - copy: Version 2012-02-12 and newer. Specifies that metadata related to any current or previous Copy Blob operation should be included in the response." + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/ClientRequestId" + } + ], + "responses": { + "201": { + "description": "Success.", + "headers": { + "x-ms-request-id" : { + "type": "string", + "description": "This header uniquely identifies the request that was made and can be used for troubleshooting the request." + }, + "x-ms-version" : { + "type": "string", + "description": "Indicates the version of the Blob service used to execute the request. This header is returned for requests made against version 2009-09-19 and above." + } + }, + "schema": { + "$ref": "#/definitions/BlobEnumerationResults" + } + }, + "default": { + "$ref": "#/responses/Default" + } + } + } + }, + "/{container}?restype=container&comp=metadata": { + "put": { + "tags": ["containers"], + "operationId": "Containers_SetMetadata", + "parameters": [ + { + "name": "restype", + "in": "query", + "required": true, + "type": "string", + "enum": ["container"] + }, + { + "name": "comp", + "in": "query", + "required": true, + "type": "string", + "enum": ["metadata"] + }, + { + "$ref": "#/parameters/Container" + }, + { + "name": "metadata", + "in": "header", + "required": true, + "type": "string", + "x-ms-header-collection-prefix": "x-ms-meta-" + }, + { + "$ref": "#/parameters/LeaseId" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/ClientRequestId" + } + ], + "responses": { + "201": { + "description": "Success.", + "headers": { + "x-ms-request-id" : { + "type": "string", + "description": "This header uniquely identifies the request that was made and can be used for troubleshooting the request." + }, + "x-ms-version" : { + "type": "string", + "description": "Indicates the version of the Blob service used to execute the request. This header is returned for requests made against version 2009-09-19 and above." + } + } + }, + "default": { + "$ref": "#/responses/Default" + } + } + }, + "get": { + "tags": ["containers"], + "operationId": "Containers_GetMetadata", + "parameters": [ + { + "name": "restype", + "in": "query", + "required": true, + "type": "string", + "enum": ["container"] + }, + { + "name": "comp", + "in": "query", + "required": true, + "type": "string", + "enum": ["metadata"] + }, + { + "$ref": "#/parameters/Container" + }, + { + "$ref": "#/parameters/LeaseId" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/ClientRequestId" + } + ], + "responses": { + "201": { + "description": "Success.", + "headers": { + "x-ms-request-id" : { + "type": "string", + "description": "This header uniquely identifies the request that was made and can be used for troubleshooting the request." + }, + "x-ms-version" : { + "type": "string", + "description": "Indicates the version of the Blob service used to execute the request. This header is returned for requests made against version 2009-09-19 and above." + }, + "metadata": { + "type": "string", + "x-ms-header-collection-prefix": "x-ms-meta-" + } + } + }, + "default": { + "$ref": "#/responses/Default" + } + } + } + }, + "/{container}?restype=container&comp=lease": { + "put": { + "tags": ["containers"], + "operationId": "Containers_Lease", + "parameters": [ + { + "name": "comp", + "in": "query", + "required": true, + "type": "string", + "enum": ["lease"] + }, + { + "$ref": "#/parameters/BlobContainer" + }, + { + "$ref": "#/parameters/LeaseId" + }, + { + "$ref": "#/parameters/LeaseAction" + }, + { + "$ref": "#/parameters/LeaseBreakPeriod" + }, + { + "$ref": "#/parameters/LeaseDuration" + }, + { + "$ref": "#/parameters/ProposedLeaseId" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/ClientRequestId" + } + ], + "responses": { + "200": { + "description": "The lease operation was accepted.", + "headers": { + "x-ms-request-id" : { + "type": "string", + "description": "This header uniquely identifies the request that was made and can be used for troubleshooting the request." + }, + "x-ms-version" : { + "type": "string", + "description": "Indicates the version of the Blob service used to execute the request. This header is returned for requests made against version 2009-09-19 and above." + }, + "x-ms-lease-id": { + "type": "string", + "description": "When you request a lease, the Blob service returns a unique lease ID. While the lease is active, you must include the lease ID with any request to delete the container, or to renew, change, or release the lease. A successful renew operation also returns the lease ID for the active lease." + }, + "x-ms-lease-time": { + "type": "integer", + "description": "Approximate time remaining in the lease period, in seconds. This header is returned only for a successful request to break the lease. If the break is immediate, 0 is returned." + } + } + }, + "default": { + "$ref": "#/responses/Default" + } + } + } + }, + "/{container}/{blob}?fakeparameter=block": { + "put": { + "tags": ["blockblobs"], + "operationId": "BlockBlobs_Creat", + "description": "Creates a blob from the contents of the request, or copied from an existing blob.", + "consumes": ["application/octet-stream"], + "parameters": [ + { + "$ref": "#/parameters/BlobContainer" + }, + { + "$ref": "#/parameters/Blob" + }, + { + "name": "x-ms-blob-type", + "in": "header", + "required": true, + "type": "string", + "default": "BlockBlob", + "enum": [ "BlockBlob" ] + }, + { + "$ref": "#/parameters/ContentType" + }, + { + "$ref": "#/parameters/LeaseId" + }, + { + "$ref": "#/parameters/CopySource" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/ClientRequestId" + }, + { + "$ref": "#/parameters/Body" + } + ], + "responses": { + "201": { + "description": "The blob was created.", + "headers": { + "x-ms-request-id" : { + "type": "string", + "description": "This header uniquely identifies the request that was made and can be used for troubleshooting the request." + }, + "x-ms-version" : { + "type": "string", + "description": "Indicates the version of the Blob service used to execute the request. This header is returned for requests made against version 2009-09-19 and above." + } + } + }, + "default": { + "$ref": "#/responses/Default" + } + } + } + }, + "/{container}/{blob}?fakeparameter=page": { + "put": { + "tags": ["pageblobs"], + "operationId": "PageBlobs_Create", + "description": "Creates an empty page blob, or copies from an existing blob identified by the source argument.", + "parameters": [ + { + "$ref": "#/parameters/BlobContainer" + }, + { + "$ref": "#/parameters/Blob" + }, + { + "name": "x-ms-blob-type", + "in": "header", + "required": true, + "type": "string", + "default": "PageBlob", + "enum": [ "PageBlob" ] + }, + { + "$ref": "#/parameters/ContentType" + }, + { + "$ref": "#/parameters/LeaseId" + }, + { + "$ref": "#/parameters/CopySource" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/ClientRequestId" + }, + { + "$ref": "#/parameters/Body" + } + ], + "responses": { + "201": { + "description": "The blob was created.", + "headers": { + "x-ms-request-id" : { + "type": "string", + "description": "This header uniquely identifies the request that was made and can be used for troubleshooting the request." + }, + "x-ms-version" : { + "type": "string", + "description": "Indicates the version of the Blob service used to execute the request. This header is returned for requests made against version 2009-09-19 and above." + } + } + }, + "default": { + "$ref": "#/responses/Default" + } + } + } + }, + "/{container}/{blob}?fakeparameter=append": { + "put": { + "tags": ["appendblobs"], + "operationId": "AppendBlobs_Create", + "description": "Creates an empty append blob, or copies from an existing blob identified by the source argument.", + "parameters": [ + { + "$ref": "#/parameters/BlobContainer" + }, + { + "$ref": "#/parameters/Blob" + }, + { + "name": "x-ms-blob-type", + "in": "header", + "required": true, + "type": "string", + "default": "AppendBlob", + "enum": [ "AppendBlob" ] + }, + { + "$ref": "#/parameters/ContentType" + }, + { + "$ref": "#/parameters/LeaseId" + }, + { + "$ref": "#/parameters/CopySource" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/ClientRequestId" + }, + { + "$ref": "#/parameters/Body" + } + ], + "responses": { + "201": { + "description": "The blob was created.", + "headers": { + "x-ms-request-id" : { + "type": "string", + "description": "This header uniquely identifies the request that was made and can be used for troubleshooting the request." + }, + "x-ms-version" : { + "type": "string", + "description": "Indicates the version of the Blob service used to execute the request. This header is returned for requests made against version 2009-09-19 and above." + } + } + }, + "default": { + "$ref": "#/responses/Default" + } + } + } + }, + "/{container}/{blob}?comp=block": { + "put": { + "tags": ["blockblobs"], + "operationId": "BlockBlobs_PutBlock", + "parameters": [ + { + "name": "comp", + "in": "query", + "required": true, + "type": "string", + "enum": ["block"] + }, + { + "$ref": "#/parameters/BlobContainer" + }, + { + "$ref": "#/parameters/Blob" + }, + { + "name": "blockid", + "x-ms-client-name": "id", + "in": "query", + "required": true, + "type": "string" + }, + { + "$ref": "#/parameters/LeaseId" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/ClientRequestId" + }, + { + "$ref": "#/parameters/Body" + } + ], + "responses": { + "201": { + "description": "The block was created.", + "headers": { + "x-ms-request-id" : { + "type": "string", + "description": "This header uniquely identifies the request that was made and can be used for troubleshooting the request." + }, + "x-ms-version" : { + "type": "string", + "description": "Indicates the version of the Blob service used to execute the request. This header is returned for requests made against version 2009-09-19 and above." + } + } + }, + "default": { + "$ref": "#/responses/Default" + } + } + } + }, + "/{container}/{blob}?comp=properties": { + "put": { + "tags": ["blobs"], + "operationId": "Blobs_SetProperties", + "parameters": [ + { + "name": "restype", + "in": "query", + "required": true, + "type": "string", + "enum": ["container"] + }, + { + "name": "comp", + "in": "query", + "required": true, + "type": "string", + "enum": ["metadata"] + }, + { + "$ref": "#/parameters/BlobContainer" + }, + { + "$ref": "#/parameters/Blob" + }, + { + "name": "metadata", + "in": "header", + "required": false, + "type": "string", + "x-ms-header-collection-prefix": "x-ms-meta-" + }, + { + "$ref": "#/parameters/LeaseId" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/ClientRequestId" + } + ], + "responses": { + "201": { + "description": "Success.", + "headers": { + "x-ms-request-id" : { + "type": "string", + "description": "This header uniquely identifies the request that was made and can be used for troubleshooting the request." + }, + "x-ms-version" : { + "type": "string", + "description": "Indicates the version of the Blob service used to execute the request. This header is returned for requests made against version 2009-09-19 and above." + } + } + }, + "default": { + "$ref": "#/responses/Default" + } + } + }, + "get": { + "tags": ["blobs"], + "operationId": "Blobs_GetProperties", + "parameters": [ + { + "name": "restype", + "in": "query", + "required": true, + "type": "string", + "enum": ["container"] + }, + { + "name": "comp", + "in": "query", + "required": true, + "type": "string", + "enum": ["metadata"] + }, + { + "$ref": "#/parameters/BlobContainer" + }, + { + "$ref": "#/parameters/Blob" + }, + { + "$ref": "#/parameters/LeaseId" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/ClientRequestId" + } + ], + "responses": { + "201": { + "description": "Success.", + "headers": { + } + }, + "default": { + "$ref": "#/responses/Default" + } + } + } + }, + "/{container}/{blob}?comp=metadata": { + "put": { + "tags": ["blobs"], + "operationId": "Blobs_SetMetadata", + "parameters": [ + { + "name": "restype", + "in": "query", + "required": true, + "type": "string", + "enum": ["container"] + }, + { + "name": "comp", + "in": "query", + "required": true, + "type": "string", + "enum": ["metadata"] + }, + { + "$ref": "#/parameters/BlobContainer" + }, + { + "$ref": "#/parameters/Blob" + }, + { + "name": "metadata", + "in": "header", + "required": true, + "type": "string", + "x-ms-header-collection-prefix": "x-ms-meta-" + }, + { + "$ref": "#/parameters/LeaseId" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/ClientRequestId" + } + ], + "responses": { + "201": { + "description": "Success.", + "headers": { + "x-ms-request-id" : { + "type": "string", + "description": "This header uniquely identifies the request that was made and can be used for troubleshooting the request." + }, + "x-ms-version" : { + "type": "string", + "description": "Indicates the version of the Blob service used to execute the request. This header is returned for requests made against version 2009-09-19 and above." + } + } + }, + "default": { + "$ref": "#/responses/Default" + } + } + }, + "get": { + "tags": ["blobs"], + "operationId": "Blobs_GetMetadata", + "parameters": [ + { + "name": "restype", + "in": "query", + "required": true, + "type": "string", + "enum": ["container"] + }, + { + "name": "comp", + "in": "query", + "required": true, + "type": "string", + "enum": ["metadata"] + }, + { + "$ref": "#/parameters/BlobContainer" + }, + { + "$ref": "#/parameters/Blob" + }, + { + "$ref": "#/parameters/LeaseId" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/ClientRequestId" + } + ], + "responses": { + "201": { + "description": "Success.", + "headers": { + "x-ms-request-id" : { + "type": "string", + "description": "This header uniquely identifies the request that was made and can be used for troubleshooting the request." + }, + "x-ms-version" : { + "type": "string", + "description": "Indicates the version of the Blob service used to execute the request. This header is returned for requests made against version 2009-09-19 and above." + }, + "metadata": { + "type": "string", + "x-ms-header-collection-prefix": "x-ms-meta-" + } + } + }, + "default": { + "$ref": "#/responses/Default" + } + } + } + }, + "/{container}/{blob}?comp=blocklist": { + "get": { + "tags": ["blockblobs"], + "operationId": "BlockBlobs_GetBlockList", + "parameters": [ + { + "name": "comp", + "in": "query", + "required": true, + "type": "string", + "enum": ["blocklist"] + }, + { + "$ref": "#/parameters/BlobContainer" + }, + { + "$ref": "#/parameters/Blob" + }, + { + "name": "blocklisttype", + "x-ms-client-name": "listType", + "in": "query", + "required": false, + "type": "string", + "default": "committed", + "enum": ["committed","uncomitted", "all"] + }, + { + "name": "snapshot", + "in": "query", + "required": false, + "type": "string" + }, + { + "$ref": "#/parameters/LeaseId" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/ClientRequestId" + } + ], + "responses": { + "200": { + "description": "Information on the block list was found.", + "headers": { + "x-ms-blob-content-length" : { + "type": "integer", + "description": "The size of the blob in bytes." + }, + "x-ms-request-id" : { + "type": "string", + "description": "This header uniquely identifies the request that was made and can be used for troubleshooting the request." + }, + "x-ms-version" : { + "type": "string", + "description": "Indicates the version of the Blob service used to execute the request. This header is returned for requests made against version 2009-09-19 and above." + } + }, + "schema": { + "$ref": "#/definitions/BlockListInformation" + } + }, + "default": { + "$ref": "#/responses/Default" + } + } + }, + "put": { + "tags": ["blockblobs"], + "operationId": "BlockBlobs_PutBlockList", + "parameters": [ + { + "name": "comp", + "in": "query", + "required": true, + "type": "string", + "enum": ["blocklist"] + }, + { + "$ref": "#/parameters/Container" + }, + { + "$ref": "#/parameters/Blob" + }, + { + "name": "x-ms-blob-cache-control", + "in":"header", + "required":false, + "type": "string", + "description": "Optional. Sets the blob’s cache control. If specified, this property is stored with the blob and returned with a read request." + }, + { + "name": "x-ms-blob-content-type", + "in":"header", + "required":false, + "type": "string", + "description": "Optional. Sets the blob’s content type. If specified, this property is stored with the blob and returned with a read request." + }, + { + "name": "x-ms-blob-content-encoding", + "in":"header", + "required":false, + "type": "string", + "description": "Optional. Sets the blob’s content encoding. If specified, this property is stored with the blob and returned with a read request." + }, + { + "name": "x-ms-blob-content-language", + "in":"header", + "required":false, + "type": "string", + "description": "Optional. Set the blob’s content language. If specified, this property is stored with the blob and returned with a read request." + }, + { + "name": "x-ms-blob-content-md5", + "in":"header", + "required":false, + "type": "string", + "description": "Optional. An MD5 hash of the blob content. Note that this hash is not validated, as the hashes for the individual blocks were validated when each was uploaded." + }, + { + "name": "x-ms-blob-content-disposition", + "in":"header", + "required":false, + "type": "string", + "description": "Optional. Sets the blob’s Content-Disposition header. Available for versions 2013-08-15 and later." + }, + { + "$ref": "#/parameters/LeaseId" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/ClientRequestId" + }, + { + "name": "blocks", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/BlockList" + } + } + ], + "responses": { + "201": { + "description": "The block list was recorded.", + "headers": { + "x-ms-request-id" : { + "type": "string", + "description": "This header uniquely identifies the request that was made and can be used for troubleshooting the request." + }, + "x-ms-version" : { + "type": "string", + "description": "Indicates the version of the Blob service used to execute the request. This header is returned for requests made against version 2009-09-19 and above." + } + } + }, + "default": { + "$ref": "#/responses/Default" + } + } + } + }, + "/{container}/{blob}?comp=page": { + "put": { + "tags": ["pageblobs"], + "operationId": "PageBlobs_PutPage", + "parameters": [ + { + "name": "comp", + "in": "query", + "required": true, + "type": "string", + "enum": ["page"] + }, + { + "$ref": "#/parameters/BlobContainer" + }, + { + "$ref": "#/parameters/Blob" + }, + { + "$ref": "#/parameters/RequiredRange" + }, + { + "name": "x-ms-page-write", + "x-ms-client-name": "pageWrite", + "in":"header", + "required":true, + "type": "string", + "description": "Required. You may specify one of the following options:\n - Update: Writes the bytes specified by the request body into the specified range. The Range and Content-Length headers must match to perform the update.\n - Clear: Clears the specified range and releases the space used in storage for that range. To clear a range, set the Content-Length header to zero, and the Range header to a value that indicates the range to clear, up to maximum blob size." + }, + { + "name": "x-ms-if-sequence-number-le", + "x-ms-client-name": "ifSequenceNumberLessThanOrEqualTo", + "in":"header", + "required":false, + "type": "integer" + }, + { + "name": "x-ms-if-sequence-number-lt", + "x-ms-client-name": "ifSequenceNumberLessThan", + "in":"header", + "required":false, + "type": "integer" + }, + { + "name": "x-ms-if-sequence-number-eq", + "x-ms-client-name": "ifSequenceNumberEqualTo", + "in":"header", + "required":false, + "type": "integer" + }, + { + "$ref" : "#/parameters/IfModifiedSince" + }, + { + "$ref" : "#/parameters/IfUnmodifiedSince" + }, + { + "$ref" : "#/parameters/IfMatch" + }, + { + "$ref" : "#/parameters/IfNoneMatch" + }, + { + "$ref": "#/parameters/LeaseId" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/ClientRequestId" + }, + { + "$ref": "#/parameters/Body" + } + ], + "responses": { + "201": { + "description": "The block was created.", + "headers": { + "x-ms-request-id" : { + "type": "string", + "description": "This header uniquely identifies the request that was made and can be used for troubleshooting the request." + }, + "x-ms-version" : { + "type": "string", + "description": "Indicates the version of the Blob service used to execute the request. This header is returned for requests made against version 2009-09-19 and above." + } + } + }, + "default": { + "$ref": "#/responses/Default" + } + } + } + }, + "/{container}/{blob}?comp=pagelist": { + "get": { + "tags": ["blobs"], + "operationId": "Blobs_ListPages", + "parameters": [ + { + "name": "comp", + "in": "query", + "required": true, + "type": "string", + "enum": ["pagelist"] + }, + { + "$ref": "#/parameters/BlobContainer" + }, + { + "$ref": "#/parameters/Blob" + }, + { + "$ref": "#/parameters/Range" + }, + { + "$ref": "#/parameters/Snapshot" + }, + { + "$ref": "#/parameters/LeaseId" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/ClientRequestId" + } + ], + "responses": { + "200": { + "description": "Information on the page blob was found.", + "headers": { + "x-ms-blob-content-length" : { + "type": "integer", + "description": "The size of the blob in bytes." + }, + "x-ms-request-id" : { + "type": "string", + "description": "This header uniquely identifies the request that was made and can be used for troubleshooting the request." + }, + "x-ms-version" : { + "type": "string", + "description": "Indicates the version of the Blob service used to execute the request. This header is returned for requests made against version 2009-09-19 and above." + } + }, + "schema": { + "type": "string" + } + }, + "default": { + "$ref": "#/responses/Default" + } + } + } + }, + "/{container}/{blob}?comp=appendblock": { + "put": { + "tags": ["blobs"], + "operationId": "Blobs_AppendBlock", + "parameters": [ + { + "name": "comp", + "in": "query", + "required": true, + "type": "string", + "enum": ["appendblock"] + }, + { + "$ref": "#/parameters/BlobContainer" + }, + { + "$ref": "#/parameters/Blob" + }, + { + "name": "x-ms-blob-condition-maxsize", + "x-ms-client-name": "maxSize", + "in":"header", + "required":false, + "type": "integer", + "description": "Optional. The max length in bytes permitted for the append blob. If the Append Block operation would cause the blob to exceed that limit or if the blob size is already greater than the value specified in this header, the request will fail with MaxBlobSizeConditionNotMet error (HTTP status code 412 – Precondition Failed)." + }, + { + "name": "x-ms-blob-condition-appendpos", + "x-ms-client-name": "appendPosition", + "in":"header", + "required":false, + "type": "integer", + "description": "Optional. A number indicating the byte offset to compare. Append Block will succeed only if the append position is equal to this number. If it is not, the request will fail with the AppendPositionConditionNotMet error (HTTP status code 412 – Precondition Failed)." + }, + { + "$ref": "#/parameters/LeaseId" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/ClientRequestId" + }, + { + "$ref": "#/parameters/Body" + } + ], + "responses": { + "201": { + "description": "The block was created.", + "headers": { + "x-ms-blob-append-offset" : { + "type": "string", + "description": "This response header is returned only for append operations. It returns the offset at which the block was committed, in bytes." + }, + "x-ms-blob-committed-block-count" : { + "type": "string", + "description": "This response header is returned only for append operations. It returns the offset at which the block was committed, in bytes." + }, + "x-ms-request-id" : { + "type": "string", + "description": "This header uniquely identifies the request that was made and can be used for troubleshooting the request." + }, + "x-ms-version" : { + "type": "string", + "description": "Indicates the version of the Blob service used to execute the request. This header is returned for requests made against version 2009-09-19 and above." + } + } + }, + "default": { + "$ref": "#/responses/Default" + } + } + } + }, + "/{container}/{blob}?comp=lease": { + "put": { + "tags": ["blobs"], + "operationId": "Blobs_Lease", + "parameters": [ + { + "name": "comp", + "in": "query", + "required": true, + "type": "string", + "enum": ["lease"] + }, + { + "$ref": "#/parameters/BlobContainer" + }, + { + "$ref": "#/parameters/Blob" + }, + { + "$ref": "#/parameters/LeaseId" + }, + { + "$ref": "#/parameters/LeaseAction" + }, + { + "$ref": "#/parameters/LeaseBreakPeriod" + }, + { + "$ref": "#/parameters/LeaseDuration" + }, + { + "$ref": "#/parameters/ProposedLeaseId" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/ClientRequestId" + } + ], + "responses": { + "200": { + "description": "The lease operation was accepted.", + "headers": { + "x-ms-request-id" : { + "type": "string", + "description": "This header uniquely identifies the request that was made and can be used for troubleshooting the request." + }, + "x-ms-version" : { + "type": "string", + "description": "Indicates the version of the Blob service used to execute the request. This header is returned for requests made against version 2009-09-19 and above." + } + } + }, + "default": { + "$ref": "#/responses/Default" + } + } + } + }, + "/{container}/{blob}?comp=snapshot": { + "put": { + "tags": ["blobs"], + "operationId": "Blobs_TakeSnapshot", + "parameters": [ + { + "name": "comp", + "in": "query", + "required": true, + "type": "string", + "enum": ["snapshot"] + }, + { + "$ref": "#/parameters/BlobContainer" + }, + { + "$ref": "#/parameters/Blob" + }, + { + "$ref": "#/parameters/IfModifiedSince" + }, + { + "$ref": "#/parameters/IfUnmodifiedSince" + }, + { + "$ref": "#/parameters/IfMatch" + }, + { + "$ref": "#/parameters/IfNoneMatch" + }, + { + "$ref": "#/parameters/LeaseId" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/ClientRequestId" + } + ], + "responses": { + "201": { + "description": "The blob snapshot was created.", + "headers": { + "x-ms-request-id" : { + "type": "string", + "description": "This header uniquely identifies the request that was made and can be used for troubleshooting the request." + }, + "x-ms-version" : { + "type": "string", + "description": "Indicates the version of the Blob service used to execute the request. This header is returned for requests made against version 2009-09-19 and above." + } + } + }, + "default": { + "$ref": "#/responses/Default" + } + } + } + } + }, + "definitions": { + "BlobError": { + "description": "Represents an error message returned from the Azure Blob service.", + "type": "object", + "xml": { + "name": "Error" + }, + "properties": { + "code": { + "type": "string", + "xml": { + "name": "Code" + } + }, + "message": { + "type": "string", + "xml": { + "name": "Message" + } + } + } + }, + "RetentionPolicy" : { + "type": "object", + "xml": { + "name": "RetentionPolicy" + }, + "properties": { + "Enabled": { + "type": "boolean", + "xml": { + "name": "Enabled" + } + }, + "Days": { + "type": "integer", + "xml": { + "name": "Days" + } + } + } + }, + "Metrics": { + "properties": { + "Version": { + "type": "string", + "xml": { + "name": "Version" + } + }, + "Enabled": { + "type": "boolean", + "xml": { + "name": "Enabled" + } + }, + "IncludeAPIs": { + "type": "boolean", + "xml": { + "name": "IncludeAPIs" + } + }, + "RetentionPolicy": { + "type": "object", + "$ref": "#/definitions/RetentionPolicy", + "xml": { + "name": "RetentionPolicy" + } + } + } + }, + "ServiceProperties": { + "type": "object", + "properties": { + "StorageServiceProperties": { + "type": "object", + "properties": { + "Logging": { + "type": "object", + "xml": { + "name": "Logging" + }, + "properties": { + "Version": { + "type": "string", + "xml": { + "name": "Version" + } + }, + "Delete": { + "type": "boolean", + "xml": { + "name": "Delete" + } + }, + "Read": { + "type": "boolean", + "xml": { + "name": "Read" + } + }, + "Write": { + "type": "boolean", + "xml": { + "name": "Write" + } + }, + "RetentionPolicy": { + "$ref": "#/definitions/RetentionPolicy" + } + } + }, + "HourMetrics": { + "$ref": "#/definitions/Metrics", + "xml": { + "name": "HourMetrics" + } + }, + "MinuteMetrics": { + "$ref": "#/definitions/Metrics", + "xml": { + "name": "MinuteMetrics" + } + } + } + } + } + }, + "ServiceStats": { + "type": "object", + "properties": { + "StorageServiceStats": { + "type": "object", + "properties": { + "GeoReplication": { + "type": "object", + "properties": { + "Status": { + "type": "string" + }, + "LastSyncTime": { + "type": "string", + "format": "date-time" + } + } + } + } + } + } + }, + "LeaseStatus": { + "type": "string", + "enum": ["locked", "unlocked"], + "x-ms-enum": { + "name": "LeaseStatus", + "modelAsString": false + } + }, + "LeaseState": { + "type": "string", + "enum": ["available","leased","expired","breaking","broken"], + "x-ms-enum": { + "name": "LeaseState", + "modelAsString": false + } + }, + "LeaseDuration": { + "type": "string", + "enum": ["pending","success","aborted","failed"], + "x-ms-enum": { + "name": "LeaseDuration", + "modelAsString": false + } + }, + "ContainerProperties": { + "type": "object", + "properties": { + "Etag": { + "type": "string" + }, + "Last-Modified": { + "type": "string", + "format": "date-time" + }, + "LeaseStatus": { + "$ref": "#/definitions/LeaseStatus" + }, + "LeaseState": { + "$ref": "#/definitions/LeaseState" + }, + "LeaseDuration": { + "$ref": "#/definitions/LeaseDuration" + } + } + }, + "Container": { + "type": "object", + "properties": { + "Name": { + "type": "string" + }, + "Properties": { + "$ref": "#/definitions/ContainerProperties" + }, + "Metadata": { + "type": "object", + "additionalProperties": { } + } + } + }, + "ContainerEnumerationResults": { + "type": "object", + "properties": { + "ServiceEndpoint": { + "type": "string", + "xml": { + "attribute": true + } + }, + "Prefix": { + "type": "string" + }, + "Marker": { + "type": "string" + }, + "MaxResults": { + "type": "integer" + }, + "Containers": { + "type": "array", + "items": { + "$ref": "#/definitions/Container" + } + }, + "NextMarker": { + "type": "string" + } + } + }, + "BlobProperties": { + "type": "object", + "properties": { + "Etag": { + "type": "string" + }, + "Last-Modified": { + "type": "string", + "format": "date-time" + }, + "Content-Length": { + "type": "integer" + }, + "Content-Type": { + "type": "string" + }, + "Content-Encoding": { + "type": "string" + }, + "Content-Language": { + "type": "string" + }, + "Content-MD5": { + "type": "string" + }, + "Cache-Control": { + "type": "string" + }, + "x-ms-blob-sequence-number": { + "type": "integer", + "x-ms-client-name": "sequenceNumber" + }, + "BlobType": { + "type": "string", + "enum": ["BlockBlob", "PageBlob", "AppendBlob"] + }, + "LeaseStatus": { + "$ref": "#/definitions/LeaseStatus" + }, + "LeaseState": { + "$ref": "#/definitions/LeaseState" + }, + "LeaseDuration": { + "$ref": "#/definitions/LeaseDuration" + }, + "CopyId": { + "type": "integer" + }, + "CopyStatus": { + "type": "string", + "enum": ["pending", "success", "aborted", "failed"] + }, + "CopySource": { + "type": "string" + }, + "CopyProgress": { + "type": "integer" + }, + "CopyCompletionTime": { + "type": "string", + "format": "date-time" + }, + "CopyStatusDescription": { + "type": "string" + }, + "ServerEncrypted": { + "type": "boolean" + } + } + }, + "Blob": { + "type": "object", + "properties": { + "Name": { + "type": "string" + }, + "Snapshot": { + "type": "string" + }, + "Properties": { + "$ref": "#/definitions/BlobProperties" + }, + "Metadata": { + "type": "object", + "additionalProperties": { } + } + } + }, + "BlobEnumerationResults": { + "type": "object", + "properties": { + "ServiceEndpoint": { + "type": "string", + "xml": { + "attribute": true + } + }, + "ContainerName": { + "type": "string", + "xml": { + "attribute": true + } + }, + "Prefix": { + "type": "string" + }, + "Marker": { + "type": "string" + }, + "Delimiter": { + "type": "string" + }, + "MaxResults": { + "type": "integer" + }, + "Blobs": { + "type": "array", + "items": { + "$ref": "#/definitions/Blob" + } + }, + "BlobPrefix": { + "type": "object", + "schema": { + "properties": { + "Name": { + "type": "string" + } + } + } + }, + "NextMarker": { + "type": "string" + } + } + }, + "BlockInformation": + { + "type": "object", + "xml": { + "name": "Block" + }, + "properties": { + "name": { + "type": "string", + "xml": { + "name": "Name" + } + }, + "size": { + "type": "integer", + "xml": { + "name": "Size" + } + } + } + }, + "BlockListInformation": { + "type": "object", + "properties": { + "CommittedBlocks" : { + "type": "array", + "items": { + "$ref": "#/definitions/BlockInformation" + }, + "xml": { + "name": "CommittedBlocks" + } + }, + "UncommittedBlocks" : { + "type": "array", + "items": { + "$ref": "#/definitions/BlockInformation" + }, + "xml": { + "name": "UncommittedBlocks" + } + } + + } + }, + "Block": { + "type": "object", + "properties": { + "State" : { + "type": "string", + "enum": ["Uncommitted", "Committed", "Latest"] + }, + "Id": { + "type": "string" + } + } + }, + "BlockList" : { + "type": "object", + "x-ms-external" : true, + "xml": { + "name": "BlockList" + }, + "properties": { + "Blocks" : { + "type": "array", + "xml": { + "name": "#/definitions/Block", + "wrapped": false + }, + "items": { + "type": "string" + } + } + } + } + }, + "parameters": { + "ApiVersionParameter": { + "name": "x-ms-version", + "x-ms-client-name": "version", + "in": "header", + "required": false, + "type": "string", + "x-ms-global": true, + "enum": [ + "2015-04-05", + "2014-02-14", + "2013-08-15", + "2012-02-12", + "2011-08-18", + "2009-09-19", + "2009-07-17", + "2009-04-14" + ], + "default": "2015-04-05", + "description": "Specifies the version of the operation to use for this request." + }, + "ClientRequestId": { + "name": "x-ms-client-request-id", + "x-ms-client-name": "requestId", + "in": "header", + "required": false, + "type": "string", + "x-ms-parameter-location": "method", + "description": "Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage analytics logging is enabled." + }, + "LeaseId": { + "name": "x-ms-lease-id", + "x-ms-client-name": "leaseId", + "in": "header", + "required": false, + "type": "string", + "x-ms-parameter-location": "method", + "description": "If specified, the operation only succeeds if the container’s lease is active and matches this ID." + }, + "LeaseAction": { + "name": "x-ms-lease-action", + "x-ms-client-name": "action", + "in": "header", + "required": true, + "type": "string", + "enum": [ "acquire", "renew", "change", "release", "break" ], + "description": "Describes what lease action to take." + }, + "LeaseBreakPeriod": { + "name": "x-ms-lease-break-period", + "x-ms-client-name": "breakPeriod", + "in": "header", + "required": false, + "type": "integer", + "x-ms-parameter-location": "method", + "description": "For a break operation, this is the proposed duration of seconds that the lease should continue before it is broken, between 0 and 60 seconds." + }, + "LeaseDuration": { + "name": "x-ms-lease-duration", + "x-ms-client-name": "duration", + "in": "header", + "required": false, + "type": "integer", + "x-ms-parameter-location": "method", + "description": "Specifies the duration of the lease, in seconds, or negative one (-1) for a lease that never expires." + }, + "ProposedLeaseId": { + "name": "x-ms-proposed-lease-id", + "x-ms-client-name": "proposedId", + "in": "header", + "required": false, + "type": "string", + "x-ms-parameter-location": "method", + "description": "Proposed lease ID, in a GUID string format." + }, + "Container": { + "name": "container", + "in": "path", + "required": true, + "type": "string", + "x-ms-parameter-location": "method", + "description": "The container name." + }, + "BlobContainer": { + "name": "container", + "in": "path", + "required": false, + "type": "string", + "x-ms-parameter-location": "method", + "description": "The container name." + }, + "Blob": { + "name": "blob", + "in": "path", + "required": true, + "type": "string", + "x-ms-parameter-location": "method", + "description": "The blob name." + }, + "BlobType": { + "name": "x-ms-blob-type", + "x-ms-client-name": "blobType", + "in": "header", + "required": false, + "type": "string", + "default": "BlockBlob", + "enum": [ + "BlockBlob", + "PageBlob", + "AppendBlob" + ], + "x-ms-parameter-location": "method", + "description": "Specifies the type of blob to create: block blob, page blob, or append blob." + }, + "Range": { + "name": "x-ms-range", + "x-ms-client-name": "range", + "in": "header", + "required": false, + "type": "string", + "x-ms-parameter-location": "method", + "description": "Return only the bytes of the blob in the specified range." + }, + "RequiredRange": { + "name": "x-ms-range", + "x-ms-client-name": "range", + "in": "header", + "required": true, + "type": "string", + "x-ms-parameter-location": "method", + "description": "Specifies the range of bytes to be written as a page. Both the start and end of the range must be specified. This header is defined by the HTTP/1.1 protocol specification. For a page update operation, the page range can be up to 4 MB in size. For a page clear operation, the page range can be up to the value of the blob's full size. Given that pages must be aligned with 512-byte boundaries, the start offset must be a modulus of 512 and the end offset must be a modulus of 512 – 1. Examples of valid byte ranges are 0-511, 512-1023 etc." + }, + "Snapshot": { + "name": "snapshot", + "in": "query", + "required": false, + "type": "string", + "format": "datetime", + "x-ms-parameter-location": "method", + "description": "The blob name." + }, + "CopySource": { + "name": "x-ms-copy-source", + "x-ms-client-name": "copySource", + "in": "header", + "required": false, + "type": "string", + "x-ms-parameter-location": "method", + "description": "Specifies the name of the source blob or file." + }, + "ContentType": { + "name": "Content-Type", + "x-ms-client-name": "contentType", + "in": "header", + "required": false, + "type": "string", + "x-ms-parameter-location": "method", + "description": "Specifies the content type of the blob." + }, + "Body": { + "name": "body", + "in": "body", + "required": true, + "schema" : { + "type": "file" + }, + "x-ms-parameter-location": "method", + "description": "Initial data for the blob, empty for page and append blobs" + }, + "IfModifiedSince": { + "name": "If-Modified-Since", + "x-ms-client-name": "ifModifiedSince", + "in": "header", + "required": false, + "type": "string", + "format": "datetime", + "x-ms-parameter-location": "method", + "description": "Specify this conditional header to snapshot the blob only if it has not been modified since the specified date/time." + }, + "IfUnmodifiedSince": { + "name": "If-Unmodified-Since", + "x-ms-client-name": "ifUnmodifiedSince", + "in": "header", + "required": false, + "type": "string", + "format": "datetime", + "x-ms-parameter-location": "method", + "description": "Specify this conditional header to snapshot the blob only if it has been modified since the specified date/time." + }, + "IfMatch": { + "name": "If-Match", + "x-ms-client-name": "ifMatches", + "in": "header", + "required": false, + "type": "string", + "x-ms-parameter-location": "method", + "description": "Specify an ETag value for this conditional header to snapshot the blob only if its ETag value matches the value specified." + }, + "IfNoneMatch": { + "name": "If-None-Match", + "x-ms-client-name": "ifNoneMatch", + "in": "header", + "required": false, + "type": "string", + "x-ms-parameter-location": "method", + "description": "Specify an ETag value for this conditional header to snapshot the blob only if its ETag value does not match the value specified." + } + }, + "responses": { + "Default": { + "description": "Error.", + "schema": { + "$ref": "#/definitions/BlobError" + } + } + } +} \ No newline at end of file diff --git a/src/dev/TestServer/server/app.js b/src/dev/TestServer/server/app.js index 84bd2fc08c..828cd63a3b 100644 --- a/src/dev/TestServer/server/app.js +++ b/src/dev/TestServer/server/app.js @@ -36,6 +36,7 @@ var azureSpecial = require('./routes/azureSpecials'); var parameterGrouping = require('./routes/azureParameterGrouping.js'); var validation = require('./routes/validation.js'); var customUri = require('./routes/customUri.js'); +var xml = require('./routes/xml.js'); // XML serialization var util = require('util'); var app = express(); @@ -506,6 +507,7 @@ app.use('/subscriptions', new azureUrl(azurecoverage).router); app.use('/parameterGrouping', new parameterGrouping(azurecoverage).router); app.use('/validation', new validation(coverage).router); app.use('/customUri', new customUri(coverage).router); +app.use('/xml', new xml().router); // catch 404 and forward to error handler app.use(function(req, res, next) { diff --git a/src/dev/TestServer/server/routes/xml.js b/src/dev/TestServer/server/routes/xml.js new file mode 100644 index 0000000000..b5b5dce8ec --- /dev/null +++ b/src/dev/TestServer/server/routes/xml.js @@ -0,0 +1,304 @@ +var express = require('express'); +var router = express.Router(); +var util = require('util'); +var utils = require('../util/utils'); + +// Expect given request body. Otherwise, 400 with comparison is returned. +var expectXmlBody = function (req, res, body) { + var rawBody = ''; + req.setEncoding('utf8'); + req.on('data', function(chunk) { rawBody += chunk }); + req.on('end', function() { + if (rawBody.replace(/\s/g, "") == body.replace(/\s/g, "")) + res.sendStatus(200); // response headers? + else + res.status(400).header('Content-Type', 'text/plain').end(` +Expected: +${body} + +Actual: +${rawBody} +`); + }); +}; + +var sendXmlBody = function (res, body) { + res.status(200).header('Content-Type', 'application/xml').end(body); +}; + +// sample XML bodies +var body_list = +` + + 3 + + + audio + + Wed, 26 Oct 2016 20:39:39 GMT + 0x8CACB9BD7C6B1B2 + container + + + + images + + Wed, 26 Oct 2016 20:39:39 GMT + 0x8CACB9BD7C1EEEC + + + + textfiles + + Wed, 26 Oct 2016 20:39:39 GMT + 0x8CACB9BD7BACAC3 + + + + video +`; + +var body_list_container = +` + + + + blob1.txt + https://myaccount.blob.core.windows.net/mycontainer/blob1.txt + + Wed, 09 Sep 2009 09:20:02 GMT + 0x8CBFF45D8A29A19 + 100 + text/html + + en-US + + no-cache + BlockBlob + unlocked + + + blue + 01 + SomeMetadataValue + + + + blob2.txt + 2009-09-09T09:20:03.0427659Z + https://myaccount.blob.core.windows.net/mycontainer/blob2.txt?snapshot=2009-09-09T09%3a20%3a03.0427659Z + + Wed, 09 Sep 2009 09:20:02 GMT + 0x8CBFF45D8B4C212 + 5000 + application/octet-stream + gzip + + + + BlockBlob + + + green + 02 + SomeMetadataValue + nasdf$@#$$ + + + + blob2.txt + 2009-09-09T09:20:03.1587543Z + https://myaccount.blob.core.windows.net/mycontainer/blob2.txt?snapshot=2009-09-09T09%3a20%3a03.1587543Z + + Wed, 09 Sep 2009 09:20:02 GMT + 0x8CBFF45D8B4C212 + 5000 + application/octet-stream + gzip + + + + BlockBlob + + + green + 02 + SomeMetadataValue + + + + blob2.txt + https://myaccount.blob.core.windows.net/mycontainer/blob2.txt + + Wed, 09 Sep 2009 09:20:02 GMT + 0x8CBFF45D8B4C212 + 5000 + application/octet-stream + gzip + + + + BlockBlob + unlocked + + + green + 02 + SomeMetadataValue + + + + blob3.txt + https://myaccount.blob.core.windows.net/mycontainer/blob3.txt + + Wed, 09 Sep 2009 09:20:03 GMT + 0x8CBFF45D911FADF + 16384 + image/jpeg + + + + + 3 + PageBlob + locked + + + yellow + 03 + SomeMetadataValue + + + + +` + +var body_acl_container = +` + + + MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI= + + 2009-09-28T08:49:37.0000000Z + 2009-09-29T08:49:37.0000000Z + rwd + + +`; + +var body_properties_service = +` + + + 1.0 + true + false + true + + true + 7 + + + + 1.0 + true + false + + true + 7 + + + + 1.0 + true + true + + true + 7 + + +`; + +var reqopt = function () { + router.get('/', function (req, res, next) { + var comp = req.query.comp; + var restype = req.query.restype; + switch(comp) { + case "list": + switch(restype) { + // https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/list-containers2 + // https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/enumerating-blob-resources + // Swagger: Service_ListContainers + case undefined: sendXmlBody(res, body_list); break; + default: res.sendStatus(404); break; + } + break; + case "properties": + switch(restype) { + // https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/get-blob-service-properties + // Swagger: Service_GetServiceProperties + case "service": sendXmlBody(res, body_properties_service); break; + default: res.sendStatus(404); break; + } + break; + default: res.sendStatus(404); break; + } + }); + router.put('/', function (req, res, next) { + var comp = req.query.comp; + var restype = req.query.restype; + switch(comp) { + case "properties": + switch(restype) { + // https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/set-blob-service-properties + case "service": expectXmlBody(req, res, body_properties_service); break; + default: res.sendStatus(404); break; + } + break; + default: res.sendStatus(404); break; + } + }); + + router.get('/mycontainer', function (req, res, next) { + var comp = req.query.comp; + var restype = req.query.restype; + switch(comp) { + case "acl": + switch(restype) { + // https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/get-container-acl + case "container": sendXmlBody(res, body_acl_container); break; + default: res.sendStatus(404); break; + } + break; + case "list": + switch(restype) { + // https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/list-blobs + // https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/enumerating-blob-resources + // Swagger: Containers_ListBlobs + case "container": sendXmlBody(res, body_list_container); break; + default: res.sendStatus(404); break; + } + break; + default: res.sendStatus(404); break; + } + }); + router.put('/mycontainer', function (req, res, next) { + var comp = req.query.comp; + var restype = req.query.restype; + switch(comp) { + case "acl": + switch(restype) { + // https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/set-container-acl + case "container": expectXmlBody(req, res, body_acl_container); break; + default: res.sendStatus(404); break; + } + break; + default: res.sendStatus(404); break; + } + }); + +}; + +reqopt.prototype.router = router; + +module.exports = reqopt; \ No newline at end of file diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureBodyDuration/AutoRestDurationTestServiceClient.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureBodyDuration/AutoRestDurationTestServiceClient.cs index 4c31c91dde..b710750fa4 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureBodyDuration/AutoRestDurationTestServiceClient.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureBodyDuration/AutoRestDurationTestServiceClient.cs @@ -33,12 +33,12 @@ public partial class AutoRestDurationTestServiceClient : ServiceClient /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// Credentials needed for the client to connect to Azure. @@ -273,27 +273,27 @@ private void Initialize() AcceptLanguage = "en-US"; LongRunningOperationRetryTimeout = 30; GenerateClientRequestId = true; - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureBodyDuration/DurationOperations.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureBodyDuration/DurationOperations.cs index 5d32b6bae6..3e4bca7a11 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureBodyDuration/DurationOperations.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureBodyDuration/DurationOperations.cs @@ -105,6 +105,8 @@ internal DurationOperations(AutoRestDurationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -151,7 +153,7 @@ internal DurationOperations(AutoRestDurationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -184,7 +186,7 @@ internal DurationOperations(AutoRestDurationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -257,6 +259,8 @@ internal DurationOperations(AutoRestDurationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -306,7 +310,7 @@ internal DurationOperations(AutoRestDurationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -394,6 +398,8 @@ internal DurationOperations(AutoRestDurationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -440,7 +446,7 @@ internal DurationOperations(AutoRestDurationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -473,7 +479,7 @@ internal DurationOperations(AutoRestDurationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -546,6 +552,8 @@ internal DurationOperations(AutoRestDurationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -592,7 +600,7 @@ internal DurationOperations(AutoRestDurationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -625,7 +633,7 @@ internal DurationOperations(AutoRestDurationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureBodyDuration/IAutoRestDurationTestServiceClient.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureBodyDuration/IAutoRestDurationTestServiceClient.cs index ff89b17ebf..2bf17a8b46 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureBodyDuration/IAutoRestDurationTestServiceClient.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureBodyDuration/IAutoRestDurationTestServiceClient.cs @@ -27,12 +27,12 @@ public partial interface IAutoRestDurationTestServiceClient : System.IDisposable /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// /// Credentials needed for the client to connect to Azure. diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureBodyDurationAllSync/AutoRestDurationTestServiceClient.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureBodyDurationAllSync/AutoRestDurationTestServiceClient.cs index 69089cb87d..4f20dfcaae 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureBodyDurationAllSync/AutoRestDurationTestServiceClient.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureBodyDurationAllSync/AutoRestDurationTestServiceClient.cs @@ -32,12 +32,12 @@ public partial class AutoRestDurationTestServiceClient : ServiceClient /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// Credentials needed for the client to connect to Azure. @@ -272,27 +272,27 @@ private void Initialize() AcceptLanguage = "en-US"; LongRunningOperationRetryTimeout = 30; GenerateClientRequestId = true; - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureBodyDurationAllSync/DurationOperations.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureBodyDurationAllSync/DurationOperations.cs index 087818ff0b..2600619777 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureBodyDurationAllSync/DurationOperations.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureBodyDurationAllSync/DurationOperations.cs @@ -104,6 +104,8 @@ internal DurationOperations(AutoRestDurationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -150,7 +152,7 @@ internal DurationOperations(AutoRestDurationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -183,7 +185,7 @@ internal DurationOperations(AutoRestDurationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -256,6 +258,8 @@ internal DurationOperations(AutoRestDurationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -305,7 +309,7 @@ internal DurationOperations(AutoRestDurationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -393,6 +397,8 @@ internal DurationOperations(AutoRestDurationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -439,7 +445,7 @@ internal DurationOperations(AutoRestDurationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -472,7 +478,7 @@ internal DurationOperations(AutoRestDurationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -545,6 +551,8 @@ internal DurationOperations(AutoRestDurationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -591,7 +599,7 @@ internal DurationOperations(AutoRestDurationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -624,7 +632,7 @@ internal DurationOperations(AutoRestDurationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureBodyDurationAllSync/IAutoRestDurationTestServiceClient.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureBodyDurationAllSync/IAutoRestDurationTestServiceClient.cs index d990d138aa..52753fccac 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureBodyDurationAllSync/IAutoRestDurationTestServiceClient.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureBodyDurationAllSync/IAutoRestDurationTestServiceClient.cs @@ -26,12 +26,12 @@ public partial interface IAutoRestDurationTestServiceClient : System.IDisposable /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// /// Credentials needed for the client to connect to Azure. diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureBodyDurationNoSync/AutoRestDurationTestServiceClient.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureBodyDurationNoSync/AutoRestDurationTestServiceClient.cs index 0bdbca1d77..4cfc4a24e7 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureBodyDurationNoSync/AutoRestDurationTestServiceClient.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureBodyDurationNoSync/AutoRestDurationTestServiceClient.cs @@ -32,12 +32,12 @@ public partial class AutoRestDurationTestServiceClient : ServiceClient /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// Credentials needed for the client to connect to Azure. @@ -272,27 +272,27 @@ private void Initialize() AcceptLanguage = "en-US"; LongRunningOperationRetryTimeout = 30; GenerateClientRequestId = true; - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureBodyDurationNoSync/DurationOperations.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureBodyDurationNoSync/DurationOperations.cs index ae3b77af6d..b898af183b 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureBodyDurationNoSync/DurationOperations.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureBodyDurationNoSync/DurationOperations.cs @@ -104,6 +104,8 @@ internal DurationOperations(AutoRestDurationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -150,7 +152,7 @@ internal DurationOperations(AutoRestDurationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -183,7 +185,7 @@ internal DurationOperations(AutoRestDurationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -256,6 +258,8 @@ internal DurationOperations(AutoRestDurationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -305,7 +309,7 @@ internal DurationOperations(AutoRestDurationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -393,6 +397,8 @@ internal DurationOperations(AutoRestDurationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -439,7 +445,7 @@ internal DurationOperations(AutoRestDurationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -472,7 +478,7 @@ internal DurationOperations(AutoRestDurationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -545,6 +551,8 @@ internal DurationOperations(AutoRestDurationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -591,7 +599,7 @@ internal DurationOperations(AutoRestDurationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -624,7 +632,7 @@ internal DurationOperations(AutoRestDurationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureBodyDurationNoSync/IAutoRestDurationTestServiceClient.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureBodyDurationNoSync/IAutoRestDurationTestServiceClient.cs index 53e4174648..8a779625c1 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureBodyDurationNoSync/IAutoRestDurationTestServiceClient.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureBodyDurationNoSync/IAutoRestDurationTestServiceClient.cs @@ -26,12 +26,12 @@ public partial interface IAutoRestDurationTestServiceClient : System.IDisposable /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// /// Credentials needed for the client to connect to Azure. diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/ArrayOperations.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/ArrayOperations.cs index fc2406d559..d82d482529 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/ArrayOperations.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/ArrayOperations.cs @@ -104,6 +104,8 @@ internal ArrayOperations(AzureCompositeModelClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -150,7 +152,7 @@ internal ArrayOperations(AzureCompositeModelClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -183,7 +185,7 @@ internal ArrayOperations(AzureCompositeModelClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -261,6 +263,8 @@ internal ArrayOperations(AzureCompositeModelClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -313,7 +317,7 @@ internal ArrayOperations(AzureCompositeModelClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -401,6 +405,8 @@ internal ArrayOperations(AzureCompositeModelClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -447,7 +453,7 @@ internal ArrayOperations(AzureCompositeModelClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -480,7 +486,7 @@ internal ArrayOperations(AzureCompositeModelClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -558,6 +564,8 @@ internal ArrayOperations(AzureCompositeModelClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -610,7 +618,7 @@ internal ArrayOperations(AzureCompositeModelClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -699,6 +707,8 @@ internal ArrayOperations(AzureCompositeModelClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -745,7 +755,7 @@ internal ArrayOperations(AzureCompositeModelClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -778,7 +788,7 @@ internal ArrayOperations(AzureCompositeModelClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/AzureCompositeModelClient.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/AzureCompositeModelClient.cs index d1f01c197e..745d8609cc 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/AzureCompositeModelClient.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/AzureCompositeModelClient.cs @@ -35,12 +35,12 @@ public partial class AzureCompositeModelClient : ServiceClient /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// Credentials needed for the client to connect to Azure. @@ -323,27 +323,27 @@ private void Initialize() AcceptLanguage = "en-US"; LongRunningOperationRetryTimeout = 30; GenerateClientRequestId = true; - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } @@ -437,6 +437,8 @@ private void Initialize() } _httpRequest.Headers.TryAddWithoutValidation("accept-language", AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -483,7 +485,7 @@ private void Initialize() ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -516,7 +518,7 @@ private void Initialize() { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -631,6 +633,8 @@ private void Initialize() } _httpRequest.Headers.TryAddWithoutValidation("accept-language", AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -683,7 +687,7 @@ private void Initialize() ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -716,7 +720,7 @@ private void Initialize() { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -831,6 +835,8 @@ private void Initialize() } _httpRequest.Headers.TryAddWithoutValidation("accept-language", AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -883,7 +889,7 @@ private void Initialize() ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -916,7 +922,7 @@ private void Initialize() { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/BasicOperations.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/BasicOperations.cs index 98f85b2190..7a61f9e73b 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/BasicOperations.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/BasicOperations.cs @@ -104,6 +104,8 @@ internal BasicOperations(AzureCompositeModelClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -150,7 +152,7 @@ internal BasicOperations(AzureCompositeModelClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -183,7 +185,7 @@ internal BasicOperations(AzureCompositeModelClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -273,6 +275,8 @@ internal BasicOperations(AzureCompositeModelClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -325,7 +329,7 @@ internal BasicOperations(AzureCompositeModelClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -413,6 +417,8 @@ internal BasicOperations(AzureCompositeModelClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -459,7 +465,7 @@ internal BasicOperations(AzureCompositeModelClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -492,7 +498,7 @@ internal BasicOperations(AzureCompositeModelClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -565,6 +571,8 @@ internal BasicOperations(AzureCompositeModelClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -611,7 +619,7 @@ internal BasicOperations(AzureCompositeModelClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -644,7 +652,7 @@ internal BasicOperations(AzureCompositeModelClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -717,6 +725,8 @@ internal BasicOperations(AzureCompositeModelClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -763,7 +773,7 @@ internal BasicOperations(AzureCompositeModelClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -796,7 +806,7 @@ internal BasicOperations(AzureCompositeModelClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -870,6 +880,8 @@ internal BasicOperations(AzureCompositeModelClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -916,7 +928,7 @@ internal BasicOperations(AzureCompositeModelClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -949,7 +961,7 @@ internal BasicOperations(AzureCompositeModelClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/DictionaryOperations.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/DictionaryOperations.cs index 002ce55c85..14a4da17f7 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/DictionaryOperations.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/DictionaryOperations.cs @@ -104,6 +104,8 @@ internal DictionaryOperations(AzureCompositeModelClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -150,7 +152,7 @@ internal DictionaryOperations(AzureCompositeModelClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -183,7 +185,7 @@ internal DictionaryOperations(AzureCompositeModelClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -261,6 +263,8 @@ internal DictionaryOperations(AzureCompositeModelClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -313,7 +317,7 @@ internal DictionaryOperations(AzureCompositeModelClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -401,6 +405,8 @@ internal DictionaryOperations(AzureCompositeModelClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -447,7 +453,7 @@ internal DictionaryOperations(AzureCompositeModelClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -480,7 +486,7 @@ internal DictionaryOperations(AzureCompositeModelClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -558,6 +564,8 @@ internal DictionaryOperations(AzureCompositeModelClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -610,7 +618,7 @@ internal DictionaryOperations(AzureCompositeModelClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -698,6 +706,8 @@ internal DictionaryOperations(AzureCompositeModelClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -744,7 +754,7 @@ internal DictionaryOperations(AzureCompositeModelClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -777,7 +787,7 @@ internal DictionaryOperations(AzureCompositeModelClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -851,6 +861,8 @@ internal DictionaryOperations(AzureCompositeModelClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -897,7 +909,7 @@ internal DictionaryOperations(AzureCompositeModelClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -930,7 +942,7 @@ internal DictionaryOperations(AzureCompositeModelClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/IAzureCompositeModelClient.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/IAzureCompositeModelClient.cs index 37eb61036a..5d346a39bc 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/IAzureCompositeModelClient.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/IAzureCompositeModelClient.cs @@ -31,12 +31,12 @@ public partial interface IAzureCompositeModelClient : System.IDisposable /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// /// Credentials needed for the client to connect to Azure. diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/InheritanceOperations.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/InheritanceOperations.cs index 177f29eed6..787f688f06 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/InheritanceOperations.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/InheritanceOperations.cs @@ -104,6 +104,8 @@ internal InheritanceOperations(AzureCompositeModelClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -150,7 +152,7 @@ internal InheritanceOperations(AzureCompositeModelClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -183,7 +185,7 @@ internal InheritanceOperations(AzureCompositeModelClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -269,6 +271,8 @@ internal InheritanceOperations(AzureCompositeModelClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -321,7 +325,7 @@ internal InheritanceOperations(AzureCompositeModelClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/Models/Cookiecuttershark.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/Models/Cookiecuttershark.cs index 7b2fff27af..9dc4bce009 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/Models/Cookiecuttershark.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/Models/Cookiecuttershark.cs @@ -14,7 +14,7 @@ namespace Fixtures.AcceptanceTestsAzureCompositeModelClient.Models using System.Collections.Generic; using System.Linq; - [Newtonsoft.Json.JsonObject("cookiecuttershark")] + [JsonObject("cookiecuttershark")] public partial class Cookiecuttershark : Shark { /// diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/Models/Goblinshark.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/Models/Goblinshark.cs index 3719d076d3..5c6bb9e831 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/Models/Goblinshark.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/Models/Goblinshark.cs @@ -14,7 +14,7 @@ namespace Fixtures.AcceptanceTestsAzureCompositeModelClient.Models using System.Collections.Generic; using System.Linq; - [Newtonsoft.Json.JsonObject("goblin")] + [JsonObject("goblin")] public partial class Goblinshark : Shark { /// diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/Models/Salmon.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/Models/Salmon.cs index 0cd207d486..9e90c021e6 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/Models/Salmon.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/Models/Salmon.cs @@ -14,7 +14,7 @@ namespace Fixtures.AcceptanceTestsAzureCompositeModelClient.Models using System.Collections.Generic; using System.Linq; - [Newtonsoft.Json.JsonObject("salmon")] + [JsonObject("salmon")] public partial class Salmon : Fish { /// diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/Models/Sawshark.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/Models/Sawshark.cs index b759ff0dc1..232dbbe0b7 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/Models/Sawshark.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/Models/Sawshark.cs @@ -14,7 +14,7 @@ namespace Fixtures.AcceptanceTestsAzureCompositeModelClient.Models using System.Collections.Generic; using System.Linq; - [Newtonsoft.Json.JsonObject("sawshark")] + [JsonObject("sawshark")] public partial class Sawshark : Shark { /// diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/Models/Shark.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/Models/Shark.cs index a932e48a89..980876703b 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/Models/Shark.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/Models/Shark.cs @@ -14,7 +14,7 @@ namespace Fixtures.AcceptanceTestsAzureCompositeModelClient.Models using System.Collections.Generic; using System.Linq; - [Newtonsoft.Json.JsonObject("shark")] + [JsonObject("shark")] public partial class Shark : Fish { /// diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/PolymorphicrecursiveOperations.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/PolymorphicrecursiveOperations.cs index 58cbe4c248..6b7011f656 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/PolymorphicrecursiveOperations.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/PolymorphicrecursiveOperations.cs @@ -104,6 +104,8 @@ internal PolymorphicrecursiveOperations(AzureCompositeModelClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -150,7 +152,7 @@ internal PolymorphicrecursiveOperations(AzureCompositeModelClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -183,7 +185,7 @@ internal PolymorphicrecursiveOperations(AzureCompositeModelClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -323,6 +325,8 @@ internal PolymorphicrecursiveOperations(AzureCompositeModelClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -375,7 +379,7 @@ internal PolymorphicrecursiveOperations(AzureCompositeModelClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/PolymorphismOperations.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/PolymorphismOperations.cs index 8bb363560c..c8ad8c7751 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/PolymorphismOperations.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/PolymorphismOperations.cs @@ -104,6 +104,8 @@ internal PolymorphismOperations(AzureCompositeModelClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -150,7 +152,7 @@ internal PolymorphismOperations(AzureCompositeModelClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -183,7 +185,7 @@ internal PolymorphismOperations(AzureCompositeModelClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -303,6 +305,8 @@ internal PolymorphismOperations(AzureCompositeModelClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -355,7 +359,7 @@ internal PolymorphismOperations(AzureCompositeModelClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -485,6 +489,8 @@ internal PolymorphismOperations(AzureCompositeModelClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -537,7 +543,7 @@ internal PolymorphismOperations(AzureCompositeModelClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/PrimitiveOperations.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/PrimitiveOperations.cs index 1691ecdc93..ee538b190a 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/PrimitiveOperations.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/PrimitiveOperations.cs @@ -104,6 +104,8 @@ internal PrimitiveOperations(AzureCompositeModelClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -150,7 +152,7 @@ internal PrimitiveOperations(AzureCompositeModelClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -183,7 +185,7 @@ internal PrimitiveOperations(AzureCompositeModelClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -267,6 +269,8 @@ internal PrimitiveOperations(AzureCompositeModelClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -319,7 +323,7 @@ internal PrimitiveOperations(AzureCompositeModelClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -407,6 +411,8 @@ internal PrimitiveOperations(AzureCompositeModelClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -453,7 +459,7 @@ internal PrimitiveOperations(AzureCompositeModelClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -486,7 +492,7 @@ internal PrimitiveOperations(AzureCompositeModelClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -570,6 +576,8 @@ internal PrimitiveOperations(AzureCompositeModelClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -622,7 +630,7 @@ internal PrimitiveOperations(AzureCompositeModelClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -710,6 +718,8 @@ internal PrimitiveOperations(AzureCompositeModelClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -756,7 +766,7 @@ internal PrimitiveOperations(AzureCompositeModelClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -789,7 +799,7 @@ internal PrimitiveOperations(AzureCompositeModelClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -873,6 +883,8 @@ internal PrimitiveOperations(AzureCompositeModelClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -925,7 +937,7 @@ internal PrimitiveOperations(AzureCompositeModelClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1013,6 +1025,8 @@ internal PrimitiveOperations(AzureCompositeModelClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1059,7 +1073,7 @@ internal PrimitiveOperations(AzureCompositeModelClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1092,7 +1106,7 @@ internal PrimitiveOperations(AzureCompositeModelClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1177,6 +1191,8 @@ internal PrimitiveOperations(AzureCompositeModelClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1229,7 +1245,7 @@ internal PrimitiveOperations(AzureCompositeModelClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1317,6 +1333,8 @@ internal PrimitiveOperations(AzureCompositeModelClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1363,7 +1381,7 @@ internal PrimitiveOperations(AzureCompositeModelClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1396,7 +1414,7 @@ internal PrimitiveOperations(AzureCompositeModelClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1480,6 +1498,8 @@ internal PrimitiveOperations(AzureCompositeModelClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1532,7 +1552,7 @@ internal PrimitiveOperations(AzureCompositeModelClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1620,6 +1640,8 @@ internal PrimitiveOperations(AzureCompositeModelClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1666,7 +1688,7 @@ internal PrimitiveOperations(AzureCompositeModelClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1699,7 +1721,7 @@ internal PrimitiveOperations(AzureCompositeModelClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1783,6 +1805,8 @@ internal PrimitiveOperations(AzureCompositeModelClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1835,7 +1859,7 @@ internal PrimitiveOperations(AzureCompositeModelClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1923,6 +1947,8 @@ internal PrimitiveOperations(AzureCompositeModelClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1969,7 +1995,7 @@ internal PrimitiveOperations(AzureCompositeModelClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2002,7 +2028,7 @@ internal PrimitiveOperations(AzureCompositeModelClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2086,6 +2112,8 @@ internal PrimitiveOperations(AzureCompositeModelClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2138,7 +2166,7 @@ internal PrimitiveOperations(AzureCompositeModelClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2226,6 +2254,8 @@ internal PrimitiveOperations(AzureCompositeModelClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2272,7 +2302,7 @@ internal PrimitiveOperations(AzureCompositeModelClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2305,7 +2335,7 @@ internal PrimitiveOperations(AzureCompositeModelClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2389,6 +2419,8 @@ internal PrimitiveOperations(AzureCompositeModelClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2441,7 +2473,7 @@ internal PrimitiveOperations(AzureCompositeModelClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2529,6 +2561,8 @@ internal PrimitiveOperations(AzureCompositeModelClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2575,7 +2609,7 @@ internal PrimitiveOperations(AzureCompositeModelClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2608,7 +2642,7 @@ internal PrimitiveOperations(AzureCompositeModelClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2693,6 +2727,8 @@ internal PrimitiveOperations(AzureCompositeModelClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2745,7 +2781,7 @@ internal PrimitiveOperations(AzureCompositeModelClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2833,6 +2869,8 @@ internal PrimitiveOperations(AzureCompositeModelClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2879,7 +2917,7 @@ internal PrimitiveOperations(AzureCompositeModelClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2912,7 +2950,7 @@ internal PrimitiveOperations(AzureCompositeModelClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2990,6 +3028,8 @@ internal PrimitiveOperations(AzureCompositeModelClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3042,7 +3082,7 @@ internal PrimitiveOperations(AzureCompositeModelClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3130,6 +3170,8 @@ internal PrimitiveOperations(AzureCompositeModelClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3176,7 +3218,7 @@ internal PrimitiveOperations(AzureCompositeModelClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3209,7 +3251,7 @@ internal PrimitiveOperations(AzureCompositeModelClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -3287,6 +3329,8 @@ internal PrimitiveOperations(AzureCompositeModelClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3339,7 +3383,7 @@ internal PrimitiveOperations(AzureCompositeModelClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/ReadonlypropertyOperations.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/ReadonlypropertyOperations.cs index 424a9e1116..750dd078ce 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/ReadonlypropertyOperations.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureCompositeModelClient/ReadonlypropertyOperations.cs @@ -104,6 +104,8 @@ internal ReadonlypropertyOperations(AzureCompositeModelClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -150,7 +152,7 @@ internal ReadonlypropertyOperations(AzureCompositeModelClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -183,7 +185,7 @@ internal ReadonlypropertyOperations(AzureCompositeModelClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -261,6 +263,8 @@ internal ReadonlypropertyOperations(AzureCompositeModelClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -313,7 +317,7 @@ internal ReadonlypropertyOperations(AzureCompositeModelClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureParameterGrouping/AutoRestParameterGroupingTestServiceClient.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureParameterGrouping/AutoRestParameterGroupingTestServiceClient.cs index bcd3aac459..0657869d53 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureParameterGrouping/AutoRestParameterGroupingTestServiceClient.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureParameterGrouping/AutoRestParameterGroupingTestServiceClient.cs @@ -33,12 +33,12 @@ public partial class AutoRestParameterGroupingTestServiceClient : ServiceClient< /// /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// Credentials needed for the client to connect to Azure. @@ -273,27 +273,27 @@ private void Initialize() AcceptLanguage = "en-US"; LongRunningOperationRetryTimeout = 30; GenerateClientRequestId = true; - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureParameterGrouping/IAutoRestParameterGroupingTestServiceClient.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureParameterGrouping/IAutoRestParameterGroupingTestServiceClient.cs index bb9a291687..47bac5811d 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureParameterGrouping/IAutoRestParameterGroupingTestServiceClient.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureParameterGrouping/IAutoRestParameterGroupingTestServiceClient.cs @@ -27,12 +27,12 @@ public partial interface IAutoRestParameterGroupingTestServiceClient : System.ID /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// /// Credentials needed for the client to connect to Azure. diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureParameterGrouping/ParameterGroupingOperations.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureParameterGrouping/ParameterGroupingOperations.cs index 73730afd88..dee0770244 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureParameterGrouping/ParameterGroupingOperations.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureParameterGrouping/ParameterGroupingOperations.cs @@ -156,6 +156,8 @@ internal ParameterGroupingOperations(AutoRestParameterGroupingTestServiceClient } _httpRequest.Headers.TryAddWithoutValidation("customHeader", customHeader); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -205,7 +207,7 @@ internal ParameterGroupingOperations(AutoRestParameterGroupingTestServiceClient ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -317,6 +319,8 @@ internal ParameterGroupingOperations(AutoRestParameterGroupingTestServiceClient } _httpRequest.Headers.TryAddWithoutValidation("customHeader", customHeader); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -363,7 +367,7 @@ internal ParameterGroupingOperations(AutoRestParameterGroupingTestServiceClient ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -502,6 +506,8 @@ internal ParameterGroupingOperations(AutoRestParameterGroupingTestServiceClient } _httpRequest.Headers.TryAddWithoutValidation("header-two", headerTwo); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -548,7 +554,7 @@ internal ParameterGroupingOperations(AutoRestParameterGroupingTestServiceClient ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -660,6 +666,8 @@ internal ParameterGroupingOperations(AutoRestParameterGroupingTestServiceClient } _httpRequest.Headers.TryAddWithoutValidation("header-one", headerOne); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -706,7 +714,7 @@ internal ParameterGroupingOperations(AutoRestParameterGroupingTestServiceClient ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureReport/AutoRestReportServiceForAzureClient.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureReport/AutoRestReportServiceForAzureClient.cs index 3536254d31..ce43368483 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureReport/AutoRestReportServiceForAzureClient.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureReport/AutoRestReportServiceForAzureClient.cs @@ -35,12 +35,12 @@ public partial class AutoRestReportServiceForAzureClient : ServiceClient /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// Credentials needed for the client to connect to Azure. @@ -269,27 +269,27 @@ private void Initialize() AcceptLanguage = "en-US"; LongRunningOperationRetryTimeout = 30; GenerateClientRequestId = true; - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } @@ -353,6 +353,8 @@ private void Initialize() } _httpRequest.Headers.TryAddWithoutValidation("accept-language", AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -399,7 +401,7 @@ private void Initialize() ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -432,7 +434,7 @@ private void Initialize() { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureReport/IAutoRestReportServiceForAzureClient.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureReport/IAutoRestReportServiceForAzureClient.cs index 877e7b77ff..dc7819d14c 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureReport/IAutoRestReportServiceForAzureClient.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureReport/IAutoRestReportServiceForAzureClient.cs @@ -31,12 +31,12 @@ public partial interface IAutoRestReportServiceForAzureClient : System.IDisposab /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// /// Credentials needed for the client to connect to Azure. diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureResource/AutoRestResourceFlatteningTestServiceClient.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureResource/AutoRestResourceFlatteningTestServiceClient.cs index 733569cd45..798dcdb91c 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureResource/AutoRestResourceFlatteningTestServiceClient.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureResource/AutoRestResourceFlatteningTestServiceClient.cs @@ -35,12 +35,12 @@ public partial class AutoRestResourceFlatteningTestServiceClient : ServiceClient /// /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// Credentials needed for the client to connect to Azure. @@ -269,28 +269,28 @@ private void Initialize() AcceptLanguage = "en-US"; LongRunningOperationRetryTimeout = 30; GenerateClientRequestId = true; - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; SerializationSettings.Converters.Add(new TransformationJsonConverter()); - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } @@ -357,6 +357,8 @@ private void Initialize() } _httpRequest.Headers.TryAddWithoutValidation("accept-language", AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -409,7 +411,7 @@ private void Initialize() ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -498,6 +500,8 @@ private void Initialize() } _httpRequest.Headers.TryAddWithoutValidation("accept-language", AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -544,7 +548,7 @@ private void Initialize() ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -577,7 +581,7 @@ private void Initialize() { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -652,6 +656,8 @@ private void Initialize() } _httpRequest.Headers.TryAddWithoutValidation("accept-language", AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -704,7 +710,7 @@ private void Initialize() ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -793,6 +799,8 @@ private void Initialize() } _httpRequest.Headers.TryAddWithoutValidation("accept-language", AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -839,7 +847,7 @@ private void Initialize() ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -872,7 +880,7 @@ private void Initialize() { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -947,6 +955,8 @@ private void Initialize() } _httpRequest.Headers.TryAddWithoutValidation("accept-language", AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -999,7 +1009,7 @@ private void Initialize() ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1088,6 +1098,8 @@ private void Initialize() } _httpRequest.Headers.TryAddWithoutValidation("accept-language", AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1134,7 +1146,7 @@ private void Initialize() ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1167,7 +1179,7 @@ private void Initialize() { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureResource/IAutoRestResourceFlatteningTestServiceClient.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureResource/IAutoRestResourceFlatteningTestServiceClient.cs index 5347e4f936..27186afdfc 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureResource/IAutoRestResourceFlatteningTestServiceClient.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureResource/IAutoRestResourceFlatteningTestServiceClient.cs @@ -31,12 +31,12 @@ public partial interface IAutoRestResourceFlatteningTestServiceClient : System.I /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// /// Credentials needed for the client to connect to Azure. diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureSpecials/ApiVersionDefaultOperations.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureSpecials/ApiVersionDefaultOperations.cs index b7e5f3b418..2cd39664e0 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureSpecials/ApiVersionDefaultOperations.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureSpecials/ApiVersionDefaultOperations.cs @@ -116,6 +116,8 @@ internal ApiVersionDefaultOperations(AutoRestAzureSpecialParametersTestClient cl } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -162,7 +164,7 @@ internal ApiVersionDefaultOperations(AutoRestAzureSpecialParametersTestClient cl ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -261,6 +263,8 @@ internal ApiVersionDefaultOperations(AutoRestAzureSpecialParametersTestClient cl } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -307,7 +311,7 @@ internal ApiVersionDefaultOperations(AutoRestAzureSpecialParametersTestClient cl ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -406,6 +410,8 @@ internal ApiVersionDefaultOperations(AutoRestAzureSpecialParametersTestClient cl } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -452,7 +458,7 @@ internal ApiVersionDefaultOperations(AutoRestAzureSpecialParametersTestClient cl ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -551,6 +557,8 @@ internal ApiVersionDefaultOperations(AutoRestAzureSpecialParametersTestClient cl } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -597,7 +605,7 @@ internal ApiVersionDefaultOperations(AutoRestAzureSpecialParametersTestClient cl ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureSpecials/ApiVersionLocalOperations.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureSpecials/ApiVersionLocalOperations.cs index fb24556da5..bbe50de042 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureSpecials/ApiVersionLocalOperations.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureSpecials/ApiVersionLocalOperations.cs @@ -109,6 +109,8 @@ internal ApiVersionLocalOperations(AutoRestAzureSpecialParametersTestClient clie } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -155,7 +157,7 @@ internal ApiVersionLocalOperations(AutoRestAzureSpecialParametersTestClient clie ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -250,6 +252,8 @@ internal ApiVersionLocalOperations(AutoRestAzureSpecialParametersTestClient clie } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -296,7 +300,7 @@ internal ApiVersionLocalOperations(AutoRestAzureSpecialParametersTestClient clie ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -388,6 +392,8 @@ internal ApiVersionLocalOperations(AutoRestAzureSpecialParametersTestClient clie } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -434,7 +440,7 @@ internal ApiVersionLocalOperations(AutoRestAzureSpecialParametersTestClient clie ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -526,6 +532,8 @@ internal ApiVersionLocalOperations(AutoRestAzureSpecialParametersTestClient clie } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -572,7 +580,7 @@ internal ApiVersionLocalOperations(AutoRestAzureSpecialParametersTestClient clie ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureSpecials/AutoRestAzureSpecialParametersTestClient.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureSpecials/AutoRestAzureSpecialParametersTestClient.cs index 8988bb1bc0..25e2038688 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureSpecials/AutoRestAzureSpecialParametersTestClient.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureSpecials/AutoRestAzureSpecialParametersTestClient.cs @@ -33,12 +33,12 @@ public partial class AutoRestAzureSpecialParametersTestClient : ServiceClient /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// Credentials needed for the client to connect to Azure. @@ -328,27 +328,27 @@ private void Initialize() AcceptLanguage = "en-US"; LongRunningOperationRetryTimeout = 30; GenerateClientRequestId = true; - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureSpecials/HeaderOperations.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureSpecials/HeaderOperations.cs index 6dd2ed4f2c..358cf41b1d 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureSpecials/HeaderOperations.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureSpecials/HeaderOperations.cs @@ -125,6 +125,8 @@ internal HeaderOperations(AutoRestAzureSpecialParametersTestClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -171,7 +173,7 @@ internal HeaderOperations(AutoRestAzureSpecialParametersTestClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -198,9 +200,9 @@ internal HeaderOperations(AutoRestAzureSpecialParametersTestClient client) } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -301,6 +303,8 @@ internal HeaderOperations(AutoRestAzureSpecialParametersTestClient client) } _httpRequest.Headers.TryAddWithoutValidation("foo-client-request-id", fooClientRequestId); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -347,7 +351,7 @@ internal HeaderOperations(AutoRestAzureSpecialParametersTestClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -374,9 +378,9 @@ internal HeaderOperations(AutoRestAzureSpecialParametersTestClient client) } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureSpecials/IAutoRestAzureSpecialParametersTestClient.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureSpecials/IAutoRestAzureSpecialParametersTestClient.cs index 55e799de97..fb4ae899bd 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureSpecials/IAutoRestAzureSpecialParametersTestClient.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureSpecials/IAutoRestAzureSpecialParametersTestClient.cs @@ -27,12 +27,12 @@ public partial interface IAutoRestAzureSpecialParametersTestClient : System.IDis /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// /// Credentials needed for the client to connect to Azure. diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureSpecials/OdataOperations.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureSpecials/OdataOperations.cs index e726683cf1..e9c5f35297 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureSpecials/OdataOperations.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureSpecials/OdataOperations.cs @@ -116,6 +116,8 @@ internal OdataOperations(AutoRestAzureSpecialParametersTestClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -162,7 +164,7 @@ internal OdataOperations(AutoRestAzureSpecialParametersTestClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureSpecials/SkipUrlEncodingOperations.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureSpecials/SkipUrlEncodingOperations.cs index 60e219aca0..39be6cc5e9 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureSpecials/SkipUrlEncodingOperations.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureSpecials/SkipUrlEncodingOperations.cs @@ -117,6 +117,8 @@ internal SkipUrlEncodingOperations(AutoRestAzureSpecialParametersTestClient clie } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -163,7 +165,7 @@ internal SkipUrlEncodingOperations(AutoRestAzureSpecialParametersTestClient clie ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -263,6 +265,8 @@ internal SkipUrlEncodingOperations(AutoRestAzureSpecialParametersTestClient clie } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -309,7 +313,7 @@ internal SkipUrlEncodingOperations(AutoRestAzureSpecialParametersTestClient clie ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -397,6 +401,8 @@ internal SkipUrlEncodingOperations(AutoRestAzureSpecialParametersTestClient clie } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -443,7 +449,7 @@ internal SkipUrlEncodingOperations(AutoRestAzureSpecialParametersTestClient clie ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -547,6 +553,8 @@ internal SkipUrlEncodingOperations(AutoRestAzureSpecialParametersTestClient clie } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -593,7 +601,7 @@ internal SkipUrlEncodingOperations(AutoRestAzureSpecialParametersTestClient clie ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -686,6 +694,8 @@ internal SkipUrlEncodingOperations(AutoRestAzureSpecialParametersTestClient clie } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -732,7 +742,7 @@ internal SkipUrlEncodingOperations(AutoRestAzureSpecialParametersTestClient clie ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -836,6 +846,8 @@ internal SkipUrlEncodingOperations(AutoRestAzureSpecialParametersTestClient clie } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -882,7 +894,7 @@ internal SkipUrlEncodingOperations(AutoRestAzureSpecialParametersTestClient clie ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -974,6 +986,8 @@ internal SkipUrlEncodingOperations(AutoRestAzureSpecialParametersTestClient clie } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1020,7 +1034,7 @@ internal SkipUrlEncodingOperations(AutoRestAzureSpecialParametersTestClient clie ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureSpecials/SubscriptionInCredentialsOperations.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureSpecials/SubscriptionInCredentialsOperations.cs index a0d5963988..8eb5b0b627 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureSpecials/SubscriptionInCredentialsOperations.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureSpecials/SubscriptionInCredentialsOperations.cs @@ -114,6 +114,8 @@ internal SubscriptionInCredentialsOperations(AutoRestAzureSpecialParametersTestC } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -160,7 +162,7 @@ internal SubscriptionInCredentialsOperations(AutoRestAzureSpecialParametersTestC ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -258,6 +260,8 @@ internal SubscriptionInCredentialsOperations(AutoRestAzureSpecialParametersTestC } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -304,7 +308,7 @@ internal SubscriptionInCredentialsOperations(AutoRestAzureSpecialParametersTestC ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -409,6 +413,8 @@ internal SubscriptionInCredentialsOperations(AutoRestAzureSpecialParametersTestC } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -455,7 +461,7 @@ internal SubscriptionInCredentialsOperations(AutoRestAzureSpecialParametersTestC ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -552,6 +558,8 @@ internal SubscriptionInCredentialsOperations(AutoRestAzureSpecialParametersTestC } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -598,7 +606,7 @@ internal SubscriptionInCredentialsOperations(AutoRestAzureSpecialParametersTestC ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -695,6 +703,8 @@ internal SubscriptionInCredentialsOperations(AutoRestAzureSpecialParametersTestC } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -741,7 +751,7 @@ internal SubscriptionInCredentialsOperations(AutoRestAzureSpecialParametersTestC ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureSpecials/SubscriptionInMethodOperations.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureSpecials/SubscriptionInMethodOperations.cs index c1b169f5a4..5887e0342d 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureSpecials/SubscriptionInMethodOperations.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureSpecials/SubscriptionInMethodOperations.cs @@ -118,6 +118,8 @@ internal SubscriptionInMethodOperations(AutoRestAzureSpecialParametersTestClient } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -164,7 +166,7 @@ internal SubscriptionInMethodOperations(AutoRestAzureSpecialParametersTestClient ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -267,6 +269,8 @@ internal SubscriptionInMethodOperations(AutoRestAzureSpecialParametersTestClient } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -313,7 +317,7 @@ internal SubscriptionInMethodOperations(AutoRestAzureSpecialParametersTestClient ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -414,6 +418,8 @@ internal SubscriptionInMethodOperations(AutoRestAzureSpecialParametersTestClient } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -460,7 +466,7 @@ internal SubscriptionInMethodOperations(AutoRestAzureSpecialParametersTestClient ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -562,6 +568,8 @@ internal SubscriptionInMethodOperations(AutoRestAzureSpecialParametersTestClient } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -608,7 +616,7 @@ internal SubscriptionInMethodOperations(AutoRestAzureSpecialParametersTestClient ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureSpecials/XMsClientRequestIdOperations.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureSpecials/XMsClientRequestIdOperations.cs index 0bdf95df26..85bec7fed7 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureSpecials/XMsClientRequestIdOperations.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/AzureSpecials/XMsClientRequestIdOperations.cs @@ -103,6 +103,8 @@ internal XMsClientRequestIdOperations(AutoRestAzureSpecialParametersTestClient c } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -255,6 +257,8 @@ internal XMsClientRequestIdOperations(AutoRestAzureSpecialParametersTestClient c } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -301,7 +305,7 @@ internal XMsClientRequestIdOperations(AutoRestAzureSpecialParametersTestClient c ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/CustomBaseUri/AutoRestParameterizedHostTestClient.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/CustomBaseUri/AutoRestParameterizedHostTestClient.cs index a68390380f..a6b77691a7 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/CustomBaseUri/AutoRestParameterizedHostTestClient.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/CustomBaseUri/AutoRestParameterizedHostTestClient.cs @@ -33,12 +33,12 @@ public partial class AutoRestParameterizedHostTestClient : ServiceClient /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// Credentials needed for the client to connect to Azure. @@ -165,27 +165,27 @@ private void Initialize() AcceptLanguage = "en-US"; LongRunningOperationRetryTimeout = 30; GenerateClientRequestId = true; - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/CustomBaseUri/IAutoRestParameterizedHostTestClient.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/CustomBaseUri/IAutoRestParameterizedHostTestClient.cs index 615c995f47..8044140ac3 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/CustomBaseUri/IAutoRestParameterizedHostTestClient.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/CustomBaseUri/IAutoRestParameterizedHostTestClient.cs @@ -26,12 +26,12 @@ public partial interface IAutoRestParameterizedHostTestClient : System.IDisposab /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// /// Credentials needed for the client to connect to Azure. diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/CustomBaseUri/PathsOperations.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/CustomBaseUri/PathsOperations.cs index 53e018147b..7b1f9caf61 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/CustomBaseUri/PathsOperations.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/CustomBaseUri/PathsOperations.cs @@ -122,6 +122,8 @@ internal PathsOperations(AutoRestParameterizedHostTestClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -168,7 +170,7 @@ internal PathsOperations(AutoRestParameterizedHostTestClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/Head/AutoRestHeadTestServiceClient.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/Head/AutoRestHeadTestServiceClient.cs index 88aa8454b9..62ce618b58 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/Head/AutoRestHeadTestServiceClient.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/Head/AutoRestHeadTestServiceClient.cs @@ -32,12 +32,12 @@ public partial class AutoRestHeadTestServiceClient : ServiceClient /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// Credentials needed for the client to connect to Azure. @@ -272,27 +272,27 @@ private void Initialize() AcceptLanguage = "en-US"; LongRunningOperationRetryTimeout = 30; GenerateClientRequestId = true; - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/Head/HttpSuccessOperations.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/Head/HttpSuccessOperations.cs index aa68301298..4fff703d5b 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/Head/HttpSuccessOperations.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/Head/HttpSuccessOperations.cs @@ -101,6 +101,8 @@ internal HttpSuccessOperations(AutoRestHeadTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -148,7 +150,7 @@ internal HttpSuccessOperations(AutoRestHeadTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -238,6 +240,8 @@ internal HttpSuccessOperations(AutoRestHeadTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -285,7 +289,7 @@ internal HttpSuccessOperations(AutoRestHeadTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -375,6 +379,8 @@ internal HttpSuccessOperations(AutoRestHeadTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -422,7 +428,7 @@ internal HttpSuccessOperations(AutoRestHeadTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/Head/IAutoRestHeadTestServiceClient.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/Head/IAutoRestHeadTestServiceClient.cs index cce2390d69..1d4629b16d 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/Head/IAutoRestHeadTestServiceClient.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/Head/IAutoRestHeadTestServiceClient.cs @@ -26,12 +26,12 @@ public partial interface IAutoRestHeadTestServiceClient : System.IDisposable /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// /// Credentials needed for the client to connect to Azure. diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/HeadExceptions/AutoRestHeadExceptionTestServiceClient.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/HeadExceptions/AutoRestHeadExceptionTestServiceClient.cs index 86f4d235d9..882d29df28 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/HeadExceptions/AutoRestHeadExceptionTestServiceClient.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/HeadExceptions/AutoRestHeadExceptionTestServiceClient.cs @@ -32,12 +32,12 @@ public partial class AutoRestHeadExceptionTestServiceClient : ServiceClient /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// Credentials needed for the client to connect to Azure. @@ -272,27 +272,27 @@ private void Initialize() AcceptLanguage = "en-US"; LongRunningOperationRetryTimeout = 30; GenerateClientRequestId = true; - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/HeadExceptions/HeadExceptionOperations.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/HeadExceptions/HeadExceptionOperations.cs index 0f5d2b084b..3a7abb624b 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/HeadExceptions/HeadExceptionOperations.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/HeadExceptions/HeadExceptionOperations.cs @@ -100,6 +100,8 @@ internal HeadExceptionOperations(AutoRestHeadExceptionTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -228,6 +230,8 @@ internal HeadExceptionOperations(AutoRestHeadExceptionTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -356,6 +360,8 @@ internal HeadExceptionOperations(AutoRestHeadExceptionTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/HeadExceptions/IAutoRestHeadExceptionTestServiceClient.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/HeadExceptions/IAutoRestHeadExceptionTestServiceClient.cs index e3fa454516..29c0fbbdb4 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/HeadExceptions/IAutoRestHeadExceptionTestServiceClient.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/HeadExceptions/IAutoRestHeadExceptionTestServiceClient.cs @@ -26,12 +26,12 @@ public partial interface IAutoRestHeadExceptionTestServiceClient : System.IDispo /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// /// Credentials needed for the client to connect to Azure. diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/Lro/AutoRestLongRunningOperationTestServiceClient.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/Lro/AutoRestLongRunningOperationTestServiceClient.cs index b7dc9008c3..8f2b95e62f 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/Lro/AutoRestLongRunningOperationTestServiceClient.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/Lro/AutoRestLongRunningOperationTestServiceClient.cs @@ -33,12 +33,12 @@ public partial class AutoRestLongRunningOperationTestServiceClient : ServiceClie /// /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// Credentials needed for the client to connect to Azure. @@ -291,28 +291,28 @@ private void Initialize() AcceptLanguage = "en-US"; LongRunningOperationRetryTimeout = 30; GenerateClientRequestId = true; - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; SerializationSettings.Converters.Add(new TransformationJsonConverter()); - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/Lro/IAutoRestLongRunningOperationTestServiceClient.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/Lro/IAutoRestLongRunningOperationTestServiceClient.cs index 7e48d818f2..2ead9938bf 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/Lro/IAutoRestLongRunningOperationTestServiceClient.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/Lro/IAutoRestLongRunningOperationTestServiceClient.cs @@ -27,12 +27,12 @@ public partial interface IAutoRestLongRunningOperationTestServiceClient : System /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// /// Credentials needed for the client to connect to Azure. diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/Lro/LRORetrysOperations.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/Lro/LRORetrysOperations.cs index 195f49a416..66c237395a 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/Lro/LRORetrysOperations.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/Lro/LRORetrysOperations.cs @@ -254,6 +254,8 @@ internal LRORetrysOperations(AutoRestLongRunningOperationTestServiceClient clien } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -307,7 +309,7 @@ internal LRORetrysOperations(AutoRestLongRunningOperationTestServiceClient clien ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -344,7 +346,7 @@ internal LRORetrysOperations(AutoRestLongRunningOperationTestServiceClient clien { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -362,7 +364,7 @@ internal LRORetrysOperations(AutoRestLongRunningOperationTestServiceClient clien { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -442,6 +444,8 @@ internal LRORetrysOperations(AutoRestLongRunningOperationTestServiceClient clien } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -495,7 +499,7 @@ internal LRORetrysOperations(AutoRestLongRunningOperationTestServiceClient clien ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -532,7 +536,7 @@ internal LRORetrysOperations(AutoRestLongRunningOperationTestServiceClient clien { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -544,9 +548,9 @@ internal LRORetrysOperations(AutoRestLongRunningOperationTestServiceClient clien } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -621,6 +625,8 @@ internal LRORetrysOperations(AutoRestLongRunningOperationTestServiceClient clien } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -668,7 +674,7 @@ internal LRORetrysOperations(AutoRestLongRunningOperationTestServiceClient clien ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -705,7 +711,7 @@ internal LRORetrysOperations(AutoRestLongRunningOperationTestServiceClient clien { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -723,7 +729,7 @@ internal LRORetrysOperations(AutoRestLongRunningOperationTestServiceClient clien { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -735,9 +741,9 @@ internal LRORetrysOperations(AutoRestLongRunningOperationTestServiceClient clien } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -808,6 +814,8 @@ internal LRORetrysOperations(AutoRestLongRunningOperationTestServiceClient clien } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -855,7 +863,7 @@ internal LRORetrysOperations(AutoRestLongRunningOperationTestServiceClient clien ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -886,9 +894,9 @@ internal LRORetrysOperations(AutoRestLongRunningOperationTestServiceClient clien } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -959,6 +967,8 @@ internal LRORetrysOperations(AutoRestLongRunningOperationTestServiceClient clien } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1006,7 +1016,7 @@ internal LRORetrysOperations(AutoRestLongRunningOperationTestServiceClient clien ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1037,9 +1047,9 @@ internal LRORetrysOperations(AutoRestLongRunningOperationTestServiceClient clien } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1114,6 +1124,8 @@ internal LRORetrysOperations(AutoRestLongRunningOperationTestServiceClient clien } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1167,7 +1179,7 @@ internal LRORetrysOperations(AutoRestLongRunningOperationTestServiceClient clien ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1198,9 +1210,9 @@ internal LRORetrysOperations(AutoRestLongRunningOperationTestServiceClient clien } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1276,6 +1288,8 @@ internal LRORetrysOperations(AutoRestLongRunningOperationTestServiceClient clien } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1329,7 +1343,7 @@ internal LRORetrysOperations(AutoRestLongRunningOperationTestServiceClient clien ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1360,9 +1374,9 @@ internal LRORetrysOperations(AutoRestLongRunningOperationTestServiceClient clien } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/Lro/LROSADsOperations.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/Lro/LROSADsOperations.cs index 2460981374..bfc16616dd 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/Lro/LROSADsOperations.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/Lro/LROSADsOperations.cs @@ -612,6 +612,8 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -665,7 +667,7 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -702,7 +704,7 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -720,7 +722,7 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -798,6 +800,8 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -851,7 +855,7 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -888,7 +892,7 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -906,7 +910,7 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -984,6 +988,8 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1037,7 +1043,7 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1074,7 +1080,7 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1092,7 +1098,7 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1171,6 +1177,8 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1224,7 +1232,7 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1261,7 +1269,7 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1273,9 +1281,9 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1344,6 +1352,8 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1391,7 +1401,7 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1422,9 +1432,9 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1493,6 +1503,8 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1540,7 +1552,7 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1571,9 +1583,9 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1644,6 +1656,8 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1691,7 +1705,7 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1722,9 +1736,9 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1797,6 +1811,8 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1850,7 +1866,7 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1881,9 +1897,9 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1956,6 +1972,8 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2009,7 +2027,7 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2040,9 +2058,9 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2117,6 +2135,8 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2170,7 +2190,7 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2201,9 +2221,9 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2280,6 +2300,8 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2333,7 +2355,7 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2370,7 +2392,7 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2388,7 +2410,7 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2467,6 +2489,8 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2520,7 +2544,7 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2557,7 +2581,7 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2569,9 +2593,9 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2649,6 +2673,8 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2702,7 +2728,7 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2739,7 +2765,7 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2751,9 +2777,9 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2823,6 +2849,8 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2870,7 +2898,7 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2961,6 +2989,8 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3008,7 +3038,7 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3039,9 +3069,9 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -3115,6 +3145,8 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3168,7 +3200,7 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3199,9 +3231,9 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -3276,6 +3308,8 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3329,7 +3363,7 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3360,9 +3394,9 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -3439,6 +3473,8 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3492,7 +3528,7 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3529,7 +3565,7 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -3608,6 +3644,8 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3661,7 +3699,7 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3698,7 +3736,7 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -3710,9 +3748,9 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -3790,6 +3828,8 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3843,7 +3883,7 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3880,7 +3920,7 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -3892,9 +3932,9 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -3964,6 +4004,8 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -4011,7 +4053,7 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -4042,9 +4084,9 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -4114,6 +4156,8 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -4161,7 +4205,7 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -4192,9 +4236,9 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -4265,6 +4309,8 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -4312,7 +4358,7 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -4343,9 +4389,9 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -4419,6 +4465,8 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -4472,7 +4520,7 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -4503,9 +4551,9 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -4580,6 +4628,8 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -4633,7 +4683,7 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -4664,9 +4714,9 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -4741,6 +4791,8 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -4794,7 +4846,7 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -4825,9 +4877,9 @@ internal LROSADsOperations(AutoRestLongRunningOperationTestServiceClient client) } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/Lro/LROsCustomHeaderOperations.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/Lro/LROsCustomHeaderOperations.cs index dba3c9c17e..a1ec0edbe8 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/Lro/LROsCustomHeaderOperations.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/Lro/LROsCustomHeaderOperations.cs @@ -204,6 +204,8 @@ internal LROsCustomHeaderOperations(AutoRestLongRunningOperationTestServiceClien } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -257,7 +259,7 @@ internal LROsCustomHeaderOperations(AutoRestLongRunningOperationTestServiceClien ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -294,7 +296,7 @@ internal LROsCustomHeaderOperations(AutoRestLongRunningOperationTestServiceClien { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -306,9 +308,9 @@ internal LROsCustomHeaderOperations(AutoRestLongRunningOperationTestServiceClien } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -388,6 +390,8 @@ internal LROsCustomHeaderOperations(AutoRestLongRunningOperationTestServiceClien } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -441,7 +445,7 @@ internal LROsCustomHeaderOperations(AutoRestLongRunningOperationTestServiceClien ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -478,7 +482,7 @@ internal LROsCustomHeaderOperations(AutoRestLongRunningOperationTestServiceClien { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -496,7 +500,7 @@ internal LROsCustomHeaderOperations(AutoRestLongRunningOperationTestServiceClien { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -573,6 +577,8 @@ internal LROsCustomHeaderOperations(AutoRestLongRunningOperationTestServiceClien } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -626,7 +632,7 @@ internal LROsCustomHeaderOperations(AutoRestLongRunningOperationTestServiceClien ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -657,9 +663,9 @@ internal LROsCustomHeaderOperations(AutoRestLongRunningOperationTestServiceClien } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -736,6 +742,8 @@ internal LROsCustomHeaderOperations(AutoRestLongRunningOperationTestServiceClien } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -789,7 +797,7 @@ internal LROsCustomHeaderOperations(AutoRestLongRunningOperationTestServiceClien ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -820,9 +828,9 @@ internal LROsCustomHeaderOperations(AutoRestLongRunningOperationTestServiceClien } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/Lro/LROsOperations.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/Lro/LROsOperations.cs index ef15030223..83dd9ac7fe 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/Lro/LROsOperations.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/Lro/LROsOperations.cs @@ -819,6 +819,8 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -872,7 +874,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -909,7 +911,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -987,6 +989,8 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1040,7 +1044,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1077,7 +1081,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1156,6 +1160,8 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1209,7 +1215,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1246,7 +1252,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1326,6 +1332,8 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1379,7 +1387,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1416,7 +1424,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1434,7 +1442,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1514,6 +1522,8 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1567,7 +1577,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1604,7 +1614,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1684,6 +1694,8 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1737,7 +1749,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1774,7 +1786,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1792,7 +1804,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1872,6 +1884,8 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1925,7 +1939,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1962,7 +1976,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2041,6 +2055,8 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2094,7 +2110,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2131,7 +2147,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2143,9 +2159,9 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2223,6 +2239,8 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2276,7 +2294,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2313,7 +2331,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2325,9 +2343,9 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2405,6 +2423,8 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2458,7 +2478,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2495,7 +2515,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2507,9 +2527,9 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2587,6 +2607,8 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2640,7 +2662,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2677,7 +2699,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2689,9 +2711,9 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2769,6 +2791,8 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2822,7 +2846,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2859,7 +2883,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2871,9 +2895,9 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2951,6 +2975,8 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3004,7 +3030,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3041,7 +3067,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -3053,9 +3079,9 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -3131,6 +3157,8 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3184,7 +3212,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3221,7 +3249,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -3298,6 +3326,8 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3351,7 +3381,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3388,7 +3418,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -3470,6 +3500,8 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3523,7 +3555,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3560,7 +3592,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -3642,6 +3674,8 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3695,7 +3729,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3732,7 +3766,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -3808,6 +3842,8 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3855,7 +3891,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3892,7 +3928,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -3910,7 +3946,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -3922,9 +3958,9 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -3999,6 +4035,8 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -4046,7 +4084,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -4083,7 +4121,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -4101,7 +4139,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -4113,9 +4151,9 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -4190,6 +4228,8 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -4237,7 +4277,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -4274,7 +4314,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -4292,7 +4332,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -4304,9 +4344,9 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -4375,6 +4415,8 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -4422,7 +4464,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -4516,6 +4558,8 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -4563,7 +4607,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -4600,7 +4644,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -4612,9 +4656,9 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -4688,6 +4732,8 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -4735,7 +4781,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -4772,7 +4818,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -4784,9 +4830,9 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -4857,6 +4903,8 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -4904,7 +4952,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -4935,9 +4983,9 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -5008,6 +5056,8 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -5055,7 +5105,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -5086,9 +5136,9 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -5159,6 +5209,8 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -5206,7 +5258,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -5237,9 +5289,9 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -5310,6 +5362,8 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -5357,7 +5411,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -5388,9 +5442,9 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -5461,6 +5515,8 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -5508,7 +5564,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -5539,9 +5595,9 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -5612,6 +5668,8 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -5659,7 +5717,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -5690,9 +5748,9 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -5766,6 +5824,8 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -5813,7 +5873,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -5850,7 +5910,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -5868,7 +5928,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -5944,6 +6004,8 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -5997,7 +6059,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -6028,9 +6090,9 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -6107,6 +6169,8 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -6160,7 +6224,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -6197,7 +6261,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -6209,9 +6273,9 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -6289,6 +6353,8 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -6342,7 +6408,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -6379,7 +6445,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -6391,9 +6457,9 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -6471,6 +6537,8 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -6524,7 +6592,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -6561,7 +6629,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -6573,9 +6641,9 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -6650,6 +6718,8 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -6703,7 +6773,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -6734,9 +6804,9 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -6811,6 +6881,8 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -6864,7 +6936,7 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -6895,9 +6967,9 @@ internal LROsOperations(AutoRestLongRunningOperationTestServiceClient client) } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/Paging/AutoRestPagingTestServiceClient.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/Paging/AutoRestPagingTestServiceClient.cs index b4084fb2ef..d086cc8dd9 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/Paging/AutoRestPagingTestServiceClient.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/Paging/AutoRestPagingTestServiceClient.cs @@ -33,12 +33,12 @@ public partial class AutoRestPagingTestServiceClient : ServiceClient /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// Credentials needed for the client to connect to Azure. @@ -273,27 +273,27 @@ private void Initialize() AcceptLanguage = "en-US"; LongRunningOperationRetryTimeout = 30; GenerateClientRequestId = true; - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/Paging/IAutoRestPagingTestServiceClient.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/Paging/IAutoRestPagingTestServiceClient.cs index fb22e58f7d..edeba03623 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/Paging/IAutoRestPagingTestServiceClient.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/Paging/IAutoRestPagingTestServiceClient.cs @@ -27,12 +27,12 @@ public partial interface IAutoRestPagingTestServiceClient : System.IDisposable /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// /// Credentials needed for the client to connect to Azure. diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/Paging/PagingOperations.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/Paging/PagingOperations.cs index 7a8bc2fc15..4c799868c8 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/Paging/PagingOperations.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/Paging/PagingOperations.cs @@ -105,6 +105,8 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -152,7 +154,7 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -189,7 +191,7 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -304,6 +306,8 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("timeout", Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(timeout, Client.SerializationSettings).Trim('"')); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -351,7 +355,7 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -388,7 +392,7 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -504,6 +508,8 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("timeout", Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(timeout, Client.SerializationSettings).Trim('"')); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -551,7 +557,7 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -588,7 +594,7 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -724,6 +730,8 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("timeout", Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(timeout, Client.SerializationSettings).Trim('"')); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -771,7 +779,7 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -808,7 +816,7 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -882,6 +890,8 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -929,7 +939,7 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -966,7 +976,7 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1041,6 +1051,8 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1088,7 +1100,7 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1125,7 +1137,7 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1198,6 +1210,8 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1245,7 +1259,7 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1282,7 +1296,7 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1355,6 +1369,8 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1402,7 +1418,7 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1439,7 +1455,7 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1512,6 +1528,8 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1559,7 +1577,7 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1596,7 +1614,7 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1696,6 +1714,8 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1743,7 +1763,7 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1780,7 +1800,7 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1888,6 +1908,8 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1935,7 +1957,7 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1972,7 +1994,7 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2081,6 +2103,8 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2128,7 +2152,7 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2165,7 +2189,7 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2281,6 +2305,8 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2328,7 +2354,7 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2365,7 +2391,7 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2452,6 +2478,8 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2499,7 +2527,7 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2536,7 +2564,7 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2665,6 +2693,8 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("timeout", Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(timeout, Client.SerializationSettings).Trim('"')); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2712,7 +2742,7 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2749,7 +2779,7 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2879,6 +2909,8 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("timeout", Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(timeout, Client.SerializationSettings).Trim('"')); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2926,7 +2958,7 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2963,7 +2995,7 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -3092,6 +3124,8 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("timeout", Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(timeout, Client.SerializationSettings).Trim('"')); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3139,7 +3173,7 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3176,7 +3210,7 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -3264,6 +3298,8 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3311,7 +3347,7 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3348,7 +3384,7 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -3437,6 +3473,8 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3484,7 +3522,7 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3521,7 +3559,7 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -3608,6 +3646,8 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3655,7 +3695,7 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3692,7 +3732,7 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -3779,6 +3819,8 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3826,7 +3868,7 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3863,7 +3905,7 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -3950,6 +3992,8 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3997,7 +4041,7 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -4034,7 +4078,7 @@ internal PagingOperations(AutoRestPagingTestServiceClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/SubscriptionIdApiVersion/GroupOperations.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/SubscriptionIdApiVersion/GroupOperations.cs index 04f5d856e4..f4a8e122d5 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/SubscriptionIdApiVersion/GroupOperations.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/SubscriptionIdApiVersion/GroupOperations.cs @@ -133,6 +133,8 @@ internal GroupOperations(MicrosoftAzureTestUrlClient client) } _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -179,7 +181,7 @@ internal GroupOperations(MicrosoftAzureTestUrlClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -212,7 +214,7 @@ internal GroupOperations(MicrosoftAzureTestUrlClient client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/SubscriptionIdApiVersion/IMicrosoftAzureTestUrlClient.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/SubscriptionIdApiVersion/IMicrosoftAzureTestUrlClient.cs index b72574cf50..2e6583d81c 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/SubscriptionIdApiVersion/IMicrosoftAzureTestUrlClient.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/SubscriptionIdApiVersion/IMicrosoftAzureTestUrlClient.cs @@ -27,12 +27,12 @@ public partial interface IMicrosoftAzureTestUrlClient : System.IDisposable /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// /// Credentials needed for the client to connect to Azure. diff --git a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/SubscriptionIdApiVersion/MicrosoftAzureTestUrlClient.cs b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/SubscriptionIdApiVersion/MicrosoftAzureTestUrlClient.cs index 888bc77c9a..c601959185 100644 --- a/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/SubscriptionIdApiVersion/MicrosoftAzureTestUrlClient.cs +++ b/src/generator/AutoRest.CSharp.Azure.Tests/Expected/AcceptanceTests/SubscriptionIdApiVersion/MicrosoftAzureTestUrlClient.cs @@ -33,12 +33,12 @@ public partial class MicrosoftAzureTestUrlClient : ServiceClient /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// Credentials needed for the client to connect to Azure. @@ -284,27 +284,27 @@ private void Initialize() AcceptLanguage = "en-US"; LongRunningOperationRetryTimeout = 30; GenerateClientRequestId = true; - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } diff --git a/src/generator/AutoRest.CSharp.Azure/CodeGeneratorCsa.cs b/src/generator/AutoRest.CSharp.Azure/CodeGeneratorCsa.cs index 73ad98aab2..0ac1ff2e63 100644 --- a/src/generator/AutoRest.CSharp.Azure/CodeGeneratorCsa.cs +++ b/src/generator/AutoRest.CSharp.Azure/CodeGeneratorCsa.cs @@ -111,6 +111,13 @@ await Write(pageTemplate, Path.Combine(Settings.Instance.ModelsName, await Write(exceptionTemplate, Path.Combine(Settings.Instance.ModelsName, $"{exceptionTemplate.Model.ExceptionTypeDefinitionName}{ImplementationFileExtension}")); } + + // Xml Serialization + if (codeModel.ShouldGenerateXmlSerialization) + { + var xmlSerializationTemplate = new XmlSerializationTemplate { Model = null }; + await Write(xmlSerializationTemplate, Path.Combine(Settings.Instance.ModelsName, $"{XmlSerialization.XmlDeserializationClass}{ImplementationFileExtension}")); + } } } } \ No newline at end of file diff --git a/src/generator/AutoRest.CSharp.Azure/TransformerCsa.cs b/src/generator/AutoRest.CSharp.Azure/TransformerCsa.cs index cdd53eeb75..7cde0c8dce 100644 --- a/src/generator/AutoRest.CSharp.Azure/TransformerCsa.cs +++ b/src/generator/AutoRest.CSharp.Azure/TransformerCsa.cs @@ -155,9 +155,9 @@ var method in if (sequenceType != null) { var pagableTypeName = string.Format(CultureInfo.InvariantCulture, pageTypeFormat, pageClassName, - sequenceType.ElementType.AsNullableType(!sequenceType.ElementType.IsValueType() || (sequenceType.IsXNullable ?? true))); + sequenceType.ElementType.AsNullableType(!sequenceType.ElementType.IsValueType() || sequenceType.IsNullable)); var ipagableTypeName = string.Format(CultureInfo.InvariantCulture, ipageTypeFormat, - sequenceType.ElementType.AsNullableType(!sequenceType.ElementType.IsValueType() || (sequenceType.IsXNullable ?? true))); + sequenceType.ElementType.AsNullableType(!sequenceType.ElementType.IsValueType() || sequenceType.IsNullable)); var pagedResult = New(pagableTypeName) as CompositeType; diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyArray/Array.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyArray/Array.cs index 2e636980bb..6947d585d7 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyArray/Array.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyArray/Array.cs @@ -87,6 +87,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -127,7 +129,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -156,7 +158,7 @@ public Array(AutoRestSwaggerBATArrayService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -212,6 +214,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -252,7 +256,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -281,7 +285,7 @@ public Array(AutoRestSwaggerBATArrayService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -337,6 +341,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -377,7 +383,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -406,7 +412,7 @@ public Array(AutoRestSwaggerBATArrayService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -472,6 +478,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -518,7 +526,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -585,6 +593,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -625,7 +635,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -654,7 +664,7 @@ public Array(AutoRestSwaggerBATArrayService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -720,6 +730,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -766,7 +778,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -833,6 +845,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -873,7 +887,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -902,7 +916,7 @@ public Array(AutoRestSwaggerBATArrayService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -958,6 +972,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -998,7 +1014,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1027,7 +1043,7 @@ public Array(AutoRestSwaggerBATArrayService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1083,6 +1099,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1123,7 +1141,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1152,7 +1170,7 @@ public Array(AutoRestSwaggerBATArrayService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1218,6 +1236,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1264,7 +1284,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1331,6 +1351,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1371,7 +1393,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1400,7 +1422,7 @@ public Array(AutoRestSwaggerBATArrayService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1456,6 +1478,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1496,7 +1520,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1525,7 +1549,7 @@ public Array(AutoRestSwaggerBATArrayService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1581,6 +1605,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1621,7 +1647,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1650,7 +1676,7 @@ public Array(AutoRestSwaggerBATArrayService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1716,6 +1742,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1762,7 +1790,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1829,6 +1857,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1869,7 +1899,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1898,7 +1928,7 @@ public Array(AutoRestSwaggerBATArrayService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1954,6 +1984,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1994,7 +2026,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2023,7 +2055,7 @@ public Array(AutoRestSwaggerBATArrayService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2079,6 +2111,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2119,7 +2153,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2148,7 +2182,7 @@ public Array(AutoRestSwaggerBATArrayService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2214,6 +2248,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2260,7 +2296,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2327,6 +2363,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2367,7 +2405,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2396,7 +2434,7 @@ public Array(AutoRestSwaggerBATArrayService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2452,6 +2490,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2492,7 +2532,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2521,7 +2561,7 @@ public Array(AutoRestSwaggerBATArrayService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2577,6 +2617,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2617,7 +2659,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2646,7 +2688,7 @@ public Array(AutoRestSwaggerBATArrayService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2712,6 +2754,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2758,7 +2802,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2825,6 +2869,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2865,7 +2911,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2894,7 +2940,7 @@ public Array(AutoRestSwaggerBATArrayService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2950,6 +2996,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2990,7 +3038,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3019,7 +3067,7 @@ public Array(AutoRestSwaggerBATArrayService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -3075,6 +3123,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3115,7 +3165,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3144,7 +3194,7 @@ public Array(AutoRestSwaggerBATArrayService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -3210,6 +3260,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3256,7 +3308,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3323,6 +3375,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3363,7 +3417,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3392,7 +3446,7 @@ public Array(AutoRestSwaggerBATArrayService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -3448,6 +3502,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3488,7 +3544,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3517,7 +3573,7 @@ public Array(AutoRestSwaggerBATArrayService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -3575,6 +3631,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3615,7 +3673,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3644,7 +3702,7 @@ public Array(AutoRestSwaggerBATArrayService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -3712,6 +3770,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3758,7 +3818,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3825,6 +3885,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3865,7 +3927,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3894,7 +3956,7 @@ public Array(AutoRestSwaggerBATArrayService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -3950,6 +4012,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3990,7 +4054,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -4019,7 +4083,7 @@ public Array(AutoRestSwaggerBATArrayService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, new DateJsonConverter()); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -4085,6 +4149,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -4131,7 +4197,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -4198,6 +4264,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -4238,7 +4306,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -4267,7 +4335,7 @@ public Array(AutoRestSwaggerBATArrayService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, new DateJsonConverter()); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -4323,6 +4391,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -4363,7 +4433,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -4392,7 +4462,7 @@ public Array(AutoRestSwaggerBATArrayService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, new DateJsonConverter()); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -4449,6 +4519,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -4489,7 +4561,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -4518,7 +4590,7 @@ public Array(AutoRestSwaggerBATArrayService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -4585,6 +4657,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -4631,7 +4705,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -4698,6 +4772,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -4738,7 +4814,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -4767,7 +4843,7 @@ public Array(AutoRestSwaggerBATArrayService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -4823,6 +4899,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -4863,7 +4941,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -4892,7 +4970,7 @@ public Array(AutoRestSwaggerBATArrayService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -4949,6 +5027,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -4989,7 +5069,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -5018,7 +5098,7 @@ public Array(AutoRestSwaggerBATArrayService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -5085,6 +5165,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -5131,7 +5213,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -5198,6 +5280,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -5238,7 +5322,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -5267,7 +5351,7 @@ public Array(AutoRestSwaggerBATArrayService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -5333,6 +5417,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -5379,7 +5465,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -5447,6 +5533,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -5487,7 +5575,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -5516,7 +5604,7 @@ public Array(AutoRestSwaggerBATArrayService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -5583,6 +5671,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -5629,7 +5719,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -5697,6 +5787,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -5737,7 +5829,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -5766,7 +5858,7 @@ public Array(AutoRestSwaggerBATArrayService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -5823,6 +5915,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -5863,7 +5957,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -5892,7 +5986,7 @@ public Array(AutoRestSwaggerBATArrayService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, new Base64UrlJsonConverter()); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -5948,6 +6042,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -5988,7 +6084,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -6017,7 +6113,7 @@ public Array(AutoRestSwaggerBATArrayService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -6073,6 +6169,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -6113,7 +6211,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -6142,7 +6240,7 @@ public Array(AutoRestSwaggerBATArrayService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -6199,6 +6297,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -6239,7 +6339,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -6268,7 +6368,7 @@ public Array(AutoRestSwaggerBATArrayService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -6325,6 +6425,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -6365,7 +6467,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -6394,7 +6496,7 @@ public Array(AutoRestSwaggerBATArrayService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -6451,6 +6553,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -6491,7 +6595,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -6520,7 +6624,7 @@ public Array(AutoRestSwaggerBATArrayService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -6587,6 +6691,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -6633,7 +6739,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -6700,6 +6806,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -6740,7 +6848,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -6769,7 +6877,7 @@ public Array(AutoRestSwaggerBATArrayService client) { _result.Body = SafeJsonConvert.DeserializeObject>>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -6825,6 +6933,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -6865,7 +6975,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -6894,7 +7004,7 @@ public Array(AutoRestSwaggerBATArrayService client) { _result.Body = SafeJsonConvert.DeserializeObject>>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -6950,6 +7060,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -6990,7 +7102,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -7019,7 +7131,7 @@ public Array(AutoRestSwaggerBATArrayService client) { _result.Body = SafeJsonConvert.DeserializeObject>>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -7075,6 +7187,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -7115,7 +7229,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -7144,7 +7258,7 @@ public Array(AutoRestSwaggerBATArrayService client) { _result.Body = SafeJsonConvert.DeserializeObject>>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -7201,6 +7315,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -7241,7 +7357,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -7270,7 +7386,7 @@ public Array(AutoRestSwaggerBATArrayService client) { _result.Body = SafeJsonConvert.DeserializeObject>>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -7337,6 +7453,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -7383,7 +7501,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -7450,6 +7568,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -7490,7 +7610,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -7519,7 +7639,7 @@ public Array(AutoRestSwaggerBATArrayService client) { _result.Body = SafeJsonConvert.DeserializeObject>>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -7575,6 +7695,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -7615,7 +7737,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -7644,7 +7766,7 @@ public Array(AutoRestSwaggerBATArrayService client) { _result.Body = SafeJsonConvert.DeserializeObject>>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -7702,6 +7824,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -7742,7 +7866,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -7771,7 +7895,7 @@ public Array(AutoRestSwaggerBATArrayService client) { _result.Body = SafeJsonConvert.DeserializeObject>>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -7829,6 +7953,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -7869,7 +7995,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -7898,7 +8024,7 @@ public Array(AutoRestSwaggerBATArrayService client) { _result.Body = SafeJsonConvert.DeserializeObject>>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -7956,6 +8082,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -7996,7 +8124,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -8025,7 +8153,7 @@ public Array(AutoRestSwaggerBATArrayService client) { _result.Body = SafeJsonConvert.DeserializeObject>>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -8093,6 +8221,8 @@ public Array(AutoRestSwaggerBATArrayService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -8139,7 +8269,7 @@ public Array(AutoRestSwaggerBATArrayService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyArray/AutoRestSwaggerBATArrayService.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyArray/AutoRestSwaggerBATArrayService.cs index 5ef2164984..462e8c33f2 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyArray/AutoRestSwaggerBATArrayService.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyArray/AutoRestSwaggerBATArrayService.cs @@ -30,12 +30,12 @@ public partial class AutoRestSwaggerBATArrayService : ServiceClient /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// Gets the IArray. @@ -123,27 +123,27 @@ private void Initialize() { Array = new Array(this); BaseUri = new System.Uri("http://localhost"); - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyArray/IAutoRestSwaggerBATArrayService.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyArray/IAutoRestSwaggerBATArrayService.cs index d921514aea..1cdf521d02 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyArray/IAutoRestSwaggerBATArrayService.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyArray/IAutoRestSwaggerBATArrayService.cs @@ -24,12 +24,12 @@ public partial interface IAutoRestSwaggerBATArrayService : System.IDisposable /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyBoolean/AutoRestBoolTestService.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyBoolean/AutoRestBoolTestService.cs index 72ffd964f3..4ab774b4d1 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyBoolean/AutoRestBoolTestService.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyBoolean/AutoRestBoolTestService.cs @@ -30,12 +30,12 @@ public partial class AutoRestBoolTestService : ServiceClient /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// Gets the IBoolModel. @@ -123,27 +123,27 @@ private void Initialize() { BoolModel = new BoolModel(this); BaseUri = new System.Uri("http://localhost"); - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyBoolean/BoolModel.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyBoolean/BoolModel.cs index f8101417c1..1dca74400d 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyBoolean/BoolModel.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyBoolean/BoolModel.cs @@ -86,6 +86,8 @@ public BoolModel(AutoRestBoolTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -126,7 +128,7 @@ public BoolModel(AutoRestBoolTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -155,7 +157,7 @@ public BoolModel(AutoRestBoolTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -211,6 +213,8 @@ public BoolModel(AutoRestBoolTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -254,7 +258,7 @@ public BoolModel(AutoRestBoolTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -321,6 +325,8 @@ public BoolModel(AutoRestBoolTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -361,7 +367,7 @@ public BoolModel(AutoRestBoolTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -390,7 +396,7 @@ public BoolModel(AutoRestBoolTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -446,6 +452,8 @@ public BoolModel(AutoRestBoolTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -489,7 +497,7 @@ public BoolModel(AutoRestBoolTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -556,6 +564,8 @@ public BoolModel(AutoRestBoolTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -596,7 +606,7 @@ public BoolModel(AutoRestBoolTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -625,7 +635,7 @@ public BoolModel(AutoRestBoolTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -681,6 +691,8 @@ public BoolModel(AutoRestBoolTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -721,7 +733,7 @@ public BoolModel(AutoRestBoolTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -750,7 +762,7 @@ public BoolModel(AutoRestBoolTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyBoolean/IAutoRestBoolTestService.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyBoolean/IAutoRestBoolTestService.cs index 6978c11c5a..475ab07a75 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyBoolean/IAutoRestBoolTestService.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyBoolean/IAutoRestBoolTestService.cs @@ -24,12 +24,12 @@ public partial interface IAutoRestBoolTestService : System.IDisposable /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyByte/AutoRestSwaggerBATByteService.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyByte/AutoRestSwaggerBATByteService.cs index 1a9d3d9c16..86b14449a9 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyByte/AutoRestSwaggerBATByteService.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyByte/AutoRestSwaggerBATByteService.cs @@ -30,12 +30,12 @@ public partial class AutoRestSwaggerBATByteService : ServiceClient /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// Gets the IByteModel. @@ -123,27 +123,27 @@ private void Initialize() { ByteModel = new ByteModel(this); BaseUri = new System.Uri("http://localhost"); - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyByte/ByteModel.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyByte/ByteModel.cs index 043ca488ba..f1413ca91d 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyByte/ByteModel.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyByte/ByteModel.cs @@ -86,6 +86,8 @@ public ByteModel(AutoRestSwaggerBATByteService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -126,7 +128,7 @@ public ByteModel(AutoRestSwaggerBATByteService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -155,7 +157,7 @@ public ByteModel(AutoRestSwaggerBATByteService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -211,6 +213,8 @@ public ByteModel(AutoRestSwaggerBATByteService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -251,7 +255,7 @@ public ByteModel(AutoRestSwaggerBATByteService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -280,7 +284,7 @@ public ByteModel(AutoRestSwaggerBATByteService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -336,6 +340,8 @@ public ByteModel(AutoRestSwaggerBATByteService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -376,7 +382,7 @@ public ByteModel(AutoRestSwaggerBATByteService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -405,7 +411,7 @@ public ByteModel(AutoRestSwaggerBATByteService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -472,6 +478,8 @@ public ByteModel(AutoRestSwaggerBATByteService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -518,7 +526,7 @@ public ByteModel(AutoRestSwaggerBATByteService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -585,6 +593,8 @@ public ByteModel(AutoRestSwaggerBATByteService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -625,7 +635,7 @@ public ByteModel(AutoRestSwaggerBATByteService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -654,7 +664,7 @@ public ByteModel(AutoRestSwaggerBATByteService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyByte/IAutoRestSwaggerBATByteService.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyByte/IAutoRestSwaggerBATByteService.cs index 98f2c18df1..7119aab20e 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyByte/IAutoRestSwaggerBATByteService.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyByte/IAutoRestSwaggerBATByteService.cs @@ -24,12 +24,12 @@ public partial interface IAutoRestSwaggerBATByteService : System.IDisposable /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Array.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Array.cs index 468400d6bb..1c2af9473c 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Array.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Array.cs @@ -86,6 +86,8 @@ public Array(AutoRestComplexTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -126,7 +128,7 @@ public Array(AutoRestComplexTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -155,7 +157,7 @@ public Array(AutoRestComplexTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -216,6 +218,8 @@ public Array(AutoRestComplexTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -262,7 +266,7 @@ public Array(AutoRestComplexTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -329,6 +333,8 @@ public Array(AutoRestComplexTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -369,7 +375,7 @@ public Array(AutoRestComplexTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -398,7 +404,7 @@ public Array(AutoRestComplexTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -459,6 +465,8 @@ public Array(AutoRestComplexTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -505,7 +513,7 @@ public Array(AutoRestComplexTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -573,6 +581,8 @@ public Array(AutoRestComplexTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -613,7 +623,7 @@ public Array(AutoRestComplexTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -642,7 +652,7 @@ public Array(AutoRestComplexTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/AutoRestComplexTestService.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/AutoRestComplexTestService.cs index 2619ccff9a..50edaafeab 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/AutoRestComplexTestService.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/AutoRestComplexTestService.cs @@ -30,12 +30,12 @@ public partial class AutoRestComplexTestService : ServiceClient /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// API ID. @@ -171,27 +171,27 @@ private void Initialize() Readonlyproperty = new Readonlyproperty(this); BaseUri = new System.Uri("http://localhost"); ApiVersion = "2014-04-01-preview"; - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/BasicOperations.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/BasicOperations.cs index 150d8853f5..f65465be06 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/BasicOperations.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/BasicOperations.cs @@ -86,6 +86,8 @@ public BasicOperations(AutoRestComplexTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -126,7 +128,7 @@ public BasicOperations(AutoRestComplexTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -155,7 +157,7 @@ public BasicOperations(AutoRestComplexTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -231,6 +233,8 @@ public BasicOperations(AutoRestComplexTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -277,7 +281,7 @@ public BasicOperations(AutoRestComplexTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -344,6 +348,8 @@ public BasicOperations(AutoRestComplexTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -384,7 +390,7 @@ public BasicOperations(AutoRestComplexTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -413,7 +419,7 @@ public BasicOperations(AutoRestComplexTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -469,6 +475,8 @@ public BasicOperations(AutoRestComplexTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -509,7 +517,7 @@ public BasicOperations(AutoRestComplexTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -538,7 +546,7 @@ public BasicOperations(AutoRestComplexTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -594,6 +602,8 @@ public BasicOperations(AutoRestComplexTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -634,7 +644,7 @@ public BasicOperations(AutoRestComplexTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -663,7 +673,7 @@ public BasicOperations(AutoRestComplexTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -720,6 +730,8 @@ public BasicOperations(AutoRestComplexTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -760,7 +772,7 @@ public BasicOperations(AutoRestComplexTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -789,7 +801,7 @@ public BasicOperations(AutoRestComplexTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Dictionary.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Dictionary.cs index acbceea568..fa1b175b1c 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Dictionary.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Dictionary.cs @@ -86,6 +86,8 @@ public Dictionary(AutoRestComplexTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -126,7 +128,7 @@ public Dictionary(AutoRestComplexTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -155,7 +157,7 @@ public Dictionary(AutoRestComplexTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -216,6 +218,8 @@ public Dictionary(AutoRestComplexTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -262,7 +266,7 @@ public Dictionary(AutoRestComplexTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -329,6 +333,8 @@ public Dictionary(AutoRestComplexTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -369,7 +375,7 @@ public Dictionary(AutoRestComplexTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -398,7 +404,7 @@ public Dictionary(AutoRestComplexTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -459,6 +465,8 @@ public Dictionary(AutoRestComplexTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -505,7 +513,7 @@ public Dictionary(AutoRestComplexTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -572,6 +580,8 @@ public Dictionary(AutoRestComplexTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -612,7 +622,7 @@ public Dictionary(AutoRestComplexTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -641,7 +651,7 @@ public Dictionary(AutoRestComplexTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -698,6 +708,8 @@ public Dictionary(AutoRestComplexTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -738,7 +750,7 @@ public Dictionary(AutoRestComplexTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -767,7 +779,7 @@ public Dictionary(AutoRestComplexTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/IAutoRestComplexTestService.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/IAutoRestComplexTestService.cs index 9a9f9f7d5f..ebb3bd869d 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/IAutoRestComplexTestService.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/IAutoRestComplexTestService.cs @@ -24,12 +24,12 @@ public partial interface IAutoRestComplexTestService : System.IDisposable /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// /// API ID. diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Inheritance.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Inheritance.cs index fa29bfbb33..90356e1a4e 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Inheritance.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Inheritance.cs @@ -86,6 +86,8 @@ public Inheritance(AutoRestComplexTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -126,7 +128,7 @@ public Inheritance(AutoRestComplexTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -155,7 +157,7 @@ public Inheritance(AutoRestComplexTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -224,6 +226,8 @@ public Inheritance(AutoRestComplexTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -270,7 +274,7 @@ public Inheritance(AutoRestComplexTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Models/Cookiecuttershark.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Models/Cookiecuttershark.cs index accf2ea178..e015d67fd9 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Models/Cookiecuttershark.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Models/Cookiecuttershark.cs @@ -14,7 +14,7 @@ namespace Fixtures.AcceptanceTestsBodyComplex.Models using System.Collections.Generic; using System.Linq; - [Newtonsoft.Json.JsonObject("cookiecuttershark")] + [JsonObject("cookiecuttershark")] public partial class Cookiecuttershark : Shark { /// diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Models/Goblinshark.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Models/Goblinshark.cs index 3def98b855..0f023c147f 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Models/Goblinshark.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Models/Goblinshark.cs @@ -14,7 +14,7 @@ namespace Fixtures.AcceptanceTestsBodyComplex.Models using System.Collections.Generic; using System.Linq; - [Newtonsoft.Json.JsonObject("goblin")] + [JsonObject("goblin")] public partial class Goblinshark : Shark { /// diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Models/Salmon.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Models/Salmon.cs index 9db7b5d64b..094db622d4 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Models/Salmon.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Models/Salmon.cs @@ -14,7 +14,7 @@ namespace Fixtures.AcceptanceTestsBodyComplex.Models using System.Collections.Generic; using System.Linq; - [Newtonsoft.Json.JsonObject("salmon")] + [JsonObject("salmon")] public partial class Salmon : Fish { /// diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Models/Sawshark.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Models/Sawshark.cs index d097d33500..43a9bc3589 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Models/Sawshark.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Models/Sawshark.cs @@ -14,7 +14,7 @@ namespace Fixtures.AcceptanceTestsBodyComplex.Models using System.Collections.Generic; using System.Linq; - [Newtonsoft.Json.JsonObject("sawshark")] + [JsonObject("sawshark")] public partial class Sawshark : Shark { /// diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Models/Shark.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Models/Shark.cs index 26387bbff3..f41e649812 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Models/Shark.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Models/Shark.cs @@ -14,7 +14,7 @@ namespace Fixtures.AcceptanceTestsBodyComplex.Models using System.Collections.Generic; using System.Linq; - [Newtonsoft.Json.JsonObject("shark")] + [JsonObject("shark")] public partial class Shark : Fish { /// diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Polymorphicrecursive.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Polymorphicrecursive.cs index dc192a4338..99073dd84f 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Polymorphicrecursive.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Polymorphicrecursive.cs @@ -86,6 +86,8 @@ public Polymorphicrecursive(AutoRestComplexTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -126,7 +128,7 @@ public Polymorphicrecursive(AutoRestComplexTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -155,7 +157,7 @@ public Polymorphicrecursive(AutoRestComplexTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -278,6 +280,8 @@ public Polymorphicrecursive(AutoRestComplexTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -324,7 +328,7 @@ public Polymorphicrecursive(AutoRestComplexTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Polymorphism.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Polymorphism.cs index c83fe12de9..eee4f93010 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Polymorphism.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Polymorphism.cs @@ -86,6 +86,8 @@ public Polymorphism(AutoRestComplexTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -126,7 +128,7 @@ public Polymorphism(AutoRestComplexTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -155,7 +157,7 @@ public Polymorphism(AutoRestComplexTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -258,6 +260,8 @@ public Polymorphism(AutoRestComplexTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -304,7 +308,7 @@ public Polymorphism(AutoRestComplexTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -413,6 +417,8 @@ public Polymorphism(AutoRestComplexTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -459,7 +465,7 @@ public Polymorphism(AutoRestComplexTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Primitive.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Primitive.cs index 649849e926..2c4943ca91 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Primitive.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Primitive.cs @@ -86,6 +86,8 @@ public Primitive(AutoRestComplexTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -126,7 +128,7 @@ public Primitive(AutoRestComplexTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -155,7 +157,7 @@ public Primitive(AutoRestComplexTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -222,6 +224,8 @@ public Primitive(AutoRestComplexTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -268,7 +272,7 @@ public Primitive(AutoRestComplexTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -335,6 +339,8 @@ public Primitive(AutoRestComplexTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -375,7 +381,7 @@ public Primitive(AutoRestComplexTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -404,7 +410,7 @@ public Primitive(AutoRestComplexTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -471,6 +477,8 @@ public Primitive(AutoRestComplexTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -517,7 +525,7 @@ public Primitive(AutoRestComplexTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -584,6 +592,8 @@ public Primitive(AutoRestComplexTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -624,7 +634,7 @@ public Primitive(AutoRestComplexTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -653,7 +663,7 @@ public Primitive(AutoRestComplexTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -720,6 +730,8 @@ public Primitive(AutoRestComplexTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -766,7 +778,7 @@ public Primitive(AutoRestComplexTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -833,6 +845,8 @@ public Primitive(AutoRestComplexTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -873,7 +887,7 @@ public Primitive(AutoRestComplexTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -902,7 +916,7 @@ public Primitive(AutoRestComplexTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -970,6 +984,8 @@ public Primitive(AutoRestComplexTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1016,7 +1032,7 @@ public Primitive(AutoRestComplexTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1083,6 +1099,8 @@ public Primitive(AutoRestComplexTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1123,7 +1141,7 @@ public Primitive(AutoRestComplexTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1152,7 +1170,7 @@ public Primitive(AutoRestComplexTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1219,6 +1237,8 @@ public Primitive(AutoRestComplexTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1265,7 +1285,7 @@ public Primitive(AutoRestComplexTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1332,6 +1352,8 @@ public Primitive(AutoRestComplexTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1372,7 +1394,7 @@ public Primitive(AutoRestComplexTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1401,7 +1423,7 @@ public Primitive(AutoRestComplexTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1468,6 +1490,8 @@ public Primitive(AutoRestComplexTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1514,7 +1538,7 @@ public Primitive(AutoRestComplexTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1581,6 +1605,8 @@ public Primitive(AutoRestComplexTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1621,7 +1647,7 @@ public Primitive(AutoRestComplexTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1650,7 +1676,7 @@ public Primitive(AutoRestComplexTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1717,6 +1743,8 @@ public Primitive(AutoRestComplexTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1763,7 +1791,7 @@ public Primitive(AutoRestComplexTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1830,6 +1858,8 @@ public Primitive(AutoRestComplexTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1870,7 +1900,7 @@ public Primitive(AutoRestComplexTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1899,7 +1929,7 @@ public Primitive(AutoRestComplexTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1966,6 +1996,8 @@ public Primitive(AutoRestComplexTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2012,7 +2044,7 @@ public Primitive(AutoRestComplexTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2079,6 +2111,8 @@ public Primitive(AutoRestComplexTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2119,7 +2153,7 @@ public Primitive(AutoRestComplexTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2148,7 +2182,7 @@ public Primitive(AutoRestComplexTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2216,6 +2250,8 @@ public Primitive(AutoRestComplexTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2262,7 +2298,7 @@ public Primitive(AutoRestComplexTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2329,6 +2365,8 @@ public Primitive(AutoRestComplexTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2369,7 +2407,7 @@ public Primitive(AutoRestComplexTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2398,7 +2436,7 @@ public Primitive(AutoRestComplexTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2459,6 +2497,8 @@ public Primitive(AutoRestComplexTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2505,7 +2545,7 @@ public Primitive(AutoRestComplexTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2572,6 +2612,8 @@ public Primitive(AutoRestComplexTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2612,7 +2654,7 @@ public Primitive(AutoRestComplexTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2641,7 +2683,7 @@ public Primitive(AutoRestComplexTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2702,6 +2744,8 @@ public Primitive(AutoRestComplexTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2748,7 +2792,7 @@ public Primitive(AutoRestComplexTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Readonlyproperty.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Readonlyproperty.cs index 3f273016e8..9d336c88b0 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Readonlyproperty.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Readonlyproperty.cs @@ -86,6 +86,8 @@ public Readonlyproperty(AutoRestComplexTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -126,7 +128,7 @@ public Readonlyproperty(AutoRestComplexTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -155,7 +157,7 @@ public Readonlyproperty(AutoRestComplexTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -216,6 +218,8 @@ public Readonlyproperty(AutoRestComplexTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -262,7 +266,7 @@ public Readonlyproperty(AutoRestComplexTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDate/AutoRestDateTestService.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDate/AutoRestDateTestService.cs index fced23b6ba..9f36ec5963 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDate/AutoRestDateTestService.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDate/AutoRestDateTestService.cs @@ -30,12 +30,12 @@ public partial class AutoRestDateTestService : ServiceClient /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// Gets the IDate. @@ -123,27 +123,27 @@ private void Initialize() { Date = new Date(this); BaseUri = new System.Uri("https://localhost"); - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDate/Date.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDate/Date.cs index faa46ad03a..2bc84a96e2 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDate/Date.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDate/Date.cs @@ -87,6 +87,8 @@ public Date(AutoRestDateTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -127,7 +129,7 @@ public Date(AutoRestDateTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -156,7 +158,7 @@ public Date(AutoRestDateTestService client) { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, new DateJsonConverter()); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -212,6 +214,8 @@ public Date(AutoRestDateTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -252,7 +256,7 @@ public Date(AutoRestDateTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -281,7 +285,7 @@ public Date(AutoRestDateTestService client) { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, new DateJsonConverter()); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -337,6 +341,8 @@ public Date(AutoRestDateTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -377,7 +383,7 @@ public Date(AutoRestDateTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -406,7 +412,7 @@ public Date(AutoRestDateTestService client) { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, new DateJsonConverter()); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -462,6 +468,8 @@ public Date(AutoRestDateTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -502,7 +510,7 @@ public Date(AutoRestDateTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -531,7 +539,7 @@ public Date(AutoRestDateTestService client) { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, new DateJsonConverter()); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -587,6 +595,8 @@ public Date(AutoRestDateTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -630,7 +640,7 @@ public Date(AutoRestDateTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -697,6 +707,8 @@ public Date(AutoRestDateTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -737,7 +749,7 @@ public Date(AutoRestDateTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -766,7 +778,7 @@ public Date(AutoRestDateTestService client) { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, new DateJsonConverter()); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -822,6 +834,8 @@ public Date(AutoRestDateTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -865,7 +879,7 @@ public Date(AutoRestDateTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -932,6 +946,8 @@ public Date(AutoRestDateTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -972,7 +988,7 @@ public Date(AutoRestDateTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1001,7 +1017,7 @@ public Date(AutoRestDateTestService client) { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, new DateJsonConverter()); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDate/IAutoRestDateTestService.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDate/IAutoRestDateTestService.cs index 7c51b73957..8b0c9e1ed4 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDate/IAutoRestDateTestService.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDate/IAutoRestDateTestService.cs @@ -24,12 +24,12 @@ public partial interface IAutoRestDateTestService : System.IDisposable /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDateTime/AutoRestDateTimeTestService.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDateTime/AutoRestDateTimeTestService.cs index d37717bd2b..b379678f37 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDateTime/AutoRestDateTimeTestService.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDateTime/AutoRestDateTimeTestService.cs @@ -30,12 +30,12 @@ public partial class AutoRestDateTimeTestService : ServiceClient /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// Gets the IDatetime. @@ -123,27 +123,27 @@ private void Initialize() { Datetime = new Datetime(this); BaseUri = new System.Uri("https://localhost"); - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDateTime/Datetime.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDateTime/Datetime.cs index ab66fac205..b5e25dbedb 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDateTime/Datetime.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDateTime/Datetime.cs @@ -86,6 +86,8 @@ public Datetime(AutoRestDateTimeTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -126,7 +128,7 @@ public Datetime(AutoRestDateTimeTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -155,7 +157,7 @@ public Datetime(AutoRestDateTimeTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -211,6 +213,8 @@ public Datetime(AutoRestDateTimeTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -251,7 +255,7 @@ public Datetime(AutoRestDateTimeTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -280,7 +284,7 @@ public Datetime(AutoRestDateTimeTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -336,6 +340,8 @@ public Datetime(AutoRestDateTimeTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -376,7 +382,7 @@ public Datetime(AutoRestDateTimeTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -405,7 +411,7 @@ public Datetime(AutoRestDateTimeTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -461,6 +467,8 @@ public Datetime(AutoRestDateTimeTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -501,7 +509,7 @@ public Datetime(AutoRestDateTimeTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -530,7 +538,7 @@ public Datetime(AutoRestDateTimeTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -586,6 +594,8 @@ public Datetime(AutoRestDateTimeTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -629,7 +639,7 @@ public Datetime(AutoRestDateTimeTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -696,6 +706,8 @@ public Datetime(AutoRestDateTimeTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -736,7 +748,7 @@ public Datetime(AutoRestDateTimeTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -765,7 +777,7 @@ public Datetime(AutoRestDateTimeTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -821,6 +833,8 @@ public Datetime(AutoRestDateTimeTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -861,7 +875,7 @@ public Datetime(AutoRestDateTimeTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -890,7 +904,7 @@ public Datetime(AutoRestDateTimeTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -947,6 +961,8 @@ public Datetime(AutoRestDateTimeTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -990,7 +1006,7 @@ public Datetime(AutoRestDateTimeTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1058,6 +1074,8 @@ public Datetime(AutoRestDateTimeTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1098,7 +1116,7 @@ public Datetime(AutoRestDateTimeTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1127,7 +1145,7 @@ public Datetime(AutoRestDateTimeTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1184,6 +1202,8 @@ public Datetime(AutoRestDateTimeTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1224,7 +1244,7 @@ public Datetime(AutoRestDateTimeTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1253,7 +1273,7 @@ public Datetime(AutoRestDateTimeTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1310,6 +1330,8 @@ public Datetime(AutoRestDateTimeTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1353,7 +1375,7 @@ public Datetime(AutoRestDateTimeTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1421,6 +1443,8 @@ public Datetime(AutoRestDateTimeTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1461,7 +1485,7 @@ public Datetime(AutoRestDateTimeTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1490,7 +1514,7 @@ public Datetime(AutoRestDateTimeTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1547,6 +1571,8 @@ public Datetime(AutoRestDateTimeTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1587,7 +1613,7 @@ public Datetime(AutoRestDateTimeTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1616,7 +1642,7 @@ public Datetime(AutoRestDateTimeTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1672,6 +1698,8 @@ public Datetime(AutoRestDateTimeTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1715,7 +1743,7 @@ public Datetime(AutoRestDateTimeTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1782,6 +1810,8 @@ public Datetime(AutoRestDateTimeTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1822,7 +1852,7 @@ public Datetime(AutoRestDateTimeTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1851,7 +1881,7 @@ public Datetime(AutoRestDateTimeTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1907,6 +1937,8 @@ public Datetime(AutoRestDateTimeTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1950,7 +1982,7 @@ public Datetime(AutoRestDateTimeTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2017,6 +2049,8 @@ public Datetime(AutoRestDateTimeTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2057,7 +2091,7 @@ public Datetime(AutoRestDateTimeTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2086,7 +2120,7 @@ public Datetime(AutoRestDateTimeTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2142,6 +2176,8 @@ public Datetime(AutoRestDateTimeTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2185,7 +2221,7 @@ public Datetime(AutoRestDateTimeTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2252,6 +2288,8 @@ public Datetime(AutoRestDateTimeTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2292,7 +2330,7 @@ public Datetime(AutoRestDateTimeTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2321,7 +2359,7 @@ public Datetime(AutoRestDateTimeTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDateTime/IAutoRestDateTimeTestService.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDateTime/IAutoRestDateTimeTestService.cs index 4813bd5c34..6560cfcbbf 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDateTime/IAutoRestDateTimeTestService.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDateTime/IAutoRestDateTimeTestService.cs @@ -24,12 +24,12 @@ public partial interface IAutoRestDateTimeTestService : System.IDisposable /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDateTimeRfc1123/AutoRestRFC1123DateTimeTestService.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDateTimeRfc1123/AutoRestRFC1123DateTimeTestService.cs index 91ba538cc7..5fcec1bbed 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDateTimeRfc1123/AutoRestRFC1123DateTimeTestService.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDateTimeRfc1123/AutoRestRFC1123DateTimeTestService.cs @@ -30,12 +30,12 @@ public partial class AutoRestRFC1123DateTimeTestService : ServiceClient /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// Gets the IDatetimerfc1123. @@ -123,27 +123,27 @@ private void Initialize() { Datetimerfc1123 = new Datetimerfc1123(this); BaseUri = new System.Uri("https://localhost"); - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDateTimeRfc1123/Datetimerfc1123.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDateTimeRfc1123/Datetimerfc1123.cs index 6c35716336..64bee284ba 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDateTimeRfc1123/Datetimerfc1123.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDateTimeRfc1123/Datetimerfc1123.cs @@ -87,6 +87,8 @@ public Datetimerfc1123(AutoRestRFC1123DateTimeTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -127,7 +129,7 @@ public Datetimerfc1123(AutoRestRFC1123DateTimeTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -156,7 +158,7 @@ public Datetimerfc1123(AutoRestRFC1123DateTimeTestService client) { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -212,6 +214,8 @@ public Datetimerfc1123(AutoRestRFC1123DateTimeTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -252,7 +256,7 @@ public Datetimerfc1123(AutoRestRFC1123DateTimeTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -281,7 +285,7 @@ public Datetimerfc1123(AutoRestRFC1123DateTimeTestService client) { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -337,6 +341,8 @@ public Datetimerfc1123(AutoRestRFC1123DateTimeTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -377,7 +383,7 @@ public Datetimerfc1123(AutoRestRFC1123DateTimeTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -406,7 +412,7 @@ public Datetimerfc1123(AutoRestRFC1123DateTimeTestService client) { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -462,6 +468,8 @@ public Datetimerfc1123(AutoRestRFC1123DateTimeTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -502,7 +510,7 @@ public Datetimerfc1123(AutoRestRFC1123DateTimeTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -531,7 +539,7 @@ public Datetimerfc1123(AutoRestRFC1123DateTimeTestService client) { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -587,6 +595,8 @@ public Datetimerfc1123(AutoRestRFC1123DateTimeTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -630,7 +640,7 @@ public Datetimerfc1123(AutoRestRFC1123DateTimeTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -697,6 +707,8 @@ public Datetimerfc1123(AutoRestRFC1123DateTimeTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -737,7 +749,7 @@ public Datetimerfc1123(AutoRestRFC1123DateTimeTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -766,7 +778,7 @@ public Datetimerfc1123(AutoRestRFC1123DateTimeTestService client) { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -822,6 +834,8 @@ public Datetimerfc1123(AutoRestRFC1123DateTimeTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -862,7 +876,7 @@ public Datetimerfc1123(AutoRestRFC1123DateTimeTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -891,7 +905,7 @@ public Datetimerfc1123(AutoRestRFC1123DateTimeTestService client) { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -947,6 +961,8 @@ public Datetimerfc1123(AutoRestRFC1123DateTimeTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -990,7 +1006,7 @@ public Datetimerfc1123(AutoRestRFC1123DateTimeTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1057,6 +1073,8 @@ public Datetimerfc1123(AutoRestRFC1123DateTimeTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1097,7 +1115,7 @@ public Datetimerfc1123(AutoRestRFC1123DateTimeTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1126,7 +1144,7 @@ public Datetimerfc1123(AutoRestRFC1123DateTimeTestService client) { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDateTimeRfc1123/IAutoRestRFC1123DateTimeTestService.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDateTimeRfc1123/IAutoRestRFC1123DateTimeTestService.cs index 2a11382f83..772bd03a90 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDateTimeRfc1123/IAutoRestRFC1123DateTimeTestService.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDateTimeRfc1123/IAutoRestRFC1123DateTimeTestService.cs @@ -24,12 +24,12 @@ public partial interface IAutoRestRFC1123DateTimeTestService : System.IDisposabl /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDictionary/AutoRestSwaggerBATdictionaryService.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDictionary/AutoRestSwaggerBATdictionaryService.cs index bf7fdc7b24..ba9eddfedb 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDictionary/AutoRestSwaggerBATdictionaryService.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDictionary/AutoRestSwaggerBATdictionaryService.cs @@ -30,12 +30,12 @@ public partial class AutoRestSwaggerBATdictionaryService : ServiceClient /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// Gets the IDictionary. @@ -123,27 +123,27 @@ private void Initialize() { Dictionary = new Dictionary(this); BaseUri = new System.Uri("http://localhost"); - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDictionary/Dictionary.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDictionary/Dictionary.cs index ba52e38e37..c56e3c678f 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDictionary/Dictionary.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDictionary/Dictionary.cs @@ -87,6 +87,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -127,7 +129,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -156,7 +158,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -212,6 +214,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -252,7 +256,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -281,7 +285,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -347,6 +351,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -393,7 +399,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -460,6 +466,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -500,7 +508,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -529,7 +537,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -585,6 +593,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -625,7 +635,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -654,7 +664,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -710,6 +720,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -750,7 +762,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -779,7 +791,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -835,6 +847,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -875,7 +889,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -904,7 +918,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -961,6 +975,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1001,7 +1017,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1030,7 +1046,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1096,6 +1112,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1142,7 +1160,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1209,6 +1227,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1249,7 +1269,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1278,7 +1298,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1334,6 +1354,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1374,7 +1396,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1403,7 +1425,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1459,6 +1481,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1499,7 +1523,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1528,7 +1552,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1594,6 +1618,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1640,7 +1666,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1707,6 +1733,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1747,7 +1775,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1776,7 +1804,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1832,6 +1860,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1872,7 +1902,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1901,7 +1931,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1957,6 +1987,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1997,7 +2029,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2026,7 +2058,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2092,6 +2124,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2138,7 +2172,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2205,6 +2239,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2245,7 +2281,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2274,7 +2310,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2330,6 +2366,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2370,7 +2408,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2399,7 +2437,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2455,6 +2493,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2495,7 +2535,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2524,7 +2564,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2590,6 +2630,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2636,7 +2678,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2703,6 +2745,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2743,7 +2787,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2772,7 +2816,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2828,6 +2872,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2868,7 +2914,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2897,7 +2943,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2953,6 +2999,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2993,7 +3041,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3022,7 +3070,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -3088,6 +3136,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3134,7 +3184,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3201,6 +3251,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3241,7 +3293,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3270,7 +3322,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -3326,6 +3378,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3366,7 +3420,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3395,7 +3449,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -3451,6 +3505,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3491,7 +3547,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3520,7 +3576,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -3586,6 +3642,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3632,7 +3690,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3699,6 +3757,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3739,7 +3799,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3768,7 +3828,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -3824,6 +3884,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3864,7 +3926,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3893,7 +3955,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -3950,6 +4012,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3990,7 +4054,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -4019,7 +4083,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, new DateJsonConverter()); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -4086,6 +4150,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -4132,7 +4198,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -4199,6 +4265,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -4239,7 +4307,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -4268,7 +4336,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, new DateJsonConverter()); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -4324,6 +4392,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -4364,7 +4434,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -4393,7 +4463,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, new DateJsonConverter()); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -4450,6 +4520,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -4490,7 +4562,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -4519,7 +4591,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -4586,6 +4658,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -4632,7 +4706,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -4699,6 +4773,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -4739,7 +4815,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -4768,7 +4844,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -4824,6 +4900,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -4864,7 +4942,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -4893,7 +4971,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -4951,6 +5029,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -4991,7 +5071,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -5020,7 +5100,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -5087,6 +5167,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -5133,7 +5215,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -5201,6 +5283,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -5241,7 +5325,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -5270,7 +5354,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -5336,6 +5420,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -5382,7 +5468,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -5450,6 +5536,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -5490,7 +5578,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -5519,7 +5607,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -5586,6 +5674,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -5632,7 +5722,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -5700,6 +5790,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -5740,7 +5832,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -5769,7 +5861,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -5826,6 +5918,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -5866,7 +5960,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -5895,7 +5989,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, new Base64UrlJsonConverter()); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -5951,6 +6045,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -5991,7 +6087,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -6020,7 +6116,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -6076,6 +6172,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -6116,7 +6214,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -6145,7 +6243,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -6202,6 +6300,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -6242,7 +6342,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -6271,7 +6371,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -6328,6 +6428,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -6368,7 +6470,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -6397,7 +6499,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -6454,6 +6556,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -6494,7 +6598,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -6523,7 +6627,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -6591,6 +6695,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -6637,7 +6743,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -6704,6 +6810,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -6744,7 +6852,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -6773,7 +6881,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -6829,6 +6937,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -6869,7 +6979,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -6898,7 +7008,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -6955,6 +7065,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -6995,7 +7107,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -7024,7 +7136,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -7081,6 +7193,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -7121,7 +7235,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -7150,7 +7264,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -7207,6 +7321,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -7247,7 +7363,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -7276,7 +7392,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -7343,6 +7459,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -7389,7 +7507,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -7456,6 +7574,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -7496,7 +7616,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -7525,7 +7645,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -7582,6 +7702,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -7622,7 +7744,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -7651,7 +7773,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -7709,6 +7831,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -7749,7 +7873,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -7778,7 +7902,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -7836,6 +7960,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -7876,7 +8002,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -7905,7 +8031,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -7963,6 +8089,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -8003,7 +8131,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -8032,7 +8160,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) { _result.Body = SafeJsonConvert.DeserializeObject>>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -8100,6 +8228,8 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -8146,7 +8276,7 @@ public Dictionary(AutoRestSwaggerBATdictionaryService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDictionary/IAutoRestSwaggerBATdictionaryService.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDictionary/IAutoRestSwaggerBATdictionaryService.cs index c3660a0601..d90bd3b233 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDictionary/IAutoRestSwaggerBATdictionaryService.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDictionary/IAutoRestSwaggerBATdictionaryService.cs @@ -24,12 +24,12 @@ public partial interface IAutoRestSwaggerBATdictionaryService : System.IDisposab /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDuration/AutoRestDurationTestService.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDuration/AutoRestDurationTestService.cs index 2f5681fe1a..6fdb42906b 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDuration/AutoRestDurationTestService.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDuration/AutoRestDurationTestService.cs @@ -30,12 +30,12 @@ public partial class AutoRestDurationTestService : ServiceClient /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// Gets the IDuration. @@ -123,27 +123,27 @@ private void Initialize() { Duration = new Duration(this); BaseUri = new System.Uri("https://localhost"); - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDuration/Duration.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDuration/Duration.cs index 7cab4519f2..ea2725276f 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDuration/Duration.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDuration/Duration.cs @@ -86,6 +86,8 @@ public Duration(AutoRestDurationTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -126,7 +128,7 @@ public Duration(AutoRestDurationTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -155,7 +157,7 @@ public Duration(AutoRestDurationTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -211,6 +213,8 @@ public Duration(AutoRestDurationTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -254,7 +258,7 @@ public Duration(AutoRestDurationTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -321,6 +325,8 @@ public Duration(AutoRestDurationTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -361,7 +367,7 @@ public Duration(AutoRestDurationTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -390,7 +396,7 @@ public Duration(AutoRestDurationTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -446,6 +452,8 @@ public Duration(AutoRestDurationTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -486,7 +494,7 @@ public Duration(AutoRestDurationTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -515,7 +523,7 @@ public Duration(AutoRestDurationTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDuration/IAutoRestDurationTestService.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDuration/IAutoRestDurationTestService.cs index 2e7e93713a..301624ecd5 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDuration/IAutoRestDurationTestService.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyDuration/IAutoRestDurationTestService.cs @@ -24,12 +24,12 @@ public partial interface IAutoRestDurationTestService : System.IDisposable /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyFile/AutoRestSwaggerBATFileService.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyFile/AutoRestSwaggerBATFileService.cs index 9d4116bf34..572b9825c8 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyFile/AutoRestSwaggerBATFileService.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyFile/AutoRestSwaggerBATFileService.cs @@ -30,12 +30,12 @@ public partial class AutoRestSwaggerBATFileService : ServiceClient /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// Gets the IFiles. @@ -123,27 +123,27 @@ private void Initialize() { Files = new Files(this); BaseUri = new System.Uri("http://localhost"); - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyFile/Files.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyFile/Files.cs index 93a477aaf9..27ef024fe2 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyFile/Files.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyFile/Files.cs @@ -86,6 +86,8 @@ public Files(AutoRestSwaggerBATFileService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -126,7 +128,7 @@ public Files(AutoRestSwaggerBATFileService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -198,6 +200,8 @@ public Files(AutoRestSwaggerBATFileService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -238,7 +242,7 @@ public Files(AutoRestSwaggerBATFileService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -310,6 +314,8 @@ public Files(AutoRestSwaggerBATFileService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -350,7 +356,7 @@ public Files(AutoRestSwaggerBATFileService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyFile/IAutoRestSwaggerBATFileService.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyFile/IAutoRestSwaggerBATFileService.cs index c94c0e5f68..1039621c5f 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyFile/IAutoRestSwaggerBATFileService.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyFile/IAutoRestSwaggerBATFileService.cs @@ -24,12 +24,12 @@ public partial interface IAutoRestSwaggerBATFileService : System.IDisposable /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyFormData/AutoRestSwaggerBATFormDataService.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyFormData/AutoRestSwaggerBATFormDataService.cs index 0b071e3320..db277650df 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyFormData/AutoRestSwaggerBATFormDataService.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyFormData/AutoRestSwaggerBATFormDataService.cs @@ -30,12 +30,12 @@ public partial class AutoRestSwaggerBATFormDataService : ServiceClient /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// Gets the IFormdata. @@ -123,27 +123,27 @@ private void Initialize() { Formdata = new Formdata(this); BaseUri = new System.Uri("http://localhost"); - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyFormData/Formdata.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyFormData/Formdata.cs index 44601158c1..38af75f86c 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyFormData/Formdata.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyFormData/Formdata.cs @@ -109,6 +109,8 @@ public Formdata(AutoRestSwaggerBATFormDataService client) _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -170,7 +172,7 @@ public Formdata(AutoRestSwaggerBATFormDataService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -256,6 +258,8 @@ public Formdata(AutoRestSwaggerBATFormDataService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -305,7 +309,7 @@ public Formdata(AutoRestSwaggerBATFormDataService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyFormData/IAutoRestSwaggerBATFormDataService.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyFormData/IAutoRestSwaggerBATFormDataService.cs index 473ebb6e93..3335456f0e 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyFormData/IAutoRestSwaggerBATFormDataService.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyFormData/IAutoRestSwaggerBATFormDataService.cs @@ -24,12 +24,12 @@ public partial interface IAutoRestSwaggerBATFormDataService : System.IDisposable /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyInteger/AutoRestIntegerTestService.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyInteger/AutoRestIntegerTestService.cs index 439d97d4af..df05eb6c79 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyInteger/AutoRestIntegerTestService.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyInteger/AutoRestIntegerTestService.cs @@ -30,12 +30,12 @@ public partial class AutoRestIntegerTestService : ServiceClient /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// Gets the IIntModel. @@ -123,27 +123,27 @@ private void Initialize() { IntModel = new IntModel(this); BaseUri = new System.Uri("http://localhost"); - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyInteger/IAutoRestIntegerTestService.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyInteger/IAutoRestIntegerTestService.cs index f06655c1fa..16ddf1d78f 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyInteger/IAutoRestIntegerTestService.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyInteger/IAutoRestIntegerTestService.cs @@ -24,12 +24,12 @@ public partial interface IAutoRestIntegerTestService : System.IDisposable /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyInteger/IntModel.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyInteger/IntModel.cs index 3b8abd86fe..afa797bc52 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyInteger/IntModel.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyInteger/IntModel.cs @@ -87,6 +87,8 @@ public IntModel(AutoRestIntegerTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -127,7 +129,7 @@ public IntModel(AutoRestIntegerTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -156,7 +158,7 @@ public IntModel(AutoRestIntegerTestService client) { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -212,6 +214,8 @@ public IntModel(AutoRestIntegerTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -252,7 +256,7 @@ public IntModel(AutoRestIntegerTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -281,7 +285,7 @@ public IntModel(AutoRestIntegerTestService client) { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -337,6 +341,8 @@ public IntModel(AutoRestIntegerTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -377,7 +383,7 @@ public IntModel(AutoRestIntegerTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -406,7 +412,7 @@ public IntModel(AutoRestIntegerTestService client) { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -462,6 +468,8 @@ public IntModel(AutoRestIntegerTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -502,7 +510,7 @@ public IntModel(AutoRestIntegerTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -531,7 +539,7 @@ public IntModel(AutoRestIntegerTestService client) { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -587,6 +595,8 @@ public IntModel(AutoRestIntegerTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -627,7 +637,7 @@ public IntModel(AutoRestIntegerTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -656,7 +666,7 @@ public IntModel(AutoRestIntegerTestService client) { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -712,6 +722,8 @@ public IntModel(AutoRestIntegerTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -752,7 +764,7 @@ public IntModel(AutoRestIntegerTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -781,7 +793,7 @@ public IntModel(AutoRestIntegerTestService client) { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -837,6 +849,8 @@ public IntModel(AutoRestIntegerTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -880,7 +894,7 @@ public IntModel(AutoRestIntegerTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -947,6 +961,8 @@ public IntModel(AutoRestIntegerTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -990,7 +1006,7 @@ public IntModel(AutoRestIntegerTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1057,6 +1073,8 @@ public IntModel(AutoRestIntegerTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1100,7 +1118,7 @@ public IntModel(AutoRestIntegerTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1167,6 +1185,8 @@ public IntModel(AutoRestIntegerTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1210,7 +1230,7 @@ public IntModel(AutoRestIntegerTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1277,6 +1297,8 @@ public IntModel(AutoRestIntegerTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1317,7 +1339,7 @@ public IntModel(AutoRestIntegerTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1346,7 +1368,7 @@ public IntModel(AutoRestIntegerTestService client) { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, new UnixTimeJsonConverter()); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1402,6 +1424,8 @@ public IntModel(AutoRestIntegerTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1445,7 +1469,7 @@ public IntModel(AutoRestIntegerTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1512,6 +1536,8 @@ public IntModel(AutoRestIntegerTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1552,7 +1578,7 @@ public IntModel(AutoRestIntegerTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1581,7 +1607,7 @@ public IntModel(AutoRestIntegerTestService client) { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, new UnixTimeJsonConverter()); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1637,6 +1663,8 @@ public IntModel(AutoRestIntegerTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1677,7 +1705,7 @@ public IntModel(AutoRestIntegerTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1706,7 +1734,7 @@ public IntModel(AutoRestIntegerTestService client) { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, new UnixTimeJsonConverter()); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyNumber/AutoRestNumberTestService.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyNumber/AutoRestNumberTestService.cs index 242e79051b..5c40d6002e 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyNumber/AutoRestNumberTestService.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyNumber/AutoRestNumberTestService.cs @@ -30,12 +30,12 @@ public partial class AutoRestNumberTestService : ServiceClient /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// Gets the INumber. @@ -123,27 +123,27 @@ private void Initialize() { Number = new Number(this); BaseUri = new System.Uri("https://localhost"); - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyNumber/IAutoRestNumberTestService.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyNumber/IAutoRestNumberTestService.cs index 662541eb0b..32d05aebe1 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyNumber/IAutoRestNumberTestService.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyNumber/IAutoRestNumberTestService.cs @@ -24,12 +24,12 @@ public partial interface IAutoRestNumberTestService : System.IDisposable /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyNumber/Number.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyNumber/Number.cs index 9f85f6449d..8fe7c5cbe8 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyNumber/Number.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyNumber/Number.cs @@ -86,6 +86,8 @@ public Number(AutoRestNumberTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -126,7 +128,7 @@ public Number(AutoRestNumberTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -155,7 +157,7 @@ public Number(AutoRestNumberTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -211,6 +213,8 @@ public Number(AutoRestNumberTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -251,7 +255,7 @@ public Number(AutoRestNumberTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -280,7 +284,7 @@ public Number(AutoRestNumberTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -336,6 +340,8 @@ public Number(AutoRestNumberTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -376,7 +382,7 @@ public Number(AutoRestNumberTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -405,7 +411,7 @@ public Number(AutoRestNumberTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -461,6 +467,8 @@ public Number(AutoRestNumberTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -501,7 +509,7 @@ public Number(AutoRestNumberTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -530,7 +538,7 @@ public Number(AutoRestNumberTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -586,6 +594,8 @@ public Number(AutoRestNumberTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -629,7 +639,7 @@ public Number(AutoRestNumberTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -696,6 +706,8 @@ public Number(AutoRestNumberTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -736,7 +748,7 @@ public Number(AutoRestNumberTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -765,7 +777,7 @@ public Number(AutoRestNumberTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -821,6 +833,8 @@ public Number(AutoRestNumberTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -864,7 +878,7 @@ public Number(AutoRestNumberTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -931,6 +945,8 @@ public Number(AutoRestNumberTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -971,7 +987,7 @@ public Number(AutoRestNumberTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1000,7 +1016,7 @@ public Number(AutoRestNumberTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1056,6 +1072,8 @@ public Number(AutoRestNumberTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1099,7 +1117,7 @@ public Number(AutoRestNumberTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1166,6 +1184,8 @@ public Number(AutoRestNumberTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1206,7 +1226,7 @@ public Number(AutoRestNumberTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1235,7 +1255,7 @@ public Number(AutoRestNumberTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1291,6 +1311,8 @@ public Number(AutoRestNumberTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1334,7 +1356,7 @@ public Number(AutoRestNumberTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1401,6 +1423,8 @@ public Number(AutoRestNumberTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1441,7 +1465,7 @@ public Number(AutoRestNumberTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1470,7 +1494,7 @@ public Number(AutoRestNumberTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1526,6 +1550,8 @@ public Number(AutoRestNumberTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1569,7 +1595,7 @@ public Number(AutoRestNumberTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1636,6 +1662,8 @@ public Number(AutoRestNumberTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1676,7 +1704,7 @@ public Number(AutoRestNumberTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1705,7 +1733,7 @@ public Number(AutoRestNumberTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1761,6 +1789,8 @@ public Number(AutoRestNumberTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1804,7 +1834,7 @@ public Number(AutoRestNumberTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1871,6 +1901,8 @@ public Number(AutoRestNumberTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1911,7 +1943,7 @@ public Number(AutoRestNumberTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1940,7 +1972,7 @@ public Number(AutoRestNumberTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1996,6 +2028,8 @@ public Number(AutoRestNumberTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2039,7 +2073,7 @@ public Number(AutoRestNumberTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2106,6 +2140,8 @@ public Number(AutoRestNumberTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2146,7 +2182,7 @@ public Number(AutoRestNumberTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2175,7 +2211,7 @@ public Number(AutoRestNumberTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2231,6 +2267,8 @@ public Number(AutoRestNumberTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2274,7 +2312,7 @@ public Number(AutoRestNumberTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2341,6 +2379,8 @@ public Number(AutoRestNumberTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2381,7 +2421,7 @@ public Number(AutoRestNumberTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2410,7 +2450,7 @@ public Number(AutoRestNumberTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2466,6 +2506,8 @@ public Number(AutoRestNumberTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2509,7 +2551,7 @@ public Number(AutoRestNumberTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2576,6 +2618,8 @@ public Number(AutoRestNumberTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2616,7 +2660,7 @@ public Number(AutoRestNumberTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2645,7 +2689,7 @@ public Number(AutoRestNumberTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2701,6 +2745,8 @@ public Number(AutoRestNumberTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2744,7 +2790,7 @@ public Number(AutoRestNumberTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2811,6 +2857,8 @@ public Number(AutoRestNumberTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2851,7 +2899,7 @@ public Number(AutoRestNumberTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2880,7 +2928,7 @@ public Number(AutoRestNumberTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyString/AutoRestSwaggerBATService.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyString/AutoRestSwaggerBATService.cs index ca853b87f2..3411af9e69 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyString/AutoRestSwaggerBATService.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyString/AutoRestSwaggerBATService.cs @@ -30,12 +30,12 @@ public partial class AutoRestSwaggerBATService : ServiceClient /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// Gets the IStringModel. @@ -129,27 +129,27 @@ private void Initialize() StringModel = new StringModel(this); EnumModel = new EnumModel(this); BaseUri = new System.Uri("http://localhost"); - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyString/EnumModel.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyString/EnumModel.cs index a0c17e83e7..7a17f6818f 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyString/EnumModel.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyString/EnumModel.cs @@ -87,6 +87,8 @@ public EnumModel(AutoRestSwaggerBATService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -127,7 +129,7 @@ public EnumModel(AutoRestSwaggerBATService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -156,7 +158,7 @@ public EnumModel(AutoRestSwaggerBATService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -214,6 +216,8 @@ public EnumModel(AutoRestSwaggerBATService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -257,7 +261,7 @@ public EnumModel(AutoRestSwaggerBATService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -325,6 +329,8 @@ public EnumModel(AutoRestSwaggerBATService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -365,7 +371,7 @@ public EnumModel(AutoRestSwaggerBATService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -394,7 +400,7 @@ public EnumModel(AutoRestSwaggerBATService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -452,6 +458,8 @@ public EnumModel(AutoRestSwaggerBATService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -495,7 +503,7 @@ public EnumModel(AutoRestSwaggerBATService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -562,6 +570,8 @@ public EnumModel(AutoRestSwaggerBATService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -602,7 +612,7 @@ public EnumModel(AutoRestSwaggerBATService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -631,7 +641,7 @@ public EnumModel(AutoRestSwaggerBATService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -693,6 +703,8 @@ public EnumModel(AutoRestSwaggerBATService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -739,7 +751,7 @@ public EnumModel(AutoRestSwaggerBATService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyString/IAutoRestSwaggerBATService.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyString/IAutoRestSwaggerBATService.cs index 9196dd1823..46773574ff 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyString/IAutoRestSwaggerBATService.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyString/IAutoRestSwaggerBATService.cs @@ -24,12 +24,12 @@ public partial interface IAutoRestSwaggerBATService : System.IDisposable /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyString/Models/Colors.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyString/Models/Colors.cs index c5436941f4..0c432f70e1 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyString/Models/Colors.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyString/Models/Colors.cs @@ -17,7 +17,7 @@ namespace Fixtures.AcceptanceTestsBodyString.Models /// /// Defines values for Colors. /// - [JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] + [JsonConverter(typeof(StringEnumConverter))] public enum Colors { [EnumMember(Value = "red color")] @@ -27,5 +27,38 @@ public enum Colors [EnumMember(Value = "blue_color")] BlueColor } + internal static class ColorsEnumExtension + { + internal static string ToSerializedValue(this Colors? value ) => + value == null ? null : (( Colors )value).ToSerializedValue(); + + internal static string ToSerializedValue(this Colors value ) + { + switch( value ) + { + case Colors.Redcolor: + return "red color"; + case Colors.GreenColor: + return "green-color"; + case Colors.BlueColor: + return "blue_color"; + } + return null; + } + + internal static Colors? ParseColors( this string value ) + { + switch( value ) + { + case "red color": + return Colors.Redcolor; + case "green-color": + return Colors.GreenColor; + case "blue_color": + return Colors.BlueColor; + } + return null; + } + } } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyString/StringModel.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyString/StringModel.cs index 5e0db0af4f..eaa92b8665 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyString/StringModel.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/BodyString/StringModel.cs @@ -87,6 +87,8 @@ public StringModel(AutoRestSwaggerBATService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -127,7 +129,7 @@ public StringModel(AutoRestSwaggerBATService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -156,7 +158,7 @@ public StringModel(AutoRestSwaggerBATService client) { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -213,6 +215,8 @@ public StringModel(AutoRestSwaggerBATService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -259,7 +263,7 @@ public StringModel(AutoRestSwaggerBATService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -326,6 +330,8 @@ public StringModel(AutoRestSwaggerBATService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -366,7 +372,7 @@ public StringModel(AutoRestSwaggerBATService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -395,7 +401,7 @@ public StringModel(AutoRestSwaggerBATService client) { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -462,6 +468,8 @@ public StringModel(AutoRestSwaggerBATService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -508,7 +516,7 @@ public StringModel(AutoRestSwaggerBATService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -576,6 +584,8 @@ public StringModel(AutoRestSwaggerBATService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -616,7 +626,7 @@ public StringModel(AutoRestSwaggerBATService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -645,7 +655,7 @@ public StringModel(AutoRestSwaggerBATService client) { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -714,6 +724,8 @@ public StringModel(AutoRestSwaggerBATService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -760,7 +772,7 @@ public StringModel(AutoRestSwaggerBATService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -829,6 +841,8 @@ public StringModel(AutoRestSwaggerBATService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -869,7 +883,7 @@ public StringModel(AutoRestSwaggerBATService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -898,7 +912,7 @@ public StringModel(AutoRestSwaggerBATService client) { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -968,6 +982,8 @@ public StringModel(AutoRestSwaggerBATService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1014,7 +1030,7 @@ public StringModel(AutoRestSwaggerBATService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1081,6 +1097,8 @@ public StringModel(AutoRestSwaggerBATService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1121,7 +1139,7 @@ public StringModel(AutoRestSwaggerBATService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1150,7 +1168,7 @@ public StringModel(AutoRestSwaggerBATService client) { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1206,6 +1224,8 @@ public StringModel(AutoRestSwaggerBATService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1246,7 +1266,7 @@ public StringModel(AutoRestSwaggerBATService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1275,7 +1295,7 @@ public StringModel(AutoRestSwaggerBATService client) { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, new Base64UrlJsonConverter()); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1331,6 +1351,8 @@ public StringModel(AutoRestSwaggerBATService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1371,7 +1393,7 @@ public StringModel(AutoRestSwaggerBATService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1400,7 +1422,7 @@ public StringModel(AutoRestSwaggerBATService client) { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, new Base64UrlJsonConverter()); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1466,6 +1488,8 @@ public StringModel(AutoRestSwaggerBATService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1512,7 +1536,7 @@ public StringModel(AutoRestSwaggerBATService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1579,6 +1603,8 @@ public StringModel(AutoRestSwaggerBATService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1619,7 +1645,7 @@ public StringModel(AutoRestSwaggerBATService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1648,7 +1674,7 @@ public StringModel(AutoRestSwaggerBATService client) { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, new Base64UrlJsonConverter()); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/CompositeBoolIntClient/BoolModel.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/CompositeBoolIntClient/BoolModel.cs index 8874acafbc..241871a28b 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/CompositeBoolIntClient/BoolModel.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/CompositeBoolIntClient/BoolModel.cs @@ -86,6 +86,8 @@ public BoolModel(CompositeBoolInt client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -126,7 +128,7 @@ public BoolModel(CompositeBoolInt client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -155,7 +157,7 @@ public BoolModel(CompositeBoolInt client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -211,6 +213,8 @@ public BoolModel(CompositeBoolInt client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -254,7 +258,7 @@ public BoolModel(CompositeBoolInt client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -321,6 +325,8 @@ public BoolModel(CompositeBoolInt client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -361,7 +367,7 @@ public BoolModel(CompositeBoolInt client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -390,7 +396,7 @@ public BoolModel(CompositeBoolInt client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -446,6 +452,8 @@ public BoolModel(CompositeBoolInt client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -489,7 +497,7 @@ public BoolModel(CompositeBoolInt client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -556,6 +564,8 @@ public BoolModel(CompositeBoolInt client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -596,7 +606,7 @@ public BoolModel(CompositeBoolInt client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -625,7 +635,7 @@ public BoolModel(CompositeBoolInt client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -681,6 +691,8 @@ public BoolModel(CompositeBoolInt client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -721,7 +733,7 @@ public BoolModel(CompositeBoolInt client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -750,7 +762,7 @@ public BoolModel(CompositeBoolInt client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/CompositeBoolIntClient/CompositeBoolInt.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/CompositeBoolIntClient/CompositeBoolInt.cs index 656ef1bae7..90ea22cca6 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/CompositeBoolIntClient/CompositeBoolInt.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/CompositeBoolIntClient/CompositeBoolInt.cs @@ -31,12 +31,12 @@ public partial class CompositeBoolInt : ServiceClient, ICompos /// /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// Gets the IBoolModel. @@ -130,27 +130,27 @@ private void Initialize() BoolModel = new BoolModel(this); IntModel = new IntModel(this); BaseUri = new System.Uri("http://localhost"); - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/CompositeBoolIntClient/ICompositeBoolInt.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/CompositeBoolIntClient/ICompositeBoolInt.cs index 50f2c7fb05..5e7a4b8456 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/CompositeBoolIntClient/ICompositeBoolInt.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/CompositeBoolIntClient/ICompositeBoolInt.cs @@ -25,12 +25,12 @@ public partial interface ICompositeBoolInt : System.IDisposable /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/CompositeBoolIntClient/IntModel.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/CompositeBoolIntClient/IntModel.cs index 614fd1bf58..8e528dab9a 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/CompositeBoolIntClient/IntModel.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/CompositeBoolIntClient/IntModel.cs @@ -87,6 +87,8 @@ public IntModel(CompositeBoolInt client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -127,7 +129,7 @@ public IntModel(CompositeBoolInt client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -156,7 +158,7 @@ public IntModel(CompositeBoolInt client) { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -212,6 +214,8 @@ public IntModel(CompositeBoolInt client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -252,7 +256,7 @@ public IntModel(CompositeBoolInt client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -281,7 +285,7 @@ public IntModel(CompositeBoolInt client) { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -337,6 +341,8 @@ public IntModel(CompositeBoolInt client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -377,7 +383,7 @@ public IntModel(CompositeBoolInt client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -406,7 +412,7 @@ public IntModel(CompositeBoolInt client) { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -462,6 +468,8 @@ public IntModel(CompositeBoolInt client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -502,7 +510,7 @@ public IntModel(CompositeBoolInt client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -531,7 +539,7 @@ public IntModel(CompositeBoolInt client) { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -587,6 +595,8 @@ public IntModel(CompositeBoolInt client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -627,7 +637,7 @@ public IntModel(CompositeBoolInt client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -656,7 +666,7 @@ public IntModel(CompositeBoolInt client) { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -712,6 +722,8 @@ public IntModel(CompositeBoolInt client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -752,7 +764,7 @@ public IntModel(CompositeBoolInt client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -781,7 +793,7 @@ public IntModel(CompositeBoolInt client) { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -837,6 +849,8 @@ public IntModel(CompositeBoolInt client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -880,7 +894,7 @@ public IntModel(CompositeBoolInt client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -947,6 +961,8 @@ public IntModel(CompositeBoolInt client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -990,7 +1006,7 @@ public IntModel(CompositeBoolInt client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1057,6 +1073,8 @@ public IntModel(CompositeBoolInt client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1100,7 +1118,7 @@ public IntModel(CompositeBoolInt client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1167,6 +1185,8 @@ public IntModel(CompositeBoolInt client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1210,7 +1230,7 @@ public IntModel(CompositeBoolInt client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1277,6 +1297,8 @@ public IntModel(CompositeBoolInt client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1317,7 +1339,7 @@ public IntModel(CompositeBoolInt client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1346,7 +1368,7 @@ public IntModel(CompositeBoolInt client) { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, new UnixTimeJsonConverter()); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1402,6 +1424,8 @@ public IntModel(CompositeBoolInt client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1445,7 +1469,7 @@ public IntModel(CompositeBoolInt client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1512,6 +1536,8 @@ public IntModel(CompositeBoolInt client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1552,7 +1578,7 @@ public IntModel(CompositeBoolInt client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1581,7 +1607,7 @@ public IntModel(CompositeBoolInt client) { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, new UnixTimeJsonConverter()); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1637,6 +1663,8 @@ public IntModel(CompositeBoolInt client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1677,7 +1705,7 @@ public IntModel(CompositeBoolInt client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1706,7 +1734,7 @@ public IntModel(CompositeBoolInt client) { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, new UnixTimeJsonConverter()); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/CustomBaseUri/AutoRestParameterizedHostTestClient.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/CustomBaseUri/AutoRestParameterizedHostTestClient.cs index 85f7853d91..d0524d5739 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/CustomBaseUri/AutoRestParameterizedHostTestClient.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/CustomBaseUri/AutoRestParameterizedHostTestClient.cs @@ -30,12 +30,12 @@ public partial class AutoRestParameterizedHostTestClient : ServiceClient /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// A string value that is used as a global part of the parameterized host @@ -84,27 +84,27 @@ private void Initialize() Paths = new Paths(this); BaseUri = "http://{accountName}{host}"; Host = "host"; - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/CustomBaseUri/IAutoRestParameterizedHostTestClient.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/CustomBaseUri/IAutoRestParameterizedHostTestClient.cs index 26838a9ac3..f59ff5a722 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/CustomBaseUri/IAutoRestParameterizedHostTestClient.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/CustomBaseUri/IAutoRestParameterizedHostTestClient.cs @@ -23,12 +23,12 @@ public partial interface IAutoRestParameterizedHostTestClient : System.IDisposab /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// /// A string value that is used as a global part of the parameterized diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/CustomBaseUri/Paths.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/CustomBaseUri/Paths.cs index 0c6072fded..94b0a90910 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/CustomBaseUri/Paths.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/CustomBaseUri/Paths.cs @@ -103,6 +103,8 @@ public Paths(AutoRestParameterizedHostTestClient client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -143,7 +145,7 @@ public Paths(AutoRestParameterizedHostTestClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/AutoRestParameterizedCustomHostTestClient.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/AutoRestParameterizedCustomHostTestClient.cs index 43ca90dff5..e8bf7a75da 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/AutoRestParameterizedCustomHostTestClient.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/AutoRestParameterizedCustomHostTestClient.cs @@ -30,12 +30,12 @@ public partial class AutoRestParameterizedCustomHostTestClient : ServiceClient /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// The subscription id with value 'test12'. @@ -90,27 +90,27 @@ private void Initialize() Paths = new Paths(this); BaseUri = "{vault}{secret}{dnsSuffix}"; DnsSuffix = "host"; - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/IAutoRestParameterizedCustomHostTestClient.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/IAutoRestParameterizedCustomHostTestClient.cs index 31c559bd1e..3d2802600d 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/IAutoRestParameterizedCustomHostTestClient.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/IAutoRestParameterizedCustomHostTestClient.cs @@ -23,12 +23,12 @@ public partial interface IAutoRestParameterizedCustomHostTestClient : System.IDi /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// /// The subscription id with value 'test12'. diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/Paths.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/Paths.cs index 6b6fffee97..613973df84 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/Paths.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/CustomBaseUriMoreOptions/Paths.cs @@ -139,6 +139,8 @@ public Paths(AutoRestParameterizedCustomHostTestClient client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -179,7 +181,7 @@ public Paths(AutoRestParameterizedCustomHostTestClient client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Header/AutoRestSwaggerBATHeaderService.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Header/AutoRestSwaggerBATHeaderService.cs index 6301571899..cf6a29906d 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Header/AutoRestSwaggerBATHeaderService.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Header/AutoRestSwaggerBATHeaderService.cs @@ -30,12 +30,12 @@ public partial class AutoRestSwaggerBATHeaderService : ServiceClient /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// Gets the IHeader. @@ -123,27 +123,27 @@ private void Initialize() { Header = new Header(this); BaseUri = new System.Uri("http://localhost"); - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Header/Header.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Header/Header.cs index fed70d3483..cd4401f5dd 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Header/Header.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Header/Header.cs @@ -106,6 +106,8 @@ public Header(AutoRestSwaggerBATHeaderService client) } _httpRequest.Headers.TryAddWithoutValidation("User-Agent", userAgent); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -146,7 +148,7 @@ public Header(AutoRestSwaggerBATHeaderService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -210,6 +212,8 @@ public Header(AutoRestSwaggerBATHeaderService client) _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -250,7 +254,7 @@ public Header(AutoRestSwaggerBATHeaderService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -273,9 +277,9 @@ public Header(AutoRestSwaggerBATHeaderService client) _result.Response = _httpResponse; try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -349,6 +353,8 @@ public Header(AutoRestSwaggerBATHeaderService client) } _httpRequest.Headers.TryAddWithoutValidation("Content-Type", contentType); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -389,7 +395,7 @@ public Header(AutoRestSwaggerBATHeaderService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -453,6 +459,8 @@ public Header(AutoRestSwaggerBATHeaderService client) _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -493,7 +501,7 @@ public Header(AutoRestSwaggerBATHeaderService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -516,9 +524,9 @@ public Header(AutoRestSwaggerBATHeaderService client) _result.Response = _httpResponse; try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -602,6 +610,8 @@ public Header(AutoRestSwaggerBATHeaderService client) _httpRequest.Headers.Remove("value"); } _httpRequest.Headers.TryAddWithoutValidation("value", SafeJsonConvert.SerializeObject(value, Client.SerializationSettings).Trim('"')); + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -642,7 +652,7 @@ public Header(AutoRestSwaggerBATHeaderService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -728,6 +738,8 @@ public Header(AutoRestSwaggerBATHeaderService client) } _httpRequest.Headers.TryAddWithoutValidation("scenario", scenario); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -768,7 +780,7 @@ public Header(AutoRestSwaggerBATHeaderService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -791,9 +803,9 @@ public Header(AutoRestSwaggerBATHeaderService client) _result.Response = _httpResponse; try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -877,6 +889,8 @@ public Header(AutoRestSwaggerBATHeaderService client) _httpRequest.Headers.Remove("value"); } _httpRequest.Headers.TryAddWithoutValidation("value", SafeJsonConvert.SerializeObject(value, Client.SerializationSettings).Trim('"')); + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -917,7 +931,7 @@ public Header(AutoRestSwaggerBATHeaderService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1003,6 +1017,8 @@ public Header(AutoRestSwaggerBATHeaderService client) } _httpRequest.Headers.TryAddWithoutValidation("scenario", scenario); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1043,7 +1059,7 @@ public Header(AutoRestSwaggerBATHeaderService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1066,9 +1082,9 @@ public Header(AutoRestSwaggerBATHeaderService client) _result.Response = _httpResponse; try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1152,6 +1168,8 @@ public Header(AutoRestSwaggerBATHeaderService client) _httpRequest.Headers.Remove("value"); } _httpRequest.Headers.TryAddWithoutValidation("value", SafeJsonConvert.SerializeObject(value, Client.SerializationSettings).Trim('"')); + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1192,7 +1210,7 @@ public Header(AutoRestSwaggerBATHeaderService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1278,6 +1296,8 @@ public Header(AutoRestSwaggerBATHeaderService client) } _httpRequest.Headers.TryAddWithoutValidation("scenario", scenario); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1318,7 +1338,7 @@ public Header(AutoRestSwaggerBATHeaderService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1341,9 +1361,9 @@ public Header(AutoRestSwaggerBATHeaderService client) _result.Response = _httpResponse; try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1427,6 +1447,8 @@ public Header(AutoRestSwaggerBATHeaderService client) _httpRequest.Headers.Remove("value"); } _httpRequest.Headers.TryAddWithoutValidation("value", SafeJsonConvert.SerializeObject(value, Client.SerializationSettings).Trim('"')); + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1467,7 +1489,7 @@ public Header(AutoRestSwaggerBATHeaderService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1553,6 +1575,8 @@ public Header(AutoRestSwaggerBATHeaderService client) } _httpRequest.Headers.TryAddWithoutValidation("scenario", scenario); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1593,7 +1617,7 @@ public Header(AutoRestSwaggerBATHeaderService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1616,9 +1640,9 @@ public Header(AutoRestSwaggerBATHeaderService client) _result.Response = _httpResponse; try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1702,6 +1726,8 @@ public Header(AutoRestSwaggerBATHeaderService client) _httpRequest.Headers.Remove("value"); } _httpRequest.Headers.TryAddWithoutValidation("value", SafeJsonConvert.SerializeObject(value, Client.SerializationSettings).Trim('"')); + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1742,7 +1768,7 @@ public Header(AutoRestSwaggerBATHeaderService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1828,6 +1854,8 @@ public Header(AutoRestSwaggerBATHeaderService client) } _httpRequest.Headers.TryAddWithoutValidation("scenario", scenario); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1868,7 +1896,7 @@ public Header(AutoRestSwaggerBATHeaderService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1891,9 +1919,9 @@ public Header(AutoRestSwaggerBATHeaderService client) _result.Response = _httpResponse; try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1983,6 +2011,8 @@ public Header(AutoRestSwaggerBATHeaderService client) } _httpRequest.Headers.TryAddWithoutValidation("value", value); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2023,7 +2053,7 @@ public Header(AutoRestSwaggerBATHeaderService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2111,6 +2141,8 @@ public Header(AutoRestSwaggerBATHeaderService client) } _httpRequest.Headers.TryAddWithoutValidation("scenario", scenario); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2151,7 +2183,7 @@ public Header(AutoRestSwaggerBATHeaderService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2174,9 +2206,9 @@ public Header(AutoRestSwaggerBATHeaderService client) _result.Response = _httpResponse; try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2260,6 +2292,8 @@ public Header(AutoRestSwaggerBATHeaderService client) _httpRequest.Headers.Remove("value"); } _httpRequest.Headers.TryAddWithoutValidation("value", SafeJsonConvert.SerializeObject(value, new DateJsonConverter()).Trim('"')); + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2300,7 +2334,7 @@ public Header(AutoRestSwaggerBATHeaderService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2386,6 +2420,8 @@ public Header(AutoRestSwaggerBATHeaderService client) } _httpRequest.Headers.TryAddWithoutValidation("scenario", scenario); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2426,7 +2462,7 @@ public Header(AutoRestSwaggerBATHeaderService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2449,9 +2485,9 @@ public Header(AutoRestSwaggerBATHeaderService client) _result.Response = _httpResponse; try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2537,6 +2573,8 @@ public Header(AutoRestSwaggerBATHeaderService client) _httpRequest.Headers.Remove("value"); } _httpRequest.Headers.TryAddWithoutValidation("value", SafeJsonConvert.SerializeObject(value, Client.SerializationSettings).Trim('"')); + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2577,7 +2615,7 @@ public Header(AutoRestSwaggerBATHeaderService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2664,6 +2702,8 @@ public Header(AutoRestSwaggerBATHeaderService client) } _httpRequest.Headers.TryAddWithoutValidation("scenario", scenario); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2704,7 +2744,7 @@ public Header(AutoRestSwaggerBATHeaderService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2727,9 +2767,9 @@ public Header(AutoRestSwaggerBATHeaderService client) _result.Response = _httpResponse; try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2818,6 +2858,8 @@ public Header(AutoRestSwaggerBATHeaderService client) } _httpRequest.Headers.TryAddWithoutValidation("value", SafeJsonConvert.SerializeObject(value, new DateTimeRfc1123JsonConverter()).Trim('"')); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2858,7 +2900,7 @@ public Header(AutoRestSwaggerBATHeaderService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2945,6 +2987,8 @@ public Header(AutoRestSwaggerBATHeaderService client) } _httpRequest.Headers.TryAddWithoutValidation("scenario", scenario); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2985,7 +3029,7 @@ public Header(AutoRestSwaggerBATHeaderService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3008,9 +3052,9 @@ public Header(AutoRestSwaggerBATHeaderService client) _result.Response = _httpResponse; try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -3094,6 +3138,8 @@ public Header(AutoRestSwaggerBATHeaderService client) _httpRequest.Headers.Remove("value"); } _httpRequest.Headers.TryAddWithoutValidation("value", SafeJsonConvert.SerializeObject(value, Client.SerializationSettings).Trim('"')); + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3134,7 +3180,7 @@ public Header(AutoRestSwaggerBATHeaderService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3220,6 +3266,8 @@ public Header(AutoRestSwaggerBATHeaderService client) } _httpRequest.Headers.TryAddWithoutValidation("scenario", scenario); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3260,7 +3308,7 @@ public Header(AutoRestSwaggerBATHeaderService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3283,9 +3331,9 @@ public Header(AutoRestSwaggerBATHeaderService client) _result.Response = _httpResponse; try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -3376,6 +3424,8 @@ public Header(AutoRestSwaggerBATHeaderService client) } _httpRequest.Headers.TryAddWithoutValidation("value", SafeJsonConvert.SerializeObject(value, Client.SerializationSettings).Trim('"')); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3416,7 +3466,7 @@ public Header(AutoRestSwaggerBATHeaderService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3502,6 +3552,8 @@ public Header(AutoRestSwaggerBATHeaderService client) } _httpRequest.Headers.TryAddWithoutValidation("scenario", scenario); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3542,7 +3594,7 @@ public Header(AutoRestSwaggerBATHeaderService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3565,9 +3617,9 @@ public Header(AutoRestSwaggerBATHeaderService client) _result.Response = _httpResponse; try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -3656,6 +3708,8 @@ public Header(AutoRestSwaggerBATHeaderService client) } _httpRequest.Headers.TryAddWithoutValidation("value", SafeJsonConvert.SerializeObject(value, Client.SerializationSettings).Trim('"')); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3696,7 +3750,7 @@ public Header(AutoRestSwaggerBATHeaderService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3783,6 +3837,8 @@ public Header(AutoRestSwaggerBATHeaderService client) } _httpRequest.Headers.TryAddWithoutValidation("scenario", scenario); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3823,7 +3879,7 @@ public Header(AutoRestSwaggerBATHeaderService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3846,9 +3902,9 @@ public Header(AutoRestSwaggerBATHeaderService client) _result.Response = _httpResponse; try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -3901,6 +3957,8 @@ public Header(AutoRestSwaggerBATHeaderService client) _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3941,7 +3999,7 @@ public Header(AutoRestSwaggerBATHeaderService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Header/IAutoRestSwaggerBATHeaderService.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Header/IAutoRestSwaggerBATHeaderService.cs index 91f5ff773f..369245dbb8 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Header/IAutoRestSwaggerBATHeaderService.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Header/IAutoRestSwaggerBATHeaderService.cs @@ -24,12 +24,12 @@ public partial interface IAutoRestSwaggerBATHeaderService : System.IDisposable /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Header/Models/GreyscaleColors.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Header/Models/GreyscaleColors.cs index 749dafc8cc..ae9512affa 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Header/Models/GreyscaleColors.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Header/Models/GreyscaleColors.cs @@ -17,7 +17,7 @@ namespace Fixtures.AcceptanceTestsHeader.Models /// /// Defines values for GreyscaleColors. /// - [JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] + [JsonConverter(typeof(StringEnumConverter))] public enum GreyscaleColors { [EnumMember(Value = "White")] @@ -27,5 +27,38 @@ public enum GreyscaleColors [EnumMember(Value = "GREY")] GREY } + internal static class GreyscaleColorsEnumExtension + { + internal static string ToSerializedValue(this GreyscaleColors? value ) => + value == null ? null : (( GreyscaleColors )value).ToSerializedValue(); + + internal static string ToSerializedValue(this GreyscaleColors value ) + { + switch( value ) + { + case GreyscaleColors.White: + return "White"; + case GreyscaleColors.Black: + return "black"; + case GreyscaleColors.GREY: + return "GREY"; + } + return null; + } + + internal static GreyscaleColors? ParseGreyscaleColors( this string value ) + { + switch( value ) + { + case "White": + return GreyscaleColors.White; + case "black": + return GreyscaleColors.Black; + case "GREY": + return GreyscaleColors.GREY; + } + return null; + } + } } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Http/AutoRestHttpInfrastructureTestService.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Http/AutoRestHttpInfrastructureTestService.cs index 76f281c86f..1cbfa1ed95 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Http/AutoRestHttpInfrastructureTestService.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Http/AutoRestHttpInfrastructureTestService.cs @@ -30,12 +30,12 @@ public partial class AutoRestHttpInfrastructureTestService : ServiceClient /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// Gets the IHttpFailure. @@ -159,27 +159,27 @@ private void Initialize() HttpRetry = new HttpRetry(this); MultipleResponses = new MultipleResponses(this); BaseUri = new System.Uri("http://localhost"); - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Http/HttpClientFailure.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Http/HttpClientFailure.cs index 031157f53d..7b267909e6 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Http/HttpClientFailure.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Http/HttpClientFailure.cs @@ -83,6 +83,8 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("HEAD"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -123,7 +125,7 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -149,7 +151,7 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_defaultResponseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -201,6 +203,8 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -241,7 +245,7 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -267,7 +271,7 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_defaultResponseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -323,6 +327,8 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -369,7 +375,7 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -395,7 +401,7 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_defaultResponseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -451,6 +457,8 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PATCH"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -497,7 +505,7 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -523,7 +531,7 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_defaultResponseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -579,6 +587,8 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -625,7 +635,7 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -651,7 +661,7 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_defaultResponseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -707,6 +717,8 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("DELETE"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -753,7 +765,7 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -779,7 +791,7 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_defaultResponseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -831,6 +843,8 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("HEAD"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -871,7 +885,7 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -897,7 +911,7 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_defaultResponseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -949,6 +963,8 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -989,7 +1005,7 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1015,7 +1031,7 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_defaultResponseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1067,6 +1083,8 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1107,7 +1125,7 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1133,7 +1151,7 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_defaultResponseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1189,6 +1207,8 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1235,7 +1255,7 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1261,7 +1281,7 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_defaultResponseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1317,6 +1337,8 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PATCH"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1363,7 +1385,7 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1389,7 +1411,7 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_defaultResponseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1445,6 +1467,8 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1491,7 +1515,7 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1517,7 +1541,7 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_defaultResponseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1573,6 +1597,8 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("DELETE"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1619,7 +1645,7 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1645,7 +1671,7 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_defaultResponseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1701,6 +1727,8 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1747,7 +1775,7 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1773,7 +1801,7 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_defaultResponseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1825,6 +1853,8 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("HEAD"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1865,7 +1895,7 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1891,7 +1921,7 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_defaultResponseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1943,6 +1973,8 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1983,7 +2015,7 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2009,7 +2041,7 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_defaultResponseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2061,6 +2093,8 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2101,7 +2135,7 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2127,7 +2161,7 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_defaultResponseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2183,6 +2217,8 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2229,7 +2265,7 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2255,7 +2291,7 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_defaultResponseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2311,6 +2347,8 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PATCH"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2357,7 +2395,7 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2383,7 +2421,7 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_defaultResponseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2439,6 +2477,8 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2485,7 +2525,7 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2511,7 +2551,7 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_defaultResponseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2563,6 +2603,8 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2603,7 +2645,7 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2629,7 +2671,7 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_defaultResponseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2685,6 +2727,8 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("DELETE"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2731,7 +2775,7 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2757,7 +2801,7 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_defaultResponseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2809,6 +2853,8 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("HEAD"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2849,7 +2895,7 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2875,7 +2921,7 @@ public HttpClientFailure(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_defaultResponseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Http/HttpFailure.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Http/HttpFailure.cs index 3995b44dcd..187278db3e 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Http/HttpFailure.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Http/HttpFailure.cs @@ -86,6 +86,8 @@ public HttpFailure(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -126,7 +128,7 @@ public HttpFailure(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -155,7 +157,7 @@ public HttpFailure(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -211,6 +213,8 @@ public HttpFailure(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -273,7 +277,7 @@ public HttpFailure(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -329,6 +333,8 @@ public HttpFailure(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -391,7 +397,7 @@ public HttpFailure(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Http/HttpRedirects.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Http/HttpRedirects.cs index 0bf999d65e..d5579e06f9 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Http/HttpRedirects.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Http/HttpRedirects.cs @@ -83,6 +83,8 @@ public HttpRedirects(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("HEAD"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -123,7 +125,7 @@ public HttpRedirects(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -146,9 +148,9 @@ public HttpRedirects(AutoRestHttpInfrastructureTestService client) _result.Response = _httpResponse; try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -203,6 +205,8 @@ public HttpRedirects(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -243,7 +247,7 @@ public HttpRedirects(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -272,7 +276,7 @@ public HttpRedirects(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -284,9 +288,9 @@ public HttpRedirects(AutoRestHttpInfrastructureTestService client) } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -338,6 +342,8 @@ public HttpRedirects(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("HEAD"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -378,7 +384,7 @@ public HttpRedirects(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -401,9 +407,9 @@ public HttpRedirects(AutoRestHttpInfrastructureTestService client) _result.Response = _httpResponse; try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -455,6 +461,8 @@ public HttpRedirects(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -495,7 +503,7 @@ public HttpRedirects(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -518,9 +526,9 @@ public HttpRedirects(AutoRestHttpInfrastructureTestService client) _result.Response = _httpResponse; try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -578,6 +586,8 @@ public HttpRedirects(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -624,7 +634,7 @@ public HttpRedirects(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -647,9 +657,9 @@ public HttpRedirects(AutoRestHttpInfrastructureTestService client) _result.Response = _httpResponse; try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -701,6 +711,8 @@ public HttpRedirects(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("HEAD"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -741,7 +753,7 @@ public HttpRedirects(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -764,9 +776,9 @@ public HttpRedirects(AutoRestHttpInfrastructureTestService client) _result.Response = _httpResponse; try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -818,6 +830,8 @@ public HttpRedirects(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -858,7 +872,7 @@ public HttpRedirects(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -881,9 +895,9 @@ public HttpRedirects(AutoRestHttpInfrastructureTestService client) _result.Response = _httpResponse; try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -941,6 +955,8 @@ public HttpRedirects(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PATCH"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -987,7 +1003,7 @@ public HttpRedirects(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1010,9 +1026,9 @@ public HttpRedirects(AutoRestHttpInfrastructureTestService client) _result.Response = _httpResponse; try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1070,6 +1086,8 @@ public HttpRedirects(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1116,7 +1134,7 @@ public HttpRedirects(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1139,9 +1157,9 @@ public HttpRedirects(AutoRestHttpInfrastructureTestService client) _result.Response = _httpResponse; try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1193,6 +1211,8 @@ public HttpRedirects(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("HEAD"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1233,7 +1253,7 @@ public HttpRedirects(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1256,9 +1276,9 @@ public HttpRedirects(AutoRestHttpInfrastructureTestService client) _result.Response = _httpResponse; try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1310,6 +1330,8 @@ public HttpRedirects(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1350,7 +1372,7 @@ public HttpRedirects(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1373,9 +1395,9 @@ public HttpRedirects(AutoRestHttpInfrastructureTestService client) _result.Response = _httpResponse; try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1431,6 +1453,8 @@ public HttpRedirects(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1477,7 +1501,7 @@ public HttpRedirects(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1500,9 +1524,9 @@ public HttpRedirects(AutoRestHttpInfrastructureTestService client) _result.Response = _httpResponse; try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1558,6 +1582,8 @@ public HttpRedirects(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PATCH"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1604,7 +1630,7 @@ public HttpRedirects(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1627,9 +1653,9 @@ public HttpRedirects(AutoRestHttpInfrastructureTestService client) _result.Response = _httpResponse; try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1685,6 +1711,8 @@ public HttpRedirects(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1731,7 +1759,7 @@ public HttpRedirects(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1754,9 +1782,9 @@ public HttpRedirects(AutoRestHttpInfrastructureTestService client) _result.Response = _httpResponse; try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1812,6 +1840,8 @@ public HttpRedirects(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("DELETE"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1858,7 +1888,7 @@ public HttpRedirects(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1881,9 +1911,9 @@ public HttpRedirects(AutoRestHttpInfrastructureTestService client) _result.Response = _httpResponse; try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(Client.DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(Client.DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Http/HttpRetry.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Http/HttpRetry.cs index 8368b38778..f48d9ef872 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Http/HttpRetry.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Http/HttpRetry.cs @@ -83,6 +83,8 @@ public HttpRetry(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("HEAD"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -123,7 +125,7 @@ public HttpRetry(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -191,6 +193,8 @@ public HttpRetry(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -237,7 +241,7 @@ public HttpRetry(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -305,6 +309,8 @@ public HttpRetry(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PATCH"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -351,7 +357,7 @@ public HttpRetry(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -415,6 +421,8 @@ public HttpRetry(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -455,7 +463,7 @@ public HttpRetry(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -523,6 +531,8 @@ public HttpRetry(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -569,7 +579,7 @@ public HttpRetry(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -637,6 +647,8 @@ public HttpRetry(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("DELETE"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -683,7 +695,7 @@ public HttpRetry(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -751,6 +763,8 @@ public HttpRetry(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -797,7 +811,7 @@ public HttpRetry(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -865,6 +879,8 @@ public HttpRetry(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PATCH"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -911,7 +927,7 @@ public HttpRetry(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Http/HttpServerFailure.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Http/HttpServerFailure.cs index 1782eee22e..d65513537c 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Http/HttpServerFailure.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Http/HttpServerFailure.cs @@ -83,6 +83,8 @@ public HttpServerFailure(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("HEAD"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -123,7 +125,7 @@ public HttpServerFailure(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -149,7 +151,7 @@ public HttpServerFailure(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_defaultResponseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -201,6 +203,8 @@ public HttpServerFailure(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -241,7 +245,7 @@ public HttpServerFailure(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -267,7 +271,7 @@ public HttpServerFailure(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_defaultResponseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -323,6 +327,8 @@ public HttpServerFailure(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -369,7 +375,7 @@ public HttpServerFailure(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -395,7 +401,7 @@ public HttpServerFailure(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_defaultResponseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -451,6 +457,8 @@ public HttpServerFailure(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("DELETE"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -497,7 +505,7 @@ public HttpServerFailure(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -523,7 +531,7 @@ public HttpServerFailure(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_defaultResponseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Http/HttpSuccess.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Http/HttpSuccess.cs index 5405a55e23..28c78b62aa 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Http/HttpSuccess.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Http/HttpSuccess.cs @@ -83,6 +83,8 @@ public HttpSuccess(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("HEAD"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -123,7 +125,7 @@ public HttpSuccess(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -190,6 +192,8 @@ public HttpSuccess(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -230,7 +234,7 @@ public HttpSuccess(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -259,7 +263,7 @@ public HttpSuccess(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -316,6 +320,8 @@ public HttpSuccess(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -362,7 +368,7 @@ public HttpSuccess(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -430,6 +436,8 @@ public HttpSuccess(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PATCH"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -476,7 +484,7 @@ public HttpSuccess(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -544,6 +552,8 @@ public HttpSuccess(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -590,7 +600,7 @@ public HttpSuccess(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -658,6 +668,8 @@ public HttpSuccess(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("DELETE"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -704,7 +716,7 @@ public HttpSuccess(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -772,6 +784,8 @@ public HttpSuccess(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -818,7 +832,7 @@ public HttpSuccess(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -886,6 +900,8 @@ public HttpSuccess(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -932,7 +948,7 @@ public HttpSuccess(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1000,6 +1016,8 @@ public HttpSuccess(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1046,7 +1064,7 @@ public HttpSuccess(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1114,6 +1132,8 @@ public HttpSuccess(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PATCH"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1160,7 +1180,7 @@ public HttpSuccess(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1228,6 +1248,8 @@ public HttpSuccess(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1274,7 +1296,7 @@ public HttpSuccess(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1342,6 +1364,8 @@ public HttpSuccess(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("DELETE"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1388,7 +1412,7 @@ public HttpSuccess(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1452,6 +1476,8 @@ public HttpSuccess(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("HEAD"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1492,7 +1518,7 @@ public HttpSuccess(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1560,6 +1586,8 @@ public HttpSuccess(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1606,7 +1634,7 @@ public HttpSuccess(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1674,6 +1702,8 @@ public HttpSuccess(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PATCH"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1720,7 +1750,7 @@ public HttpSuccess(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1788,6 +1818,8 @@ public HttpSuccess(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1834,7 +1866,7 @@ public HttpSuccess(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1902,6 +1934,8 @@ public HttpSuccess(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("DELETE"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1948,7 +1982,7 @@ public HttpSuccess(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2012,6 +2046,8 @@ public HttpSuccess(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("HEAD"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2052,7 +2088,7 @@ public HttpSuccess(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Http/IAutoRestHttpInfrastructureTestService.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Http/IAutoRestHttpInfrastructureTestService.cs index eaf9ab8592..e9f27aaf70 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Http/IAutoRestHttpInfrastructureTestService.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Http/IAutoRestHttpInfrastructureTestService.cs @@ -24,12 +24,12 @@ public partial interface IAutoRestHttpInfrastructureTestService : System.IDispos /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Http/MultipleResponses.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Http/MultipleResponses.cs index 7a1d4d3af8..d3902915fa 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Http/MultipleResponses.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Http/MultipleResponses.cs @@ -86,6 +86,8 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -126,7 +128,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -155,7 +157,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -211,6 +213,8 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -251,7 +255,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -280,7 +284,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -336,6 +340,8 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -376,7 +382,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -405,7 +411,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -461,6 +467,8 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -501,7 +509,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -530,7 +538,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -587,6 +595,8 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -627,7 +637,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -656,7 +666,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -712,6 +722,8 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -752,7 +764,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -781,7 +793,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -799,7 +811,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -856,6 +868,8 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -896,7 +910,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -925,7 +939,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -943,7 +957,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1000,6 +1014,8 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1040,7 +1056,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1069,7 +1085,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1087,7 +1103,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1143,6 +1159,8 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1183,7 +1201,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1212,7 +1230,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1230,7 +1248,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1248,7 +1266,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1304,6 +1322,8 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1344,7 +1364,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1373,7 +1393,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1391,7 +1411,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1409,7 +1429,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1465,6 +1485,8 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1505,7 +1527,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1534,7 +1556,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1552,7 +1574,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1570,7 +1592,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1627,6 +1649,8 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1667,7 +1691,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1696,7 +1720,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1714,7 +1738,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1732,7 +1756,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1785,6 +1809,8 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1825,7 +1851,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1889,6 +1915,8 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1929,7 +1957,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1994,6 +2022,8 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2034,7 +2064,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2098,6 +2128,8 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2195,6 +2227,8 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2292,6 +2326,8 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2389,6 +2425,8 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2486,6 +2524,8 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2526,7 +2566,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2552,7 +2592,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_defaultResponseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2604,6 +2644,8 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2644,7 +2686,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2670,7 +2712,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_defaultResponseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2722,6 +2764,8 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2762,7 +2806,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2788,7 +2832,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_defaultResponseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2840,6 +2884,8 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2880,7 +2926,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2906,7 +2952,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_defaultResponseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2958,6 +3004,8 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3055,6 +3103,8 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3152,6 +3202,8 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3249,6 +3301,8 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3350,6 +3404,8 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3412,7 +3468,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -3468,6 +3524,8 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3530,7 +3588,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -3586,6 +3644,8 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3648,7 +3708,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -3705,6 +3765,8 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3767,7 +3829,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -3823,6 +3885,8 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3885,7 +3949,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -3941,6 +4005,8 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -4003,7 +4069,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -4059,6 +4125,8 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -4121,7 +4189,7 @@ public MultipleResponses(AutoRestHttpInfrastructureTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/ModelFlattening/AutoRestResourceFlatteningTestService.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/ModelFlattening/AutoRestResourceFlatteningTestService.cs index 2cb0c8c671..bfebe37926 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/ModelFlattening/AutoRestResourceFlatteningTestService.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/ModelFlattening/AutoRestResourceFlatteningTestService.cs @@ -32,12 +32,12 @@ public partial class AutoRestResourceFlatteningTestService : ServiceClient /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// Initializes a new instance of the AutoRestResourceFlatteningTestService class. @@ -119,28 +119,28 @@ public AutoRestResourceFlatteningTestService(System.Uri baseUri, System.Net.Http private void Initialize() { BaseUri = new System.Uri("http://localhost"); - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; SerializationSettings.Converters.Add(new TransformationJsonConverter()); - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } @@ -189,6 +189,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -235,7 +237,7 @@ private void Initialize() ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -303,6 +305,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -343,7 +347,7 @@ private void Initialize() ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -372,7 +376,7 @@ private void Initialize() { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -430,6 +434,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -476,7 +482,7 @@ private void Initialize() ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -544,6 +550,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -584,7 +592,7 @@ private void Initialize() ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -613,7 +621,7 @@ private void Initialize() { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -671,6 +679,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -717,7 +727,7 @@ private void Initialize() ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -785,6 +795,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -825,7 +837,7 @@ private void Initialize() ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -854,7 +866,7 @@ private void Initialize() { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -919,6 +931,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -965,7 +979,7 @@ private void Initialize() ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -994,7 +1008,7 @@ private void Initialize() { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1093,6 +1107,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1139,7 +1155,7 @@ private void Initialize() ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1168,7 +1184,7 @@ private void Initialize() { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1290,6 +1306,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1336,7 +1354,7 @@ private void Initialize() ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1365,7 +1383,7 @@ private void Initialize() { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/ModelFlattening/IAutoRestResourceFlatteningTestService.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/ModelFlattening/IAutoRestResourceFlatteningTestService.cs index ac1af608ef..f48526052a 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/ModelFlattening/IAutoRestResourceFlatteningTestService.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/ModelFlattening/IAutoRestResourceFlatteningTestService.cs @@ -29,12 +29,12 @@ public partial interface IAutoRestResourceFlatteningTestService : System.IDispos /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/ParameterFlattening/AutoRestParameterFlattening.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/ParameterFlattening/AutoRestParameterFlattening.cs index cc434c0d66..6c29ab6570 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/ParameterFlattening/AutoRestParameterFlattening.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/ParameterFlattening/AutoRestParameterFlattening.cs @@ -30,12 +30,12 @@ public partial class AutoRestParameterFlattening : ServiceClient /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// Gets the IAvailabilitySets. @@ -123,27 +123,27 @@ private void Initialize() { AvailabilitySets = new AvailabilitySets(this); BaseUri = new System.Uri("http://localhost"); - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/ParameterFlattening/AvailabilitySets.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/ParameterFlattening/AvailabilitySets.cs index ab6ea05055..f0842beb5f 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/ParameterFlattening/AvailabilitySets.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/ParameterFlattening/AvailabilitySets.cs @@ -126,6 +126,8 @@ public AvailabilitySets(AutoRestParameterFlattening client) _httpRequest.Method = new System.Net.Http.HttpMethod("PATCH"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/ParameterFlattening/IAutoRestParameterFlattening.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/ParameterFlattening/IAutoRestParameterFlattening.cs index 1d5af99b8e..109208791e 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/ParameterFlattening/IAutoRestParameterFlattening.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/ParameterFlattening/IAutoRestParameterFlattening.cs @@ -24,12 +24,12 @@ public partial interface IAutoRestParameterFlattening : System.IDisposable /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Report/AutoRestReportService.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Report/AutoRestReportService.cs index 60ae55f247..317a5dfb72 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Report/AutoRestReportService.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Report/AutoRestReportService.cs @@ -32,12 +32,12 @@ public partial class AutoRestReportService : ServiceClient /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// Initializes a new instance of the AutoRestReportService class. @@ -119,27 +119,27 @@ public AutoRestReportService(System.Uri baseUri, System.Net.Http.HttpClientHandl private void Initialize() { BaseUri = new System.Uri("http://localhost"); - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } @@ -185,6 +185,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -225,7 +227,7 @@ private void Initialize() ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -254,7 +256,7 @@ private void Initialize() { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Report/IAutoRestReportService.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Report/IAutoRestReportService.cs index c8c968af79..76db9c4350 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Report/IAutoRestReportService.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Report/IAutoRestReportService.cs @@ -29,12 +29,12 @@ public partial interface IAutoRestReportService : System.IDisposable /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/RequiredOptional/AutoRestRequiredOptionalTestService.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/RequiredOptional/AutoRestRequiredOptionalTestService.cs index 24d28fb367..a53da36b64 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/RequiredOptional/AutoRestRequiredOptionalTestService.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/RequiredOptional/AutoRestRequiredOptionalTestService.cs @@ -30,12 +30,12 @@ public partial class AutoRestRequiredOptionalTestService : ServiceClient /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// number of items to skip @@ -144,27 +144,27 @@ private void Initialize() ImplicitModel = new ImplicitModel(this); ExplicitModel = new ExplicitModel(this); BaseUri = new System.Uri("http://localhost"); - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/RequiredOptional/ExplicitModel.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/RequiredOptional/ExplicitModel.cs index f6bc5c70cd..88085a2698 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/RequiredOptional/ExplicitModel.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/RequiredOptional/ExplicitModel.cs @@ -87,6 +87,8 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -130,7 +132,7 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -156,7 +158,7 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_defaultResponseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -211,6 +213,8 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -257,7 +261,7 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -328,6 +332,8 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -374,7 +380,7 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -400,7 +406,7 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_defaultResponseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -462,6 +468,8 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -508,7 +516,7 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -581,6 +589,8 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) _httpRequest.Headers.Remove("headerParameter"); } _httpRequest.Headers.TryAddWithoutValidation("headerParameter", Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(headerParameter, Client.SerializationSettings).Trim('"')); + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -621,7 +631,7 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -647,7 +657,7 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_defaultResponseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -711,6 +721,8 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) } _httpRequest.Headers.TryAddWithoutValidation("headerParameter", Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(headerParameter, Client.SerializationSettings).Trim('"')); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -751,7 +763,7 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -829,6 +841,8 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -875,7 +889,7 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -901,7 +915,7 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_defaultResponseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -956,6 +970,8 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1002,7 +1018,7 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1086,6 +1102,8 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1132,7 +1150,7 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1158,7 +1176,7 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_defaultResponseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1220,6 +1238,8 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1266,7 +1286,7 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1352,6 +1372,8 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) } _httpRequest.Headers.TryAddWithoutValidation("headerParameter", headerParameter); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1392,7 +1414,7 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1418,7 +1440,7 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_defaultResponseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1482,6 +1504,8 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) } _httpRequest.Headers.TryAddWithoutValidation("bodyParameter", bodyParameter); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1522,7 +1546,7 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1604,6 +1628,8 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1650,7 +1676,7 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1676,7 +1702,7 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_defaultResponseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1735,6 +1761,8 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1781,7 +1809,7 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1869,6 +1897,8 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1915,7 +1945,7 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1941,7 +1971,7 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_defaultResponseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2007,6 +2037,8 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2053,7 +2085,7 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2131,6 +2163,8 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2177,7 +2211,7 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2203,7 +2237,7 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_defaultResponseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2258,6 +2292,8 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2304,7 +2340,7 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2388,6 +2424,8 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2434,7 +2472,7 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2460,7 +2498,7 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_defaultResponseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2522,6 +2560,8 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2568,7 +2608,7 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2654,6 +2694,8 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) } _httpRequest.Headers.TryAddWithoutValidation("headerParameter", Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(headerParameter, Client.SerializationSettings).Trim('"')); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2694,7 +2736,7 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2720,7 +2762,7 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_defaultResponseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2784,6 +2826,8 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) } _httpRequest.Headers.TryAddWithoutValidation("headerParameter", Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(headerParameter, Client.SerializationSettings).Trim('"')); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2824,7 +2868,7 @@ public ExplicitModel(AutoRestRequiredOptionalTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/RequiredOptional/IAutoRestRequiredOptionalTestService.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/RequiredOptional/IAutoRestRequiredOptionalTestService.cs index 17f02b050a..10f671fc66 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/RequiredOptional/IAutoRestRequiredOptionalTestService.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/RequiredOptional/IAutoRestRequiredOptionalTestService.cs @@ -24,12 +24,12 @@ public partial interface IAutoRestRequiredOptionalTestService : System.IDisposab /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// /// number of items to skip diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/RequiredOptional/ImplicitModel.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/RequiredOptional/ImplicitModel.cs index 2e8691df4d..2ab9cbd342 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/RequiredOptional/ImplicitModel.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/RequiredOptional/ImplicitModel.cs @@ -97,6 +97,8 @@ public ImplicitModel(AutoRestRequiredOptionalTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -137,7 +139,7 @@ public ImplicitModel(AutoRestRequiredOptionalTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -163,7 +165,7 @@ public ImplicitModel(AutoRestRequiredOptionalTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_defaultResponseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -227,6 +229,8 @@ public ImplicitModel(AutoRestRequiredOptionalTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -267,7 +271,7 @@ public ImplicitModel(AutoRestRequiredOptionalTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -342,6 +346,8 @@ public ImplicitModel(AutoRestRequiredOptionalTestService client) } _httpRequest.Headers.TryAddWithoutValidation("queryParameter", queryParameter); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -382,7 +388,7 @@ public ImplicitModel(AutoRestRequiredOptionalTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -449,6 +455,8 @@ public ImplicitModel(AutoRestRequiredOptionalTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -495,7 +503,7 @@ public ImplicitModel(AutoRestRequiredOptionalTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -570,6 +578,8 @@ public ImplicitModel(AutoRestRequiredOptionalTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -610,7 +620,7 @@ public ImplicitModel(AutoRestRequiredOptionalTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -636,7 +646,7 @@ public ImplicitModel(AutoRestRequiredOptionalTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_defaultResponseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -707,6 +717,8 @@ public ImplicitModel(AutoRestRequiredOptionalTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -747,7 +759,7 @@ public ImplicitModel(AutoRestRequiredOptionalTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -773,7 +785,7 @@ public ImplicitModel(AutoRestRequiredOptionalTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_defaultResponseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -834,6 +846,8 @@ public ImplicitModel(AutoRestRequiredOptionalTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -874,7 +888,7 @@ public ImplicitModel(AutoRestRequiredOptionalTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -900,7 +914,7 @@ public ImplicitModel(AutoRestRequiredOptionalTestService client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject(_defaultResponseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Url/AutoRestUrlTestService.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Url/AutoRestUrlTestService.cs index bbcbac2e4e..c7a277e142 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Url/AutoRestUrlTestService.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Url/AutoRestUrlTestService.cs @@ -30,12 +30,12 @@ public partial class AutoRestUrlTestService : ServiceClient /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// A string value 'globalItemStringPath' that appears in the path @@ -145,27 +145,27 @@ private void Initialize() Queries = new Queries(this); PathItems = new PathItems(this); BaseUri = new System.Uri("http://localhost"); - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Url/IAutoRestUrlTestService.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Url/IAutoRestUrlTestService.cs index 1bd604f997..e464397f3a 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Url/IAutoRestUrlTestService.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Url/IAutoRestUrlTestService.cs @@ -24,12 +24,12 @@ public partial interface IAutoRestUrlTestService : System.IDisposable /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// /// A string value 'globalItemStringPath' that appears in the path diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Url/Models/UriColor.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Url/Models/UriColor.cs index c8b9a0761d..4dfa387d77 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Url/Models/UriColor.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Url/Models/UriColor.cs @@ -17,7 +17,7 @@ namespace Fixtures.AcceptanceTestsUrl.Models /// /// Defines values for UriColor. /// - [JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] + [JsonConverter(typeof(StringEnumConverter))] public enum UriColor { [EnumMember(Value = "red color")] @@ -27,5 +27,38 @@ public enum UriColor [EnumMember(Value = "blue color")] Bluecolor } + internal static class UriColorEnumExtension + { + internal static string ToSerializedValue(this UriColor? value ) => + value == null ? null : (( UriColor )value).ToSerializedValue(); + + internal static string ToSerializedValue(this UriColor value ) + { + switch( value ) + { + case UriColor.Redcolor: + return "red color"; + case UriColor.Greencolor: + return "green color"; + case UriColor.Bluecolor: + return "blue color"; + } + return null; + } + + internal static UriColor? ParseUriColor( this string value ) + { + switch( value ) + { + case "red color": + return UriColor.Redcolor; + case "green color": + return UriColor.Greencolor; + case "blue color": + return UriColor.Bluecolor; + } + return null; + } + } } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Url/PathItems.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Url/PathItems.cs index 04be6b299e..c937d1f624 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Url/PathItems.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Url/PathItems.cs @@ -141,6 +141,8 @@ public PathItems(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -181,7 +183,7 @@ public PathItems(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -302,6 +304,8 @@ public PathItems(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -342,7 +346,7 @@ public PathItems(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -463,6 +467,8 @@ public PathItems(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -503,7 +509,7 @@ public PathItems(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -624,6 +630,8 @@ public PathItems(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -664,7 +672,7 @@ public PathItems(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Url/Paths.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Url/Paths.cs index 98ab6bdc34..d980ee52f8 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Url/Paths.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Url/Paths.cs @@ -87,6 +87,8 @@ public Paths(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -127,7 +129,7 @@ public Paths(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -194,6 +196,8 @@ public Paths(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -234,7 +238,7 @@ public Paths(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -301,6 +305,8 @@ public Paths(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -341,7 +347,7 @@ public Paths(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -408,6 +414,8 @@ public Paths(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -448,7 +456,7 @@ public Paths(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -515,6 +523,8 @@ public Paths(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -555,7 +565,7 @@ public Paths(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -622,6 +632,8 @@ public Paths(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -662,7 +674,7 @@ public Paths(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -729,6 +741,8 @@ public Paths(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -769,7 +783,7 @@ public Paths(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -836,6 +850,8 @@ public Paths(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -876,7 +892,7 @@ public Paths(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -943,6 +959,8 @@ public Paths(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -983,7 +1001,7 @@ public Paths(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1050,6 +1068,8 @@ public Paths(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1090,7 +1110,7 @@ public Paths(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1157,6 +1177,8 @@ public Paths(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1197,7 +1219,7 @@ public Paths(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1264,6 +1286,8 @@ public Paths(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1304,7 +1328,7 @@ public Paths(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1371,6 +1395,8 @@ public Paths(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1411,7 +1437,7 @@ public Paths(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1490,6 +1516,8 @@ public Paths(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1530,7 +1558,7 @@ public Paths(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1600,6 +1628,8 @@ public Paths(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1640,7 +1670,7 @@ public Paths(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1710,6 +1740,8 @@ public Paths(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1750,7 +1782,7 @@ public Paths(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1829,6 +1861,8 @@ public Paths(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1869,7 +1903,7 @@ public Paths(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1936,6 +1970,8 @@ public Paths(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1976,7 +2012,7 @@ public Paths(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2055,6 +2091,8 @@ public Paths(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2095,7 +2133,7 @@ public Paths(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2162,6 +2200,8 @@ public Paths(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2202,7 +2242,7 @@ public Paths(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2272,6 +2312,8 @@ public Paths(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2312,7 +2354,7 @@ public Paths(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2379,6 +2421,8 @@ public Paths(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2419,7 +2463,7 @@ public Paths(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2489,6 +2533,8 @@ public Paths(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2529,7 +2575,7 @@ public Paths(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2608,6 +2654,8 @@ public Paths(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2648,7 +2696,7 @@ public Paths(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2729,6 +2777,8 @@ public Paths(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2769,7 +2819,7 @@ public Paths(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2838,6 +2888,8 @@ public Paths(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2878,7 +2930,7 @@ public Paths(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Url/Queries.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Url/Queries.cs index c450f2f621..0db72766a1 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Url/Queries.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Url/Queries.cs @@ -92,6 +92,8 @@ public Queries(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -132,7 +134,7 @@ public Queries(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -204,6 +206,8 @@ public Queries(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -244,7 +248,7 @@ public Queries(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -321,6 +325,8 @@ public Queries(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -361,7 +367,7 @@ public Queries(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -433,6 +439,8 @@ public Queries(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -473,7 +481,7 @@ public Queries(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -545,6 +553,8 @@ public Queries(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -585,7 +595,7 @@ public Queries(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -662,6 +672,8 @@ public Queries(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -702,7 +714,7 @@ public Queries(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -774,6 +786,8 @@ public Queries(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -814,7 +828,7 @@ public Queries(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -886,6 +900,8 @@ public Queries(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -926,7 +942,7 @@ public Queries(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1003,6 +1019,8 @@ public Queries(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1043,7 +1061,7 @@ public Queries(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1115,6 +1133,8 @@ public Queries(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1155,7 +1175,7 @@ public Queries(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1227,6 +1247,8 @@ public Queries(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1267,7 +1289,7 @@ public Queries(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1344,6 +1366,8 @@ public Queries(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1384,7 +1408,7 @@ public Queries(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1456,6 +1480,8 @@ public Queries(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1496,7 +1522,7 @@ public Queries(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1568,6 +1594,8 @@ public Queries(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1608,7 +1636,7 @@ public Queries(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1685,6 +1713,8 @@ public Queries(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1725,7 +1755,7 @@ public Queries(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1800,6 +1830,8 @@ public Queries(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1840,7 +1872,7 @@ public Queries(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -1915,6 +1947,8 @@ public Queries(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1955,7 +1989,7 @@ public Queries(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2030,6 +2064,8 @@ public Queries(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2070,7 +2106,7 @@ public Queries(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2147,6 +2183,8 @@ public Queries(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2187,7 +2225,7 @@ public Queries(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2265,6 +2303,8 @@ public Queries(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2305,7 +2345,7 @@ public Queries(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2383,6 +2423,8 @@ public Queries(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2423,7 +2465,7 @@ public Queries(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2500,6 +2542,8 @@ public Queries(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2540,7 +2584,7 @@ public Queries(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2615,6 +2659,8 @@ public Queries(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2655,7 +2701,7 @@ public Queries(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2732,6 +2778,8 @@ public Queries(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2772,7 +2820,7 @@ public Queries(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2844,6 +2892,8 @@ public Queries(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2884,7 +2934,7 @@ public Queries(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -2961,6 +3011,8 @@ public Queries(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3001,7 +3053,7 @@ public Queries(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3073,6 +3125,8 @@ public Queries(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3113,7 +3167,7 @@ public Queries(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3190,6 +3244,8 @@ public Queries(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3230,7 +3286,7 @@ public Queries(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3309,6 +3365,8 @@ public Queries(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3349,7 +3407,7 @@ public Queries(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3426,6 +3484,8 @@ public Queries(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3466,7 +3526,7 @@ public Queries(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3543,6 +3603,8 @@ public Queries(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3583,7 +3645,7 @@ public Queries(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3662,6 +3724,8 @@ public Queries(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3702,7 +3766,7 @@ public Queries(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3781,6 +3845,8 @@ public Queries(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3821,7 +3887,7 @@ public Queries(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -3900,6 +3966,8 @@ public Queries(AutoRestUrlTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -3940,7 +4008,7 @@ public Queries(AutoRestUrlTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/UrlMultiCollectionFormat/AutoRestUrlMutliCollectionFormatTestService.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/UrlMultiCollectionFormat/AutoRestUrlMutliCollectionFormatTestService.cs index 79e6c10c87..50b4d9a8c7 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/UrlMultiCollectionFormat/AutoRestUrlMutliCollectionFormatTestService.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/UrlMultiCollectionFormat/AutoRestUrlMutliCollectionFormatTestService.cs @@ -30,12 +30,12 @@ public partial class AutoRestUrlMutliCollectionFormatTestService : ServiceClient /// /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// Gets the IQueries. @@ -123,27 +123,27 @@ private void Initialize() { Queries = new Queries(this); BaseUri = new System.Uri("http://localhost"); - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/UrlMultiCollectionFormat/IAutoRestUrlMutliCollectionFormatTestService.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/UrlMultiCollectionFormat/IAutoRestUrlMutliCollectionFormatTestService.cs index 5972efb755..2a9b709ca2 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/UrlMultiCollectionFormat/IAutoRestUrlMutliCollectionFormatTestService.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/UrlMultiCollectionFormat/IAutoRestUrlMutliCollectionFormatTestService.cs @@ -24,12 +24,12 @@ public partial interface IAutoRestUrlMutliCollectionFormatTestService : System.I /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/UrlMultiCollectionFormat/Queries.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/UrlMultiCollectionFormat/Queries.cs index f5bc449d04..2d156a9f6d 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/UrlMultiCollectionFormat/Queries.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/UrlMultiCollectionFormat/Queries.cs @@ -106,6 +106,8 @@ public Queries(AutoRestUrlMutliCollectionFormatTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -146,7 +148,7 @@ public Queries(AutoRestUrlMutliCollectionFormatTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -233,6 +235,8 @@ public Queries(AutoRestUrlMutliCollectionFormatTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -273,7 +277,7 @@ public Queries(AutoRestUrlMutliCollectionFormatTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -362,6 +366,8 @@ public Queries(AutoRestUrlMutliCollectionFormatTestService client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -402,7 +408,7 @@ public Queries(AutoRestUrlMutliCollectionFormatTestService client) ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Validation/AutoRestValidationTest.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Validation/AutoRestValidationTest.cs index cc4a7181b2..dc028995e6 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Validation/AutoRestValidationTest.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Validation/AutoRestValidationTest.cs @@ -33,12 +33,12 @@ public partial class AutoRestValidationTest : ServiceClient /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// Subscription ID. @@ -130,27 +130,27 @@ public AutoRestValidationTest(System.Uri baseUri, System.Net.Http.HttpClientHand private void Initialize() { BaseUri = new System.Uri("http://localhost"); - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } @@ -268,6 +268,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -308,7 +310,7 @@ private void Initialize() ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -337,7 +339,7 @@ private void Initialize() { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -472,6 +474,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -518,7 +522,7 @@ private void Initialize() ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -547,7 +551,7 @@ private void Initialize() { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -600,6 +604,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -707,6 +713,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -775,7 +783,7 @@ private void Initialize() { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Validation/IAutoRestValidationTest.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Validation/IAutoRestValidationTest.cs index 7d146f71ec..33f4f95741 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Validation/IAutoRestValidationTest.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Validation/IAutoRestValidationTest.cs @@ -30,12 +30,12 @@ public partial interface IAutoRestValidationTest : System.IDisposable /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// /// Subscription ID. diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Validation/Models/EnumConst.cs b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Validation/Models/EnumConst.cs index 4f714744f8..280841430c 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Validation/Models/EnumConst.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/AcceptanceTests/Validation/Models/EnumConst.cs @@ -17,11 +17,36 @@ namespace Fixtures.AcceptanceTestsValidation.Models /// /// Defines values for EnumConst. /// - [JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] + [JsonConverter(typeof(StringEnumConverter))] public enum EnumConst { [EnumMember(Value = "constant_string_as_enum")] ConstantStringAsEnum } + internal static class EnumConstEnumExtension + { + internal static string ToSerializedValue(this EnumConst? value ) => + value == null ? null : (( EnumConst )value).ToSerializedValue(); + + internal static string ToSerializedValue(this EnumConst value ) + { + switch( value ) + { + case EnumConst.ConstantStringAsEnum: + return "constant_string_as_enum"; + } + return null; + } + + internal static EnumConst? ParseEnumConst( this string value ) + { + switch( value ) + { + case "constant_string_as_enum": + return EnumConst.ConstantStringAsEnum; + } + return null; + } + } } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/Additional.Properties/Get.cs b/src/generator/AutoRest.CSharp.Tests/Expected/Additional.Properties/Get.cs index a43299ee97..4ca7045dba 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/Additional.Properties/Get.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/Additional.Properties/Get.cs @@ -104,6 +104,8 @@ public Get(PetStoreonHeroku client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -166,7 +168,7 @@ public Get(PetStoreonHeroku client) { _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/Additional.Properties/IPetStoreonHeroku.cs b/src/generator/AutoRest.CSharp.Tests/Expected/Additional.Properties/IPetStoreonHeroku.cs index d059e37083..ea90862551 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/Additional.Properties/IPetStoreonHeroku.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/Additional.Properties/IPetStoreonHeroku.cs @@ -25,12 +25,12 @@ public partial interface IPetStoreonHeroku : System.IDisposable /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/Additional.Properties/PetStoreonHeroku.cs b/src/generator/AutoRest.CSharp.Tests/Expected/Additional.Properties/PetStoreonHeroku.cs index 0a88a4889f..336ae028d3 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/Additional.Properties/PetStoreonHeroku.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/Additional.Properties/PetStoreonHeroku.cs @@ -31,12 +31,12 @@ public partial class PetStoreonHeroku : ServiceClient, IPetSto /// /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// Gets the IGet. @@ -136,27 +136,27 @@ private void Initialize() Post = new Post(this); Put = new Put(this); BaseUri = new System.Uri("http://petstore-api.herokuapp.com/my/pet"); - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/Additional.Properties/Post.cs b/src/generator/AutoRest.CSharp.Tests/Expected/Additional.Properties/Post.cs index 2c26d0f90c..47a9bec8c8 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/Additional.Properties/Post.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/Additional.Properties/Post.cs @@ -93,6 +93,8 @@ public Post(PetStoreonHeroku client) _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/Additional.Properties/Put.cs b/src/generator/AutoRest.CSharp.Tests/Expected/Additional.Properties/Put.cs index 679282adb0..99988fe551 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/Additional.Properties/Put.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/Additional.Properties/Put.cs @@ -93,6 +93,8 @@ public Put(PetStoreonHeroku client) _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/DateTimeOffset/ISwaggerDateTimeOffsetClient.cs b/src/generator/AutoRest.CSharp.Tests/Expected/DateTimeOffset/ISwaggerDateTimeOffsetClient.cs index 8060016a27..6b2b0043e4 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/DateTimeOffset/ISwaggerDateTimeOffsetClient.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/DateTimeOffset/ISwaggerDateTimeOffsetClient.cs @@ -29,12 +29,12 @@ public partial interface ISwaggerDateTimeOffsetClient : System.IDisposable /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/DateTimeOffset/SwaggerDateTimeOffsetClient.cs b/src/generator/AutoRest.CSharp.Tests/Expected/DateTimeOffset/SwaggerDateTimeOffsetClient.cs index 84a04d45a8..92ea22e194 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/DateTimeOffset/SwaggerDateTimeOffsetClient.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/DateTimeOffset/SwaggerDateTimeOffsetClient.cs @@ -32,12 +32,12 @@ public partial class SwaggerDateTimeOffsetClient : ServiceClient /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// Initializes a new instance of the SwaggerDateTimeOffsetClient class. @@ -119,27 +119,27 @@ public SwaggerDateTimeOffsetClient(System.Uri baseUri, System.Net.Http.HttpClien private void Initialize() { BaseUri = new System.Uri("http://localhost:3000/api"); - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } @@ -201,6 +201,8 @@ private void Initialize() } _httpRequest.Headers.TryAddWithoutValidation("response-code", responseCode); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -247,7 +249,7 @@ private void Initialize() ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -276,7 +278,7 @@ private void Initialize() { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -348,6 +350,8 @@ private void Initialize() } _httpRequest.Headers.TryAddWithoutValidation("response-code", responseCode); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -394,7 +398,7 @@ private void Initialize() ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -423,7 +427,7 @@ private void Initialize() { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -495,6 +499,8 @@ private void Initialize() } _httpRequest.Headers.TryAddWithoutValidation("response-code", responseCode); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -541,7 +547,7 @@ private void Initialize() ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -570,7 +576,7 @@ private void Initialize() { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -642,6 +648,8 @@ private void Initialize() } _httpRequest.Headers.TryAddWithoutValidation("response-code", responseCode); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -688,7 +696,7 @@ private void Initialize() ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -717,7 +725,7 @@ private void Initialize() { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/Internal.Ctors/IInternalClient.cs b/src/generator/AutoRest.CSharp.Tests/Expected/Internal.Ctors/IInternalClient.cs index cd7a2826ff..bb12529380 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/Internal.Ctors/IInternalClient.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/Internal.Ctors/IInternalClient.cs @@ -24,12 +24,12 @@ public partial interface IInternalClient : System.IDisposable /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/Internal.Ctors/InternalClient.cs b/src/generator/AutoRest.CSharp.Tests/Expected/Internal.Ctors/InternalClient.cs index 3339e869d6..1741df01f2 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/Internal.Ctors/InternalClient.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/Internal.Ctors/InternalClient.cs @@ -30,12 +30,12 @@ public partial class InternalClient : ServiceClient, IInternalCl /// /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// Gets the IPets. @@ -123,27 +123,27 @@ private void Initialize() { Pets = new Pets(this); BaseUri = new System.Uri("http://petstore.swagger.wordnik.com/api"); - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/Internal.Ctors/Pets.cs b/src/generator/AutoRest.CSharp.Tests/Expected/Internal.Ctors/Pets.cs index 5ef39907af..1c9be68ee3 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/Internal.Ctors/Pets.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/Internal.Ctors/Pets.cs @@ -81,6 +81,8 @@ public Pets(InternalClient client) _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/Mirror.Polymorphic/IPolymorphicAnimalStore.cs b/src/generator/AutoRest.CSharp.Tests/Expected/Mirror.Polymorphic/IPolymorphicAnimalStore.cs index 339b7f8f12..83815f21e6 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/Mirror.Polymorphic/IPolymorphicAnimalStore.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/Mirror.Polymorphic/IPolymorphicAnimalStore.cs @@ -29,12 +29,12 @@ public partial interface IPolymorphicAnimalStore : System.IDisposable /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/Mirror.Polymorphic/PolymorphicAnimalStore.cs b/src/generator/AutoRest.CSharp.Tests/Expected/Mirror.Polymorphic/PolymorphicAnimalStore.cs index 21fe8a4b71..56d39ebec3 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/Mirror.Polymorphic/PolymorphicAnimalStore.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/Mirror.Polymorphic/PolymorphicAnimalStore.cs @@ -32,12 +32,12 @@ public partial class PolymorphicAnimalStore : ServiceClient /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// Initializes a new instance of the PolymorphicAnimalStore class. @@ -119,27 +119,27 @@ public PolymorphicAnimalStore(System.Uri baseUri, System.Net.Http.HttpClientHand private void Initialize() { BaseUri = new System.Uri("https://management.azure.com/"); - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } @@ -197,6 +197,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -243,7 +245,7 @@ private void Initialize() ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -272,7 +274,7 @@ private void Initialize() { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/Mirror.Primitives/ISwaggerDataTypesClient.cs b/src/generator/AutoRest.CSharp.Tests/Expected/Mirror.Primitives/ISwaggerDataTypesClient.cs index dd23404878..c1a0b8e84c 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/Mirror.Primitives/ISwaggerDataTypesClient.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/Mirror.Primitives/ISwaggerDataTypesClient.cs @@ -29,12 +29,12 @@ public partial interface ISwaggerDataTypesClient : System.IDisposable /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/Mirror.Primitives/SwaggerDataTypesClient.cs b/src/generator/AutoRest.CSharp.Tests/Expected/Mirror.Primitives/SwaggerDataTypesClient.cs index 339e672d97..0f4626c19a 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/Mirror.Primitives/SwaggerDataTypesClient.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/Mirror.Primitives/SwaggerDataTypesClient.cs @@ -32,12 +32,12 @@ public partial class SwaggerDataTypesClient : ServiceClient /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// Initializes a new instance of the SwaggerDataTypesClient class. @@ -119,27 +119,27 @@ public SwaggerDataTypesClient(System.Uri baseUri, System.Net.Http.HttpClientHand private void Initialize() { BaseUri = new System.Uri("http://localhost:3000/"); - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } @@ -201,6 +201,8 @@ private void Initialize() } _httpRequest.Headers.TryAddWithoutValidation("response-code", responseCode); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -247,7 +249,7 @@ private void Initialize() ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -276,7 +278,7 @@ private void Initialize() { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -348,6 +350,8 @@ private void Initialize() } _httpRequest.Headers.TryAddWithoutValidation("response-code", responseCode); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -394,7 +398,7 @@ private void Initialize() ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -423,7 +427,7 @@ private void Initialize() { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -495,6 +499,8 @@ private void Initialize() } _httpRequest.Headers.TryAddWithoutValidation("response-code", responseCode); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -541,7 +547,7 @@ private void Initialize() ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -570,7 +576,7 @@ private void Initialize() { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -642,6 +648,8 @@ private void Initialize() } _httpRequest.Headers.TryAddWithoutValidation("response-code", responseCode); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -688,7 +696,7 @@ private void Initialize() ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -717,7 +725,7 @@ private void Initialize() { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/Mirror.RecursiveTypes/IRecursiveTypesAPI.cs b/src/generator/AutoRest.CSharp.Tests/Expected/Mirror.RecursiveTypes/IRecursiveTypesAPI.cs index dadc85d811..e997eed1ea 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/Mirror.RecursiveTypes/IRecursiveTypesAPI.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/Mirror.RecursiveTypes/IRecursiveTypesAPI.cs @@ -29,12 +29,12 @@ public partial interface IRecursiveTypesAPI : System.IDisposable /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/Mirror.RecursiveTypes/RecursiveTypesAPI.cs b/src/generator/AutoRest.CSharp.Tests/Expected/Mirror.RecursiveTypes/RecursiveTypesAPI.cs index aae53396ec..f7dc999ee4 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/Mirror.RecursiveTypes/RecursiveTypesAPI.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/Mirror.RecursiveTypes/RecursiveTypesAPI.cs @@ -32,12 +32,12 @@ public partial class RecursiveTypesAPI : ServiceClient, IRecu /// /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// Initializes a new instance of the RecursiveTypesAPI class. @@ -119,27 +119,27 @@ public RecursiveTypesAPI(System.Uri baseUri, System.Net.Http.HttpClientHandler r private void Initialize() { BaseUri = new System.Uri("https://management.azure.com/"); - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } @@ -228,6 +228,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -274,7 +276,7 @@ private void Initialize() ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -303,7 +305,7 @@ private void Initialize() { _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/Mirror.Sequences/ISequenceRequestResponseTest.cs b/src/generator/AutoRest.CSharp.Tests/Expected/Mirror.Sequences/ISequenceRequestResponseTest.cs index 42a9258eaf..70942d03a1 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/Mirror.Sequences/ISequenceRequestResponseTest.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/Mirror.Sequences/ISequenceRequestResponseTest.cs @@ -30,12 +30,12 @@ public partial interface ISequenceRequestResponseTest : System.IDisposable /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/Mirror.Sequences/SequenceRequestResponseTest.cs b/src/generator/AutoRest.CSharp.Tests/Expected/Mirror.Sequences/SequenceRequestResponseTest.cs index 2fa8751150..edeb4210cc 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/Mirror.Sequences/SequenceRequestResponseTest.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/Mirror.Sequences/SequenceRequestResponseTest.cs @@ -33,12 +33,12 @@ public partial class SequenceRequestResponseTest : ServiceClient /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// Initializes a new instance of the SequenceRequestResponseTest class. @@ -120,27 +120,27 @@ public SequenceRequestResponseTest(System.Uri baseUri, System.Net.Http.HttpClien private void Initialize() { BaseUri = new System.Uri("http://petstore.swagger.wordnik.com/api"); - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } @@ -210,6 +210,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -256,7 +258,7 @@ private void Initialize() ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -285,7 +287,7 @@ private void Initialize() { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -355,6 +357,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -401,7 +405,7 @@ private void Initialize() ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -430,7 +434,7 @@ private void Initialize() { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -500,6 +504,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -546,7 +552,7 @@ private void Initialize() ex.Body = _errorBody; } } - catch (Newtonsoft.Json.JsonException) + catch (JsonException) { // Ignore the exception } @@ -575,7 +581,7 @@ private void Initialize() { _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2/ISwaggerPetstoreV2.cs b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2/ISwaggerPetstoreV2.cs index bd8e34f918..01d832cad6 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2/ISwaggerPetstoreV2.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2/ISwaggerPetstoreV2.cs @@ -34,12 +34,12 @@ public partial interface ISwaggerPetstoreV2 : System.IDisposable /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// /// Subscription credentials which uniquely identify client diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2/Models/ApiResponse.cs b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2/Models/ApiResponse.cs index 9c40b67b11..f92d98815f 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2/Models/ApiResponse.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2/Models/ApiResponse.cs @@ -11,6 +11,8 @@ namespace Fixtures.PetstoreV2.Models using PetstoreV2; using Newtonsoft.Json; using System.Linq; + using System.Xml; + using System.Xml.Linq; public partial class ApiResponse { @@ -44,6 +46,56 @@ public ApiResponse() { } [JsonProperty(PropertyName = "message")] public string Message { get; set; } + /// + /// Serializes the object to an XML node + /// + internal XElement XmlSerialize(XElement result) + { + if( null != Code ) + { + result.Add(new XElement("code", Code) ); + } + if( null != Type ) + { + result.Add(new XElement("type", Type) ); + } + if( null != Message ) + { + result.Add(new XElement("message", Message) ); + } + return result; + } + /// + /// Deserializes an XML node to an instance of ApiResponse + /// + internal static ApiResponse XmlDeserialize(string payload) + { + // deserialize to xml and use the overload to do the work + return XmlDeserialize( XElement.Parse( payload ) ); + } + internal static ApiResponse XmlDeserialize(XElement payload) + { + var result = new ApiResponse(); + var deserializeCode = XmlSerialization.ToDeserializer(e => (int?)e); + int? resultCode; + if (deserializeCode(payload, "code", out resultCode)) + { + result.Code = resultCode; + } + var deserializeType = XmlSerialization.ToDeserializer(e => (string)e); + string resultType; + if (deserializeType(payload, "type", out resultType)) + { + result.Type = resultType; + } + var deserializeMessage = XmlSerialization.ToDeserializer(e => (string)e); + string resultMessage; + if (deserializeMessage(payload, "message", out resultMessage)) + { + result.Message = resultMessage; + } + return result; + } } } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2/Models/Category.cs b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2/Models/Category.cs index ec3275b85b..6fb09fd0ee 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2/Models/Category.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2/Models/Category.cs @@ -11,6 +11,8 @@ namespace Fixtures.PetstoreV2.Models using PetstoreV2; using Newtonsoft.Json; using System.Linq; + using System.Xml; + using System.Xml.Linq; public partial class Category { @@ -38,6 +40,46 @@ public Category() { } [JsonProperty(PropertyName = "name")] public string Name { get; set; } + /// + /// Serializes the object to an XML node + /// + internal XElement XmlSerialize(XElement result) + { + if( null != Id ) + { + result.Add(new XElement("id", Id) ); + } + if( null != Name ) + { + result.Add(new XElement("name", Name) ); + } + return result; + } + /// + /// Deserializes an XML node to an instance of Category + /// + internal static Category XmlDeserialize(string payload) + { + // deserialize to xml and use the overload to do the work + return XmlDeserialize( XElement.Parse( payload ) ); + } + internal static Category XmlDeserialize(XElement payload) + { + var result = new Category(); + var deserializeId = XmlSerialization.ToDeserializer(e => (long?)e); + long? resultId; + if (deserializeId(payload, "id", out resultId)) + { + result.Id = resultId; + } + var deserializeName = XmlSerialization.ToDeserializer(e => (string)e); + string resultName; + if (deserializeName(payload, "name", out resultName)) + { + result.Name = resultName; + } + return result; + } } } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2/Models/LoginUserHeaders.cs b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2/Models/LoginUserHeaders.cs index 1ac85734c3..b3c7f4655e 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2/Models/LoginUserHeaders.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2/Models/LoginUserHeaders.cs @@ -11,6 +11,8 @@ namespace Fixtures.PetstoreV2.Models using PetstoreV2; using Newtonsoft.Json; using System.Linq; + using System.Xml; + using System.Xml.Linq; /// /// Defines headers for loginUser operation. @@ -45,6 +47,46 @@ public LoginUserHeaders() { } [JsonProperty(PropertyName = "X-Expires-After")] public System.DateTime? XExpiresAfter { get; set; } + /// + /// Serializes the object to an XML node + /// + internal XElement XmlSerialize(XElement result) + { + if( null != XRateLimit ) + { + result.Add(new XElement("X-Rate-Limit", XRateLimit) ); + } + if( null != XExpiresAfter ) + { + result.Add(new XElement("X-Expires-After", XExpiresAfter) ); + } + return result; + } + /// + /// Deserializes an XML node to an instance of LoginUserHeaders + /// + internal static LoginUserHeaders XmlDeserialize(string payload) + { + // deserialize to xml and use the overload to do the work + return XmlDeserialize( XElement.Parse( payload ) ); + } + internal static LoginUserHeaders XmlDeserialize(XElement payload) + { + var result = new LoginUserHeaders(); + var deserializeXRateLimit = XmlSerialization.ToDeserializer(e => (int?)e); + int? resultXRateLimit; + if (deserializeXRateLimit(payload, "X-Rate-Limit", out resultXRateLimit)) + { + result.XRateLimit = resultXRateLimit; + } + var deserializeXExpiresAfter = XmlSerialization.ToDeserializer(e => (System.DateTime?)e); + System.DateTime? resultXExpiresAfter; + if (deserializeXExpiresAfter(payload, "X-Expires-After", out resultXExpiresAfter)) + { + result.XExpiresAfter = resultXExpiresAfter; + } + return result; + } } } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2/Models/Order.cs b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2/Models/Order.cs index c88f7c3c8c..b7387ae56e 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2/Models/Order.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2/Models/Order.cs @@ -11,6 +11,8 @@ namespace Fixtures.PetstoreV2.Models using PetstoreV2; using Newtonsoft.Json; using System.Linq; + using System.Xml; + using System.Xml.Linq; public partial class Order { @@ -66,6 +68,86 @@ public Order() { } [JsonProperty(PropertyName = "complete")] public bool? Complete { get; set; } + /// + /// Serializes the object to an XML node + /// + internal XElement XmlSerialize(XElement result) + { + if( null != Id ) + { + result.Add(new XElement("id", Id) ); + } + if( null != PetId ) + { + result.Add(new XElement("petId", PetId) ); + } + if( null != Quantity ) + { + result.Add(new XElement("quantity", Quantity) ); + } + if( null != ShipDate ) + { + result.Add(new XElement("shipDate", ShipDate) ); + } + if( null != Status ) + { + result.Add(new XElement("status", Status) ); + } + if( null != Complete ) + { + result.Add(new XElement("complete", Complete) ); + } + return result; + } + /// + /// Deserializes an XML node to an instance of Order + /// + internal static Order XmlDeserialize(string payload) + { + // deserialize to xml and use the overload to do the work + return XmlDeserialize( XElement.Parse( payload ) ); + } + internal static Order XmlDeserialize(XElement payload) + { + var result = new Order(); + var deserializeId = XmlSerialization.ToDeserializer(e => (long?)e); + long? resultId; + if (deserializeId(payload, "id", out resultId)) + { + result.Id = resultId; + } + var deserializePetId = XmlSerialization.ToDeserializer(e => (long?)e); + long? resultPetId; + if (deserializePetId(payload, "petId", out resultPetId)) + { + result.PetId = resultPetId; + } + var deserializeQuantity = XmlSerialization.ToDeserializer(e => (int?)e); + int? resultQuantity; + if (deserializeQuantity(payload, "quantity", out resultQuantity)) + { + result.Quantity = resultQuantity; + } + var deserializeShipDate = XmlSerialization.ToDeserializer(e => (System.DateTime?)e); + System.DateTime? resultShipDate; + if (deserializeShipDate(payload, "shipDate", out resultShipDate)) + { + result.ShipDate = resultShipDate; + } + var deserializeStatus = XmlSerialization.ToDeserializer(e => (string)e); + string resultStatus; + if (deserializeStatus(payload, "status", out resultStatus)) + { + result.Status = resultStatus; + } + var deserializeComplete = XmlSerialization.ToDeserializer(e => (bool?)e); + bool? resultComplete; + if (deserializeComplete(payload, "complete", out resultComplete)) + { + result.Complete = resultComplete; + } + return result; + } } } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2/Models/Pet.cs b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2/Models/Pet.cs index a8ee79ebf4..dda12f190e 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2/Models/Pet.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2/Models/Pet.cs @@ -14,6 +14,8 @@ namespace Fixtures.PetstoreV2.Models using System.Collections; using System.Collections.Generic; using System.Linq; + using System.Xml; + using System.Xml.Linq; public partial class Pet { @@ -104,6 +106,128 @@ public virtual void Validate() throw new ValidationException(ValidationRules.CannotBeNull, "PhotoUrls"); } } + /// + /// Serializes the object to an XML node + /// + internal XElement XmlSerialize(XElement result) + { + if( null != Id ) + { + result.Add(new XElement("id", Id) ); + } + if( null != Category ) + { + result.Add(Category.XmlSerialize(new XElement( "category" ))); + } + if( null != Name ) + { + result.Add(new XElement("name", Name) ); + } + if( null != PhotoUrls ) + { + var seq = new XElement("photoUrl"); + foreach( var value in PhotoUrls ){ + seq.Add(new XElement( "photoUrl", value ) ); + } + result.Add(seq); + } + if( null != Tags ) + { + var seq = new XElement("tag"); + foreach( var value in Tags ){ + seq.Add(value.XmlSerialize( new XElement( "tag") ) ); + } + result.Add(seq); + } + if( null != SByteProperty ) + { + result.Add(new XElement("sByte", SByteProperty) ); + } + if( null != Birthday ) + { + result.Add(new XElement("birthday", Birthday) ); + } + if( null != Dictionary ) + { + var dict = new XElement("dictionary"); + foreach( var key in Dictionary.Keys ) { + dict.Add(Dictionary[key].XmlSerialize(new XElement(key) ) ); + } + result.Add(dict); + } + if( null != Status ) + { + result.Add(new XElement("status", Status) ); + } + return result; + } + /// + /// Deserializes an XML node to an instance of Pet + /// + internal static Pet XmlDeserialize(string payload) + { + // deserialize to xml and use the overload to do the work + return XmlDeserialize( XElement.Parse( payload ) ); + } + internal static Pet XmlDeserialize(XElement payload) + { + var result = new Pet(); + var deserializeId = XmlSerialization.ToDeserializer(e => (long?)e); + long? resultId; + if (deserializeId(payload, "id", out resultId)) + { + result.Id = resultId; + } + var deserializeCategory = XmlSerialization.ToDeserializer(e => Category.XmlDeserialize(e)); + Category resultCategory; + if (deserializeCategory(payload, "category", out resultCategory)) + { + result.Category = resultCategory; + } + var deserializeName = XmlSerialization.ToDeserializer(e => (string)e); + string resultName; + if (deserializeName(payload, "name", out resultName)) + { + result.Name = resultName; + } + var deserializePhotoUrls = XmlSerialization.CreateListXmlDeserializer(XmlSerialization.ToDeserializer(e => (string)e), "photoUrl"); + IList resultPhotoUrls; + if (deserializePhotoUrls(payload, "photoUrl", out resultPhotoUrls)) + { + result.PhotoUrls = resultPhotoUrls; + } + var deserializeTags = XmlSerialization.CreateListXmlDeserializer(XmlSerialization.ToDeserializer(e => Tag.XmlDeserialize(e)), "tag"); + IList resultTags; + if (deserializeTags(payload, "tag", out resultTags)) + { + result.Tags = resultTags; + } + var deserializeSByteProperty = XmlSerialization.ToDeserializer(e => System.Convert.FromBase64String(e.Value)); + byte[] resultSByteProperty; + if (deserializeSByteProperty(payload, "sByte", out resultSByteProperty)) + { + result.SByteProperty = resultSByteProperty; + } + var deserializeBirthday = XmlSerialization.ToDeserializer(e => (System.DateTime?)e); + System.DateTime? resultBirthday; + if (deserializeBirthday(payload, "birthday", out resultBirthday)) + { + result.Birthday = resultBirthday; + } + var deserializeDictionary = XmlSerialization.CreateDictionaryXmlDeserializer(XmlSerialization.ToDeserializer(e => Category.XmlDeserialize(e))); + IDictionary resultDictionary; + if (deserializeDictionary(payload, "dictionary", out resultDictionary)) + { + result.Dictionary = resultDictionary; + } + var deserializeStatus = XmlSerialization.ToDeserializer(e => (string)e); + string resultStatus; + if (deserializeStatus(payload, "status", out resultStatus)) + { + result.Status = resultStatus; + } + return result; + } } } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2/Models/Tag.cs b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2/Models/Tag.cs index bba00b12bf..cbe986facb 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2/Models/Tag.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2/Models/Tag.cs @@ -11,6 +11,8 @@ namespace Fixtures.PetstoreV2.Models using PetstoreV2; using Newtonsoft.Json; using System.Linq; + using System.Xml; + using System.Xml.Linq; public partial class Tag { @@ -38,6 +40,46 @@ public Tag() { } [JsonProperty(PropertyName = "name")] public string Name { get; set; } + /// + /// Serializes the object to an XML node + /// + internal XElement XmlSerialize(XElement result) + { + if( null != Id ) + { + result.Add(new XElement("id", Id) ); + } + if( null != Name ) + { + result.Add(new XElement("name", Name) ); + } + return result; + } + /// + /// Deserializes an XML node to an instance of Tag + /// + internal static Tag XmlDeserialize(string payload) + { + // deserialize to xml and use the overload to do the work + return XmlDeserialize( XElement.Parse( payload ) ); + } + internal static Tag XmlDeserialize(XElement payload) + { + var result = new Tag(); + var deserializeId = XmlSerialization.ToDeserializer(e => (long?)e); + long? resultId; + if (deserializeId(payload, "id", out resultId)) + { + result.Id = resultId; + } + var deserializeName = XmlSerialization.ToDeserializer(e => (string)e); + string resultName; + if (deserializeName(payload, "name", out resultName)) + { + result.Name = resultName; + } + return result; + } } } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2/Models/User.cs b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2/Models/User.cs index a501e14da4..fa386df378 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2/Models/User.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2/Models/User.cs @@ -11,6 +11,8 @@ namespace Fixtures.PetstoreV2.Models using PetstoreV2; using Newtonsoft.Json; using System.Linq; + using System.Xml; + using System.Xml.Linq; public partial class User { @@ -76,6 +78,106 @@ public User() { } [JsonProperty(PropertyName = "userStatus")] public int? UserStatus { get; set; } + /// + /// Serializes the object to an XML node + /// + internal XElement XmlSerialize(XElement result) + { + if( null != Id ) + { + result.Add(new XElement("id", Id) ); + } + if( null != Username ) + { + result.Add(new XElement("username", Username) ); + } + if( null != FirstName ) + { + result.Add(new XElement("firstName", FirstName) ); + } + if( null != LastName ) + { + result.Add(new XElement("lastName", LastName) ); + } + if( null != Email ) + { + result.Add(new XElement("email", Email) ); + } + if( null != Password ) + { + result.Add(new XElement("password", Password) ); + } + if( null != Phone ) + { + result.Add(new XElement("phone", Phone) ); + } + if( null != UserStatus ) + { + result.Add(new XElement("userStatus", UserStatus) ); + } + return result; + } + /// + /// Deserializes an XML node to an instance of User + /// + internal static User XmlDeserialize(string payload) + { + // deserialize to xml and use the overload to do the work + return XmlDeserialize( XElement.Parse( payload ) ); + } + internal static User XmlDeserialize(XElement payload) + { + var result = new User(); + var deserializeId = XmlSerialization.ToDeserializer(e => (long?)e); + long? resultId; + if (deserializeId(payload, "id", out resultId)) + { + result.Id = resultId; + } + var deserializeUsername = XmlSerialization.ToDeserializer(e => (string)e); + string resultUsername; + if (deserializeUsername(payload, "username", out resultUsername)) + { + result.Username = resultUsername; + } + var deserializeFirstName = XmlSerialization.ToDeserializer(e => (string)e); + string resultFirstName; + if (deserializeFirstName(payload, "firstName", out resultFirstName)) + { + result.FirstName = resultFirstName; + } + var deserializeLastName = XmlSerialization.ToDeserializer(e => (string)e); + string resultLastName; + if (deserializeLastName(payload, "lastName", out resultLastName)) + { + result.LastName = resultLastName; + } + var deserializeEmail = XmlSerialization.ToDeserializer(e => (string)e); + string resultEmail; + if (deserializeEmail(payload, "email", out resultEmail)) + { + result.Email = resultEmail; + } + var deserializePassword = XmlSerialization.ToDeserializer(e => (string)e); + string resultPassword; + if (deserializePassword(payload, "password", out resultPassword)) + { + result.Password = resultPassword; + } + var deserializePhone = XmlSerialization.ToDeserializer(e => (string)e); + string resultPhone; + if (deserializePhone(payload, "phone", out resultPhone)) + { + result.Phone = resultPhone; + } + var deserializeUserStatus = XmlSerialization.ToDeserializer(e => (int?)e); + int? resultUserStatus; + if (deserializeUserStatus(payload, "userStatus", out resultUserStatus)) + { + result.UserStatus = resultUserStatus; + } + return result; + } } } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2/Models/XmlSerialization.cs b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2/Models/XmlSerialization.cs new file mode 100644 index 0000000000..026ea770ad --- /dev/null +++ b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2/Models/XmlSerialization.cs @@ -0,0 +1,90 @@ +namespace Fixtures.PetstoreV2 +{ + using System.Collections; + using System.Collections.Generic; + using System.Xml; + using System.Xml.Linq; + internal static class XmlSerialization + { + internal delegate bool XmlRootDeserializer( XElement root, out T result ); + internal delegate bool XmlDeserializer( XElement parent, string propertyName, out T result ); + internal static XmlRootDeserializer Root( XmlDeserializer deserializer ) => + (XElement root, out T result) => deserializer(new XElement("artificialRoot", root), root.Name.LocalName, out result); + private static XmlDeserializer Unroot( XmlRootDeserializer deserializer ) + { + return (XElement parent, string propertyName, out T result) => { + result = default(T); + var element = parent.Element(propertyName); + if (element == null) + { + return false; + } + return deserializer(element, out result); + }; + } + private static XmlRootDeserializer ToRootDeserializer( System.Func unsafeDeserializer ) + => (XElement root, out T result) => { + try + { + result = unsafeDeserializer(root); + return true; + } + catch + { + result = default(T); + return false; + }}; + internal static XmlDeserializer ToDeserializer( System.Func unsafeDeserializer ) + => Unroot(ToRootDeserializer(unsafeDeserializer)); + internal static XmlDeserializer> CreateListXmlDeserializer( XmlDeserializer elementDeserializer, string elementTagName = null /*if isWrapped = false*/ ) + { + if (elementTagName != null) + { + // create non-wrapped deserializer and forward + var slave = CreateListXmlDeserializer( elementDeserializer ); + return (XElement parent, string propertyName, out IList result) => { + result = null; + var wrapper = parent.Element(propertyName); + return wrapper != null && slave(wrapper, elementTagName, out result); + }; + } + var rootElementDeserializer = Root(elementDeserializer); + return (XElement parent, string propertyName, out IList result) => { + result = new List(); + foreach (var element in parent.Elements(propertyName)) + { + T elementResult; + if (!rootElementDeserializer(element, out elementResult)) + { + return false; + } + result.Add(elementResult); + } + return true; + }; + } + internal static XmlDeserializer> CreateDictionaryXmlDeserializer( XmlDeserializer elementDeserializer ) + { + return (XElement parent, string propertyName, out IDictionary result) => { + result = null; + var childElement = parent.Element(propertyName); + if (childElement == null) + { + return false; + } + result = new Dictionary(); + foreach (var element in childElement.Elements()) + { + T elementResult; + if (!elementDeserializer(childElement, element.Name.LocalName, out elementResult)) + { + return false; + } + result.Add(element.Name.LocalName, elementResult); + } + return true; + }; + } + } +} + diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2/SwaggerPetstoreV2.cs b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2/SwaggerPetstoreV2.cs index a7f2731788..2511746511 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2/SwaggerPetstoreV2.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2/SwaggerPetstoreV2.cs @@ -38,12 +38,12 @@ public partial class SwaggerPetstoreV2 : ServiceClient, ISwag /// /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// Subscription credentials which uniquely identify client subscription. @@ -252,27 +252,27 @@ public SwaggerPetstoreV2(System.Uri baseUri, ServiceClientCredentials credential private void Initialize() { BaseUri = new System.Uri("http://petstore.swagger.io/v2"); - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } @@ -336,6 +336,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -408,9 +410,17 @@ private void Initialize() _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + Pet _tmp_ = null; + if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" && + XmlSerialization.Root(XmlSerialization.ToDeserializer(e => Pet.XmlDeserialize(e)))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_)) + { + _result.Body = _tmp_; + }else + { + _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + } } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -481,6 +491,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -619,6 +631,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -685,9 +699,17 @@ private void Initialize() _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings); + IList _tmp_ = null; + if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" && + XmlSerialization.Root(XmlSerialization.CreateListXmlDeserializer(XmlSerialization.ToDeserializer(e => Pet.XmlDeserialize(e)), "null"))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_)) + { + _result.Body = _tmp_; + }else + { + _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings); + } } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -770,6 +792,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -836,9 +860,17 @@ private void Initialize() _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings); + IList _tmp_ = null; + if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" && + XmlSerialization.Root(XmlSerialization.CreateListXmlDeserializer(XmlSerialization.ToDeserializer(e => Pet.XmlDeserialize(e)), "null"))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_)) + { + _result.Body = _tmp_; + }else + { + _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings); + } } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -902,6 +934,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -968,9 +1002,17 @@ private void Initialize() _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + Pet _tmp_ = null; + if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" && + XmlSerialization.Root(XmlSerialization.ToDeserializer(e => Pet.XmlDeserialize(e)))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_)) + { + _result.Body = _tmp_; + }else + { + _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + } } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1050,6 +1092,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1195,6 +1239,8 @@ private void Initialize() } _httpRequest.Headers.TryAddWithoutValidation("api_key", apiKey); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1304,6 +1350,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1370,9 +1418,17 @@ private void Initialize() _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings); + IDictionary _tmp_ = null; + if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" && + XmlSerialization.Root(XmlSerialization.CreateDictionaryXmlDeserializer(XmlSerialization.ToDeserializer(e => (int?)e)))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_)) + { + _result.Body = _tmp_; + }else + { + _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings); + } } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1442,6 +1498,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1514,9 +1572,17 @@ private void Initialize() _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + Order _tmp_ = null; + if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" && + XmlSerialization.Root(XmlSerialization.ToDeserializer(e => Order.XmlDeserialize(e)))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_)) + { + _result.Body = _tmp_; + }else + { + _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + } } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1602,6 +1668,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1668,9 +1736,17 @@ private void Initialize() _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + Order _tmp_ = null; + if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" && + XmlSerialization.Root(XmlSerialization.ToDeserializer(e => Order.XmlDeserialize(e)))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_)) + { + _result.Body = _tmp_; + }else + { + _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + } } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1749,6 +1825,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("DELETE"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1869,6 +1947,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1992,6 +2072,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2115,6 +2197,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2262,6 +2346,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2328,9 +2414,17 @@ private void Initialize() _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + string _tmp_ = null; + if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" && + XmlSerialization.Root(XmlSerialization.ToDeserializer(e => (string)e))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_)) + { + _result.Body = _tmp_; + }else + { + _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + } } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2342,9 +2436,9 @@ private void Initialize() } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2396,6 +2490,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2517,6 +2613,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2583,9 +2681,17 @@ private void Initialize() _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + User _tmp_ = null; + if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" && + XmlSerialization.Root(XmlSerialization.ToDeserializer(e => User.XmlDeserialize(e)))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_)) + { + _result.Body = _tmp_; + }else + { + _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + } } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2664,6 +2770,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2791,6 +2899,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("DELETE"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2AllSync/ISwaggerPetstoreV2.cs b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2AllSync/ISwaggerPetstoreV2.cs index aaf7888c9f..6dc5a20cb1 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2AllSync/ISwaggerPetstoreV2.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2AllSync/ISwaggerPetstoreV2.cs @@ -34,12 +34,12 @@ public partial interface ISwaggerPetstoreV2 : System.IDisposable /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2AllSync/Models/ApiResponse.cs b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2AllSync/Models/ApiResponse.cs index 3882c0c5d2..ebfda38336 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2AllSync/Models/ApiResponse.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2AllSync/Models/ApiResponse.cs @@ -11,6 +11,8 @@ namespace Fixtures.PetstoreV2AllSync.Models using PetstoreV2AllSync; using Newtonsoft.Json; using System.Linq; + using System.Xml; + using System.Xml.Linq; public partial class ApiResponse { @@ -44,6 +46,56 @@ public ApiResponse() { } [JsonProperty(PropertyName = "message")] public string Message { get; set; } + /// + /// Serializes the object to an XML node + /// + internal XElement XmlSerialize(XElement result) + { + if( null != Code ) + { + result.Add(new XElement("code", Code) ); + } + if( null != Type ) + { + result.Add(new XElement("type", Type) ); + } + if( null != Message ) + { + result.Add(new XElement("message", Message) ); + } + return result; + } + /// + /// Deserializes an XML node to an instance of ApiResponse + /// + internal static ApiResponse XmlDeserialize(string payload) + { + // deserialize to xml and use the overload to do the work + return XmlDeserialize( XElement.Parse( payload ) ); + } + internal static ApiResponse XmlDeserialize(XElement payload) + { + var result = new ApiResponse(); + var deserializeCode = XmlSerialization.ToDeserializer(e => (int?)e); + int? resultCode; + if (deserializeCode(payload, "code", out resultCode)) + { + result.Code = resultCode; + } + var deserializeType = XmlSerialization.ToDeserializer(e => (string)e); + string resultType; + if (deserializeType(payload, "type", out resultType)) + { + result.Type = resultType; + } + var deserializeMessage = XmlSerialization.ToDeserializer(e => (string)e); + string resultMessage; + if (deserializeMessage(payload, "message", out resultMessage)) + { + result.Message = resultMessage; + } + return result; + } } } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2AllSync/Models/Category.cs b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2AllSync/Models/Category.cs index 27ea4c9378..46e3b5b385 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2AllSync/Models/Category.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2AllSync/Models/Category.cs @@ -11,6 +11,8 @@ namespace Fixtures.PetstoreV2AllSync.Models using PetstoreV2AllSync; using Newtonsoft.Json; using System.Linq; + using System.Xml; + using System.Xml.Linq; public partial class Category { @@ -38,6 +40,46 @@ public Category() { } [JsonProperty(PropertyName = "name")] public string Name { get; set; } + /// + /// Serializes the object to an XML node + /// + internal XElement XmlSerialize(XElement result) + { + if( null != Id ) + { + result.Add(new XElement("id", Id) ); + } + if( null != Name ) + { + result.Add(new XElement("name", Name) ); + } + return result; + } + /// + /// Deserializes an XML node to an instance of Category + /// + internal static Category XmlDeserialize(string payload) + { + // deserialize to xml and use the overload to do the work + return XmlDeserialize( XElement.Parse( payload ) ); + } + internal static Category XmlDeserialize(XElement payload) + { + var result = new Category(); + var deserializeId = XmlSerialization.ToDeserializer(e => (long?)e); + long? resultId; + if (deserializeId(payload, "id", out resultId)) + { + result.Id = resultId; + } + var deserializeName = XmlSerialization.ToDeserializer(e => (string)e); + string resultName; + if (deserializeName(payload, "name", out resultName)) + { + result.Name = resultName; + } + return result; + } } } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2AllSync/Models/LoginUserHeaders.cs b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2AllSync/Models/LoginUserHeaders.cs index e24bc8f5ff..f26bc121eb 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2AllSync/Models/LoginUserHeaders.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2AllSync/Models/LoginUserHeaders.cs @@ -11,6 +11,8 @@ namespace Fixtures.PetstoreV2AllSync.Models using PetstoreV2AllSync; using Newtonsoft.Json; using System.Linq; + using System.Xml; + using System.Xml.Linq; /// /// Defines headers for loginUser operation. @@ -45,6 +47,46 @@ public LoginUserHeaders() { } [JsonProperty(PropertyName = "X-Expires-After")] public System.DateTime? XExpiresAfter { get; set; } + /// + /// Serializes the object to an XML node + /// + internal XElement XmlSerialize(XElement result) + { + if( null != XRateLimit ) + { + result.Add(new XElement("X-Rate-Limit", XRateLimit) ); + } + if( null != XExpiresAfter ) + { + result.Add(new XElement("X-Expires-After", XExpiresAfter) ); + } + return result; + } + /// + /// Deserializes an XML node to an instance of LoginUserHeaders + /// + internal static LoginUserHeaders XmlDeserialize(string payload) + { + // deserialize to xml and use the overload to do the work + return XmlDeserialize( XElement.Parse( payload ) ); + } + internal static LoginUserHeaders XmlDeserialize(XElement payload) + { + var result = new LoginUserHeaders(); + var deserializeXRateLimit = XmlSerialization.ToDeserializer(e => (int?)e); + int? resultXRateLimit; + if (deserializeXRateLimit(payload, "X-Rate-Limit", out resultXRateLimit)) + { + result.XRateLimit = resultXRateLimit; + } + var deserializeXExpiresAfter = XmlSerialization.ToDeserializer(e => (System.DateTime?)e); + System.DateTime? resultXExpiresAfter; + if (deserializeXExpiresAfter(payload, "X-Expires-After", out resultXExpiresAfter)) + { + result.XExpiresAfter = resultXExpiresAfter; + } + return result; + } } } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2AllSync/Models/Order.cs b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2AllSync/Models/Order.cs index a47d8fc8bd..fe14c899c9 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2AllSync/Models/Order.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2AllSync/Models/Order.cs @@ -11,6 +11,8 @@ namespace Fixtures.PetstoreV2AllSync.Models using PetstoreV2AllSync; using Newtonsoft.Json; using System.Linq; + using System.Xml; + using System.Xml.Linq; public partial class Order { @@ -66,6 +68,86 @@ public Order() { } [JsonProperty(PropertyName = "complete")] public bool? Complete { get; set; } + /// + /// Serializes the object to an XML node + /// + internal XElement XmlSerialize(XElement result) + { + if( null != Id ) + { + result.Add(new XElement("id", Id) ); + } + if( null != PetId ) + { + result.Add(new XElement("petId", PetId) ); + } + if( null != Quantity ) + { + result.Add(new XElement("quantity", Quantity) ); + } + if( null != ShipDate ) + { + result.Add(new XElement("shipDate", ShipDate) ); + } + if( null != Status ) + { + result.Add(new XElement("status", Status) ); + } + if( null != Complete ) + { + result.Add(new XElement("complete", Complete) ); + } + return result; + } + /// + /// Deserializes an XML node to an instance of Order + /// + internal static Order XmlDeserialize(string payload) + { + // deserialize to xml and use the overload to do the work + return XmlDeserialize( XElement.Parse( payload ) ); + } + internal static Order XmlDeserialize(XElement payload) + { + var result = new Order(); + var deserializeId = XmlSerialization.ToDeserializer(e => (long?)e); + long? resultId; + if (deserializeId(payload, "id", out resultId)) + { + result.Id = resultId; + } + var deserializePetId = XmlSerialization.ToDeserializer(e => (long?)e); + long? resultPetId; + if (deserializePetId(payload, "petId", out resultPetId)) + { + result.PetId = resultPetId; + } + var deserializeQuantity = XmlSerialization.ToDeserializer(e => (int?)e); + int? resultQuantity; + if (deserializeQuantity(payload, "quantity", out resultQuantity)) + { + result.Quantity = resultQuantity; + } + var deserializeShipDate = XmlSerialization.ToDeserializer(e => (System.DateTime?)e); + System.DateTime? resultShipDate; + if (deserializeShipDate(payload, "shipDate", out resultShipDate)) + { + result.ShipDate = resultShipDate; + } + var deserializeStatus = XmlSerialization.ToDeserializer(e => (string)e); + string resultStatus; + if (deserializeStatus(payload, "status", out resultStatus)) + { + result.Status = resultStatus; + } + var deserializeComplete = XmlSerialization.ToDeserializer(e => (bool?)e); + bool? resultComplete; + if (deserializeComplete(payload, "complete", out resultComplete)) + { + result.Complete = resultComplete; + } + return result; + } } } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2AllSync/Models/Pet.cs b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2AllSync/Models/Pet.cs index b46ef5c6f2..a6c28a455e 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2AllSync/Models/Pet.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2AllSync/Models/Pet.cs @@ -14,6 +14,8 @@ namespace Fixtures.PetstoreV2AllSync.Models using System.Collections; using System.Collections.Generic; using System.Linq; + using System.Xml; + using System.Xml.Linq; public partial class Pet { @@ -104,6 +106,128 @@ public virtual void Validate() throw new ValidationException(ValidationRules.CannotBeNull, "PhotoUrls"); } } + /// + /// Serializes the object to an XML node + /// + internal XElement XmlSerialize(XElement result) + { + if( null != Id ) + { + result.Add(new XElement("id", Id) ); + } + if( null != Category ) + { + result.Add(Category.XmlSerialize(new XElement( "category" ))); + } + if( null != Name ) + { + result.Add(new XElement("name", Name) ); + } + if( null != PhotoUrls ) + { + var seq = new XElement("photoUrl"); + foreach( var value in PhotoUrls ){ + seq.Add(new XElement( "photoUrl", value ) ); + } + result.Add(seq); + } + if( null != Tags ) + { + var seq = new XElement("tag"); + foreach( var value in Tags ){ + seq.Add(value.XmlSerialize( new XElement( "tag") ) ); + } + result.Add(seq); + } + if( null != SByteProperty ) + { + result.Add(new XElement("sByte", SByteProperty) ); + } + if( null != Birthday ) + { + result.Add(new XElement("birthday", Birthday) ); + } + if( null != Dictionary ) + { + var dict = new XElement("dictionary"); + foreach( var key in Dictionary.Keys ) { + dict.Add(Dictionary[key].XmlSerialize(new XElement(key) ) ); + } + result.Add(dict); + } + if( null != Status ) + { + result.Add(new XElement("status", Status) ); + } + return result; + } + /// + /// Deserializes an XML node to an instance of Pet + /// + internal static Pet XmlDeserialize(string payload) + { + // deserialize to xml and use the overload to do the work + return XmlDeserialize( XElement.Parse( payload ) ); + } + internal static Pet XmlDeserialize(XElement payload) + { + var result = new Pet(); + var deserializeId = XmlSerialization.ToDeserializer(e => (long?)e); + long? resultId; + if (deserializeId(payload, "id", out resultId)) + { + result.Id = resultId; + } + var deserializeCategory = XmlSerialization.ToDeserializer(e => Category.XmlDeserialize(e)); + Category resultCategory; + if (deserializeCategory(payload, "category", out resultCategory)) + { + result.Category = resultCategory; + } + var deserializeName = XmlSerialization.ToDeserializer(e => (string)e); + string resultName; + if (deserializeName(payload, "name", out resultName)) + { + result.Name = resultName; + } + var deserializePhotoUrls = XmlSerialization.CreateListXmlDeserializer(XmlSerialization.ToDeserializer(e => (string)e), "photoUrl"); + IList resultPhotoUrls; + if (deserializePhotoUrls(payload, "photoUrl", out resultPhotoUrls)) + { + result.PhotoUrls = resultPhotoUrls; + } + var deserializeTags = XmlSerialization.CreateListXmlDeserializer(XmlSerialization.ToDeserializer(e => Tag.XmlDeserialize(e)), "tag"); + IList resultTags; + if (deserializeTags(payload, "tag", out resultTags)) + { + result.Tags = resultTags; + } + var deserializeSByteProperty = XmlSerialization.ToDeserializer(e => System.Convert.FromBase64String(e.Value)); + byte[] resultSByteProperty; + if (deserializeSByteProperty(payload, "sByte", out resultSByteProperty)) + { + result.SByteProperty = resultSByteProperty; + } + var deserializeBirthday = XmlSerialization.ToDeserializer(e => (System.DateTime?)e); + System.DateTime? resultBirthday; + if (deserializeBirthday(payload, "birthday", out resultBirthday)) + { + result.Birthday = resultBirthday; + } + var deserializeDictionary = XmlSerialization.CreateDictionaryXmlDeserializer(XmlSerialization.ToDeserializer(e => Category.XmlDeserialize(e))); + IDictionary resultDictionary; + if (deserializeDictionary(payload, "dictionary", out resultDictionary)) + { + result.Dictionary = resultDictionary; + } + var deserializeStatus = XmlSerialization.ToDeserializer(e => (string)e); + string resultStatus; + if (deserializeStatus(payload, "status", out resultStatus)) + { + result.Status = resultStatus; + } + return result; + } } } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2AllSync/Models/Tag.cs b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2AllSync/Models/Tag.cs index 9974869cfd..2fa1cecb08 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2AllSync/Models/Tag.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2AllSync/Models/Tag.cs @@ -11,6 +11,8 @@ namespace Fixtures.PetstoreV2AllSync.Models using PetstoreV2AllSync; using Newtonsoft.Json; using System.Linq; + using System.Xml; + using System.Xml.Linq; public partial class Tag { @@ -38,6 +40,46 @@ public Tag() { } [JsonProperty(PropertyName = "name")] public string Name { get; set; } + /// + /// Serializes the object to an XML node + /// + internal XElement XmlSerialize(XElement result) + { + if( null != Id ) + { + result.Add(new XElement("id", Id) ); + } + if( null != Name ) + { + result.Add(new XElement("name", Name) ); + } + return result; + } + /// + /// Deserializes an XML node to an instance of Tag + /// + internal static Tag XmlDeserialize(string payload) + { + // deserialize to xml and use the overload to do the work + return XmlDeserialize( XElement.Parse( payload ) ); + } + internal static Tag XmlDeserialize(XElement payload) + { + var result = new Tag(); + var deserializeId = XmlSerialization.ToDeserializer(e => (long?)e); + long? resultId; + if (deserializeId(payload, "id", out resultId)) + { + result.Id = resultId; + } + var deserializeName = XmlSerialization.ToDeserializer(e => (string)e); + string resultName; + if (deserializeName(payload, "name", out resultName)) + { + result.Name = resultName; + } + return result; + } } } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2AllSync/Models/User.cs b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2AllSync/Models/User.cs index 03c822102d..7727acaa71 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2AllSync/Models/User.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2AllSync/Models/User.cs @@ -11,6 +11,8 @@ namespace Fixtures.PetstoreV2AllSync.Models using PetstoreV2AllSync; using Newtonsoft.Json; using System.Linq; + using System.Xml; + using System.Xml.Linq; public partial class User { @@ -76,6 +78,106 @@ public User() { } [JsonProperty(PropertyName = "userStatus")] public int? UserStatus { get; set; } + /// + /// Serializes the object to an XML node + /// + internal XElement XmlSerialize(XElement result) + { + if( null != Id ) + { + result.Add(new XElement("id", Id) ); + } + if( null != Username ) + { + result.Add(new XElement("username", Username) ); + } + if( null != FirstName ) + { + result.Add(new XElement("firstName", FirstName) ); + } + if( null != LastName ) + { + result.Add(new XElement("lastName", LastName) ); + } + if( null != Email ) + { + result.Add(new XElement("email", Email) ); + } + if( null != Password ) + { + result.Add(new XElement("password", Password) ); + } + if( null != Phone ) + { + result.Add(new XElement("phone", Phone) ); + } + if( null != UserStatus ) + { + result.Add(new XElement("userStatus", UserStatus) ); + } + return result; + } + /// + /// Deserializes an XML node to an instance of User + /// + internal static User XmlDeserialize(string payload) + { + // deserialize to xml and use the overload to do the work + return XmlDeserialize( XElement.Parse( payload ) ); + } + internal static User XmlDeserialize(XElement payload) + { + var result = new User(); + var deserializeId = XmlSerialization.ToDeserializer(e => (long?)e); + long? resultId; + if (deserializeId(payload, "id", out resultId)) + { + result.Id = resultId; + } + var deserializeUsername = XmlSerialization.ToDeserializer(e => (string)e); + string resultUsername; + if (deserializeUsername(payload, "username", out resultUsername)) + { + result.Username = resultUsername; + } + var deserializeFirstName = XmlSerialization.ToDeserializer(e => (string)e); + string resultFirstName; + if (deserializeFirstName(payload, "firstName", out resultFirstName)) + { + result.FirstName = resultFirstName; + } + var deserializeLastName = XmlSerialization.ToDeserializer(e => (string)e); + string resultLastName; + if (deserializeLastName(payload, "lastName", out resultLastName)) + { + result.LastName = resultLastName; + } + var deserializeEmail = XmlSerialization.ToDeserializer(e => (string)e); + string resultEmail; + if (deserializeEmail(payload, "email", out resultEmail)) + { + result.Email = resultEmail; + } + var deserializePassword = XmlSerialization.ToDeserializer(e => (string)e); + string resultPassword; + if (deserializePassword(payload, "password", out resultPassword)) + { + result.Password = resultPassword; + } + var deserializePhone = XmlSerialization.ToDeserializer(e => (string)e); + string resultPhone; + if (deserializePhone(payload, "phone", out resultPhone)) + { + result.Phone = resultPhone; + } + var deserializeUserStatus = XmlSerialization.ToDeserializer(e => (int?)e); + int? resultUserStatus; + if (deserializeUserStatus(payload, "userStatus", out resultUserStatus)) + { + result.UserStatus = resultUserStatus; + } + return result; + } } } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2AllSync/Models/XmlSerialization.cs b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2AllSync/Models/XmlSerialization.cs new file mode 100644 index 0000000000..e15bbbba79 --- /dev/null +++ b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2AllSync/Models/XmlSerialization.cs @@ -0,0 +1,90 @@ +namespace Fixtures.PetstoreV2AllSync +{ + using System.Collections; + using System.Collections.Generic; + using System.Xml; + using System.Xml.Linq; + internal static class XmlSerialization + { + internal delegate bool XmlRootDeserializer( XElement root, out T result ); + internal delegate bool XmlDeserializer( XElement parent, string propertyName, out T result ); + internal static XmlRootDeserializer Root( XmlDeserializer deserializer ) => + (XElement root, out T result) => deserializer(new XElement("artificialRoot", root), root.Name.LocalName, out result); + private static XmlDeserializer Unroot( XmlRootDeserializer deserializer ) + { + return (XElement parent, string propertyName, out T result) => { + result = default(T); + var element = parent.Element(propertyName); + if (element == null) + { + return false; + } + return deserializer(element, out result); + }; + } + private static XmlRootDeserializer ToRootDeserializer( System.Func unsafeDeserializer ) + => (XElement root, out T result) => { + try + { + result = unsafeDeserializer(root); + return true; + } + catch + { + result = default(T); + return false; + }}; + internal static XmlDeserializer ToDeserializer( System.Func unsafeDeserializer ) + => Unroot(ToRootDeserializer(unsafeDeserializer)); + internal static XmlDeserializer> CreateListXmlDeserializer( XmlDeserializer elementDeserializer, string elementTagName = null /*if isWrapped = false*/ ) + { + if (elementTagName != null) + { + // create non-wrapped deserializer and forward + var slave = CreateListXmlDeserializer( elementDeserializer ); + return (XElement parent, string propertyName, out IList result) => { + result = null; + var wrapper = parent.Element(propertyName); + return wrapper != null && slave(wrapper, elementTagName, out result); + }; + } + var rootElementDeserializer = Root(elementDeserializer); + return (XElement parent, string propertyName, out IList result) => { + result = new List(); + foreach (var element in parent.Elements(propertyName)) + { + T elementResult; + if (!rootElementDeserializer(element, out elementResult)) + { + return false; + } + result.Add(elementResult); + } + return true; + }; + } + internal static XmlDeserializer> CreateDictionaryXmlDeserializer( XmlDeserializer elementDeserializer ) + { + return (XElement parent, string propertyName, out IDictionary result) => { + result = null; + var childElement = parent.Element(propertyName); + if (childElement == null) + { + return false; + } + result = new Dictionary(); + foreach (var element in childElement.Elements()) + { + T elementResult; + if (!elementDeserializer(childElement, element.Name.LocalName, out elementResult)) + { + return false; + } + result.Add(element.Name.LocalName, elementResult); + } + return true; + }; + } + } +} + diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2AllSync/SwaggerPetstoreV2.cs b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2AllSync/SwaggerPetstoreV2.cs index 9e48c2bdf4..1bb81a5263 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2AllSync/SwaggerPetstoreV2.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2AllSync/SwaggerPetstoreV2.cs @@ -38,12 +38,12 @@ public partial class SwaggerPetstoreV2 : ServiceClient, ISwag /// /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// Initializes a new instance of the SwaggerPetstoreV2 class. @@ -125,27 +125,27 @@ public SwaggerPetstoreV2(System.Uri baseUri, System.Net.Http.HttpClientHandler r private void Initialize() { BaseUri = new System.Uri("http://petstore.swagger.io/v2"); - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } @@ -209,6 +209,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -275,9 +277,17 @@ private void Initialize() _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + Pet _tmp_ = null; + if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" && + XmlSerialization.Root(XmlSerialization.ToDeserializer(e => Pet.XmlDeserialize(e)))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_)) + { + _result.Body = _tmp_; + }else + { + _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + } } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -348,6 +358,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -480,6 +492,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -540,9 +554,17 @@ private void Initialize() _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings); + IList _tmp_ = null; + if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" && + XmlSerialization.Root(XmlSerialization.CreateListXmlDeserializer(XmlSerialization.ToDeserializer(e => Pet.XmlDeserialize(e)), "null"))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_)) + { + _result.Body = _tmp_; + }else + { + _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings); + } } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -625,6 +647,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -685,9 +709,17 @@ private void Initialize() _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings); + IList _tmp_ = null; + if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" && + XmlSerialization.Root(XmlSerialization.CreateListXmlDeserializer(XmlSerialization.ToDeserializer(e => Pet.XmlDeserialize(e)), "null"))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_)) + { + _result.Body = _tmp_; + }else + { + _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings); + } } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -751,6 +783,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -811,9 +845,17 @@ private void Initialize() _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + Pet _tmp_ = null; + if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" && + XmlSerialization.Root(XmlSerialization.ToDeserializer(e => Pet.XmlDeserialize(e)))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_)) + { + _result.Body = _tmp_; + }else + { + _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + } } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -893,6 +935,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1032,6 +1076,8 @@ private void Initialize() } _httpRequest.Headers.TryAddWithoutValidation("api_key", apiKey); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1135,6 +1181,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1195,9 +1243,17 @@ private void Initialize() _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings); + IDictionary _tmp_ = null; + if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" && + XmlSerialization.Root(XmlSerialization.CreateDictionaryXmlDeserializer(XmlSerialization.ToDeserializer(e => (int?)e)))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_)) + { + _result.Body = _tmp_; + }else + { + _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings); + } } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1267,6 +1323,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1333,9 +1391,17 @@ private void Initialize() _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + Order _tmp_ = null; + if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" && + XmlSerialization.Root(XmlSerialization.ToDeserializer(e => Order.XmlDeserialize(e)))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_)) + { + _result.Body = _tmp_; + }else + { + _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + } } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1421,6 +1487,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1481,9 +1549,17 @@ private void Initialize() _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + Order _tmp_ = null; + if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" && + XmlSerialization.Root(XmlSerialization.ToDeserializer(e => Order.XmlDeserialize(e)))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_)) + { + _result.Body = _tmp_; + }else + { + _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + } } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1562,6 +1638,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("DELETE"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1676,6 +1754,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1793,6 +1873,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1910,6 +1992,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2051,6 +2135,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2111,9 +2197,17 @@ private void Initialize() _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + string _tmp_ = null; + if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" && + XmlSerialization.Root(XmlSerialization.ToDeserializer(e => (string)e))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_)) + { + _result.Body = _tmp_; + }else + { + _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + } } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2125,9 +2219,9 @@ private void Initialize() } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2179,6 +2273,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2294,6 +2390,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2354,9 +2452,17 @@ private void Initialize() _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + User _tmp_ = null; + if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" && + XmlSerialization.Root(XmlSerialization.ToDeserializer(e => User.XmlDeserialize(e)))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_)) + { + _result.Body = _tmp_; + }else + { + _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + } } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2435,6 +2541,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2556,6 +2664,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("DELETE"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2NoSync/ISwaggerPetstoreV2.cs b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2NoSync/ISwaggerPetstoreV2.cs index 243040acf7..61f21b68be 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2NoSync/ISwaggerPetstoreV2.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2NoSync/ISwaggerPetstoreV2.cs @@ -34,12 +34,12 @@ public partial interface ISwaggerPetstoreV2 : System.IDisposable /// /// Gets or sets json serialization settings. /// - Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; } + JsonSerializerSettings SerializationSettings { get; } /// /// Gets or sets json deserialization settings. /// - Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; } + JsonSerializerSettings DeserializationSettings { get; } /// diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2NoSync/Models/ApiResponse.cs b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2NoSync/Models/ApiResponse.cs index 3a812b9e19..82e056a000 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2NoSync/Models/ApiResponse.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2NoSync/Models/ApiResponse.cs @@ -11,6 +11,8 @@ namespace Fixtures.PetstoreV2NoSync.Models using PetstoreV2NoSync; using Newtonsoft.Json; using System.Linq; + using System.Xml; + using System.Xml.Linq; public partial class ApiResponse { @@ -44,6 +46,56 @@ public ApiResponse() { } [JsonProperty(PropertyName = "message")] public string Message { get; set; } + /// + /// Serializes the object to an XML node + /// + internal XElement XmlSerialize(XElement result) + { + if( null != Code ) + { + result.Add(new XElement("code", Code) ); + } + if( null != Type ) + { + result.Add(new XElement("type", Type) ); + } + if( null != Message ) + { + result.Add(new XElement("message", Message) ); + } + return result; + } + /// + /// Deserializes an XML node to an instance of ApiResponse + /// + internal static ApiResponse XmlDeserialize(string payload) + { + // deserialize to xml and use the overload to do the work + return XmlDeserialize( XElement.Parse( payload ) ); + } + internal static ApiResponse XmlDeserialize(XElement payload) + { + var result = new ApiResponse(); + var deserializeCode = XmlSerialization.ToDeserializer(e => (int?)e); + int? resultCode; + if (deserializeCode(payload, "code", out resultCode)) + { + result.Code = resultCode; + } + var deserializeType = XmlSerialization.ToDeserializer(e => (string)e); + string resultType; + if (deserializeType(payload, "type", out resultType)) + { + result.Type = resultType; + } + var deserializeMessage = XmlSerialization.ToDeserializer(e => (string)e); + string resultMessage; + if (deserializeMessage(payload, "message", out resultMessage)) + { + result.Message = resultMessage; + } + return result; + } } } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2NoSync/Models/Category.cs b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2NoSync/Models/Category.cs index c29ff8d0d6..607f5de57f 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2NoSync/Models/Category.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2NoSync/Models/Category.cs @@ -11,6 +11,8 @@ namespace Fixtures.PetstoreV2NoSync.Models using PetstoreV2NoSync; using Newtonsoft.Json; using System.Linq; + using System.Xml; + using System.Xml.Linq; public partial class Category { @@ -38,6 +40,46 @@ public Category() { } [JsonProperty(PropertyName = "name")] public string Name { get; set; } + /// + /// Serializes the object to an XML node + /// + internal XElement XmlSerialize(XElement result) + { + if( null != Id ) + { + result.Add(new XElement("id", Id) ); + } + if( null != Name ) + { + result.Add(new XElement("name", Name) ); + } + return result; + } + /// + /// Deserializes an XML node to an instance of Category + /// + internal static Category XmlDeserialize(string payload) + { + // deserialize to xml and use the overload to do the work + return XmlDeserialize( XElement.Parse( payload ) ); + } + internal static Category XmlDeserialize(XElement payload) + { + var result = new Category(); + var deserializeId = XmlSerialization.ToDeserializer(e => (long?)e); + long? resultId; + if (deserializeId(payload, "id", out resultId)) + { + result.Id = resultId; + } + var deserializeName = XmlSerialization.ToDeserializer(e => (string)e); + string resultName; + if (deserializeName(payload, "name", out resultName)) + { + result.Name = resultName; + } + return result; + } } } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2NoSync/Models/LoginUserHeaders.cs b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2NoSync/Models/LoginUserHeaders.cs index 6cb81c48f3..83a2536c65 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2NoSync/Models/LoginUserHeaders.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2NoSync/Models/LoginUserHeaders.cs @@ -11,6 +11,8 @@ namespace Fixtures.PetstoreV2NoSync.Models using PetstoreV2NoSync; using Newtonsoft.Json; using System.Linq; + using System.Xml; + using System.Xml.Linq; /// /// Defines headers for loginUser operation. @@ -45,6 +47,46 @@ public LoginUserHeaders() { } [JsonProperty(PropertyName = "X-Expires-After")] public System.DateTime? XExpiresAfter { get; set; } + /// + /// Serializes the object to an XML node + /// + internal XElement XmlSerialize(XElement result) + { + if( null != XRateLimit ) + { + result.Add(new XElement("X-Rate-Limit", XRateLimit) ); + } + if( null != XExpiresAfter ) + { + result.Add(new XElement("X-Expires-After", XExpiresAfter) ); + } + return result; + } + /// + /// Deserializes an XML node to an instance of LoginUserHeaders + /// + internal static LoginUserHeaders XmlDeserialize(string payload) + { + // deserialize to xml and use the overload to do the work + return XmlDeserialize( XElement.Parse( payload ) ); + } + internal static LoginUserHeaders XmlDeserialize(XElement payload) + { + var result = new LoginUserHeaders(); + var deserializeXRateLimit = XmlSerialization.ToDeserializer(e => (int?)e); + int? resultXRateLimit; + if (deserializeXRateLimit(payload, "X-Rate-Limit", out resultXRateLimit)) + { + result.XRateLimit = resultXRateLimit; + } + var deserializeXExpiresAfter = XmlSerialization.ToDeserializer(e => (System.DateTime?)e); + System.DateTime? resultXExpiresAfter; + if (deserializeXExpiresAfter(payload, "X-Expires-After", out resultXExpiresAfter)) + { + result.XExpiresAfter = resultXExpiresAfter; + } + return result; + } } } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2NoSync/Models/Order.cs b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2NoSync/Models/Order.cs index 1873b1353a..ba6f2473d0 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2NoSync/Models/Order.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2NoSync/Models/Order.cs @@ -11,6 +11,8 @@ namespace Fixtures.PetstoreV2NoSync.Models using PetstoreV2NoSync; using Newtonsoft.Json; using System.Linq; + using System.Xml; + using System.Xml.Linq; public partial class Order { @@ -66,6 +68,86 @@ public Order() { } [JsonProperty(PropertyName = "complete")] public bool? Complete { get; set; } + /// + /// Serializes the object to an XML node + /// + internal XElement XmlSerialize(XElement result) + { + if( null != Id ) + { + result.Add(new XElement("id", Id) ); + } + if( null != PetId ) + { + result.Add(new XElement("petId", PetId) ); + } + if( null != Quantity ) + { + result.Add(new XElement("quantity", Quantity) ); + } + if( null != ShipDate ) + { + result.Add(new XElement("shipDate", ShipDate) ); + } + if( null != Status ) + { + result.Add(new XElement("status", Status) ); + } + if( null != Complete ) + { + result.Add(new XElement("complete", Complete) ); + } + return result; + } + /// + /// Deserializes an XML node to an instance of Order + /// + internal static Order XmlDeserialize(string payload) + { + // deserialize to xml and use the overload to do the work + return XmlDeserialize( XElement.Parse( payload ) ); + } + internal static Order XmlDeserialize(XElement payload) + { + var result = new Order(); + var deserializeId = XmlSerialization.ToDeserializer(e => (long?)e); + long? resultId; + if (deserializeId(payload, "id", out resultId)) + { + result.Id = resultId; + } + var deserializePetId = XmlSerialization.ToDeserializer(e => (long?)e); + long? resultPetId; + if (deserializePetId(payload, "petId", out resultPetId)) + { + result.PetId = resultPetId; + } + var deserializeQuantity = XmlSerialization.ToDeserializer(e => (int?)e); + int? resultQuantity; + if (deserializeQuantity(payload, "quantity", out resultQuantity)) + { + result.Quantity = resultQuantity; + } + var deserializeShipDate = XmlSerialization.ToDeserializer(e => (System.DateTime?)e); + System.DateTime? resultShipDate; + if (deserializeShipDate(payload, "shipDate", out resultShipDate)) + { + result.ShipDate = resultShipDate; + } + var deserializeStatus = XmlSerialization.ToDeserializer(e => (string)e); + string resultStatus; + if (deserializeStatus(payload, "status", out resultStatus)) + { + result.Status = resultStatus; + } + var deserializeComplete = XmlSerialization.ToDeserializer(e => (bool?)e); + bool? resultComplete; + if (deserializeComplete(payload, "complete", out resultComplete)) + { + result.Complete = resultComplete; + } + return result; + } } } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2NoSync/Models/Pet.cs b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2NoSync/Models/Pet.cs index 27c08e3ffd..df02c4de11 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2NoSync/Models/Pet.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2NoSync/Models/Pet.cs @@ -14,6 +14,8 @@ namespace Fixtures.PetstoreV2NoSync.Models using System.Collections; using System.Collections.Generic; using System.Linq; + using System.Xml; + using System.Xml.Linq; public partial class Pet { @@ -104,6 +106,128 @@ public virtual void Validate() throw new ValidationException(ValidationRules.CannotBeNull, "PhotoUrls"); } } + /// + /// Serializes the object to an XML node + /// + internal XElement XmlSerialize(XElement result) + { + if( null != Id ) + { + result.Add(new XElement("id", Id) ); + } + if( null != Category ) + { + result.Add(Category.XmlSerialize(new XElement( "category" ))); + } + if( null != Name ) + { + result.Add(new XElement("name", Name) ); + } + if( null != PhotoUrls ) + { + var seq = new XElement("photoUrl"); + foreach( var value in PhotoUrls ){ + seq.Add(new XElement( "photoUrl", value ) ); + } + result.Add(seq); + } + if( null != Tags ) + { + var seq = new XElement("tag"); + foreach( var value in Tags ){ + seq.Add(value.XmlSerialize( new XElement( "tag") ) ); + } + result.Add(seq); + } + if( null != SByteProperty ) + { + result.Add(new XElement("sByte", SByteProperty) ); + } + if( null != Birthday ) + { + result.Add(new XElement("birthday", Birthday) ); + } + if( null != Dictionary ) + { + var dict = new XElement("dictionary"); + foreach( var key in Dictionary.Keys ) { + dict.Add(Dictionary[key].XmlSerialize(new XElement(key) ) ); + } + result.Add(dict); + } + if( null != Status ) + { + result.Add(new XElement("status", Status) ); + } + return result; + } + /// + /// Deserializes an XML node to an instance of Pet + /// + internal static Pet XmlDeserialize(string payload) + { + // deserialize to xml and use the overload to do the work + return XmlDeserialize( XElement.Parse( payload ) ); + } + internal static Pet XmlDeserialize(XElement payload) + { + var result = new Pet(); + var deserializeId = XmlSerialization.ToDeserializer(e => (long?)e); + long? resultId; + if (deserializeId(payload, "id", out resultId)) + { + result.Id = resultId; + } + var deserializeCategory = XmlSerialization.ToDeserializer(e => Category.XmlDeserialize(e)); + Category resultCategory; + if (deserializeCategory(payload, "category", out resultCategory)) + { + result.Category = resultCategory; + } + var deserializeName = XmlSerialization.ToDeserializer(e => (string)e); + string resultName; + if (deserializeName(payload, "name", out resultName)) + { + result.Name = resultName; + } + var deserializePhotoUrls = XmlSerialization.CreateListXmlDeserializer(XmlSerialization.ToDeserializer(e => (string)e), "photoUrl"); + IList resultPhotoUrls; + if (deserializePhotoUrls(payload, "photoUrl", out resultPhotoUrls)) + { + result.PhotoUrls = resultPhotoUrls; + } + var deserializeTags = XmlSerialization.CreateListXmlDeserializer(XmlSerialization.ToDeserializer(e => Tag.XmlDeserialize(e)), "tag"); + IList resultTags; + if (deserializeTags(payload, "tag", out resultTags)) + { + result.Tags = resultTags; + } + var deserializeSByteProperty = XmlSerialization.ToDeserializer(e => System.Convert.FromBase64String(e.Value)); + byte[] resultSByteProperty; + if (deserializeSByteProperty(payload, "sByte", out resultSByteProperty)) + { + result.SByteProperty = resultSByteProperty; + } + var deserializeBirthday = XmlSerialization.ToDeserializer(e => (System.DateTime?)e); + System.DateTime? resultBirthday; + if (deserializeBirthday(payload, "birthday", out resultBirthday)) + { + result.Birthday = resultBirthday; + } + var deserializeDictionary = XmlSerialization.CreateDictionaryXmlDeserializer(XmlSerialization.ToDeserializer(e => Category.XmlDeserialize(e))); + IDictionary resultDictionary; + if (deserializeDictionary(payload, "dictionary", out resultDictionary)) + { + result.Dictionary = resultDictionary; + } + var deserializeStatus = XmlSerialization.ToDeserializer(e => (string)e); + string resultStatus; + if (deserializeStatus(payload, "status", out resultStatus)) + { + result.Status = resultStatus; + } + return result; + } } } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2NoSync/Models/Tag.cs b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2NoSync/Models/Tag.cs index b5d3bb720e..e5126473a7 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2NoSync/Models/Tag.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2NoSync/Models/Tag.cs @@ -11,6 +11,8 @@ namespace Fixtures.PetstoreV2NoSync.Models using PetstoreV2NoSync; using Newtonsoft.Json; using System.Linq; + using System.Xml; + using System.Xml.Linq; public partial class Tag { @@ -38,6 +40,46 @@ public Tag() { } [JsonProperty(PropertyName = "name")] public string Name { get; set; } + /// + /// Serializes the object to an XML node + /// + internal XElement XmlSerialize(XElement result) + { + if( null != Id ) + { + result.Add(new XElement("id", Id) ); + } + if( null != Name ) + { + result.Add(new XElement("name", Name) ); + } + return result; + } + /// + /// Deserializes an XML node to an instance of Tag + /// + internal static Tag XmlDeserialize(string payload) + { + // deserialize to xml and use the overload to do the work + return XmlDeserialize( XElement.Parse( payload ) ); + } + internal static Tag XmlDeserialize(XElement payload) + { + var result = new Tag(); + var deserializeId = XmlSerialization.ToDeserializer(e => (long?)e); + long? resultId; + if (deserializeId(payload, "id", out resultId)) + { + result.Id = resultId; + } + var deserializeName = XmlSerialization.ToDeserializer(e => (string)e); + string resultName; + if (deserializeName(payload, "name", out resultName)) + { + result.Name = resultName; + } + return result; + } } } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2NoSync/Models/User.cs b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2NoSync/Models/User.cs index 4a153bee9c..d25eac39d3 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2NoSync/Models/User.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2NoSync/Models/User.cs @@ -11,6 +11,8 @@ namespace Fixtures.PetstoreV2NoSync.Models using PetstoreV2NoSync; using Newtonsoft.Json; using System.Linq; + using System.Xml; + using System.Xml.Linq; public partial class User { @@ -76,6 +78,106 @@ public User() { } [JsonProperty(PropertyName = "userStatus")] public int? UserStatus { get; set; } + /// + /// Serializes the object to an XML node + /// + internal XElement XmlSerialize(XElement result) + { + if( null != Id ) + { + result.Add(new XElement("id", Id) ); + } + if( null != Username ) + { + result.Add(new XElement("username", Username) ); + } + if( null != FirstName ) + { + result.Add(new XElement("firstName", FirstName) ); + } + if( null != LastName ) + { + result.Add(new XElement("lastName", LastName) ); + } + if( null != Email ) + { + result.Add(new XElement("email", Email) ); + } + if( null != Password ) + { + result.Add(new XElement("password", Password) ); + } + if( null != Phone ) + { + result.Add(new XElement("phone", Phone) ); + } + if( null != UserStatus ) + { + result.Add(new XElement("userStatus", UserStatus) ); + } + return result; + } + /// + /// Deserializes an XML node to an instance of User + /// + internal static User XmlDeserialize(string payload) + { + // deserialize to xml and use the overload to do the work + return XmlDeserialize( XElement.Parse( payload ) ); + } + internal static User XmlDeserialize(XElement payload) + { + var result = new User(); + var deserializeId = XmlSerialization.ToDeserializer(e => (long?)e); + long? resultId; + if (deserializeId(payload, "id", out resultId)) + { + result.Id = resultId; + } + var deserializeUsername = XmlSerialization.ToDeserializer(e => (string)e); + string resultUsername; + if (deserializeUsername(payload, "username", out resultUsername)) + { + result.Username = resultUsername; + } + var deserializeFirstName = XmlSerialization.ToDeserializer(e => (string)e); + string resultFirstName; + if (deserializeFirstName(payload, "firstName", out resultFirstName)) + { + result.FirstName = resultFirstName; + } + var deserializeLastName = XmlSerialization.ToDeserializer(e => (string)e); + string resultLastName; + if (deserializeLastName(payload, "lastName", out resultLastName)) + { + result.LastName = resultLastName; + } + var deserializeEmail = XmlSerialization.ToDeserializer(e => (string)e); + string resultEmail; + if (deserializeEmail(payload, "email", out resultEmail)) + { + result.Email = resultEmail; + } + var deserializePassword = XmlSerialization.ToDeserializer(e => (string)e); + string resultPassword; + if (deserializePassword(payload, "password", out resultPassword)) + { + result.Password = resultPassword; + } + var deserializePhone = XmlSerialization.ToDeserializer(e => (string)e); + string resultPhone; + if (deserializePhone(payload, "phone", out resultPhone)) + { + result.Phone = resultPhone; + } + var deserializeUserStatus = XmlSerialization.ToDeserializer(e => (int?)e); + int? resultUserStatus; + if (deserializeUserStatus(payload, "userStatus", out resultUserStatus)) + { + result.UserStatus = resultUserStatus; + } + return result; + } } } diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2NoSync/Models/XmlSerialization.cs b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2NoSync/Models/XmlSerialization.cs new file mode 100644 index 0000000000..bb2986ac58 --- /dev/null +++ b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2NoSync/Models/XmlSerialization.cs @@ -0,0 +1,90 @@ +namespace Fixtures.PetstoreV2NoSync +{ + using System.Collections; + using System.Collections.Generic; + using System.Xml; + using System.Xml.Linq; + internal static class XmlSerialization + { + internal delegate bool XmlRootDeserializer( XElement root, out T result ); + internal delegate bool XmlDeserializer( XElement parent, string propertyName, out T result ); + internal static XmlRootDeserializer Root( XmlDeserializer deserializer ) => + (XElement root, out T result) => deserializer(new XElement("artificialRoot", root), root.Name.LocalName, out result); + private static XmlDeserializer Unroot( XmlRootDeserializer deserializer ) + { + return (XElement parent, string propertyName, out T result) => { + result = default(T); + var element = parent.Element(propertyName); + if (element == null) + { + return false; + } + return deserializer(element, out result); + }; + } + private static XmlRootDeserializer ToRootDeserializer( System.Func unsafeDeserializer ) + => (XElement root, out T result) => { + try + { + result = unsafeDeserializer(root); + return true; + } + catch + { + result = default(T); + return false; + }}; + internal static XmlDeserializer ToDeserializer( System.Func unsafeDeserializer ) + => Unroot(ToRootDeserializer(unsafeDeserializer)); + internal static XmlDeserializer> CreateListXmlDeserializer( XmlDeserializer elementDeserializer, string elementTagName = null /*if isWrapped = false*/ ) + { + if (elementTagName != null) + { + // create non-wrapped deserializer and forward + var slave = CreateListXmlDeserializer( elementDeserializer ); + return (XElement parent, string propertyName, out IList result) => { + result = null; + var wrapper = parent.Element(propertyName); + return wrapper != null && slave(wrapper, elementTagName, out result); + }; + } + var rootElementDeserializer = Root(elementDeserializer); + return (XElement parent, string propertyName, out IList result) => { + result = new List(); + foreach (var element in parent.Elements(propertyName)) + { + T elementResult; + if (!rootElementDeserializer(element, out elementResult)) + { + return false; + } + result.Add(elementResult); + } + return true; + }; + } + internal static XmlDeserializer> CreateDictionaryXmlDeserializer( XmlDeserializer elementDeserializer ) + { + return (XElement parent, string propertyName, out IDictionary result) => { + result = null; + var childElement = parent.Element(propertyName); + if (childElement == null) + { + return false; + } + result = new Dictionary(); + foreach (var element in childElement.Elements()) + { + T elementResult; + if (!elementDeserializer(childElement, element.Name.LocalName, out elementResult)) + { + return false; + } + result.Add(element.Name.LocalName, elementResult); + } + return true; + }; + } + } +} + diff --git a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2NoSync/SwaggerPetstoreV2.cs b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2NoSync/SwaggerPetstoreV2.cs index 2503abcce1..2d5627d346 100644 --- a/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2NoSync/SwaggerPetstoreV2.cs +++ b/src/generator/AutoRest.CSharp.Tests/Expected/PetstoreV2NoSync/SwaggerPetstoreV2.cs @@ -38,12 +38,12 @@ public partial class SwaggerPetstoreV2 : ServiceClient, ISwag /// /// Gets or sets json serialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings SerializationSettings { get; private set; } + public JsonSerializerSettings SerializationSettings { get; private set; } /// /// Gets or sets json deserialization settings. /// - public Newtonsoft.Json.JsonSerializerSettings DeserializationSettings { get; private set; } + public JsonSerializerSettings DeserializationSettings { get; private set; } /// /// Initializes a new instance of the SwaggerPetstoreV2 class. @@ -125,27 +125,27 @@ public SwaggerPetstoreV2(System.Uri baseUri, System.Net.Http.HttpClientHandler r private void Initialize() { BaseUri = new System.Uri("http://petstore.swagger.io/v2"); - SerializationSettings = new Newtonsoft.Json.JsonSerializerSettings + SerializationSettings = new JsonSerializerSettings { - Formatting = Newtonsoft.Json.Formatting.Indented, - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } }; - DeserializationSettings = new Newtonsoft.Json.JsonSerializerSettings + DeserializationSettings = new JsonSerializerSettings { - DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, - DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, - NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, - ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, ContractResolver = new ReadOnlyJsonContractResolver(), - Converters = new System.Collections.Generic.List + Converters = new List { new Iso8601TimeSpanConverter() } @@ -209,6 +209,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -275,9 +277,17 @@ private void Initialize() _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + Pet _tmp_ = null; + if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" && + XmlSerialization.Root(XmlSerialization.ToDeserializer(e => Pet.XmlDeserialize(e)))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_)) + { + _result.Body = _tmp_; + }else + { + _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + } } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -348,6 +358,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -480,6 +492,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -540,9 +554,17 @@ private void Initialize() _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings); + IList _tmp_ = null; + if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" && + XmlSerialization.Root(XmlSerialization.CreateListXmlDeserializer(XmlSerialization.ToDeserializer(e => Pet.XmlDeserialize(e)), "null"))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_)) + { + _result.Body = _tmp_; + }else + { + _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings); + } } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -625,6 +647,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -685,9 +709,17 @@ private void Initialize() _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings); + IList _tmp_ = null; + if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" && + XmlSerialization.Root(XmlSerialization.CreateListXmlDeserializer(XmlSerialization.ToDeserializer(e => Pet.XmlDeserialize(e)), "null"))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_)) + { + _result.Body = _tmp_; + }else + { + _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings); + } } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -751,6 +783,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -811,9 +845,17 @@ private void Initialize() _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + Pet _tmp_ = null; + if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" && + XmlSerialization.Root(XmlSerialization.ToDeserializer(e => Pet.XmlDeserialize(e)))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_)) + { + _result.Body = _tmp_; + }else + { + _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + } } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -893,6 +935,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1032,6 +1076,8 @@ private void Initialize() } _httpRequest.Headers.TryAddWithoutValidation("api_key", apiKey); } + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1135,6 +1181,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1195,9 +1243,17 @@ private void Initialize() _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings); + IDictionary _tmp_ = null; + if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" && + XmlSerialization.Root(XmlSerialization.CreateDictionaryXmlDeserializer(XmlSerialization.ToDeserializer(e => (int?)e)))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_)) + { + _result.Body = _tmp_; + }else + { + _result.Body = SafeJsonConvert.DeserializeObject>(_responseContent, DeserializationSettings); + } } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1267,6 +1323,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1333,9 +1391,17 @@ private void Initialize() _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + Order _tmp_ = null; + if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" && + XmlSerialization.Root(XmlSerialization.ToDeserializer(e => Order.XmlDeserialize(e)))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_)) + { + _result.Body = _tmp_; + }else + { + _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + } } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1421,6 +1487,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1481,9 +1549,17 @@ private void Initialize() _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + Order _tmp_ = null; + if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" && + XmlSerialization.Root(XmlSerialization.ToDeserializer(e => Order.XmlDeserialize(e)))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_)) + { + _result.Body = _tmp_; + }else + { + _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + } } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -1562,6 +1638,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("DELETE"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1676,6 +1754,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1793,6 +1873,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -1910,6 +1992,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("POST"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2051,6 +2135,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2111,9 +2197,17 @@ private void Initialize() _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + string _tmp_ = null; + if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" && + XmlSerialization.Root(XmlSerialization.ToDeserializer(e => (string)e))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_)) + { + _result.Body = _tmp_; + }else + { + _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + } } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2125,9 +2219,9 @@ private void Initialize() } try { - _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(Newtonsoft.Json.JsonSerializer.Create(DeserializationSettings)); + _result.Headers = _httpResponse.GetHeadersAsJson().ToObject(JsonSerializer.Create(DeserializationSettings)); } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2179,6 +2273,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2294,6 +2390,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("GET"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2354,9 +2452,17 @@ private void Initialize() _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); try { - _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + User _tmp_ = null; + if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" && + XmlSerialization.Root(XmlSerialization.ToDeserializer(e => User.XmlDeserialize(e)))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_)) + { + _result.Body = _tmp_; + }else + { + _result.Body = SafeJsonConvert.DeserializeObject(_responseContent, DeserializationSettings); + } } - catch (Newtonsoft.Json.JsonException ex) + catch (JsonException ex) { _httpRequest.Dispose(); if (_httpResponse != null) @@ -2435,6 +2541,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("PUT"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) @@ -2556,6 +2664,8 @@ private void Initialize() _httpRequest.Method = new System.Net.Http.HttpMethod("DELETE"); _httpRequest.RequestUri = new System.Uri(_url); // Set Headers + + if (customHeaders != null) { foreach(var _header in customHeaders) diff --git a/src/generator/AutoRest.CSharp.Unit.Tests/BugTest.cs b/src/generator/AutoRest.CSharp.Unit.Tests/BugTest.cs index 3d63d48ed8..0b36f18ba1 100644 --- a/src/generator/AutoRest.CSharp.Unit.Tests/BugTest.cs +++ b/src/generator/AutoRest.CSharp.Unit.Tests/BugTest.cs @@ -20,7 +20,7 @@ namespace AutoRest.CSharp.Unit.Tests public class BugTest { private ITestOutputHelper _output; - internal static string[] SuppressWarnings = {"CS1701", "CS1591" }; + internal static string[] SuppressWarnings = {"CS1701", "CS1591" , "CS1573"}; //Todo: Remove CS1591 when issue https://github.com/Azure/autorest/issues/1387 is fixed @@ -47,7 +47,8 @@ internal bool StartVsCode(params object[] args) startInfo = new ProcessStartInfo(exe, args.Aggregate( - $@"""{Path.Combine(exe, @"..\resources\app\out\cli.js")}""", + // $@"""{Path.Combine(exe, @"..\resources\app\out\cli.js")}""", + "", (s, o) => $"{s} {Q}{o}{Q}")); startInfo.EnvironmentVariables.Add("ATOM_SHELL_INTERNAL_RUN_AS_NODE", "1"); startInfo.UseShellExecute = false; @@ -98,7 +99,7 @@ public BugTest() protected virtual MemoryFileSystem CreateMockFilesystem() { var fs = new MemoryFileSystem(); - fs.Copy(Path.Combine("Resource", "AutoRest.json")); + fs.CopyFile(Path.Combine("Resource", "AutoRest.json"), "AutoRest.json"); return fs; } @@ -186,6 +187,7 @@ protected async Task Compile(IFileSystem fileSystem) .Select(each => each.Location) .Concat(assemblies) )); + var result = await compiler.Compile(OutputKind.DynamicallyLinkedLibrary); // if it failed compiling and we're in an interactive session diff --git a/src/generator/AutoRest.CSharp.Unit.Tests/Resource/XmlSerialization/GeneratedCode/Program._cs b/src/generator/AutoRest.CSharp.Unit.Tests/Resource/XmlSerialization/GeneratedCode/Program._cs new file mode 100644 index 0000000000..2762ded6a6 --- /dev/null +++ b/src/generator/AutoRest.CSharp.Unit.Tests/Resource/XmlSerialization/GeneratedCode/Program._cs @@ -0,0 +1,49 @@ +namespace XmlSerialization { + + using System; + using Test; + using Test.Models; + + public class Program { + public int Main(string baseUri) { + var client = new SimpleAPI(); + client.BaseUri = new Uri(baseUri); + var result = client.Service.ListContainers(); + + var r2 = client.Service.SetServiceProperties(new StorageServiceProperties { + Logging = new StorageServicePropertiesLogging { + Version = "1.0", + Delete = true, + Read = false, + Write = true, + RetentionPolicy = new RetentionPolicy { + Enabled = true, + Days = 7 + } + }, + HourMetrics = new Metrics { + Version = "1.0", + Enabled = true, + IncludeAPIs = false, + RetentionPolicy = new RetentionPolicy { + Enabled = true, + Days = 7 + } + }, + MinuteMetrics = new Metrics { + Version = "1.0", + Enabled = true, + IncludeAPIs = true, + RetentionPolicy = new RetentionPolicy { + Enabled = true, + Days = 7 + } + }, + + + }); + + return 0; + } + } +} diff --git a/src/generator/AutoRest.CSharp.Unit.Tests/Resource/XmlSerialization/XmlSerialization.yaml b/src/generator/AutoRest.CSharp.Unit.Tests/Resource/XmlSerialization/XmlSerialization.yaml new file mode 100644 index 0000000000..a9ba256ebd --- /dev/null +++ b/src/generator/AutoRest.CSharp.Unit.Tests/Resource/XmlSerialization/XmlSerialization.yaml @@ -0,0 +1,594 @@ +swagger: '2.0' +info: + version: 1.0.0 + title: Simple API +produces: + - application/xml +consumes: + - application/xml +paths: + "/?comp=list": + get: + tags: + - service + operationId: Service_ListContainers + parameters: + - name: comp + in: query + required: true + type: string + enum: + - list + - name: prefix + in: query + required: false + type: string + description: Filters the results to return only containers whose name begins + with the specified prefix. + - name: marker + in: query + required: false + type: string + description: A string value that identifies the portion of the list to be + returned with the next list operation. + - name: maxresults + in: query + required: false + type: integer + description: Specifies the maximum number of containers to return. + - "$ref": "#/parameters/ApiVersionParameter" + - "$ref": "#/parameters/ClientRequestId" + responses: + '200': + description: Success. + headers: + x-ms-request-id: + type: string + description: This header uniquely identifies the request that was made + and can be used for troubleshooting the request. + x-ms-version: + type: string + description: Indicates the version of the Blob service used to execute + the request. This header is returned for requests made against version + 2009-09-19 and above. + schema: + "$ref": "#/definitions/ContainerEnumerationResults" + default: + "$ref": "#/responses/Default" + "/?restype=service&comp=properties": + get: + tags: + - service + operationId: Service_GetServiceProperties + parameters: + - name: restype + in: query + required: true + type: string + enum: + - service + - name: comp + in: query + required: true + type: string + enum: + - properties + - "$ref": "#/parameters/ApiVersionParameter" + - "$ref": "#/parameters/ClientRequestId" + responses: + '200': + description: Success. + headers: + x-ms-request-id: + type: string + description: This header uniquely identifies the request that was made + and can be used for troubleshooting the request. + x-ms-version: + type: string + description: Indicates the version of the Blob service used to execute + the request. This header is returned for requests made against version + 2009-09-19 and above. + schema: + "$ref": "#/definitions/StorageServiceProperties" + default: + "$ref": "#/responses/Default" + put: + tags: + - service + operationId: Service_SetServiceProperties + parameters: + - name: restype + in: query + required: true + type: string + enum: + - service + - name: comp + in: query + required: true + type: string + enum: + - properties + - "$ref": "#/parameters/ApiVersionParameter" + - "$ref": "#/parameters/ClientRequestId" + - name: body + in: body + required: true + schema: + "$ref": "#/definitions/StorageServiceProperties" + responses: + '200': + description: Success. + headers: + x-ms-request-id: + type: string + description: This header uniquely identifies the request that was made + and can be used for troubleshooting the request. + x-ms-version: + type: string + description: Indicates the version of the Blob service used to execute + the request. This header is returned for requests made against version + 2009-09-19 and above. + default: + "$ref": "#/responses/Default" + "/{container}?restype=container&comp=list": + get: + tags: + - containers + operationId: Containers_ListBlobs + parameters: + - name: restype + in: query + required: true + type: string + enum: + - container + - name: comp + in: query + required: true + type: string + enum: + - list + - "$ref": "#/parameters/Container" + - name: prefix + in: query + required: false + type: string + description: Filters the results to return only containers whose name begins + with the specified prefix. + - name: delimiter + in: query + required: false + type: string + description: Optional. When the request includes this parameter, the operation + returns a BlobPrefix element in the response body that acts as a placeholder + for all blobs whose names begin with the same substring up to the appearance + of the delimiter character. The delimiter may be a single character or a + string. + - name: marker + in: query + required: false + type: string + description: A string value that identifies the portion of the list to be + returned with the next list operation. + - name: maxresults + in: query + required: false + type: integer + description: Specifies the maximum number of containers to return. + - name: include + in: query + required: false + type: string + enum: + - snapshots + - metadata + - uncommittedblobs + - copy + description: > + Optional. Specifies one or more datasets to include in the response: + - snapshots: Specifies that snapshots should be included in the enumeration. + Snapshots are listed from oldest to newest in the response. - metadata: + Specifies that blob metadata be returned in the response. - uncommittedblobs: + Specifies that blobs for which blocks have been uploaded, but which have + not been committed using Put Block List, be included in the response. - + copy: Version 2012-02-12 and newer. Specifies that metadata related to any + current or previous Copy Blob operation should be included in the response. + - "$ref": "#/parameters/ApiVersionParameter" + - "$ref": "#/parameters/ClientRequestId" + responses: + '201': + description: Success. + headers: + x-ms-request-id: + type: string + description: This header uniquely identifies the request that was made + and can be used for troubleshooting the request. + x-ms-version: + type: string + description: Indicates the version of the Blob service used to execute + the request. This header is returned for requests made against version + 2009-09-19 and above. + schema: + "$ref": "#/definitions/BlobEnumerationResults" + default: + "$ref": "#/responses/Default" + "/{container}?restype=container&comp=acl": + get: + tags: + - service + operationId: Containers_GetACL + parameters: + - name: restype + in: query + required: true + type: string + enum: + - container + - name: comp + in: query + required: true + type: string + enum: + - acl + - "$ref": "#/parameters/Container" + - "$ref": "#/parameters/ApiVersionParameter" + - "$ref": "#/parameters/ClientRequestId" + responses: + '200': + description: Success. + headers: + x-ms-request-id: + type: string + description: This header uniquely identifies the request that was made + and can be used for troubleshooting the request. + x-ms-version: + type: string + description: Indicates the version of the Blob service used to execute + the request. This header is returned for requests made against version + 2009-09-19 and above. + schema: + "$ref": "#/definitions/SignedIdentifiers" + default: + "$ref": "#/responses/Default" + put: + tags: + - service + operationId: Container_SetACL + parameters: + - name: restype + in: query + required: true + type: string + enum: + - container + - name: comp + in: query + required: true + type: string + enum: + - acl + - "$ref": "#/parameters/Container" + - "$ref": "#/parameters/ApiVersionParameter" + - "$ref": "#/parameters/ClientRequestId" + - name: body + in: body + required: true + schema: + "$ref": "#/definitions/SignedIdentifiers" + responses: + '200': + description: Success. + headers: + x-ms-request-id: + type: string + description: This header uniquely identifies the request that was made + and can be used for troubleshooting the request. + x-ms-version: + type: string + description: Indicates the version of the Blob service used to execute + the request. This header is returned for requests made against version + 2009-09-19 and above. + default: + "$ref": "#/responses/Default" + +definitions: + Blob: + type: object + properties: + Name: + type: string + Snapshot: + type: string + Properties: + "$ref": "#/definitions/BlobProperties" + Metadata: + type: object + additionalProperties: {} + BlobEnumerationResults: + type: object + properties: + ServiceEndpoint: + type: string + xml: + attribute: true + ContainerName: + type: string + xml: + attribute: true + Prefix: + type: string + Marker: + type: string + Delimiter: + type: string + MaxResults: + type: integer + Blobs: + type: array + items: + "$ref": "#/definitions/Blob" + BlobPrefix: + type: object + schema: + properties: + Name: + type: string + NextMarker: + type: string + BlobProperties: + type: object + properties: + Etag: + type: string + Last-Modified: + type: string + format: date-time + Content-Length: + type: integer + Content-Type: + type: string + Content-Encoding: + type: string + Content-Language: + type: string + Content-MD5: + type: string + Cache-Control: + type: string + x-ms-blob-sequence-number: + type: integer + x-ms-client-name: sequenceNumber + BlobType: + type: string + enum: + - BlockBlob + - PageBlob + - AppendBlob + LeaseStatus: + "$ref": "#/definitions/LeaseStatus" + LeaseState: + "$ref": "#/definitions/LeaseState" + LeaseDuration: + "$ref": "#/definitions/LeaseDuration" + CopyId: + type: integer + CopyStatus: + type: string + enum: + - pending + - success + - aborted + - failed + CopySource: + type: string + CopyProgress: + type: integer + CopyCompletionTime: + type: string + format: date-time + CopyStatusDescription: + type: string + ServerEncrypted: + type: boolean + Container: + type: object + properties: + Name: + type: string + Properties: + "$ref": "#/definitions/ContainerProperties" + Metadata: + type: object + additionalProperties: {} + ContainerEnumerationResults: + type: object + properties: + ServiceEndpoint: + type: string + xml: + attribute: true + Prefix: + type: string + Marker: + type: string + MaxResults: + type: integer + Containers: + type: array + items: + "$ref": "#/definitions/Container" + NextMarker: + type: string + ContainerProperties: + type: object + properties: + Etag: + type: string + Last-Modified: + type: string + format: date-time + LeaseStatus: + "$ref": "#/definitions/LeaseStatus" + LeaseState: + "$ref": "#/definitions/LeaseState" + LeaseDuration: + "$ref": "#/definitions/LeaseDuration" + LeaseStatus: + type: string + enum: + - locked + - unlocked + x-ms-enum: + name: LeaseStatus + modelAsString: false + LeaseState: + type: string + enum: + - available + - leased + - expired + - breaking + - broken + x-ms-enum: + name: LeaseState + modelAsString: false + LeaseDuration: + type: string + enum: + - pending + - success + - aborted + - failed + x-ms-enum: + name: LeaseDuration + modelAsString: false + Metrics: + properties: + Version: + type: string + xml: + name: Version + Enabled: + type: boolean + xml: + name: Enabled + IncludeAPIs: + type: boolean + xml: + name: IncludeAPIs + RetentionPolicy: + type: object + "$ref": "#/definitions/RetentionPolicy" + xml: + name: RetentionPolicy + RetentionPolicy: + type: object + xml: + name: RetentionPolicy + properties: + Enabled: + type: boolean + xml: + name: Enabled + Days: + type: integer + xml: + name: Days + StorageServiceProperties: + type: object + properties: + Logging: + type: object + xml: + name: Logging + properties: + Version: + type: string + xml: + name: Version + Delete: + type: boolean + xml: + name: Delete + Read: + type: boolean + xml: + name: Read + Write: + type: boolean + xml: + name: Write + RetentionPolicy: + "$ref": "#/definitions/RetentionPolicy" + HourMetrics: + "$ref": "#/definitions/Metrics" + xml: + name: HourMetrics + MinuteMetrics: + "$ref": "#/definitions/Metrics" + xml: + name: MinuteMetrics + SignedIdentifiers: + type: array + items: + "$ref": "#/definitions/SignedIdentifier" + SignedIdentifier: + type: object + properties: + Id: + type: string + minLength: "64" + maxLength: "64" + AccessPolicy: + type: object + properties: + Start: + type: string + format: date-time + Expiry: + type: string + format: date-time + Permission: + type: string + +parameters: + ApiVersionParameter: + name: x-ms-version + x-ms-client-name: version + in: header + required: false + type: string + x-ms-global: true + #enum: + #- '2015-04-05' + #- '2014-02-14' + #- '2013-08-15' + #- '2012-02-12' + #- '2011-08-18' + #- '2009-09-19' + #- '2009-07-17' + #- '2009-04-14' + default: '2015-04-05' + description: Specifies the version of the operation to use for this request. + ClientRequestId: + name: x-ms-client-request-id + x-ms-client-name: requestId + in: header + required: false + type: string + x-ms-parameter-location: method + description: Provides a client-generated, opaque value with a 1 KB character limit + that is recorded in the analytics logs when storage analytics logging is enabled. + Container: + name: container + in: path + required: true + type: string + x-ms-parameter-location: method + description: The container name. + +responses: + Default: + description: Error. + \ No newline at end of file diff --git a/src/generator/AutoRest.CSharp.Unit.Tests/ServiceController.cs b/src/generator/AutoRest.CSharp.Unit.Tests/ServiceController.cs new file mode 100644 index 0000000000..a86a82fbc0 --- /dev/null +++ b/src/generator/AutoRest.CSharp.Unit.Tests/ServiceController.cs @@ -0,0 +1,313 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +using System; +using System.Configuration; +using System.Diagnostics; +using System.Globalization; +using System.IO; +using Microsoft.Extensions.Logging; +#if PORTABLE + +#endif + +namespace AutoRest.CSharp.Unit.Tests +{ + using System.Text.RegularExpressions; + using System.Threading; + + public class ProcessOutputListener + { + public ProcessOutputListener() + { + this.ProcessStarted = new ManualResetEvent(false); + } + + public ManualResetEvent ProcessStarted { get; private set; } + + public void ProcessOutput(object sendingProcess, DataReceivedEventArgs data) + { + if (data == null) + { + throw new ArgumentNullException("data"); + } + + ScrubAndWriteValue("SERVICE STDOUT", data.Data); + if (data.Data != null && data.Data.Contains("Server started")) + { + ProcessStarted.Set(); + } + } + + public void ProcessError(object sendingProcess, DataReceivedEventArgs data) + { + if (data == null) + { + throw new ArgumentNullException("data"); + } + + ScrubAndWriteValue("SERVICE ERROR", data.Data); + } + + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", + "CA1801:ReviewUnusedParameters", + MessageId = "prefix", + Justification = "To avoid the warning when build under Release")] + private static void ScrubAndWriteValue(string prefix, string data) + { + if (!string.IsNullOrEmpty(data)) + { + string scrubbed = Regex.Replace(data, @"[^\u0000-\u007F]", string.Empty); + scrubbed = Regex.Replace(scrubbed, @"\x1b\[\d+m", " "); + if (!string.IsNullOrWhiteSpace(scrubbed)) + { + Debug.WriteLine("{0}: {1}", prefix, scrubbed); + } + } + } + } + + /// + /// Control creation and execution of node.js deserialization service + /// + public class ServiceController : IDisposable + { + private const string NpmCommand = "npm.cmd"; + private const string NpmArgument = "install"; + private const string NodeCommand = "node.exe"; + private const string NodeArgument = "./startup/www"; + + private ProcessOutputListener _listener; + + private object _sync = new object(); + public ServiceController(int? portNumber = null) + { + Port = portNumber?? GetRandomPortNumber(); + EnsureService(); + } + +#if PORTABLE + private static readonly ILogger _logger; + static ServiceController() + { + var factory = new LoggerFactory(); + _logger = factory.CreateLogger(); + factory.AddConsole(); + } +#endif + /// + /// Directory containing the acceptance test files. + /// + private static string AcceptanceTestsPath + { + get { + var serverPath = Path.Combine(Environment.GetEnvironmentVariable("AUTOREST_TEST_SERVER_PATH") ?? Directory.GetCurrentDirectory(), "server"); + + if (!Directory.Exists(serverPath)) + { + // otherwise walk up the path till we find a folder + serverPath = FindFolderByWalkingUpPath(@"dev\TestServer\server"); + if (serverPath == null) + { + throw new Exception("Unable to find TestServerPath.\r\n"); + } + } + + return serverPath; + } + } + + public static string FindFolderByWalkingUpPath(string folderName, string currentDirectory = null) + { + try + { + currentDirectory = currentDirectory ?? Environment.CurrentDirectory; + if (!string.IsNullOrEmpty(currentDirectory)) + { + try + { + currentDirectory = Path.GetFullPath(currentDirectory); + } + catch + { + } + + while (!string.IsNullOrEmpty(currentDirectory)) + { + var chkPath = Path.Combine(currentDirectory, folderName); + if (Directory.Exists(chkPath)) + { + return chkPath; + } + currentDirectory = Path.GetDirectoryName(currentDirectory); + } + } + } + catch + { + } + return null; + } + + /// + /// Teardown action + /// + public Action TearDown { get; set; } + + /// + /// Port number the service is listening on. + /// + public int Port { get; set; } + + public Uri Uri => new Uri(string.Format(CultureInfo.InvariantCulture, "http://localhost:{0}", Port)); + + /// + /// The process running the service. + /// + private Process ServiceProcess { get; set; } + + public void Dispose() + { + try { + TearDown?.Invoke(); + } + finally + { + Dispose(true); + GC.SuppressFinalize(this); + } + } + + protected virtual void Dispose(bool disposing) + { + if (disposing && ServiceProcess != null && !ServiceProcess.HasExited) + { + EndServiceProcess(ServiceProcess); + ServiceProcess = null; + } + } + + /// + /// Ensure that the node service is running - either create it, or track it if it is already running. + /// + public void EnsureService() + { + lock (_sync) + { + if (ServiceProcess == null) + { + StartServiceProcess(); + } + } + } + + public static string GetPathToExecutable(string executableName) + { + var paths = Environment.GetEnvironmentVariable("PATH"); + foreach (var path in paths.Split(new[] { Path.PathSeparator }, StringSplitOptions.RemoveEmptyEntries)) + { + var fullPath = Path.Combine(path, Path.GetFileName(executableName)); + if (File.Exists(fullPath)) + { + return fullPath; + } + + var ext = Path.GetExtension(executableName); + var exec = (ext == ".cmd" || ext == ".exe") ? Path.GetFileNameWithoutExtension(executableName) : executableName; + fullPath = Path.Combine(path, exec); + if (File.Exists(fullPath)) + { + return fullPath; + } + } + + return null; + } + + private static int GetRandomPortNumber() + { + var rand = new Random(); + return rand.Next(3000, 3999); + } + + public void StartServiceProcess() + { + var npmPath = GetPathToExecutable(NpmCommand); + if (npmPath == null) + { + throw new InvalidOperationException("Could not find path to " + NpmCommand); + } + + using (var prepareProcess = StartServiceProcess(npmPath, NpmArgument, AcceptanceTestsPath, + waitForServerStart: false)) + { + // Wait for maximum of two minutes; One-time preparation. + if (prepareProcess.WaitForExit(120000)) + { + var nodePath = GetPathToExecutable(NodeCommand); + if (nodePath == null) + { + throw new InvalidOperationException("Could not find path to " + NodeCommand); + } + + ServiceProcess = StartServiceProcess(nodePath, NodeArgument, AcceptanceTestsPath); + } + else + { + throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, + "Failed to start {0} {1} '{2}'.", + npmPath, NpmArgument, AcceptanceTestsPath)); + } + } + } + + /// + /// Run the given command with arguments. Return the result in standard output. + /// + /// The path to the command to execute. + /// The arguments to pass to the command. + /// The working directory for the process being launched. + /// Wait for the service to print a start message + /// The process + private Process StartServiceProcess( + string path, + string arguments, + string workingDirectory, + bool waitForServerStart = true) + { + _listener = new ProcessOutputListener(); + var process = new Process(); + var startInfo = process.StartInfo; + startInfo.CreateNoWindow = false; + startInfo.RedirectStandardOutput = true; + startInfo.RedirectStandardError = true; + startInfo.WorkingDirectory = workingDirectory; + startInfo.UseShellExecute = false; + startInfo.FileName = path; + startInfo.Arguments = arguments; +#if PORTABLE + startInfo.Environment["PORT"] = Port.ToString(CultureInfo.InvariantCulture); +#else + startInfo.EnvironmentVariables["PORT"] = Port.ToString(CultureInfo.InvariantCulture); +#endif + process.OutputDataReceived += _listener.ProcessOutput; + process.ErrorDataReceived += _listener.ProcessError; + process.Start(); + process.BeginOutputReadLine(); + if (waitForServerStart) + { + _listener.ProcessStarted.WaitOne(TimeSpan.FromSeconds(30)); + } + return process; + } + + private static void EndServiceProcess(Process process) + { + //_logger.LogInformation("Begin killing process..."); + process.Kill(); + process.WaitForExit(2000); + process.Dispose(); + //_logger.LogInformation("Process killed..."); + } + } +} diff --git a/src/generator/AutoRest.CSharp.Unit.Tests/TestExtensions.cs b/src/generator/AutoRest.CSharp.Unit.Tests/TestExtensions.cs index 138ae8b24c..3330c33cdf 100644 --- a/src/generator/AutoRest.CSharp.Unit.Tests/TestExtensions.cs +++ b/src/generator/AutoRest.CSharp.Unit.Tests/TestExtensions.cs @@ -30,39 +30,26 @@ public static bool IsAnonymousType(this Type type) return name[0] == '<' && name[1] == '>' && name.IndexOf("AnonymousType", StringComparison.Ordinal) > 0; } - internal static void Copy(this IFileSystem fileSystem, string source) - { - Copy(fileSystem, source, (File.Exists(source)? Path.GetFileName(source): source)); + internal static void CopyFile(this IFileSystem fileSystem, string source, string destination) { + destination = destination.Replace("._", "."); + fileSystem.WriteFile(destination, File.ReadAllText(source)); } - internal static void Copy(this IFileSystem fileSystem, string source, string destination) + internal static void CopyFolder(this IFileSystem fileSystem, string basePath, string source, string destination) { - // if copying a file - if (File.Exists(source)) - { - fileSystem.WriteFile(destination, File.ReadAllText(source)); - return; - } - - // if copying a directory - if (fileSystem.DirectoryExists(destination)) - { - fileSystem.DeleteDirectory(destination); - } fileSystem.CreateDirectory(destination); // Copy dirs recursively - foreach (var child in Directory.GetDirectories(Path.GetFullPath(source), "*", SearchOption.TopDirectoryOnly).Select(p => Path.GetDirectoryName(p))) + foreach (var child in Directory.EnumerateDirectories(Path.GetFullPath(Path.Combine(basePath, source))).Select(Path.GetFileName)) { - fileSystem.Copy(Path.Combine(source, child), Path.Combine(destination, child)); + fileSystem.CopyFolder(basePath, Path.Combine(source, child), Path.Combine(destination, child)); } + // Copy files - foreach (var childFile in Directory.GetFiles(Path.GetFullPath(source), "*", SearchOption.TopDirectoryOnly).Select(p=>Path.GetFileName(p))) + foreach (var childFile in Directory.EnumerateFiles(Path.GetFullPath(Path.Combine(basePath, source))).Select(Path.GetFileName)) { - fileSystem.Copy(Path.Combine(source, childFile), - Path.Combine(destination, childFile)); + fileSystem.CopyFile(Path.Combine(basePath,source,childFile), Path.Combine(destination, childFile)); } - } internal static string[] GetFilesByExtension(this IFileSystem fileSystem, string path, SearchOption s, params string[] fileExts) @@ -70,7 +57,7 @@ internal static string[] GetFilesByExtension(this IFileSystem fileSystem, string return fileSystem.GetFiles(path, "*.*", s).Where(f => fileExts.Contains(f.Substring(f.LastIndexOf(".")+1))).ToArray(); } - internal static MemoryFileSystem GenerateCodeInto(this string inputDir, MemoryFileSystem fileSystem, string codeGenerator="CSharp", string modeler = "Swagger") + internal static MemoryFileSystem GenerateCodeInto(this string testName, MemoryFileSystem fileSystem, string codeGenerator="CSharp", string modeler = "Swagger") { using (NewContext) { @@ -84,16 +71,26 @@ internal static MemoryFileSystem GenerateCodeInto(this string inputDir, MemoryF CodeGenerationMode = "rest-client" }; - return inputDir.GenerateCodeInto(fileSystem, settings); + return testName.GenerateCodeInto(fileSystem, settings); } } - internal static MemoryFileSystem GenerateCodeInto(this string inputDir, MemoryFileSystem fileSystem, Settings settings) + internal static MemoryFileSystem GenerateCodeInto(this string testName, MemoryFileSystem fileSystem, Settings settings) { - fileSystem.Copy(Path.Combine("Resource", inputDir)); - var fileExt = (File.Exists(Path.Combine("Resource", Path.Combine(inputDir, inputDir + ".yaml"))) ? ".yaml" : ".json"); - settings.Input = Path.Combine("Resource", Path.Combine(inputDir, inputDir + fileExt)); + // copy the whole input directory into the memoryfilesystem. + fileSystem.CopyFolder("Resource", testName,""); + + // find the appropriately named .yaml or .json file for the swagger. + foreach (var ext in new[] {".yaml", ".json", ".md"}) { + var name = testName + ext; + if (fileSystem.FileExists(name)) { + settings.Input = name; + } + } + if (string.IsNullOrWhiteSpace(settings.Input)) { + throw new Exception($"Can't find swagger file ${testName} [.yaml] [.json] [.md]"); + } var plugin = ExtensionsLoader.GetPlugin(); var modeler = ExtensionsLoader.GetModeler(); diff --git a/src/generator/AutoRest.CSharp.Unit.Tests/XmlSerialization.cs b/src/generator/AutoRest.CSharp.Unit.Tests/XmlSerialization.cs new file mode 100644 index 0000000000..7b25623021 --- /dev/null +++ b/src/generator/AutoRest.CSharp.Unit.Tests/XmlSerialization.cs @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// +namespace AutoRest.CSharp.Unit.Tests { + using System; + using System.Collections; + using System.Linq; + using System.Reflection; + using System.Threading.Tasks; + using Microsoft.CodeAnalysis; + using Xunit; + using Xunit.Abstractions; + + public class XmlSerialization : BugTest + { + public XmlSerialization(ITestOutputHelper output) : base(output) + { + } + + /// + /// Xml Serialization tests + /// + [Fact] + public async Task CheckXmlSerialization() { + using (var fileSystem = GenerateCodeForTestFromSpec(codeGenerator: "CSharp")) + { + Assert.True(fileSystem.FileExists(@"GeneratedCode\Models\StorageServiceProperties.cs")); + Assert.True(fileSystem.FileExists(@"GeneratedCode\SimpleAPI.cs")); + + var result = await Compile(fileSystem); + + // filter the warnings + var warnings = result.Messages.Where( + each => each.Severity == DiagnosticSeverity.Warning && + !SuppressWarnings.Contains(each.Id)).ToArray(); + + // filter the errors + var errors = result.Messages.Where(each => each.Severity == DiagnosticSeverity.Error).ToArray(); + + Write(warnings, fileSystem); + Write(errors, fileSystem); + + // use this to write out all the messages, even hidden ones. + // Write(result.Messages, fileSystem); + + // Don't proceed unless we have zero warnings. + Assert.Empty(warnings); + // Don't proceed unless we have zero Errors. + Assert.Empty(errors); + + // try to load the assembly + var asm = Assembly.Load(result.Output.GetBuffer()); + Assert.NotNull(asm); + + using (var service =new ServiceController()) { + + var program = asm.ExportedTypes.FirstOrDefault(each => each.FullName == "XmlSerialization.Program"); + + dynamic test = program.GetConstructor(new Type[0]).Invoke(new object[0]); + // var testResult = (int)program.GetMethod("Main").Invoke(null, new object[] {$"{service.Uri.AbsolutePath}/xml"}); + int testResult = test.Main($"{service.Uri.AbsoluteUri}xml"); + + Assert.Equal(0, testResult); + + // Should also succeed. + Assert.True(result.Succeeded); + } + } + } + } +} \ No newline at end of file diff --git a/src/generator/AutoRest.CSharp/CodeGeneratorCs.cs b/src/generator/AutoRest.CSharp/CodeGeneratorCs.cs index 242c9fded0..adb0d6674b 100644 --- a/src/generator/AutoRest.CSharp/CodeGeneratorCs.cs +++ b/src/generator/AutoRest.CSharp/CodeGeneratorCs.cs @@ -104,7 +104,13 @@ private async Task GenerateClientSideCode(CodeModelCs codeModel) var exceptionTemplate = new ExceptionTemplate { Model = exceptionType, }; await Write(exceptionTemplate, Path.Combine(Settings.Instance.ModelsName, $"{exceptionTemplate.Model.ExceptionTypeDefinitionName}{ImplementationFileExtension}")); } - + + // Xml Serialization + if (codeModel.ShouldGenerateXmlSerialization) + { + var xmlSerializationTemplate = new XmlSerializationTemplate(); + await Write(xmlSerializationTemplate, Path.Combine(Settings.Instance.ModelsName, $"{XmlSerialization.XmlDeserializationClass}{ImplementationFileExtension}")); + } } private async Task GenerateRestCode(CodeModelCs codeModel) @@ -153,7 +159,6 @@ public override async Task Generate(CodeModel cm) string.Format(CultureInfo.InvariantCulture, string.Format(AutoRest.Core.Properties.Resources.ParameterValueIsNotValid, Settings.Instance.CodeGenerationMode, "server/client"), "CodeGenerator")); } - } } } diff --git a/src/generator/AutoRest.CSharp/Model/ParameterCs.cs b/src/generator/AutoRest.CSharp/Model/ParameterCs.cs index 170a1b44c6..5f221ccc38 100644 --- a/src/generator/AutoRest.CSharp/Model/ParameterCs.cs +++ b/src/generator/AutoRest.CSharp/Model/ParameterCs.cs @@ -4,6 +4,7 @@ using AutoRest.Core; using AutoRest.Core.Model; using AutoRest.Core.Utilities; +using AutoRest.Extensions; namespace AutoRest.CSharp.Model { @@ -11,7 +12,7 @@ public class ParameterCs : Parameter { public ParameterCs() { - Name.OnGet += value => IsClientProperty ? true== Method?.Group.IsNullOrEmpty() ? $"this.{ClientProperty.Name}" : $"this.Client.{ClientProperty.Name}" : CodeNamer.Instance.GetParameterName(value); + Name.OnGet += value => IsClientProperty ? true == Method?.Group.IsNullOrEmpty() ? $"this.{ClientProperty.Name}" : $"this.Client.{ClientProperty.Name}" : CodeNamer.Instance.GetParameterName(value); } /// /// Gets True if parameter can call .Validate method @@ -20,5 +21,26 @@ public ParameterCs() public override string ModelTypeName => ModelType.AsNullableType(this.IsNullable()); + public string HeaderCollectionPrefix => Extensions.GetValue(SwaggerExtensions.HeaderCollectionPrefix); + public bool IsHeaderCollection => !string.IsNullOrEmpty(HeaderCollectionPrefix); + + /// + /// Gets or sets the model type. + /// + public override IModelType ModelType + { + get + { + if (base.ModelType == null || !this.IsHeaderCollection) + { + return base.ModelType; + } + return new DictionaryTypeCs { ValueType = base.ModelType, CodeModel = base.ModelType.CodeModel, SupportsAdditionalProperties = false }; + } + set + { + base.ModelType = value; + } + } } } \ No newline at end of file diff --git a/src/generator/AutoRest.CSharp/Model/PropertyCs.cs b/src/generator/AutoRest.CSharp/Model/PropertyCs.cs index 5a121d8c7b..eb63a9ef3b 100644 --- a/src/generator/AutoRest.CSharp/Model/PropertyCs.cs +++ b/src/generator/AutoRest.CSharp/Model/PropertyCs.cs @@ -2,11 +2,16 @@ // Licensed under the MIT License. See License.txt in the project root for license information. using AutoRest.Core.Model; +using AutoRest.Core.Utilities; +using AutoRest.Extensions; namespace AutoRest.CSharp.Model { public class PropertyCs : Property { public override string ModelTypeName => ModelType.AsNullableType(this.IsNullable()); + + public string HeaderCollectionPrefix => Extensions.GetValue(SwaggerExtensions.HeaderCollectionPrefix); + public bool IsHeaderCollection => !string.IsNullOrEmpty(HeaderCollectionPrefix); } } \ No newline at end of file diff --git a/src/generator/AutoRest.CSharp/Model/SequenceTypeCs.cs b/src/generator/AutoRest.CSharp/Model/SequenceTypeCs.cs index 2f79c79b9c..66bbc0df16 100644 --- a/src/generator/AutoRest.CSharp/Model/SequenceTypeCs.cs +++ b/src/generator/AutoRest.CSharp/Model/SequenceTypeCs.cs @@ -11,19 +11,19 @@ public class SequenceTypeCs : SequenceType { public SequenceTypeCs() { - Name.OnGet += v => $"System.Collections.Generic.IList<{ElementType.AsNullableType(!ElementType.IsValueType() || (this.IsXNullable ?? true))}>"; + Name.OnGet += v => $"System.Collections.Generic.IList<{ElementType.AsNullableType(!ElementType.IsValueType() || IsNullable)}>"; } - public virtual bool? IsXNullable => Extensions.Get("x-nullable"); + public virtual bool IsNullable => Extensions.Get("x-nullable") ?? true; } public class DictionaryTypeCs : DictionaryType { public DictionaryTypeCs() { - Name.OnGet += v => $"System.Collections.Generic.IDictionary"; + Name.OnGet += v => $"System.Collections.Generic.IDictionary"; } - public virtual bool? IsXNullable => Extensions.Get("x-nullable"); + public virtual bool IsNullable => Extensions.Get("x-nullable") ?? true; } } \ No newline at end of file diff --git a/src/generator/AutoRest.CSharp/Templates/Rest/Client/MethodGroupTemplate.cshtml b/src/generator/AutoRest.CSharp/Templates/Rest/Client/MethodGroupTemplate.cshtml index 54cfceb478..24ceb9c428 100644 --- a/src/generator/AutoRest.CSharp/Templates/Rest/Client/MethodGroupTemplate.cshtml +++ b/src/generator/AutoRest.CSharp/Templates/Rest/Client/MethodGroupTemplate.cshtml @@ -5,6 +5,7 @@ @EmptyLine namespace @Settings.Namespace { + using System.Linq; using System.IO; using Microsoft.Rest; @foreach (var usingString in Model.Usings) { diff --git a/src/generator/AutoRest.CSharp/Templates/Rest/Client/MethodTemplate.cshtml b/src/generator/AutoRest.CSharp/Templates/Rest/Client/MethodTemplate.cshtml index 92007d5148..797c285825 100644 --- a/src/generator/AutoRest.CSharp/Templates/Rest/Client/MethodTemplate.cshtml +++ b/src/generator/AutoRest.CSharp/Templates/Rest/Client/MethodTemplate.cshtml @@ -5,6 +5,7 @@ @using AutoRest.Core.Utilities @using AutoRest.CSharp @using AutoRest.CSharp.Model +@using AutoRest.Extensions @inherits AutoRest.Core.Template @if (!string.IsNullOrWhiteSpace(Model.Description) || !string.IsNullOrEmpty(Model.Summary)) @@ -141,7 +142,7 @@ else _httpRequest.RequestUri = new System.Uri(_url); // Set Headers @(Model.SetDefaultHeaders) - @foreach (ParameterCs parameter in Model.LogicalParameters.Where(p => p.Location == ParameterLocation.Header)) + @foreach (var parameter in Model.LogicalParameters.OfType().Where(p => p.Location == ParameterLocation.Header && !p.IsHeaderCollection)) { if (!parameter.IsNullable()) { @@ -163,6 +164,23 @@ else @:} } } + @EmptyLine + @foreach (var parameter in Model.LogicalParameters.OfType().Where(p => p.Location == ParameterLocation.Header && p.IsHeaderCollection)) + { + @:if (@(parameter.Name) != null) + @:{ + @: foreach (var _header in @(parameter.Name)) + @: { + @: var key = "@(parameter.HeaderCollectionPrefix)" + _header.Key; + @: if (_httpRequest.Headers.Contains(key)) + @: { + @: _httpRequest.Headers.Remove(key); + @: } + @: _httpRequest.Headers.TryAddWithoutValidation(key, _header.Value); + @: } + @:} + } + @EmptyLine if (customHeaders != null) { foreach(var _header in customHeaders) @@ -199,28 +217,68 @@ else } else { - if (!Model.RequestBody.IsNullable()) + if (Model.RequestContentType.StartsWith("application/xml")) { - @:_requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(@(Model.RequestBody.Name), @(Model.GetSerializationSettingsReference(Model.RequestBody.ModelType))); + if (!Model.RequestBody.IsNullable()) { + if (Model.RequestBody.ModelType is SequenceType && (Model.RequestBody.ModelType as SequenceType).ElementType is CompositeType) + { // for primitive sequences for now + @:_requestContent = new System.Xml.Linq.XElement("@Model.RequestBody.ModelType.XmlName", @(Model.RequestBody.Name).Select(x => x.XmlSerialize(new System.Xml.Linq.XElement("@((Model.RequestBody.ModelType as SequenceType).ElementXmlName)")))).ToString(); + } + else if (Model.RequestBody.ModelType is SequenceType) + { // for primitive sequences for now + @:_requestContent = new System.Xml.Linq.XElement("@Model.RequestBody.ModelType.XmlName", @(Model.RequestBody.Name).Select(x => new System.Xml.Linq.XElement("@((Model.RequestBody.ModelType as SequenceType).ElementXmlName)", x))).ToString(); + } + else + { + @:_requestContent = @(Model.RequestBody.Name).XmlSerialize( new System.Xml.Linq.XElement("@Model.RequestBody.ModelType.XmlName") ).ToString(); + @:_requestContent = $"\n{_requestContent}"; + } @:_httpRequest.Content = new System.Net.Http.StringContent(_requestContent, System.Text.Encoding.UTF8); @:_httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("@(Model.RequestContentType)"); - } - else - { + } + else { @:if(@(Model.RequestBody.Name) != null) @:{ - @: _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(@(Model.RequestBody.Name), @(Model.GetSerializationSettingsReference(Model.RequestBody.ModelType))); - @: _httpRequest.Content = new System.Net.Http.StringContent(_requestContent, System.Text.Encoding.UTF8); - @: _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("@(Model.RequestContentType)"); + if (Model.RequestBody.ModelType is SequenceType && (Model.RequestBody.ModelType as SequenceType).ElementType is CompositeType) + { // for primitive sequences for now + @:_requestContent = new System.Xml.Linq.XElement("@Model.RequestBody.ModelType.XmlName", @(Model.RequestBody.Name).Select(x => x.XmlSerialize(new System.Xml.Linq.XElement("@((Model.RequestBody.ModelType as SequenceType).ElementXmlName)")))).ToString(); + } + else if (Model.RequestBody.ModelType is SequenceType) + { // for primitive sequences for now + @:_requestContent = new System.Xml.Linq.XElement("@Model.RequestBody.ModelType.XmlName", @(Model.RequestBody.Name).Select(x => new System.Xml.Linq.XElement("@((Model.RequestBody.ModelType as SequenceType).ElementXmlName)", x))).ToString(); + } + else + { + @:_requestContent = @(Model.RequestBody.Name).XmlSerialize( new System.Xml.Linq.XElement("@Model.RequestBody.ModelType.XmlName") ).ToString(); + @:_requestContent = $"\n{_requestContent}"; + } + @:_httpRequest.Content = new System.Net.Http.StringContent(_requestContent, System.Text.Encoding.UTF8); + @:_httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("@(Model.RequestContentType)"); @:} + } + } + else + { + if (!Model.RequestBody.IsNullable()) { + _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(@(Model.RequestBody.Name), @(Model.GetSerializationSettingsReference(Model.RequestBody.ModelType))); + _httpRequest.Content = new System.Net.Http.StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("@(Model.RequestContentType)"); + } + else { + if(@(Model.RequestBody.Name) != null) + { + _requestContent = Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(@(Model.RequestBody.Name), @(Model.GetSerializationSettingsReference(Model.RequestBody.ModelType))); + _httpRequest.Content = new System.Net.Http.StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("@(Model.RequestContentType)"); + } + } } } } - else if (Model.LogicalParameters.Where(p => p.Location == ParameterLocation.FormData).Any()) + else if (Model.LogicalParameters.Any(p => p.Location == ParameterLocation.FormData)) { - - System.Net.Http.MultipartFormDataContent _multiPartContent = new System.Net.Http.MultipartFormDataContent(); - + @:System.Net.Http.MultipartFormDataContent _multiPartContent = new System.Net.Http.MultipartFormDataContent(); + foreach (ParameterCs parameter in Model.LogicalParameters.Where(p => p.Location == ParameterLocation.FormData)) { @:if (@(parameter.Name) != null) @@ -363,7 +421,22 @@ else @:_responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); @:try @:{ - @:_result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject<@(responsePair.Value.Body.AsNullableType())>(_responseContent, @(Model.GetDeserializationSettingsReference(responsePair.Value.Body))); + @if (Model.CodeModel.ShouldGenerateXmlSerialization) + { + @responsePair.Value.Body.AsNullableType() _tmp_ = null; + if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" && + @(XmlSerialization.XmlDeserializationClass).Root(@(XmlSerialization.GenerateDeserializer(Model.CodeModel, responsePair.Value.Body)))(System.Xml.Linq.XElement.Parse(_responseContent), out _tmp_)) + { + _result.Body = _tmp_; + }else + { + _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject<@(responsePair.Value.Body.AsNullableType())>(_responseContent, @(Model.GetDeserializationSettingsReference(responsePair.Value.Body))); + } + } + else + { + _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject<@(responsePair.Value.Body.AsNullableType())>(_responseContent, @(Model.GetDeserializationSettingsReference(responsePair.Value.Body))); + } @:} @:catch (Newtonsoft.Json.JsonException ex) @:{ @@ -390,7 +463,22 @@ else @:string _defaultResponseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); @:try @:{ + if (Model.CodeModel.ShouldGenerateXmlSerialization) + { + @: @Model.DefaultResponse.Body.AsNullableType() _tmp_ = null; + @: if (_httpResponse.Content.Headers.ContentType.MediaType == "application/xml" && + @: @(XmlSerialization.XmlDeserializationClass).Root(@(XmlSerialization.GenerateDeserializer(Model.CodeModel, Model.DefaultResponse.Body)))(System.Xml.Linq.XElement.Parse(_defaultResponseContent), out _tmp_)) + @:{ + @: _result.Body = _tmp_; + @:} else + @:{ + @: _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject<@(Model.DefaultResponse.Body.AsNullableType())>(_defaultResponseContent, @(Model.GetDeserializationSettingsReference(Model.DefaultResponse.Body))); + @:} + } + else + { @:_result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject<@(Model.DefaultResponse.Body.AsNullableType())>(_defaultResponseContent, @(Model.GetDeserializationSettingsReference(Model.DefaultResponse.Body))); + } @:} @:catch (Newtonsoft.Json.JsonException ex) @:{ @@ -410,6 +498,17 @@ else @:try @:{ @:_result.Headers = _httpResponse.GetHeadersAsJson().ToObject<@(Model.ReturnType.Headers.Name)>(Newtonsoft.Json.JsonSerializer.Create(@(Model.GetDeserializationSettingsReference(Model.DefaultResponse.Body)))); + foreach (var property in (Model.ReturnType.Headers as CompositeType).Properties.OfType().Where(p => p.IsHeaderCollection)) + { + @:_result.Headers.@(property.Name) = new @(property.ModelTypeName.Replace("IDictionary", "Dictionary"))(); + @:foreach (var header in _httpResponse.Headers) + @:{ + @: if (header.Key.StartsWith("@(property.HeaderCollectionPrefix)")) + @: { + @: _result.Headers.@(property.Name)[header.Key.Replace("@(property.HeaderCollectionPrefix)", "")] = header.Value.FirstOrDefault() as @((property.ModelType as DictionaryType).ValueType.Name); + @: } + @:} + } @:} @:catch (Newtonsoft.Json.JsonException ex) @:{ diff --git a/src/generator/AutoRest.CSharp/Templates/Rest/Client/XmlSerializationTemplate.cshtml b/src/generator/AutoRest.CSharp/Templates/Rest/Client/XmlSerializationTemplate.cshtml new file mode 100644 index 0000000000..b841838d1e --- /dev/null +++ b/src/generator/AutoRest.CSharp/Templates/Rest/Client/XmlSerializationTemplate.cshtml @@ -0,0 +1,99 @@ +@using System +@using System.Linq +@using AutoRest.Core.Utilities +@using AutoRest.CSharp +@using AutoRest.CSharp.Model +@using AutoRest.CSharp.Templates +@inherits AutoRest.Core.Template + +namespace @Settings.Namespace +{ + internal static class @(XmlSerialization.XmlDeserializationClass) + { + internal delegate bool XmlRootDeserializer( System.Xml.Linq.XElement root, out T result ); + internal delegate bool XmlDeserializer( System.Xml.Linq.XElement parent, string propertyName, out T result ); + + internal static XmlRootDeserializer Root( XmlDeserializer deserializer ) => + (System.Xml.Linq.XElement root, out T result) => deserializer(new System.Xml.Linq.XElement("artificialRoot", root), root.Name.LocalName, out result); + + private static XmlDeserializer Unroot( XmlRootDeserializer deserializer ) + { + return (System.Xml.Linq.XElement parent, string propertyName, out T result) => { + result = default(T); + var element = parent.Element(propertyName); + if (element == null) + { + return false; + } + return deserializer(element, out result); + }; + } + + private static XmlRootDeserializer ToRootDeserializer( System.Func unsafeDeserializer ) + => (System.Xml.Linq.XElement root, out T result) => { + try + { + result = unsafeDeserializer(root); + return true; + } + catch + { + result = default(T); + return false; + }}; + + internal static XmlDeserializer ToDeserializer( System.Func unsafeDeserializer ) + => Unroot(ToRootDeserializer(unsafeDeserializer)); + + internal static XmlDeserializer> CreateListXmlDeserializer( XmlDeserializer elementDeserializer, string elementTagName = null /*if isWrapped = false*/ ) + { + if (elementTagName != null) + { + // create non-wrapped deserializer and forward + var slave = CreateListXmlDeserializer( elementDeserializer ); + return (System.Xml.Linq.XElement parent, string propertyName, out System.Collections.Generic.IList result) => { + result = null; + var wrapper = parent.Element(propertyName); + return wrapper != null && slave(wrapper, elementTagName, out result); + }; + } + var rootElementDeserializer = Root(elementDeserializer); + return (System.Xml.Linq.XElement parent, string propertyName, out System.Collections.Generic.IList result) => { + result = new System.Collections.Generic.List(); + foreach (var element in parent.Elements(propertyName)) + { + T elementResult; + if (!rootElementDeserializer(element, out elementResult)) + { + return false; + } + result.Add(elementResult); + } + return true; + }; + } + + internal static XmlDeserializer> CreateDictionaryXmlDeserializer( XmlDeserializer elementDeserializer ) + { + return (System.Xml.Linq.XElement parent, string propertyName, out System.Collections.Generic.IDictionary result) => { + result = null; + var childElement = parent.Element(propertyName); + if (childElement == null) + { + return false; + } + result = new System.Collections.Generic.Dictionary(); + foreach (var element in childElement.Elements()) + { + T elementResult; + if (!elementDeserializer(childElement, element.Name.LocalName, out elementResult)) + { + return false; + } + result.Add(element.Name.LocalName, elementResult); + } + return true; + }; + } + } +} \ No newline at end of file diff --git a/src/generator/AutoRest.CSharp/Templates/Rest/Common/EnumTemplate.cshtml b/src/generator/AutoRest.CSharp/Templates/Rest/Common/EnumTemplate.cshtml index f0db285733..eef53606f9 100644 --- a/src/generator/AutoRest.CSharp/Templates/Rest/Common/EnumTemplate.cshtml +++ b/src/generator/AutoRest.CSharp/Templates/Rest/Common/EnumTemplate.cshtml @@ -21,10 +21,46 @@ namespace @(Settings.Namespace).@(Settings.ModelsName) } @: [System.Runtime.Serialization.EnumMember(Value = "@Model.Values.Last().SerializedName")] @: @(Model.Values.Last().MemberName) - @:} - } - else - { + @:} + + internal static class @(Model.ClassName)EnumExtension + { + internal static string ToSerializedValue(this @(Model.ClassName)? value ) => + value == null ? null : (( @(Model.ClassName) )value).ToSerializedValue(); +@EmptyLine + internal static string ToSerializedValue(this @(Model.ClassName) value ) + { + switch( value ) + { + @for (int i = 0; i < Model.Values.Count; i++) + { + case @(Model.ClassName).@(Model.Values[i].MemberName): + return "@Model.Values[i].SerializedName"; + } + + } + return null; + } +@EmptyLine + internal static @(Model.ClassName)? Parse@(Model.ClassName)( this string value ) + { + switch( value ) + { + @for (int i = 0; i < Model.Values.Count; i++) + { + case "@Model.Values[i].SerializedName": + return @(Model.ClassName).@(Model.Values[i].MemberName); + } + } + return null; + } + + } + + + } + else + { @:public static class @Model.ClassName @:{ foreach (var t in Model.Values) diff --git a/src/generator/AutoRest.CSharp/Templates/Rest/Common/ModelTemplate.cshtml b/src/generator/AutoRest.CSharp/Templates/Rest/Common/ModelTemplate.cshtml index b2398f68ce..31175d6fbb 100644 --- a/src/generator/AutoRest.CSharp/Templates/Rest/Common/ModelTemplate.cshtml +++ b/src/generator/AutoRest.CSharp/Templates/Rest/Common/ModelTemplate.cshtml @@ -1,9 +1,11 @@ @using System.Linq +@using System.Runtime.Remoting.Messaging @using AutoRest.Core @using AutoRest.Core.Model @using AutoRest.Core.Utilities @using AutoRest.CSharp @using AutoRest.CSharp.Model +@using AutoRest.Extensions @inherits Template @Header("// ") @EmptyLine @@ -63,7 +65,6 @@ namespace @(Settings.Namespace).@(Settings.ModelsName) { @:public @(Model.Name)() { } } - @EmptyLine @@ -226,6 +227,145 @@ namespace @(Settings.Namespace).@(Settings.ModelsName) @://Nothing to validate } @:} +} + + @if (Model.CodeModel.ShouldGenerateXmlSerialization) { + /// + /// Serializes the object to an XML node + /// + internal System.Xml.Linq.XElement XmlSerialize(System.Xml.Linq.XElement result) + { + foreach(var property in Model.Properties.Where(p => !p.IsConstant && !p.WasFlattened())) { + @if (property.IsNullable()) { + if( null != @(property.Name) ) + {} + @if (property.ModelType is CompositeType) { + result.Add(@(property.Name).XmlSerialize(new System.Xml.Linq.XElement( "@(property.XmlName)" ))); + } + else if (property.ModelType is DictionaryType) + { + var vt = ((DictionaryType)property.ModelType).ValueType; + if (vt is DictionaryType || vt is SequenceType) + { + // todo: nothing right now. + } else if (vt is CompositeType) { + var dict = new System.Xml.Linq.XElement("@property.XmlName"); + foreach( var key in @(property.Name).Keys ) { + dict.Add(@(property.Name)[key].XmlSerialize(new System.Xml.Linq.XElement(key) ) ); + } + result.Add(dict); + } else { + var dict = new System.Xml.Linq.XElement("@property.XmlName"); + foreach( var key in @(property.Name).Keys ){ + dict.Add(new System.Xml.Linq.XElement( key, @(property.Name)[key] ) ); + } + result.Add(dict);} + } + else if (property.ModelType is SequenceType) + { + var et = ((SequenceType)property.ModelType).ElementType; + if (et is DictionaryType || et is SequenceType) + { + // todo: nothing right now. + } else if (et is CompositeType) {if ((property.ModelType as SequenceType).XmlIsWrapped) { + var seq = new System.Xml.Linq.XElement("@property.XmlName"); + foreach( var value in @(property.Name) ){ + seq.Add(value.XmlSerialize( new System.Xml.Linq.XElement( "@((property.ModelType as SequenceType).ElementXmlName)") ) ); + } + result.Add(seq);} + else { + foreach( var value in @(property.Name) ){ + result.Add(value.XmlSerialize( new System.Xml.Linq.XElement( "@property.XmlName") ) ); + }}} else {if ((property.ModelType as SequenceType).XmlIsWrapped) { + var seq = new System.Xml.Linq.XElement("@property.XmlName"); + foreach( var value in @(property.Name) ){ + seq.Add(new System.Xml.Linq.XElement( "@((property.ModelType as SequenceType).ElementXmlName)", value ) ); + } + result.Add(seq);} + else { + foreach( var value in @(property.Name) ){ + result.Add(new System.Xml.Linq.XElement( "@property.XmlName", value ) ); + }}} + } else if (property.ModelType is EnumType && !((EnumType)property.ModelType).ModelAsString) { + // serialize it as a enum type. + if (property.XmlIsAttribute) { + result.Add(new System.Xml.Linq.XAttribute("@property.XmlName", @(property.Name).ToSerializedValue()) ); + } else { + result.Add(new System.Xml.Linq.XElement("@property.XmlName", @(property.Name).ToSerializedValue()) ); + } + } else { + // serialize it as a primitive/value type. + var primitiveExpression = property.Name; + var knownType = (property.ModelType as PrimaryType)?.KnownPrimaryType; + if (knownType == KnownPrimaryType.DateTimeRfc1123) + { + primitiveExpression = property.IsNullable() + ? $"{primitiveExpression}?.ToUniversalTime().ToString(\"R\")" + : $"{primitiveExpression}.ToUniversalTime().ToString(\"R\")"; + } + if (property.XmlIsAttribute) { + result.Add(new System.Xml.Linq.XAttribute("@property.XmlName", @(primitiveExpression)) ); + } else { + result.Add(new System.Xml.Linq.XElement("@property.XmlName", @(primitiveExpression)) ); + } + } + @if (property.IsNullable()) { + } + } + } + + return result; + } + + /// + /// Deserializes an XML node to an instance of @Model.Name + /// + internal static @Model.Name XmlDeserialize(string payload) + { + // deserialize to xml and use the overload to do the work + return XmlDeserialize( System.Xml.Linq.XElement.Parse( payload ) ); + } + + internal static @Model.Name XmlDeserialize(System.Xml.Linq.XElement payload) + { + var result = new @(Model.Name)(); + @if (Model.Properties.Any(p => !p.IsConstant && !p.WasFlattened() && p.XmlIsAttribute)) { + System.Xml.Linq.XAttribute attribute; } + @*@if (Model.Properties.Any(p => !p.IsConstant && !p.WasFlattened() && !p.XmlIsAttribute)) { + System.Xml.Linq.XElement element; + }*@ + + @foreach(var property in Model.Properties.Where(p => !p.IsConstant && !p.WasFlattened())) { + @if (property.XmlIsAttribute) { + if( null != (attribute = payload.Attribute("@property.XmlName"))) + { + @if (property.ModelType is EnumType && !((EnumType)property.ModelType).ModelAsString) { + + result.@(property.Name) =attribute.Value.Parse@(property.ModelType.Name)(); + + } else { + result.@(property.Name) = (@property.ModelTypeName)attribute; + } + } + + continue; + } + + var deserializerName = $"deserialize{property.Name}"; + var resultName = $"result{property.Name}"; + + + var @(deserializerName) = @(XmlSerialization.GenerateDeserializer(Model.CodeModel, property.ModelType, property.ModelTypeName)); + @property.ModelTypeName @(resultName); + if (@(deserializerName)(payload, "@property.XmlName", out @(resultName))) + { + result.@(property.Name) = @(resultName); + } + } + return result; + } + } + } -} \ No newline at end of file +} diff --git a/src/generator/AutoRest.CSharp/XmlSerialization.cs b/src/generator/AutoRest.CSharp/XmlSerialization.cs new file mode 100644 index 0000000000..adb04aa6e2 --- /dev/null +++ b/src/generator/AutoRest.CSharp/XmlSerialization.cs @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// + +using AutoRest.Core; +using AutoRest.Core.Model; +using AutoRest.CSharp.Model; + +namespace AutoRest.CSharp +{ + public static class XmlSerialization + { + public static readonly string XmlDeserializationClass = "XmlSerialization"; + + /// + /// Generates code for an expression of type XmlDeserializer<T>. + /// + public static string GenerateDeserializer(CodeModel cm, IModelType modelType, string typeName = null) + { + var name = typeName ?? modelType.Name; + if (modelType is CompositeType) + return $"{XmlDeserializationClass}.ToDeserializer(e => {name}.XmlDeserialize(e))"; + if (modelType is DictionaryType) + return $"{XmlDeserializationClass}.CreateDictionaryXmlDeserializer({GenerateDeserializer(cm, (modelType as DictionaryType).ValueType, (modelType as DictionaryType).ValueType.AsNullableType((modelType as DictionaryTypeCs).IsNullable))})"; + if (modelType is SequenceType) + return $"{XmlDeserializationClass}.CreateListXmlDeserializer({GenerateDeserializer(cm, (modelType as SequenceType).ElementType)}, {((modelType as SequenceType).XmlIsWrapped ? $"\"{(modelType as SequenceType).ElementXmlName}\"" : "null")})"; + if ((modelType as EnumType)?.ModelAsString == false) + return $"{XmlDeserializationClass}.ToDeserializer(e => ({name})e.Value.Parse{modelType.Name}())"; + if ((modelType as PrimaryType)?.KnownPrimaryType == KnownPrimaryType.ByteArray) + return $"{XmlDeserializationClass}.ToDeserializer(e => System.Convert.FromBase64String(e.Value))"; + return $"{XmlDeserializationClass}.ToDeserializer(e => ({name})e)"; + } + } +} \ No newline at end of file diff --git a/src/modeler/AutoRest.Swagger.Tests/Swagger/swagger-xml-paths.yaml b/src/modeler/AutoRest.Swagger.Tests/Swagger/swagger-xml-paths.yaml new file mode 100644 index 0000000000..f1a544b616 --- /dev/null +++ b/src/modeler/AutoRest.Swagger.Tests/Swagger/swagger-xml-paths.yaml @@ -0,0 +1,32 @@ +swagger: "2.0" +info: + title: Xml Tests + version: 1.0.0 +schemes: +- http +consumes: +- application/xml +- application/json +produces: +- application/xml +- application/json +definitions: + ModelComplex: + type: object + properties: + PropertySimple: + description: CUSTOM_PropertySimple # description ~ RealPath (need prefix since "description" is sometimes overridden by something "better" by the modeler) + summary: PropertyOverride # summary ~ RealXmlPath + type: string + xml: + name: PropertyOverride + PropertyArray: + description: CUSTOM_PropertyArray + summary: + type: array + items: + type: string + additionalProperties: + type: string + description: CUSTOM_ + summary: \ No newline at end of file diff --git a/src/modeler/AutoRest.Swagger.Tests/Swagger/swagger-xml.yaml b/src/modeler/AutoRest.Swagger.Tests/Swagger/swagger-xml.yaml new file mode 100644 index 0000000000..c57f824ca1 --- /dev/null +++ b/src/modeler/AutoRest.Swagger.Tests/Swagger/swagger-xml.yaml @@ -0,0 +1,51 @@ +swagger: "2.0" +info: + title: Xml Tests + version: 1.0.0 +schemes: +- http +consumes: +- application/xml +- application/json +produces: +- application/xml +- application/json +definitions: + ModelPlain: + description: ModelPlain + type: object + properties: + PropertyPlain: + description: PropertyPlain + type: string + PropertyOverridden: + description: PropertyOverride + type: string + xml: + name: PropertyOverride + ModelOverridden: + description: ModelOverride + type: object + xml: + name: ModelOverride + properties: + PropertyPlain: + description: PropertyPlain + type: string + PropertyOverridden: + description: PropertyOverride + type: string + xml: + name: PropertyOverride + ModelComplex: + description: ModelComplex + type: object + properties: + PropertyPlain: + description: PropertyPlain + $ref: "#/definitions/ModelOverridden" + PropertyOverridden: + description: PropertyOverride + $ref: "#/definitions/ModelOverridden" + xml: + name: PropertyOverride \ No newline at end of file diff --git a/src/modeler/AutoRest.Swagger.Tests/SwaggerModelerXmlTests.cs b/src/modeler/AutoRest.Swagger.Tests/SwaggerModelerXmlTests.cs new file mode 100644 index 0000000000..97977d4077 --- /dev/null +++ b/src/modeler/AutoRest.Swagger.Tests/SwaggerModelerXmlTests.cs @@ -0,0 +1,97 @@ + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +using System; +using System.IO; +using System.Linq; +using System.Net; +using AutoRest.Core; +using AutoRest.Core.Model; +using AutoRest.Core.Extensibility; +using AutoRest.Core.Utilities; +using AutoRest.CSharp; +using Newtonsoft.Json.Linq; +using Xunit; +using static AutoRest.Core.Utilities.DependencyInjection; +using System.Globalization; + +namespace AutoRest.Swagger.Tests +{ + public class SwaggerModelerXmlTests + { + [Fact] + public void TestNameOverrideRules() + { + using (NewContext) + { + new Settings + { + Namespace = "Test", + Input = Path.Combine("Swagger", "swagger-xml.yaml") + }; + Modeler modeler = new SwaggerModeler(); + var codeModel = modeler.Build(); + foreach (var modelType in codeModel.ModelTypes) + { + Assert.Equal(modelType.Documentation, modelType.XmlName); + foreach (var property in codeModel.Properties) + { + Assert.Equal(property.Documentation, property.XmlName); + } + } + } + } + + [Fact] + public void TestRealPathRegular() + { + using (NewContext) + { + new Settings + { + Namespace = "Test", + Input = Path.Combine("Swagger", "swagger-xml.yaml") + }; + Modeler modeler = new SwaggerModeler(); + var codeModel = modeler.Build(); + foreach (var property in codeModel.ModelTypes.SelectMany(m => m.Properties)) + { + Assert.Equal(property.Name, string.Join(".", property.RealPath)); + Assert.Equal(property.XmlName, string.Join(".", property.RealXmlPath)); + } + } + } + + [Fact] + public void TestRealPathIrregular() + { + using (NewContext) + { + new Settings + { + Namespace = "Test", + Input = Path.Combine("Swagger", "swagger-xml-paths.yaml") + }; + Modeler modeler = new SwaggerModeler(); + var codeModel = modeler.Build(); + foreach (var property in codeModel.ModelTypes.SelectMany(m => m.Properties)) + { + var expectedRealPath = property.Documentation.StartsWith("CUSTOM_") + ? property.Documentation.Substring("CUSTOM_".Length) + : null; + var expectedRealXmlPath = property.Summary; + + if (expectedRealPath != null) + { + Assert.Equal(expectedRealPath, string.Join(".", property.RealPath)); + } + if (expectedRealXmlPath != null) + { + Assert.Equal(expectedRealXmlPath, string.Join(".", property.RealXmlPath)); + } + } + } + } + } +} diff --git a/src/modeler/AutoRest.Swagger/Model/Schema.cs b/src/modeler/AutoRest.Swagger/Model/Schema.cs index 3f0a75589e..662a705de0 100644 --- a/src/modeler/AutoRest.Swagger/Model/Schema.cs +++ b/src/modeler/AutoRest.Swagger/Model/Schema.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Globalization; +using AutoRest.Core.Model; using AutoRest.Core.Validation; using AutoRest.Swagger.Validation; using System.Collections.Generic; @@ -67,6 +68,11 @@ public class Schema : SwaggerObject /// public IList AllOf { get; set; } + /// + /// A metadata object that allows for more fine-tuned XML model definitions. + /// + public XmlProperties Xml { get; set; } + [JsonIgnore] internal bool IsReferenced { get; set; } diff --git a/src/modeler/AutoRest.Swagger/ObjectBuilder.cs b/src/modeler/AutoRest.Swagger/ObjectBuilder.cs index e833fcd217..648a034a8b 100644 --- a/src/modeler/AutoRest.Swagger/ObjectBuilder.cs +++ b/src/modeler/AutoRest.Swagger/ObjectBuilder.cs @@ -51,6 +51,7 @@ public virtual IModelType BuildServiceType(string serviceTypeName) { type = New(KnownPrimaryType.Stream); } + type.XmlProperties = (SwaggerObject as Schema)?.Xml; type.Format = SwaggerObject.Format; if (SwaggerObject.Enum != null && type.KnownPrimaryType == KnownPrimaryType.String && !(IsSwaggerObjectConstant(SwaggerObject))) { @@ -102,6 +103,7 @@ public virtual IModelType BuildServiceType(string serviceTypeName) enumType.SetName( string.Empty); enumType.SerializedName = string.Empty; } + enumType.XmlProperties = (SwaggerObject as Schema)?.Xml; return enumType; } if (SwaggerObject.Type == DataType.Array) @@ -121,7 +123,9 @@ public virtual IModelType BuildServiceType(string serviceTypeName) return New(new { ElementType = elementType, - Extensions = SwaggerObject.Items.Extensions + Extensions = SwaggerObject.Items.Extensions, + XmlProperties = (SwaggerObject as Schema)?.Xml, + ElementXmlProperties = SwaggerObject.Items?.Xml }); } if (SwaggerObject.AdditionalProperties != null) @@ -140,7 +144,8 @@ public virtual IModelType BuildServiceType(string serviceTypeName) ValueType = SwaggerObject.AdditionalProperties.GetBuilder(Modeler) .BuildServiceType((dictionaryValueServiceTypeName)), - Extensions = SwaggerObject.AdditionalProperties.Extensions + Extensions = SwaggerObject.AdditionalProperties.Extensions, + XmlProperties = (SwaggerObject as Schema)?.Xml }); } diff --git a/src/modeler/AutoRest.Swagger/OperationBuilder.cs b/src/modeler/AutoRest.Swagger/OperationBuilder.cs index a2c5b1e6c9..f4fbd0794a 100644 --- a/src/modeler/AutoRest.Swagger/OperationBuilder.cs +++ b/src/modeler/AutoRest.Swagger/OperationBuilder.cs @@ -29,6 +29,7 @@ public class OperationBuilder private SwaggerModeler _swaggerModeler; private Operation _operation; private const string APP_JSON_MIME = "application/json"; + private const string APP_XML_MIME = "application/xml"; public OperationBuilder(Operation operation, SwaggerModeler swaggerModeler) { @@ -50,28 +51,38 @@ public Method BuildMethod(HttpMethod httpMethod, string url, string methodName, { EnsureUniqueMethodName(methodName, methodGroup); - var method = New(new + var method = New(new { HttpMethod = httpMethod, Url = url, Name = methodName, SerializedName = _operation.OperationId }); - + + // assume that without specifying Consumes, that a service will consume JSON method.RequestContentType = _effectiveConsumes.FirstOrDefault() ?? APP_JSON_MIME; - string produce = _effectiveConsumes.FirstOrDefault(s => s.StartsWith(APP_JSON_MIME, StringComparison.OrdinalIgnoreCase)); - if (!string.IsNullOrEmpty(produce)) + + + // does the method Consume JSON or XML? + string serviceConsumes = _effectiveConsumes.FirstOrDefault(s => s.StartsWith(APP_JSON_MIME, StringComparison.OrdinalIgnoreCase)) ?? _effectiveConsumes.FirstOrDefault(s => s.StartsWith(APP_XML_MIME, StringComparison.OrdinalIgnoreCase)); + if (!string.IsNullOrEmpty(serviceConsumes)) { - method.RequestContentType = produce; + method.RequestContentType = serviceConsumes; } - if (method.RequestContentType.StartsWith(APP_JSON_MIME, StringComparison.OrdinalIgnoreCase) && + + // if they accept JSON or XML, and don't specify the charset, lets default to utf-8 + if ((method.RequestContentType.StartsWith(APP_JSON_MIME, StringComparison.OrdinalIgnoreCase) || + method.RequestContentType.StartsWith(APP_XML_MIME, StringComparison.OrdinalIgnoreCase)) && method.RequestContentType.IndexOf("charset=", StringComparison.OrdinalIgnoreCase) == -1) { // Enable UTF-8 charset method.RequestContentType += "; charset=utf-8"; } + // if the method produces xml, make sure that the method knows that. + method.ResponseContentTypes = _effectiveProduces.ToArray(); + method.Description = _operation.Description; method.Summary = _operation.Summary; method.ExternalDocsUrl = _operation.ExternalDocs?.Url; @@ -95,22 +106,41 @@ public Method BuildMethod(HttpMethod httpMethod, string url, string methodName, var headerTypeName = string.Format(CultureInfo.InvariantCulture, "{0}-{1}-Headers", methodGroup, methodName).Trim('-'); - var headerType = New(headerTypeName,new + var headerType = New(headerTypeName, new { SerializedName = headerTypeName, + RealPath = new string[] { headerTypeName }, Documentation = string.Format(CultureInfo.InvariantCulture, "Defines headers for {0} operation.", methodName) }); responseHeaders.ForEach(h => { - - var property = New(new + if (h.Value.Extensions != null && h.Value.Extensions.ContainsKey("x-ms-header-collection-prefix")) { - Name = h.Key, - SerializedName = h.Key, - ModelType = h.Value.GetBuilder(this._swaggerModeler).BuildServiceType(h.Key), - Documentation = h.Value.Description - }); - headerType.Add(property); + var property = New(new + { + Name = h.Key, + SerializedName = h.Key, + RealPath = new string[] { h.Key }, + Extensions = h.Value.Extensions, + ModelType = New(new + { + ValueType = h.Value.GetBuilder(this._swaggerModeler).BuildServiceType(h.Key) + }) + }); + headerType.Add(property); + } + else + { + var property = New(new + { + Name = h.Key, + SerializedName = h.Key, + RealPath = new string[] { h.Key }, + ModelType = h.Value.GetBuilder(this._swaggerModeler).BuildServiceType(h.Key), + Documentation = h.Value.Description + }); + headerType.Add(property); + } }); if (!headerType.Properties.Any()) @@ -319,7 +349,7 @@ private bool TryBuildResponse(string methodName, HttpStatusCode responseStatusCo { bool handled = false; IModelType serviceType; - if (SwaggerOperationProducesJson()) + if (SwaggerOperationProducesSomethingDeserializable()) { if (TryBuildResponseBody(methodName, response, s => GenerateResponseObjectName(s, responseStatusCode), out serviceType)) @@ -367,7 +397,7 @@ private bool TryBuildEmptyResponse(string methodName, HttpStatusCode responseSta private void TryBuildDefaultResponse(string methodName, OperationResponse response, Method method, IModelType headerType) { IModelType errorModel = null; - if (SwaggerOperationProducesJson()) + if (SwaggerOperationProducesSomethingDeserializable()) { if (TryBuildResponseBody(methodName, response, s => GenerateErrorModelName(s), out errorModel)) { @@ -381,7 +411,7 @@ private bool TryBuildResponseBody(string methodName, OperationResponse response, { bool handled = false; responseType = null; - if (SwaggerOperationProducesJson()) + if (SwaggerOperationProducesSomethingDeserializable()) { if (response.Schema != null) { @@ -404,17 +434,12 @@ private bool TryBuildResponseBody(string methodName, OperationResponse response, return handled; } - private bool SwaggerOperationProducesJson() + private bool SwaggerOperationProducesSomethingDeserializable() { - return _effectiveProduces != null && - _effectiveProduces.Any(s => s.StartsWith(APP_JSON_MIME, StringComparison.OrdinalIgnoreCase)); + return true == _effectiveProduces?.Any(s => s.StartsWith(APP_JSON_MIME, StringComparison.OrdinalIgnoreCase) || s.StartsWith(APP_XML_MIME, StringComparison.OrdinalIgnoreCase)); } - private bool SwaggerOperationProducesNotEmpty() - { - return _effectiveProduces != null - && _effectiveProduces.Any(); - } + private bool SwaggerOperationProducesNotEmpty() => true == _effectiveProduces?.Any(); private void EnsureUniqueMethodName(string methodName, string methodGroup) { diff --git a/src/modeler/AutoRest.Swagger/SchemaBuilder.cs b/src/modeler/AutoRest.Swagger/SchemaBuilder.cs index e57b8c21f4..e57a96a24e 100644 --- a/src/modeler/AutoRest.Swagger/SchemaBuilder.cs +++ b/src/modeler/AutoRest.Swagger/SchemaBuilder.cs @@ -9,6 +9,7 @@ using AutoRest.Swagger.Model; using AutoRest.Swagger.Properties; using static AutoRest.Core.Utilities.DependencyInjection; +using System.Linq; namespace AutoRest.Swagger { @@ -42,7 +43,10 @@ public override IModelType BuildServiceType(string serviceTypeName) var primaryType = _schema.GetSimplePrimaryType(); if (primaryType != KnownPrimaryType.None) { - return New(primaryType); + var result = New(primaryType); + // xml properties + result.XmlProperties = _schema.Xml; + return result; } // Otherwise create new object type @@ -82,7 +86,9 @@ public override IModelType BuildServiceType(string serviceTypeName) { Name = name, ModelType = propertyType, - Documentation = "Unmatched properties from the message are deserialized this collection" + Documentation = "Unmatched properties from the message are deserialized this collection", + XmlProperties = _schema.AdditionalProperties.Xml, + RealPath = new string[0] })); } @@ -133,9 +139,11 @@ public override IModelType BuildServiceType(string serviceTypeName) { Name = name, SerializedName = name, + RealPath = new string[] { name }, ModelType = propertyType, IsReadOnly = property.Value.ReadOnly, - Summary = property.Value.Title + Summary = property.Value.Title, + XmlProperties = property.Value.Xml }); PopulateParameter(propertyObj, refSchema != null ? refSchema : property.Value); var propertyCompositeType = propertyType as CompositeType; @@ -190,6 +198,8 @@ public override IModelType BuildServiceType(string serviceTypeName) } Modeler.GeneratedTypes[localName] = objectType; + // xml properties + objectType.XmlProperties = _schema.Xml; return objectType; } diff --git a/src/modeler/AutoRest.Swagger/SwaggerModeler.cs b/src/modeler/AutoRest.Swagger/SwaggerModeler.cs index f9a5f61320..9d301cbf73 100644 --- a/src/modeler/AutoRest.Swagger/SwaggerModeler.cs +++ b/src/modeler/AutoRest.Swagger/SwaggerModeler.cs @@ -100,6 +100,7 @@ public CodeModel Build(ServiceDefinition serviceDefinition) var clientProperty = New(); clientProperty.LoadFrom(parameter); + clientProperty.RealPath = new string[] { parameter.SerializedName.Value }; CodeModel.Add(clientProperty); }