diff --git a/test/CadlRanchProjects/type/property/optionality/src/Generated/Docs/Plaindate.xml b/test/CadlRanchProjects/type/property/optionality/src/Generated/Docs/Plaindate.xml deleted file mode 100644 index 9bb65da6fa3..00000000000 --- a/test/CadlRanchProjects/type/property/optionality/src/Generated/Docs/Plaindate.xml +++ /dev/null @@ -1,325 +0,0 @@ - - - - - -This sample shows how to call GetAllAsync. - response = await client.GetAllAsync(); -]]> -This sample shows how to call GetAllAsync with all parameters. - response = await client.GetAllAsync(); -]]> - - - -This sample shows how to call GetAll. - response = client.GetAll(); -]]> -This sample shows how to call GetAll with all parameters. - response = client.GetAll(); -]]> - - - -This sample shows how to call GetAllAsync and parse the result. - -This sample shows how to call GetAllAsync with all parameters and parse the result. - - - - -This sample shows how to call GetAll and parse the result. - -This sample shows how to call GetAll with all parameters and parse the result. - - - - -This sample shows how to call GetDefaultAsync. - response = await client.GetDefaultAsync(); -]]> -This sample shows how to call GetDefaultAsync with all parameters. - response = await client.GetDefaultAsync(); -]]> - - - -This sample shows how to call GetDefault. - response = client.GetDefault(); -]]> -This sample shows how to call GetDefault with all parameters. - response = client.GetDefault(); -]]> - - - -This sample shows how to call GetDefaultAsync and parse the result. - -This sample shows how to call GetDefaultAsync with all parameters and parse the result. - - - - -This sample shows how to call GetDefault and parse the result. - -This sample shows how to call GetDefault with all parameters and parse the result. - - - - -This sample shows how to call PutAllAsync. - -This sample shows how to call PutAllAsync with all parameters. - - - - -This sample shows how to call PutAll. - -This sample shows how to call PutAll with all parameters. - - - - -This sample shows how to call PutAllAsync. - -This sample shows how to call PutAllAsync with all request content. - - - - -This sample shows how to call PutAll. - -This sample shows how to call PutAll with all request content. - - - - -This sample shows how to call PutDefaultAsync. - -This sample shows how to call PutDefaultAsync with all parameters. - - - - -This sample shows how to call PutDefault. - -This sample shows how to call PutDefault with all parameters. - - - - -This sample shows how to call PutDefaultAsync. - -This sample shows how to call PutDefaultAsync with all request content. - - - - -This sample shows how to call PutDefault. - -This sample shows how to call PutDefault with all request content. - - - - \ No newline at end of file diff --git a/test/CadlRanchProjects/type/property/optionality/src/Generated/Docs/Plaintime.xml b/test/CadlRanchProjects/type/property/optionality/src/Generated/Docs/Plaintime.xml deleted file mode 100644 index b973cfa113c..00000000000 --- a/test/CadlRanchProjects/type/property/optionality/src/Generated/Docs/Plaintime.xml +++ /dev/null @@ -1,325 +0,0 @@ - - - - - -This sample shows how to call GetAllAsync. - response = await client.GetAllAsync(); -]]> -This sample shows how to call GetAllAsync with all parameters. - response = await client.GetAllAsync(); -]]> - - - -This sample shows how to call GetAll. - response = client.GetAll(); -]]> -This sample shows how to call GetAll with all parameters. - response = client.GetAll(); -]]> - - - -This sample shows how to call GetAllAsync and parse the result. - -This sample shows how to call GetAllAsync with all parameters and parse the result. - - - - -This sample shows how to call GetAll and parse the result. - -This sample shows how to call GetAll with all parameters and parse the result. - - - - -This sample shows how to call GetDefaultAsync. - response = await client.GetDefaultAsync(); -]]> -This sample shows how to call GetDefaultAsync with all parameters. - response = await client.GetDefaultAsync(); -]]> - - - -This sample shows how to call GetDefault. - response = client.GetDefault(); -]]> -This sample shows how to call GetDefault with all parameters. - response = client.GetDefault(); -]]> - - - -This sample shows how to call GetDefaultAsync and parse the result. - -This sample shows how to call GetDefaultAsync with all parameters and parse the result. - - - - -This sample shows how to call GetDefault and parse the result. - -This sample shows how to call GetDefault with all parameters and parse the result. - - - - -This sample shows how to call PutAllAsync. - -This sample shows how to call PutAllAsync with all parameters. - - - - -This sample shows how to call PutAll. - -This sample shows how to call PutAll with all parameters. - - - - -This sample shows how to call PutAllAsync. - -This sample shows how to call PutAllAsync with all request content. - - - - -This sample shows how to call PutAll. - -This sample shows how to call PutAll with all request content. - - - - -This sample shows how to call PutDefaultAsync. - -This sample shows how to call PutDefaultAsync with all parameters. - - - - -This sample shows how to call PutDefault. - -This sample shows how to call PutDefault with all parameters. - - - - -This sample shows how to call PutDefaultAsync. - -This sample shows how to call PutDefaultAsync with all request content. - - - - -This sample shows how to call PutDefault. - -This sample shows how to call PutDefault with all request content. - - - - \ No newline at end of file diff --git a/test/CadlRanchProjects/type/property/optionality/src/Generated/Models/PlaindateProperty.Serialization.cs b/test/CadlRanchProjects/type/property/optionality/src/Generated/Models/PlaindateProperty.Serialization.cs deleted file mode 100644 index 80fc58add18..00000000000 --- a/test/CadlRanchProjects/type/property/optionality/src/Generated/Models/PlaindateProperty.Serialization.cs +++ /dev/null @@ -1,143 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; -using Azure; -using Azure.Core; - -namespace _Type.Property.Optionality.Models -{ - public partial class PlainDateProperty : IUtf8JsonSerializable, IJsonModel - { - void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel)this).Write(writer, ModelSerializationExtensions.WireOptions); - - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(PlainDateProperty)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (Optional.IsDefined(Property)) - { - writer.WritePropertyName("property"u8); - writer.WriteStringValue(Property.Value, "D"); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); - } - - PlainDateProperty IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(PlainDateProperty)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializePlainDateProperty(document.RootElement, options); - } - - internal static PlainDateProperty DeserializePlainDateProperty(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - DateTimeOffset? property = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property0 in element.EnumerateObject()) - { - if (property0.NameEquals("property"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - property = property0.Value.GetDateTimeOffset("D"); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property0.Name, BinaryData.FromString(property0.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new PlainDateProperty(property, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(PlainDateProperty)} does not support writing '{options.Format}' format."); - } - } - - PlainDateProperty IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializePlainDateProperty(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(PlainDateProperty)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - /// Deserializes the model from a raw response. - /// The response to deserialize the model from. - internal static PlainDateProperty FromResponse(Response response) - { - using var document = JsonDocument.Parse(response.Content); - return DeserializePlainDateProperty(document.RootElement); - } - - /// Convert into a . - internal virtual RequestContent ToRequestContent() - { - var content = new Utf8JsonRequestContent(); - content.JsonWriter.WriteObjectValue(this, ModelSerializationExtensions.WireOptions); - return content; - } - } -} diff --git a/test/CadlRanchProjects/type/property/optionality/src/Generated/Models/PlaindateProperty.cs b/test/CadlRanchProjects/type/property/optionality/src/Generated/Models/PlaindateProperty.cs deleted file mode 100644 index 9a5d1395bb9..00000000000 --- a/test/CadlRanchProjects/type/property/optionality/src/Generated/Models/PlaindateProperty.cs +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace _Type.Property.Optionality.Models -{ - /// Model with a plainDate property. - public partial class PlainDateProperty - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; - - /// Initializes a new instance of . - public PlainDateProperty() - { - } - - /// Initializes a new instance of . - /// Property. - /// Keeps track of any properties unknown to the library. - internal PlainDateProperty(DateTimeOffset? property, IDictionary serializedAdditionalRawData) - { - Property = property; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Property. - public DateTimeOffset? Property { get; set; } - } -} diff --git a/test/CadlRanchProjects/type/property/optionality/src/Generated/Plaindate.cs b/test/CadlRanchProjects/type/property/optionality/src/Generated/Plaindate.cs deleted file mode 100644 index a86d0340dbf..00000000000 --- a/test/CadlRanchProjects/type/property/optionality/src/Generated/Plaindate.cs +++ /dev/null @@ -1,513 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Threading; -using System.Threading.Tasks; -using Azure; -using Azure.Core; -using Azure.Core.Pipeline; -using _Type.Property.Optionality.Models; - -namespace _Type.Property.Optionality -{ - // Data plane generated sub-client. - /// The PlainDate sub-client. - public partial class PlainDate - { - private readonly HttpPipeline _pipeline; - private readonly Uri _endpoint; - - /// The ClientDiagnostics is used to provide tracing support for the client library. - internal ClientDiagnostics ClientDiagnostics { get; } - - /// The HTTP pipeline for sending and receiving REST requests and responses. - public virtual HttpPipeline Pipeline => _pipeline; - - /// Initializes a new instance of PlainDate for mocking. - protected PlainDate() - { - } - - /// Initializes a new instance of PlainDate. - /// The handler for diagnostic messaging in the client. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// The to use. - internal PlainDate(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint) - { - ClientDiagnostics = clientDiagnostics; - _pipeline = pipeline; - _endpoint = endpoint; - } - - /// Get models that will return all properties in the model. - /// The cancellation token to use. - /// - public virtual async Task> GetAllAsync(CancellationToken cancellationToken = default) - { - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await GetAllAsync(context).ConfigureAwait(false); - return Response.FromValue(PlainDateProperty.FromResponse(response), response); - } - - /// Get models that will return all properties in the model. - /// The cancellation token to use. - /// - public virtual Response GetAll(CancellationToken cancellationToken = default) - { - RequestContext context = FromCancellationToken(cancellationToken); - Response response = GetAll(context); - return Response.FromValue(PlainDateProperty.FromResponse(response), response); - } - - /// - /// [Protocol Method] Get models that will return all properties in the model - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// Service returned a non-success status code. - /// The response returned from the service. - /// - public virtual async Task GetAllAsync(RequestContext context) - { - using var scope = ClientDiagnostics.CreateScope("PlainDate.GetAll"); - scope.Start(); - try - { - using HttpMessage message = CreateGetAllRequest(context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Get models that will return all properties in the model - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// Service returned a non-success status code. - /// The response returned from the service. - /// - public virtual Response GetAll(RequestContext context) - { - using var scope = ClientDiagnostics.CreateScope("PlainDate.GetAll"); - scope.Start(); - try - { - using HttpMessage message = CreateGetAllRequest(context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Get models that will return the default object. - /// The cancellation token to use. - /// - public virtual async Task> GetDefaultAsync(CancellationToken cancellationToken = default) - { - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await GetDefaultAsync(context).ConfigureAwait(false); - return Response.FromValue(PlainDateProperty.FromResponse(response), response); - } - - /// Get models that will return the default object. - /// The cancellation token to use. - /// - public virtual Response GetDefault(CancellationToken cancellationToken = default) - { - RequestContext context = FromCancellationToken(cancellationToken); - Response response = GetDefault(context); - return Response.FromValue(PlainDateProperty.FromResponse(response), response); - } - - /// - /// [Protocol Method] Get models that will return the default object - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// Service returned a non-success status code. - /// The response returned from the service. - /// - public virtual async Task GetDefaultAsync(RequestContext context) - { - using var scope = ClientDiagnostics.CreateScope("PlainDate.GetDefault"); - scope.Start(); - try - { - using HttpMessage message = CreateGetDefaultRequest(context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Get models that will return the default object - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// Service returned a non-success status code. - /// The response returned from the service. - /// - public virtual Response GetDefault(RequestContext context) - { - using var scope = ClientDiagnostics.CreateScope("PlainDate.GetDefault"); - scope.Start(); - try - { - using HttpMessage message = CreateGetDefaultRequest(context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Put a body with all properties present. - /// The to use. - /// The cancellation token to use. - /// is null. - /// - public virtual async Task PutAllAsync(PlainDateProperty body, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(body, nameof(body)); - - using RequestContent content = body.ToRequestContent(); - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await PutAllAsync(content, context).ConfigureAwait(false); - return response; - } - - /// Put a body with all properties present. - /// The to use. - /// The cancellation token to use. - /// is null. - /// - public virtual Response PutAll(PlainDateProperty body, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(body, nameof(body)); - - using RequestContent content = body.ToRequestContent(); - RequestContext context = FromCancellationToken(cancellationToken); - Response response = PutAll(content, context); - return response; - } - - /// - /// [Protocol Method] Put a body with all properties present. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The content to send as the body of the request. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// Service returned a non-success status code. - /// The response returned from the service. - /// - public virtual async Task PutAllAsync(RequestContent content, RequestContext context = null) - { - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("PlainDate.PutAll"); - scope.Start(); - try - { - using HttpMessage message = CreatePutAllRequest(content, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Put a body with all properties present. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The content to send as the body of the request. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// Service returned a non-success status code. - /// The response returned from the service. - /// - public virtual Response PutAll(RequestContent content, RequestContext context = null) - { - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("PlainDate.PutAll"); - scope.Start(); - try - { - using HttpMessage message = CreatePutAllRequest(content, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Put a body with default properties. - /// The to use. - /// The cancellation token to use. - /// is null. - /// - public virtual async Task PutDefaultAsync(PlainDateProperty body, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(body, nameof(body)); - - using RequestContent content = body.ToRequestContent(); - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await PutDefaultAsync(content, context).ConfigureAwait(false); - return response; - } - - /// Put a body with default properties. - /// The to use. - /// The cancellation token to use. - /// is null. - /// - public virtual Response PutDefault(PlainDateProperty body, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(body, nameof(body)); - - using RequestContent content = body.ToRequestContent(); - RequestContext context = FromCancellationToken(cancellationToken); - Response response = PutDefault(content, context); - return response; - } - - /// - /// [Protocol Method] Put a body with default properties. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The content to send as the body of the request. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// Service returned a non-success status code. - /// The response returned from the service. - /// - public virtual async Task PutDefaultAsync(RequestContent content, RequestContext context = null) - { - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("PlainDate.PutDefault"); - scope.Start(); - try - { - using HttpMessage message = CreatePutDefaultRequest(content, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Put a body with default properties. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The content to send as the body of the request. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// Service returned a non-success status code. - /// The response returned from the service. - /// - public virtual Response PutDefault(RequestContent content, RequestContext context = null) - { - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("PlainDate.PutDefault"); - scope.Start(); - try - { - using HttpMessage message = CreatePutDefaultRequest(content, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - internal HttpMessage CreateGetAllRequest(RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/type/property/optional/plainDate/all", false); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - internal HttpMessage CreateGetDefaultRequest(RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/type/property/optional/plainDate/default", false); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - internal HttpMessage CreatePutAllRequest(RequestContent content, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier204); - var request = message.Request; - request.Method = RequestMethod.Put; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/type/property/optional/plainDate/all", false); - request.Uri = uri; - request.Headers.Add("Content-Type", "application/json"); - request.Content = content; - return message; - } - - internal HttpMessage CreatePutDefaultRequest(RequestContent content, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier204); - var request = message.Request; - request.Method = RequestMethod.Put; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/type/property/optional/plainDate/default", false); - request.Uri = uri; - request.Headers.Add("Content-Type", "application/json"); - request.Content = content; - return message; - } - - private static RequestContext DefaultRequestContext = new RequestContext(); - internal static RequestContext FromCancellationToken(CancellationToken cancellationToken = default) - { - if (!cancellationToken.CanBeCanceled) - { - return DefaultRequestContext; - } - - return new RequestContext() { CancellationToken = cancellationToken }; - } - - private static ResponseClassifier _responseClassifier200; - private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 }); - private static ResponseClassifier _responseClassifier204; - private static ResponseClassifier ResponseClassifier204 => _responseClassifier204 ??= new StatusCodeClassifier(stackalloc ushort[] { 204 }); - } -} diff --git a/test/CadlRanchProjects/type/property/optionality/src/Generated/Plaintime.cs b/test/CadlRanchProjects/type/property/optionality/src/Generated/Plaintime.cs deleted file mode 100644 index 30d6aebc1dc..00000000000 --- a/test/CadlRanchProjects/type/property/optionality/src/Generated/Plaintime.cs +++ /dev/null @@ -1,513 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Threading; -using System.Threading.Tasks; -using Azure; -using Azure.Core; -using Azure.Core.Pipeline; -using _Type.Property.Optionality.Models; - -namespace _Type.Property.Optionality -{ - // Data plane generated sub-client. - /// The PlainTime sub-client. - public partial class PlainTime - { - private readonly HttpPipeline _pipeline; - private readonly Uri _endpoint; - - /// The ClientDiagnostics is used to provide tracing support for the client library. - internal ClientDiagnostics ClientDiagnostics { get; } - - /// The HTTP pipeline for sending and receiving REST requests and responses. - public virtual HttpPipeline Pipeline => _pipeline; - - /// Initializes a new instance of PlainTime for mocking. - protected PlainTime() - { - } - - /// Initializes a new instance of PlainTime. - /// The handler for diagnostic messaging in the client. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// The to use. - internal PlainTime(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint) - { - ClientDiagnostics = clientDiagnostics; - _pipeline = pipeline; - _endpoint = endpoint; - } - - /// Get models that will return all properties in the model. - /// The cancellation token to use. - /// - public virtual async Task> GetAllAsync(CancellationToken cancellationToken = default) - { - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await GetAllAsync(context).ConfigureAwait(false); - return Response.FromValue(PlainTimeProperty.FromResponse(response), response); - } - - /// Get models that will return all properties in the model. - /// The cancellation token to use. - /// - public virtual Response GetAll(CancellationToken cancellationToken = default) - { - RequestContext context = FromCancellationToken(cancellationToken); - Response response = GetAll(context); - return Response.FromValue(PlainTimeProperty.FromResponse(response), response); - } - - /// - /// [Protocol Method] Get models that will return all properties in the model - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// Service returned a non-success status code. - /// The response returned from the service. - /// - public virtual async Task GetAllAsync(RequestContext context) - { - using var scope = ClientDiagnostics.CreateScope("PlainTime.GetAll"); - scope.Start(); - try - { - using HttpMessage message = CreateGetAllRequest(context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Get models that will return all properties in the model - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// Service returned a non-success status code. - /// The response returned from the service. - /// - public virtual Response GetAll(RequestContext context) - { - using var scope = ClientDiagnostics.CreateScope("PlainTime.GetAll"); - scope.Start(); - try - { - using HttpMessage message = CreateGetAllRequest(context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Get models that will return the default object. - /// The cancellation token to use. - /// - public virtual async Task> GetDefaultAsync(CancellationToken cancellationToken = default) - { - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await GetDefaultAsync(context).ConfigureAwait(false); - return Response.FromValue(PlainTimeProperty.FromResponse(response), response); - } - - /// Get models that will return the default object. - /// The cancellation token to use. - /// - public virtual Response GetDefault(CancellationToken cancellationToken = default) - { - RequestContext context = FromCancellationToken(cancellationToken); - Response response = GetDefault(context); - return Response.FromValue(PlainTimeProperty.FromResponse(response), response); - } - - /// - /// [Protocol Method] Get models that will return the default object - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// Service returned a non-success status code. - /// The response returned from the service. - /// - public virtual async Task GetDefaultAsync(RequestContext context) - { - using var scope = ClientDiagnostics.CreateScope("PlainTime.GetDefault"); - scope.Start(); - try - { - using HttpMessage message = CreateGetDefaultRequest(context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Get models that will return the default object - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// Service returned a non-success status code. - /// The response returned from the service. - /// - public virtual Response GetDefault(RequestContext context) - { - using var scope = ClientDiagnostics.CreateScope("PlainTime.GetDefault"); - scope.Start(); - try - { - using HttpMessage message = CreateGetDefaultRequest(context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Put a body with all properties present. - /// The to use. - /// The cancellation token to use. - /// is null. - /// - public virtual async Task PutAllAsync(PlainTimeProperty body, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(body, nameof(body)); - - using RequestContent content = body.ToRequestContent(); - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await PutAllAsync(content, context).ConfigureAwait(false); - return response; - } - - /// Put a body with all properties present. - /// The to use. - /// The cancellation token to use. - /// is null. - /// - public virtual Response PutAll(PlainTimeProperty body, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(body, nameof(body)); - - using RequestContent content = body.ToRequestContent(); - RequestContext context = FromCancellationToken(cancellationToken); - Response response = PutAll(content, context); - return response; - } - - /// - /// [Protocol Method] Put a body with all properties present. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The content to send as the body of the request. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// Service returned a non-success status code. - /// The response returned from the service. - /// - public virtual async Task PutAllAsync(RequestContent content, RequestContext context = null) - { - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("PlainTime.PutAll"); - scope.Start(); - try - { - using HttpMessage message = CreatePutAllRequest(content, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Put a body with all properties present. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The content to send as the body of the request. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// Service returned a non-success status code. - /// The response returned from the service. - /// - public virtual Response PutAll(RequestContent content, RequestContext context = null) - { - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("PlainTime.PutAll"); - scope.Start(); - try - { - using HttpMessage message = CreatePutAllRequest(content, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// Put a body with default properties. - /// The to use. - /// The cancellation token to use. - /// is null. - /// - public virtual async Task PutDefaultAsync(PlainTimeProperty body, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(body, nameof(body)); - - using RequestContent content = body.ToRequestContent(); - RequestContext context = FromCancellationToken(cancellationToken); - Response response = await PutDefaultAsync(content, context).ConfigureAwait(false); - return response; - } - - /// Put a body with default properties. - /// The to use. - /// The cancellation token to use. - /// is null. - /// - public virtual Response PutDefault(PlainTimeProperty body, CancellationToken cancellationToken = default) - { - Argument.AssertNotNull(body, nameof(body)); - - using RequestContent content = body.ToRequestContent(); - RequestContext context = FromCancellationToken(cancellationToken); - Response response = PutDefault(content, context); - return response; - } - - /// - /// [Protocol Method] Put a body with default properties. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The content to send as the body of the request. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// Service returned a non-success status code. - /// The response returned from the service. - /// - public virtual async Task PutDefaultAsync(RequestContent content, RequestContext context = null) - { - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("PlainTime.PutDefault"); - scope.Start(); - try - { - using HttpMessage message = CreatePutDefaultRequest(content, context); - return await _pipeline.ProcessMessageAsync(message, context).ConfigureAwait(false); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - /// - /// [Protocol Method] Put a body with default properties. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The content to send as the body of the request. - /// The request context, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// Service returned a non-success status code. - /// The response returned from the service. - /// - public virtual Response PutDefault(RequestContent content, RequestContext context = null) - { - Argument.AssertNotNull(content, nameof(content)); - - using var scope = ClientDiagnostics.CreateScope("PlainTime.PutDefault"); - scope.Start(); - try - { - using HttpMessage message = CreatePutDefaultRequest(content, context); - return _pipeline.ProcessMessage(message, context); - } - catch (Exception e) - { - scope.Failed(e); - throw; - } - } - - internal HttpMessage CreateGetAllRequest(RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/type/property/optional/plainTime/all", false); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - internal HttpMessage CreateGetDefaultRequest(RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier200); - var request = message.Request; - request.Method = RequestMethod.Get; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/type/property/optional/plainTime/default", false); - request.Uri = uri; - request.Headers.Add("Accept", "application/json"); - return message; - } - - internal HttpMessage CreatePutAllRequest(RequestContent content, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier204); - var request = message.Request; - request.Method = RequestMethod.Put; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/type/property/optional/plainTime/all", false); - request.Uri = uri; - request.Headers.Add("Content-Type", "application/json"); - request.Content = content; - return message; - } - - internal HttpMessage CreatePutDefaultRequest(RequestContent content, RequestContext context) - { - var message = _pipeline.CreateMessage(context, ResponseClassifier204); - var request = message.Request; - request.Method = RequestMethod.Put; - var uri = new RawRequestUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/type/property/optional/plainTime/default", false); - request.Uri = uri; - request.Headers.Add("Content-Type", "application/json"); - request.Content = content; - return message; - } - - private static RequestContext DefaultRequestContext = new RequestContext(); - internal static RequestContext FromCancellationToken(CancellationToken cancellationToken = default) - { - if (!cancellationToken.CanBeCanceled) - { - return DefaultRequestContext; - } - - return new RequestContext() { CancellationToken = cancellationToken }; - } - - private static ResponseClassifier _responseClassifier200; - private static ResponseClassifier ResponseClassifier200 => _responseClassifier200 ??= new StatusCodeClassifier(stackalloc ushort[] { 200 }); - private static ResponseClassifier _responseClassifier204; - private static ResponseClassifier ResponseClassifier204 => _responseClassifier204 ??= new StatusCodeClassifier(stackalloc ushort[] { 204 }); - } -} diff --git a/test/CadlRanchProjects/type/property/optionality/tests/Generated/Samples/Samples_Plaindate.cs b/test/CadlRanchProjects/type/property/optionality/tests/Generated/Samples/Samples_Plaindate.cs deleted file mode 100644 index 8a9d4e4dccd..00000000000 --- a/test/CadlRanchProjects/type/property/optionality/tests/Generated/Samples/Samples_Plaindate.cs +++ /dev/null @@ -1,389 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Text.Json; -using System.Threading.Tasks; -using Azure; -using Azure.Core; -using Azure.Identity; -using NUnit.Framework; -using _Type.Property.Optionality.Models; - -namespace _Type.Property.Optionality.Samples -{ - public partial class Samples_PlainDate - { - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_PlainDate_GetAll_ShortVersion() - { - PlainDate client = new OptionalClient().GetPlainDateClient(); - - Response response = client.GetAll(null); - - JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.ToString()); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_PlainDate_GetAll_ShortVersion_Async() - { - PlainDate client = new OptionalClient().GetPlainDateClient(); - - Response response = await client.GetAllAsync(null); - - JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.ToString()); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_PlainDate_GetAll_ShortVersion_Convenience() - { - PlainDate client = new OptionalClient().GetPlainDateClient(); - - Response response = client.GetAll(); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_PlainDate_GetAll_ShortVersion_Convenience_Async() - { - PlainDate client = new OptionalClient().GetPlainDateClient(); - - Response response = await client.GetAllAsync(); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_PlainDate_GetAll_AllParameters() - { - PlainDate client = new OptionalClient().GetPlainDateClient(); - - Response response = client.GetAll(null); - - JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.GetProperty("property").ToString()); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_PlainDate_GetAll_AllParameters_Async() - { - PlainDate client = new OptionalClient().GetPlainDateClient(); - - Response response = await client.GetAllAsync(null); - - JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.GetProperty("property").ToString()); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_PlainDate_GetAll_AllParameters_Convenience() - { - PlainDate client = new OptionalClient().GetPlainDateClient(); - - Response response = client.GetAll(); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_PlainDate_GetAll_AllParameters_Convenience_Async() - { - PlainDate client = new OptionalClient().GetPlainDateClient(); - - Response response = await client.GetAllAsync(); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_PlainDate_GetDefault_ShortVersion() - { - PlainDate client = new OptionalClient().GetPlainDateClient(); - - Response response = client.GetDefault(null); - - JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.ToString()); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_PlainDate_GetDefault_ShortVersion_Async() - { - PlainDate client = new OptionalClient().GetPlainDateClient(); - - Response response = await client.GetDefaultAsync(null); - - JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.ToString()); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_PlainDate_GetDefault_ShortVersion_Convenience() - { - PlainDate client = new OptionalClient().GetPlainDateClient(); - - Response response = client.GetDefault(); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_PlainDate_GetDefault_ShortVersion_Convenience_Async() - { - PlainDate client = new OptionalClient().GetPlainDateClient(); - - Response response = await client.GetDefaultAsync(); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_PlainDate_GetDefault_AllParameters() - { - PlainDate client = new OptionalClient().GetPlainDateClient(); - - Response response = client.GetDefault(null); - - JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.GetProperty("property").ToString()); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_PlainDate_GetDefault_AllParameters_Async() - { - PlainDate client = new OptionalClient().GetPlainDateClient(); - - Response response = await client.GetDefaultAsync(null); - - JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.GetProperty("property").ToString()); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_PlainDate_GetDefault_AllParameters_Convenience() - { - PlainDate client = new OptionalClient().GetPlainDateClient(); - - Response response = client.GetDefault(); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_PlainDate_GetDefault_AllParameters_Convenience_Async() - { - PlainDate client = new OptionalClient().GetPlainDateClient(); - - Response response = await client.GetDefaultAsync(); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_PlainDate_PutAll_ShortVersion() - { - PlainDate client = new OptionalClient().GetPlainDateClient(); - - using RequestContent content = RequestContent.Create(new object()); - Response response = client.PutAll(content); - - Console.WriteLine(response.Status); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_PlainDate_PutAll_ShortVersion_Async() - { - PlainDate client = new OptionalClient().GetPlainDateClient(); - - using RequestContent content = RequestContent.Create(new object()); - Response response = await client.PutAllAsync(content); - - Console.WriteLine(response.Status); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_PlainDate_PutAll_ShortVersion_Convenience() - { - PlainDate client = new OptionalClient().GetPlainDateClient(); - - PlainDateProperty body = new PlainDateProperty(); - Response response = client.PutAll(body); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_PlainDate_PutAll_ShortVersion_Convenience_Async() - { - PlainDate client = new OptionalClient().GetPlainDateClient(); - - PlainDateProperty body = new PlainDateProperty(); - Response response = await client.PutAllAsync(body); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_PlainDate_PutAll_AllParameters() - { - PlainDate client = new OptionalClient().GetPlainDateClient(); - - using RequestContent content = RequestContent.Create(new - { - property = "2022-05-10", - }); - Response response = client.PutAll(content); - - Console.WriteLine(response.Status); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_PlainDate_PutAll_AllParameters_Async() - { - PlainDate client = new OptionalClient().GetPlainDateClient(); - - using RequestContent content = RequestContent.Create(new - { - property = "2022-05-10", - }); - Response response = await client.PutAllAsync(content); - - Console.WriteLine(response.Status); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_PlainDate_PutAll_AllParameters_Convenience() - { - PlainDate client = new OptionalClient().GetPlainDateClient(); - - PlainDateProperty body = new PlainDateProperty - { - Property = DateTimeOffset.Parse("2022-05-10"), - }; - Response response = client.PutAll(body); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_PlainDate_PutAll_AllParameters_Convenience_Async() - { - PlainDate client = new OptionalClient().GetPlainDateClient(); - - PlainDateProperty body = new PlainDateProperty - { - Property = DateTimeOffset.Parse("2022-05-10"), - }; - Response response = await client.PutAllAsync(body); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_PlainDate_PutDefault_ShortVersion() - { - PlainDate client = new OptionalClient().GetPlainDateClient(); - - using RequestContent content = RequestContent.Create(new object()); - Response response = client.PutDefault(content); - - Console.WriteLine(response.Status); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_PlainDate_PutDefault_ShortVersion_Async() - { - PlainDate client = new OptionalClient().GetPlainDateClient(); - - using RequestContent content = RequestContent.Create(new object()); - Response response = await client.PutDefaultAsync(content); - - Console.WriteLine(response.Status); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_PlainDate_PutDefault_ShortVersion_Convenience() - { - PlainDate client = new OptionalClient().GetPlainDateClient(); - - PlainDateProperty body = new PlainDateProperty(); - Response response = client.PutDefault(body); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_PlainDate_PutDefault_ShortVersion_Convenience_Async() - { - PlainDate client = new OptionalClient().GetPlainDateClient(); - - PlainDateProperty body = new PlainDateProperty(); - Response response = await client.PutDefaultAsync(body); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_PlainDate_PutDefault_AllParameters() - { - PlainDate client = new OptionalClient().GetPlainDateClient(); - - using RequestContent content = RequestContent.Create(new - { - property = "2022-05-10", - }); - Response response = client.PutDefault(content); - - Console.WriteLine(response.Status); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_PlainDate_PutDefault_AllParameters_Async() - { - PlainDate client = new OptionalClient().GetPlainDateClient(); - - using RequestContent content = RequestContent.Create(new - { - property = "2022-05-10", - }); - Response response = await client.PutDefaultAsync(content); - - Console.WriteLine(response.Status); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_PlainDate_PutDefault_AllParameters_Convenience() - { - PlainDate client = new OptionalClient().GetPlainDateClient(); - - PlainDateProperty body = new PlainDateProperty - { - Property = DateTimeOffset.Parse("2022-05-10"), - }; - Response response = client.PutDefault(body); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_PlainDate_PutDefault_AllParameters_Convenience_Async() - { - PlainDate client = new OptionalClient().GetPlainDateClient(); - - PlainDateProperty body = new PlainDateProperty - { - Property = DateTimeOffset.Parse("2022-05-10"), - }; - Response response = await client.PutDefaultAsync(body); - } - } -} diff --git a/test/CadlRanchProjects/type/property/optionality/tests/Generated/Samples/Samples_Plaintime.cs b/test/CadlRanchProjects/type/property/optionality/tests/Generated/Samples/Samples_Plaintime.cs deleted file mode 100644 index 318b615ebd3..00000000000 --- a/test/CadlRanchProjects/type/property/optionality/tests/Generated/Samples/Samples_Plaintime.cs +++ /dev/null @@ -1,389 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// - -#nullable disable - -using System; -using System.Text.Json; -using System.Threading.Tasks; -using Azure; -using Azure.Core; -using Azure.Identity; -using NUnit.Framework; -using _Type.Property.Optionality.Models; - -namespace _Type.Property.Optionality.Samples -{ - public partial class Samples_PlainTime - { - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_PlainTime_GetAll_ShortVersion() - { - PlainTime client = new OptionalClient().GetPlainTimeClient(); - - Response response = client.GetAll(null); - - JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.ToString()); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_PlainTime_GetAll_ShortVersion_Async() - { - PlainTime client = new OptionalClient().GetPlainTimeClient(); - - Response response = await client.GetAllAsync(null); - - JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.ToString()); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_PlainTime_GetAll_ShortVersion_Convenience() - { - PlainTime client = new OptionalClient().GetPlainTimeClient(); - - Response response = client.GetAll(); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_PlainTime_GetAll_ShortVersion_Convenience_Async() - { - PlainTime client = new OptionalClient().GetPlainTimeClient(); - - Response response = await client.GetAllAsync(); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_PlainTime_GetAll_AllParameters() - { - PlainTime client = new OptionalClient().GetPlainTimeClient(); - - Response response = client.GetAll(null); - - JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.GetProperty("property").ToString()); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_PlainTime_GetAll_AllParameters_Async() - { - PlainTime client = new OptionalClient().GetPlainTimeClient(); - - Response response = await client.GetAllAsync(null); - - JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.GetProperty("property").ToString()); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_PlainTime_GetAll_AllParameters_Convenience() - { - PlainTime client = new OptionalClient().GetPlainTimeClient(); - - Response response = client.GetAll(); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_PlainTime_GetAll_AllParameters_Convenience_Async() - { - PlainTime client = new OptionalClient().GetPlainTimeClient(); - - Response response = await client.GetAllAsync(); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_PlainTime_GetDefault_ShortVersion() - { - PlainTime client = new OptionalClient().GetPlainTimeClient(); - - Response response = client.GetDefault(null); - - JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.ToString()); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_PlainTime_GetDefault_ShortVersion_Async() - { - PlainTime client = new OptionalClient().GetPlainTimeClient(); - - Response response = await client.GetDefaultAsync(null); - - JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.ToString()); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_PlainTime_GetDefault_ShortVersion_Convenience() - { - PlainTime client = new OptionalClient().GetPlainTimeClient(); - - Response response = client.GetDefault(); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_PlainTime_GetDefault_ShortVersion_Convenience_Async() - { - PlainTime client = new OptionalClient().GetPlainTimeClient(); - - Response response = await client.GetDefaultAsync(); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_PlainTime_GetDefault_AllParameters() - { - PlainTime client = new OptionalClient().GetPlainTimeClient(); - - Response response = client.GetDefault(null); - - JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.GetProperty("property").ToString()); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_PlainTime_GetDefault_AllParameters_Async() - { - PlainTime client = new OptionalClient().GetPlainTimeClient(); - - Response response = await client.GetDefaultAsync(null); - - JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement; - Console.WriteLine(result.GetProperty("property").ToString()); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_PlainTime_GetDefault_AllParameters_Convenience() - { - PlainTime client = new OptionalClient().GetPlainTimeClient(); - - Response response = client.GetDefault(); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_PlainTime_GetDefault_AllParameters_Convenience_Async() - { - PlainTime client = new OptionalClient().GetPlainTimeClient(); - - Response response = await client.GetDefaultAsync(); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_PlainTime_PutAll_ShortVersion() - { - PlainTime client = new OptionalClient().GetPlainTimeClient(); - - using RequestContent content = RequestContent.Create(new object()); - Response response = client.PutAll(content); - - Console.WriteLine(response.Status); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_PlainTime_PutAll_ShortVersion_Async() - { - PlainTime client = new OptionalClient().GetPlainTimeClient(); - - using RequestContent content = RequestContent.Create(new object()); - Response response = await client.PutAllAsync(content); - - Console.WriteLine(response.Status); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_PlainTime_PutAll_ShortVersion_Convenience() - { - PlainTime client = new OptionalClient().GetPlainTimeClient(); - - PlainTimeProperty body = new PlainTimeProperty(); - Response response = client.PutAll(body); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_PlainTime_PutAll_ShortVersion_Convenience_Async() - { - PlainTime client = new OptionalClient().GetPlainTimeClient(); - - PlainTimeProperty body = new PlainTimeProperty(); - Response response = await client.PutAllAsync(body); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_PlainTime_PutAll_AllParameters() - { - PlainTime client = new OptionalClient().GetPlainTimeClient(); - - using RequestContent content = RequestContent.Create(new - { - property = "01:23:45", - }); - Response response = client.PutAll(content); - - Console.WriteLine(response.Status); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_PlainTime_PutAll_AllParameters_Async() - { - PlainTime client = new OptionalClient().GetPlainTimeClient(); - - using RequestContent content = RequestContent.Create(new - { - property = "01:23:45", - }); - Response response = await client.PutAllAsync(content); - - Console.WriteLine(response.Status); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_PlainTime_PutAll_AllParameters_Convenience() - { - PlainTime client = new OptionalClient().GetPlainTimeClient(); - - PlainTimeProperty body = new PlainTimeProperty - { - Property = TimeSpan.Parse("01:23:45"), - }; - Response response = client.PutAll(body); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_PlainTime_PutAll_AllParameters_Convenience_Async() - { - PlainTime client = new OptionalClient().GetPlainTimeClient(); - - PlainTimeProperty body = new PlainTimeProperty - { - Property = TimeSpan.Parse("01:23:45"), - }; - Response response = await client.PutAllAsync(body); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_PlainTime_PutDefault_ShortVersion() - { - PlainTime client = new OptionalClient().GetPlainTimeClient(); - - using RequestContent content = RequestContent.Create(new object()); - Response response = client.PutDefault(content); - - Console.WriteLine(response.Status); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_PlainTime_PutDefault_ShortVersion_Async() - { - PlainTime client = new OptionalClient().GetPlainTimeClient(); - - using RequestContent content = RequestContent.Create(new object()); - Response response = await client.PutDefaultAsync(content); - - Console.WriteLine(response.Status); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_PlainTime_PutDefault_ShortVersion_Convenience() - { - PlainTime client = new OptionalClient().GetPlainTimeClient(); - - PlainTimeProperty body = new PlainTimeProperty(); - Response response = client.PutDefault(body); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_PlainTime_PutDefault_ShortVersion_Convenience_Async() - { - PlainTime client = new OptionalClient().GetPlainTimeClient(); - - PlainTimeProperty body = new PlainTimeProperty(); - Response response = await client.PutDefaultAsync(body); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_PlainTime_PutDefault_AllParameters() - { - PlainTime client = new OptionalClient().GetPlainTimeClient(); - - using RequestContent content = RequestContent.Create(new - { - property = "01:23:45", - }); - Response response = client.PutDefault(content); - - Console.WriteLine(response.Status); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_PlainTime_PutDefault_AllParameters_Async() - { - PlainTime client = new OptionalClient().GetPlainTimeClient(); - - using RequestContent content = RequestContent.Create(new - { - property = "01:23:45", - }); - Response response = await client.PutDefaultAsync(content); - - Console.WriteLine(response.Status); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public void Example_PlainTime_PutDefault_AllParameters_Convenience() - { - PlainTime client = new OptionalClient().GetPlainTimeClient(); - - PlainTimeProperty body = new PlainTimeProperty - { - Property = TimeSpan.Parse("01:23:45"), - }; - Response response = client.PutDefault(body); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Example_PlainTime_PutDefault_AllParameters_Convenience_Async() - { - PlainTime client = new OptionalClient().GetPlainTimeClient(); - - PlainTimeProperty body = new PlainTimeProperty - { - Property = TimeSpan.Parse("01:23:45"), - }; - Response response = await client.PutDefaultAsync(body); - } - } -} diff --git a/test/CadlRanchProjectsNonAzure/type/property/optionality/src/Generated/Models/PlaindateProperty.Serialization.cs b/test/CadlRanchProjectsNonAzure/type/property/optionality/src/Generated/Models/PlaindateProperty.Serialization.cs deleted file mode 100644 index 855c071aee7..00000000000 --- a/test/CadlRanchProjectsNonAzure/type/property/optionality/src/Generated/Models/PlaindateProperty.Serialization.cs +++ /dev/null @@ -1,135 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Collections.Generic; -using System.Text.Json; - -namespace Scm._Type.Property.Optionality.Models -{ - public partial class PlainDateProperty : IJsonModel - { - void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(PlainDateProperty)} does not support writing '{format}' format."); - } - - writer.WriteStartObject(); - if (Optional.IsDefined(Property)) - { - writer.WritePropertyName("property"u8); - writer.WriteStringValue(Property.Value, "D"); - } - if (options.Format != "W" && _serializedAdditionalRawData != null) - { - foreach (var item in _serializedAdditionalRawData) - { - writer.WritePropertyName(item.Key); -#if NET6_0_OR_GREATER - writer.WriteRawValue(item.Value); -#else - using (JsonDocument document = JsonDocument.Parse(item.Value)) - { - JsonSerializer.Serialize(writer, document.RootElement); - } -#endif - } - } - writer.WriteEndObject(); - } - - PlainDateProperty IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - if (format != "J") - { - throw new FormatException($"The model {nameof(PlainDateProperty)} does not support reading '{format}' format."); - } - - using JsonDocument document = JsonDocument.ParseValue(ref reader); - return DeserializePlainDateProperty(document.RootElement, options); - } - - internal static PlainDateProperty DeserializePlainDateProperty(JsonElement element, ModelReaderWriterOptions options = null) - { - options ??= ModelSerializationExtensions.WireOptions; - - if (element.ValueKind == JsonValueKind.Null) - { - return null; - } - DateTimeOffset? property = default; - IDictionary serializedAdditionalRawData = default; - Dictionary rawDataDictionary = new Dictionary(); - foreach (var property0 in element.EnumerateObject()) - { - if (property0.NameEquals("property"u8)) - { - if (property0.Value.ValueKind == JsonValueKind.Null) - { - continue; - } - property = property0.Value.GetDateTimeOffset("D"); - continue; - } - if (options.Format != "W") - { - rawDataDictionary.Add(property0.Name, BinaryData.FromString(property0.Value.GetRawText())); - } - } - serializedAdditionalRawData = rawDataDictionary; - return new PlainDateProperty(property, serializedAdditionalRawData); - } - - BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - return ModelReaderWriter.Write(this, options); - default: - throw new FormatException($"The model {nameof(PlainDateProperty)} does not support writing '{options.Format}' format."); - } - } - - PlainDateProperty IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) - { - var format = options.Format == "W" ? ((IPersistableModel)this).GetFormatFromOptions(options) : options.Format; - - switch (format) - { - case "J": - { - using JsonDocument document = JsonDocument.Parse(data); - return DeserializePlainDateProperty(document.RootElement, options); - } - default: - throw new FormatException($"The model {nameof(PlainDateProperty)} does not support reading '{options.Format}' format."); - } - } - - string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => "J"; - - /// Deserializes the model from a raw response. - /// The result to deserialize the model from. - internal static PlainDateProperty FromResponse(PipelineResponse response) - { - using var document = JsonDocument.Parse(response.Content); - return DeserializePlainDateProperty(document.RootElement); - } - - /// Convert into a . - internal virtual BinaryContent ToBinaryContent() - { - return BinaryContent.Create(this, ModelSerializationExtensions.WireOptions); - } - } -} diff --git a/test/CadlRanchProjectsNonAzure/type/property/optionality/src/Generated/Models/PlaindateProperty.cs b/test/CadlRanchProjectsNonAzure/type/property/optionality/src/Generated/Models/PlaindateProperty.cs deleted file mode 100644 index f5e5ed4a07e..00000000000 --- a/test/CadlRanchProjectsNonAzure/type/property/optionality/src/Generated/Models/PlaindateProperty.cs +++ /dev/null @@ -1,62 +0,0 @@ -// - -#nullable disable - -using System; -using System.Collections.Generic; - -namespace Scm._Type.Property.Optionality.Models -{ - /// Model with a plainDate property. - public partial class PlainDateProperty - { - /// - /// Keeps track of any properties unknown to the library. - /// - /// To assign an object to the value of this property use . - /// - /// - /// To assign an already formatted json string to this property use . - /// - /// - /// Examples: - /// - /// - /// BinaryData.FromObjectAsJson("foo") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromString("\"foo\"") - /// Creates a payload of "foo". - /// - /// - /// BinaryData.FromObjectAsJson(new { key = "value" }) - /// Creates a payload of { "key": "value" }. - /// - /// - /// BinaryData.FromString("{\"key\": \"value\"}") - /// Creates a payload of { "key": "value" }. - /// - /// - /// - /// - private IDictionary _serializedAdditionalRawData; - - /// Initializes a new instance of . - public PlainDateProperty() - { - } - - /// Initializes a new instance of . - /// Property. - /// Keeps track of any properties unknown to the library. - internal PlainDateProperty(DateTimeOffset? property, IDictionary serializedAdditionalRawData) - { - Property = property; - _serializedAdditionalRawData = serializedAdditionalRawData; - } - - /// Property. - public DateTimeOffset? Property { get; set; } - } -} diff --git a/test/CadlRanchProjectsNonAzure/type/property/optionality/src/Generated/Plaindate.cs b/test/CadlRanchProjectsNonAzure/type/property/optionality/src/Generated/Plaindate.cs deleted file mode 100644 index 6a36ad01b50..00000000000 --- a/test/CadlRanchProjectsNonAzure/type/property/optionality/src/Generated/Plaindate.cs +++ /dev/null @@ -1,388 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Threading.Tasks; -using Scm._Type.Property.Optionality.Models; - -namespace Scm._Type.Property.Optionality -{ - // Data plane generated sub-client. - /// The PlainDate sub-client. - public partial class PlainDate - { - private readonly ClientPipeline _pipeline; - private readonly Uri _endpoint; - - /// The HTTP pipeline for sending and receiving REST requests and responses. - public virtual ClientPipeline Pipeline => _pipeline; - - /// Initializes a new instance of PlainDate for mocking. - protected PlainDate() - { - } - - /// Initializes a new instance of PlainDate. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// The to use. - internal PlainDate(ClientPipeline pipeline, Uri endpoint) - { - _pipeline = pipeline; - _endpoint = endpoint; - } - - /// Get models that will return all properties in the model. - public virtual async Task> GetAllAsync() - { - ClientResult result = await GetAllAsync(null).ConfigureAwait(false); - return ClientResult.FromValue(PlainDateProperty.FromResponse(result.GetRawResponse()), result.GetRawResponse()); - } - - /// Get models that will return all properties in the model. - public virtual ClientResult GetAll() - { - ClientResult result = GetAll(null); - return ClientResult.FromValue(PlainDateProperty.FromResponse(result.GetRawResponse()), result.GetRawResponse()); - } - - /// - /// [Protocol Method] Get models that will return all properties in the model - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task GetAllAsync(RequestOptions options) - { - using PipelineMessage message = CreateGetAllRequest(options); - return ClientResult.FromResponse(await _pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - - /// - /// [Protocol Method] Get models that will return all properties in the model - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual ClientResult GetAll(RequestOptions options) - { - using PipelineMessage message = CreateGetAllRequest(options); - return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options)); - } - - /// Get models that will return the default object. - public virtual async Task> GetDefaultAsync() - { - ClientResult result = await GetDefaultAsync(null).ConfigureAwait(false); - return ClientResult.FromValue(PlainDateProperty.FromResponse(result.GetRawResponse()), result.GetRawResponse()); - } - - /// Get models that will return the default object. - public virtual ClientResult GetDefault() - { - ClientResult result = GetDefault(null); - return ClientResult.FromValue(PlainDateProperty.FromResponse(result.GetRawResponse()), result.GetRawResponse()); - } - - /// - /// [Protocol Method] Get models that will return the default object - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task GetDefaultAsync(RequestOptions options) - { - using PipelineMessage message = CreateGetDefaultRequest(options); - return ClientResult.FromResponse(await _pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - - /// - /// [Protocol Method] Get models that will return the default object - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual ClientResult GetDefault(RequestOptions options) - { - using PipelineMessage message = CreateGetDefaultRequest(options); - return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options)); - } - - /// Put a body with all properties present. - /// The to use. - /// is null. - public virtual async Task PutAllAsync(PlainDateProperty body) - { - Argument.AssertNotNull(body, nameof(body)); - - using BinaryContent content = body.ToBinaryContent(); - ClientResult result = await PutAllAsync(content, null).ConfigureAwait(false); - return result; - } - - /// Put a body with all properties present. - /// The to use. - /// is null. - public virtual ClientResult PutAll(PlainDateProperty body) - { - Argument.AssertNotNull(body, nameof(body)); - - using BinaryContent content = body.ToBinaryContent(); - ClientResult result = PutAll(content, null); - return result; - } - - /// - /// [Protocol Method] Put a body with all properties present. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The content to send as the body of the request. - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task PutAllAsync(BinaryContent content, RequestOptions options = null) - { - Argument.AssertNotNull(content, nameof(content)); - - using PipelineMessage message = CreatePutAllRequest(content, options); - return ClientResult.FromResponse(await _pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - - /// - /// [Protocol Method] Put a body with all properties present. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The content to send as the body of the request. - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual ClientResult PutAll(BinaryContent content, RequestOptions options = null) - { - Argument.AssertNotNull(content, nameof(content)); - - using PipelineMessage message = CreatePutAllRequest(content, options); - return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options)); - } - - /// Put a body with default properties. - /// The to use. - /// is null. - public virtual async Task PutDefaultAsync(PlainDateProperty body) - { - Argument.AssertNotNull(body, nameof(body)); - - using BinaryContent content = body.ToBinaryContent(); - ClientResult result = await PutDefaultAsync(content, null).ConfigureAwait(false); - return result; - } - - /// Put a body with default properties. - /// The to use. - /// is null. - public virtual ClientResult PutDefault(PlainDateProperty body) - { - Argument.AssertNotNull(body, nameof(body)); - - using BinaryContent content = body.ToBinaryContent(); - ClientResult result = PutDefault(content, null); - return result; - } - - /// - /// [Protocol Method] Put a body with default properties. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The content to send as the body of the request. - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task PutDefaultAsync(BinaryContent content, RequestOptions options = null) - { - Argument.AssertNotNull(content, nameof(content)); - - using PipelineMessage message = CreatePutDefaultRequest(content, options); - return ClientResult.FromResponse(await _pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - - /// - /// [Protocol Method] Put a body with default properties. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The content to send as the body of the request. - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual ClientResult PutDefault(BinaryContent content, RequestOptions options = null) - { - Argument.AssertNotNull(content, nameof(content)); - - using PipelineMessage message = CreatePutDefaultRequest(content, options); - return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options)); - } - - internal PipelineMessage CreateGetAllRequest(RequestOptions options) - { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "GET"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/type/property/optional/plainDate/all", false); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; - } - - internal PipelineMessage CreateGetDefaultRequest(RequestOptions options) - { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "GET"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/type/property/optional/plainDate/default", false); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; - } - - internal PipelineMessage CreatePutAllRequest(BinaryContent content, RequestOptions options) - { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier204; - var request = message.Request; - request.Method = "PUT"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/type/property/optional/plainDate/all", false); - request.Uri = uri.ToUri(); - request.Headers.Set("Content-Type", "application/json"); - request.Content = content; - message.Apply(options); - return message; - } - - internal PipelineMessage CreatePutDefaultRequest(BinaryContent content, RequestOptions options) - { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier204; - var request = message.Request; - request.Method = "PUT"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/type/property/optional/plainDate/default", false); - request.Uri = uri.ToUri(); - request.Headers.Set("Content-Type", "application/json"); - request.Content = content; - message.Apply(options); - return message; - } - - private static PipelineMessageClassifier _pipelineMessageClassifier200; - private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); - private static PipelineMessageClassifier _pipelineMessageClassifier204; - private static PipelineMessageClassifier PipelineMessageClassifier204 => _pipelineMessageClassifier204 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 204 }); - } -} diff --git a/test/CadlRanchProjectsNonAzure/type/property/optionality/src/Generated/Plaintime.cs b/test/CadlRanchProjectsNonAzure/type/property/optionality/src/Generated/Plaintime.cs deleted file mode 100644 index d97654766f1..00000000000 --- a/test/CadlRanchProjectsNonAzure/type/property/optionality/src/Generated/Plaintime.cs +++ /dev/null @@ -1,388 +0,0 @@ -// - -#nullable disable - -using System; -using System.ClientModel; -using System.ClientModel.Primitives; -using System.Threading.Tasks; -using Scm._Type.Property.Optionality.Models; - -namespace Scm._Type.Property.Optionality -{ - // Data plane generated sub-client. - /// The PlainTime sub-client. - public partial class PlainTime - { - private readonly ClientPipeline _pipeline; - private readonly Uri _endpoint; - - /// The HTTP pipeline for sending and receiving REST requests and responses. - public virtual ClientPipeline Pipeline => _pipeline; - - /// Initializes a new instance of PlainTime for mocking. - protected PlainTime() - { - } - - /// Initializes a new instance of PlainTime. - /// The HTTP pipeline for sending and receiving REST requests and responses. - /// The to use. - internal PlainTime(ClientPipeline pipeline, Uri endpoint) - { - _pipeline = pipeline; - _endpoint = endpoint; - } - - /// Get models that will return all properties in the model. - public virtual async Task> GetAllAsync() - { - ClientResult result = await GetAllAsync(null).ConfigureAwait(false); - return ClientResult.FromValue(PlainTimeProperty.FromResponse(result.GetRawResponse()), result.GetRawResponse()); - } - - /// Get models that will return all properties in the model. - public virtual ClientResult GetAll() - { - ClientResult result = GetAll(null); - return ClientResult.FromValue(PlainTimeProperty.FromResponse(result.GetRawResponse()), result.GetRawResponse()); - } - - /// - /// [Protocol Method] Get models that will return all properties in the model - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task GetAllAsync(RequestOptions options) - { - using PipelineMessage message = CreateGetAllRequest(options); - return ClientResult.FromResponse(await _pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - - /// - /// [Protocol Method] Get models that will return all properties in the model - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual ClientResult GetAll(RequestOptions options) - { - using PipelineMessage message = CreateGetAllRequest(options); - return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options)); - } - - /// Get models that will return the default object. - public virtual async Task> GetDefaultAsync() - { - ClientResult result = await GetDefaultAsync(null).ConfigureAwait(false); - return ClientResult.FromValue(PlainTimeProperty.FromResponse(result.GetRawResponse()), result.GetRawResponse()); - } - - /// Get models that will return the default object. - public virtual ClientResult GetDefault() - { - ClientResult result = GetDefault(null); - return ClientResult.FromValue(PlainTimeProperty.FromResponse(result.GetRawResponse()), result.GetRawResponse()); - } - - /// - /// [Protocol Method] Get models that will return the default object - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task GetDefaultAsync(RequestOptions options) - { - using PipelineMessage message = CreateGetDefaultRequest(options); - return ClientResult.FromResponse(await _pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - - /// - /// [Protocol Method] Get models that will return the default object - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual ClientResult GetDefault(RequestOptions options) - { - using PipelineMessage message = CreateGetDefaultRequest(options); - return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options)); - } - - /// Put a body with all properties present. - /// The to use. - /// is null. - public virtual async Task PutAllAsync(PlainTimeProperty body) - { - Argument.AssertNotNull(body, nameof(body)); - - using BinaryContent content = body.ToBinaryContent(); - ClientResult result = await PutAllAsync(content, null).ConfigureAwait(false); - return result; - } - - /// Put a body with all properties present. - /// The to use. - /// is null. - public virtual ClientResult PutAll(PlainTimeProperty body) - { - Argument.AssertNotNull(body, nameof(body)); - - using BinaryContent content = body.ToBinaryContent(); - ClientResult result = PutAll(content, null); - return result; - } - - /// - /// [Protocol Method] Put a body with all properties present. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The content to send as the body of the request. - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task PutAllAsync(BinaryContent content, RequestOptions options = null) - { - Argument.AssertNotNull(content, nameof(content)); - - using PipelineMessage message = CreatePutAllRequest(content, options); - return ClientResult.FromResponse(await _pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - - /// - /// [Protocol Method] Put a body with all properties present. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The content to send as the body of the request. - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual ClientResult PutAll(BinaryContent content, RequestOptions options = null) - { - Argument.AssertNotNull(content, nameof(content)); - - using PipelineMessage message = CreatePutAllRequest(content, options); - return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options)); - } - - /// Put a body with default properties. - /// The to use. - /// is null. - public virtual async Task PutDefaultAsync(PlainTimeProperty body) - { - Argument.AssertNotNull(body, nameof(body)); - - using BinaryContent content = body.ToBinaryContent(); - ClientResult result = await PutDefaultAsync(content, null).ConfigureAwait(false); - return result; - } - - /// Put a body with default properties. - /// The to use. - /// is null. - public virtual ClientResult PutDefault(PlainTimeProperty body) - { - Argument.AssertNotNull(body, nameof(body)); - - using BinaryContent content = body.ToBinaryContent(); - ClientResult result = PutDefault(content, null); - return result; - } - - /// - /// [Protocol Method] Put a body with default properties. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The content to send as the body of the request. - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual async Task PutDefaultAsync(BinaryContent content, RequestOptions options = null) - { - Argument.AssertNotNull(content, nameof(content)); - - using PipelineMessage message = CreatePutDefaultRequest(content, options); - return ClientResult.FromResponse(await _pipeline.ProcessMessageAsync(message, options).ConfigureAwait(false)); - } - - /// - /// [Protocol Method] Put a body with default properties. - /// - /// - /// - /// This protocol method allows explicit creation of the request and processing of the response for advanced scenarios. - /// - /// - /// - /// - /// Please try the simpler convenience overload with strongly typed models first. - /// - /// - /// - /// - /// The content to send as the body of the request. - /// The request options, which can override default behaviors of the client pipeline on a per-call basis. - /// is null. - /// Service returned a non-success status code. - /// The response returned from the service. - public virtual ClientResult PutDefault(BinaryContent content, RequestOptions options = null) - { - Argument.AssertNotNull(content, nameof(content)); - - using PipelineMessage message = CreatePutDefaultRequest(content, options); - return ClientResult.FromResponse(_pipeline.ProcessMessage(message, options)); - } - - internal PipelineMessage CreateGetAllRequest(RequestOptions options) - { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "GET"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/type/property/optional/plainTime/all", false); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; - } - - internal PipelineMessage CreateGetDefaultRequest(RequestOptions options) - { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier200; - var request = message.Request; - request.Method = "GET"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/type/property/optional/plainTime/default", false); - request.Uri = uri.ToUri(); - request.Headers.Set("Accept", "application/json"); - message.Apply(options); - return message; - } - - internal PipelineMessage CreatePutAllRequest(BinaryContent content, RequestOptions options) - { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier204; - var request = message.Request; - request.Method = "PUT"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/type/property/optional/plainTime/all", false); - request.Uri = uri.ToUri(); - request.Headers.Set("Content-Type", "application/json"); - request.Content = content; - message.Apply(options); - return message; - } - - internal PipelineMessage CreatePutDefaultRequest(BinaryContent content, RequestOptions options) - { - var message = _pipeline.CreateMessage(); - message.ResponseClassifier = PipelineMessageClassifier204; - var request = message.Request; - request.Method = "PUT"; - var uri = new ClientUriBuilder(); - uri.Reset(_endpoint); - uri.AppendPath("/type/property/optional/plainTime/default", false); - request.Uri = uri.ToUri(); - request.Headers.Set("Content-Type", "application/json"); - request.Content = content; - message.Apply(options); - return message; - } - - private static PipelineMessageClassifier _pipelineMessageClassifier200; - private static PipelineMessageClassifier PipelineMessageClassifier200 => _pipelineMessageClassifier200 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 200 }); - private static PipelineMessageClassifier _pipelineMessageClassifier204; - private static PipelineMessageClassifier PipelineMessageClassifier204 => _pipelineMessageClassifier204 ??= PipelineMessageClassifier.Create(stackalloc ushort[] { 204 }); - } -}