diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/src/OutputTypes/ScmTypeFactory.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/src/OutputTypes/ScmTypeFactory.cs index 87f0123df1..65a0de09ec 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/src/OutputTypes/ScmTypeFactory.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/src/OutputTypes/ScmTypeFactory.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using Microsoft.Generator.CSharp.ClientModel.Providers; using Microsoft.Generator.CSharp.Input; using Microsoft.Generator.CSharp.Providers; @@ -18,36 +19,7 @@ public class ScmTypeFactory : TypeFactory /// /// The input operation to create methods for. /// The enclosing type of the operation. - public override MethodProviderCollection? CreateMethodProviders(InputOperation operation, TypeProvider enclosingType) - { - if (_operations.TryGetValue(operation, out var methods)) - { - return methods; - } - - methods = GetOperationKind(operation).ToString() switch - { - "Default" => MethodProviderCollection.DefaultCSharpMethodCollection(operation, enclosingType), - _ => null, - }; - - _operations.Add(operation, methods); - return methods; - } - - /// - /// Returns the of the given operation. - /// By default, the operation kind is . - /// - private static InputOperationKinds GetOperationKind(InputOperation operation) - { - return operation switch - { - { LongRunning: { } } => InputOperationKinds.LongRunning, - { Paging: { } } => InputOperationKinds.Paging, - _ => InputOperationKinds.Default, - }; - } + public override MethodProviderCollection CreateMethodProviders(InputOperation operation, TypeProvider enclosingType) => new ScmMethodProviderCollection(operation, enclosingType); public virtual CSharpType MatchConditionsType() { diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/src/Providers/ScmMethodProviderCollection.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/src/Providers/ScmMethodProviderCollection.cs new file mode 100644 index 0000000000..059fd29fcc --- /dev/null +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/src/Providers/ScmMethodProviderCollection.cs @@ -0,0 +1,96 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Collections.Generic; +using Microsoft.Generator.CSharp.Expressions; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.Generator.CSharp.Input; +using Microsoft.Generator.CSharp.Providers; +using Microsoft.Generator.CSharp.Statements; +using static Microsoft.Generator.CSharp.Snippets.Snippet; +using Microsoft.Generator.CSharp.Snippets; + +namespace Microsoft.Generator.CSharp.ClientModel.Providers +{ + internal class ScmMethodProviderCollection : MethodProviderCollection + { + public ScmMethodProviderCollection(InputOperation operation, TypeProvider enclosingType) + : base(operation, enclosingType) + { + } + + protected override IReadOnlyList BuildMethods() + { + return + [ + // TO-DO: Add Protocol and Convenience methods https://github.com/Azure/autorest.csharp/issues/4585, https://github.com/Azure/autorest.csharp/issues/4586 + BuildCreateMessageMethod(_operation, _enclosingType), + BuildProtocolMethod(_operation, _enclosingType, false), + BuildProtocolMethod(_operation, _enclosingType, true) + ]; + } + private static MethodProvider BuildProtocolMethod(InputOperation operation, TypeProvider enclosingType, bool isAsync) + { + List methodParameters = new(); + foreach (InputParameter inputParam in operation.Parameters) + { + if (inputParam.Kind != InputOperationParameterKind.Method) + continue; + methodParameters.Add(ClientModelPlugin.Instance.TypeFactory.CreateCSharpParam(inputParam)); + } + + var methodModifier = MethodSignatureModifiers.Public | MethodSignatureModifiers.Virtual; + if (isAsync) + { + methodModifier |= MethodSignatureModifiers.Async; + } + var opName = operation.Name.ToCleanName(); + var methodSignature = new MethodSignature( + isAsync ? opName + "Async" : opName, + FormattableStringHelpers.FromString(operation.Description), + methodModifier, + GetResponseType(operation.Responses, isAsync), + null, + Parameters: [.. methodParameters, KnownParameters.CancellationTokenParameter]); + MethodBodyStatement[] methodBody = + [ + //UsingDeclare("message", typeof(RequestMess) + //using PipelineMessage message = CreateSayHiRequest(headParameter, queryParameter, optionalQuery, options); + isAsync ? new InvokeStaticPropertyExpression(typeof(Task), nameof(Task.CompletedTask), true).Terminate() : EmptyStatement + ]; + + return new MethodProvider(methodSignature, methodBody, enclosingType); + } + + private static CSharpType? GetResponseType(IReadOnlyList responses, bool isAsync) + { + var response = responses.FirstOrDefault(r => !r.IsErrorResponse); + if (response is null || response.BodyType is null) + return null; + var returnType = ClientModelPlugin.Instance.TypeFactory.CreateCSharpType(response.BodyType); + if (isAsync) + { + returnType = returnType.WrapInTask(); + } + return returnType; + } + + private static MethodProvider BuildCreateMessageMethod(InputOperation operation, TypeProvider enclosingType) + { + // TO-DO: properly build method https://github.com/Azure/autorest.csharp/issues/4583 + List methodParameters = new(); + foreach (var inputParam in operation.Parameters) + { + methodParameters.Add(ClientModelPlugin.Instance.TypeFactory.CreateCSharpParam(inputParam)); + } + + var methodModifier = MethodSignatureModifiers.Internal; + var methodSignatureName = $"Create{operation.Name.ToCleanName()}Request"; + var methodSignature = new MethodSignature(methodSignatureName, FormattableStringHelpers.FromString(operation.Description), methodModifier, null, null, Parameters: methodParameters); + var methodBody = Throw(New.NotImplementedException(Literal("Method not implemented."))); + + return new MethodProvider(methodSignature, methodBody, enclosingType); + } + } +} diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Mocks/MockTypeFactory.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Mocks/MockTypeFactory.cs index 3c94e672eb..84a6e9374b 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Mocks/MockTypeFactory.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Mocks/MockTypeFactory.cs @@ -10,7 +10,7 @@ namespace Microsoft.Generator.CSharp.ClientModel.Tests { internal class MockTypeFactory : ScmTypeFactory { - public override MethodProviderCollection? CreateMethodProviders(InputOperation operation, TypeProvider enclosingType) + public override MethodProviderCollection CreateMethodProviders(InputOperation operation, TypeProvider enclosingType) { throw new NotImplementedException(); } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Mocks/MockTypeProvider.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Mocks/MockTypeProvider.cs new file mode 100644 index 0000000000..93fdd332fa --- /dev/null +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Mocks/MockTypeProvider.cs @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using Microsoft.Generator.CSharp.Providers; + +namespace Microsoft.Generator.CSharp.ClientModel.Tests +{ + internal class MockTypeProvider : TypeProvider + { + public override string RelativeFilePath => throw new NotImplementedException(); + public override string Name => throw new NotImplementedException(); + } +} diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/MethodProviderCollectionTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/ScmMethodProviderCollectionTests.cs similarity index 83% rename from packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/MethodProviderCollectionTests.cs rename to packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/ScmMethodProviderCollectionTests.cs index f9699a67e1..d535ec641d 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Providers/MethodProviderCollectionTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/test/Providers/ScmMethodProviderCollectionTests.cs @@ -5,18 +5,19 @@ using System.Collections.Generic; using System.IO; using System.Reflection; +using Microsoft.Generator.CSharp.ClientModel.Providers; using Microsoft.Generator.CSharp.Input; using Microsoft.Generator.CSharp.Providers; using Moq; using Moq.Protected; using NUnit.Framework; -namespace Microsoft.Generator.CSharp.Tests.Providers +namespace Microsoft.Generator.CSharp.ClientModel.Tests.Providers { - internal class MethodProviderCollectionTests + internal class ScmMethodProviderCollectionTests { #pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. - private TypeFactory _typeFactory; + private ScmTypeFactory _typeFactory; #pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. private readonly string _mocksFolder = "Mocks"; private FieldInfo? _mockPlugin; @@ -25,16 +26,17 @@ internal class MethodProviderCollectionTests public void Setup() { var mockParameter = new ParameterProvider("mockParam", $"mock description", typeof(bool), null); - var mockTypeFactory = new Mock() { }; + var mockTypeFactory = new Mock() { }; mockTypeFactory.Protected().Setup("CreateCSharpTypeCore", ItExpr.IsAny()).Returns(new CSharpType(typeof(bool))); mockTypeFactory.Setup(t => t.CreateCSharpParam(It.IsAny())).Returns(mockParameter); _typeFactory = mockTypeFactory.Object; var configFilePath = Path.Combine(AppContext.BaseDirectory, _mocksFolder); // initialize the mock singleton instance of the plugin - _mockPlugin = typeof(CodeModelPlugin).GetField("_instance", BindingFlags.Static | BindingFlags.NonPublic); - var mockGeneratorContext = new Mock(Configuration.Load(configFilePath)); - var mockPluginInstance = new Mock(mockGeneratorContext.Object) { }; + _mockPlugin = typeof(ClientModelPlugin).GetField("_instance", BindingFlags.Static | BindingFlags.NonPublic); + var mockConfiguration = new Mock() { }; + var mockGeneratorContext = new Mock(mockConfiguration.Object); + var mockPluginInstance = new Mock(mockGeneratorContext.Object) { }; mockPluginInstance.SetupGet(p => p.TypeFactory).Returns(_typeFactory); _mockPlugin?.SetValue(null, mockPluginInstance.Object); @@ -50,9 +52,9 @@ public void Teardown() [TestCaseSource(nameof(DefaultCSharpMethodCollectionTestCases))] public void TestDefaultCSharpMethodCollection(InputOperation inputOperation) { - var methodCollection = MethodProviderCollection.DefaultCSharpMethodCollection(inputOperation, new MockTypeProvider()); + var methodCollection = new ScmMethodProviderCollection(inputOperation, new MockTypeProvider()); Assert.IsNotNull(methodCollection); - Assert.AreEqual(1, methodCollection?.Count); + Assert.AreEqual(3, methodCollection.Count); var method = methodCollection![0]; var signature = method.Signature; @@ -93,5 +95,4 @@ public static IEnumerable DefaultCSharpMethodCollectionTestCases } } } - } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Configuration.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Configuration.cs index f37483a489..284c495a39 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Configuration.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Configuration.cs @@ -15,6 +15,15 @@ public class Configuration { private const string ConfigurationFileName = "Configuration.json"; + // for mocking + protected Configuration() + { + OutputDirectory = null!; + AdditionalConfigOptions = null!; + LibraryName = null!; + Namespace = null!; + } + private Configuration( string outputPath, Dictionary additionalConfigOptions, diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Expressions/InvokeStaticPropertyExpression.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Expressions/InvokeStaticPropertyExpression.cs new file mode 100644 index 0000000000..e43ad47f54 --- /dev/null +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Expressions/InvokeStaticPropertyExpression.cs @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Microsoft.Generator.CSharp.Statements; + +namespace Microsoft.Generator.CSharp.Expressions +{ + public sealed record InvokeStaticPropertyExpression(CSharpType? ContainingType, string PropertyName, bool CallAsAsync = false) : ValueExpression + { + internal override void Write(CodeWriter writer) + { + writer.AppendRawIf("await ", CallAsAsync); + if (ContainingType != null) + { + writer.Append($"{ContainingType}."); + } + + writer.AppendRaw(PropertyName); + writer.AppendRawIf(".ConfigureAwait(false)", CallAsAsync); + } + + private MethodBodyStatement? _terminated; + public MethodBodyStatement Terminate() => _terminated ??= new ExpressionStatement(this); + } +} diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/OutputTypes/CSharpType.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/OutputTypes/CSharpType.cs index 532191f4a1..d61a0e3cd2 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/OutputTypes/CSharpType.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/OutputTypes/CSharpType.cs @@ -7,6 +7,7 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Linq; +using System.Threading.Tasks; using Microsoft.Generator.CSharp.Providers; namespace Microsoft.Generator.CSharp @@ -608,5 +609,15 @@ public CSharpType MakeGenericType(IReadOnlyList arguments) return new CSharpType(Implementation, arguments, IsNullable); } } + + public CSharpType WrapInTask() + { + if (IsFrameworkType && FrameworkType == typeof(Task<>)) + { + return this; + } + + return new CSharpType(typeof(Task<>), this); + } } } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/OutputTypes/TypeFactory.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/OutputTypes/TypeFactory.cs index d567e232a1..768d863d02 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/OutputTypes/TypeFactory.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/OutputTypes/TypeFactory.cs @@ -94,7 +94,7 @@ public CSharpType CreateCSharpType(InputType inputType) /// An instance of containing the chain of methods /// associated with the input operation, or null if no methods are constructed. /// - public abstract MethodProviderCollection? CreateMethodProviders(InputOperation operation, TypeProvider enclosingType); + public virtual MethodProviderCollection CreateMethodProviders(InputOperation operation, TypeProvider enclosingType) => new(operation, enclosingType); /// /// Factory method for retrieving the serialization format for a given input type. diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Providers/MethodProviderCollection.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Providers/MethodProviderCollection.cs index f90faf97ad..21c6f9b43a 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Providers/MethodProviderCollection.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/Providers/MethodProviderCollection.cs @@ -3,68 +3,41 @@ using System.Collections; using System.Collections.Generic; -using System.Linq; using Microsoft.Generator.CSharp.Input; -using Microsoft.Generator.CSharp.Snippets; namespace Microsoft.Generator.CSharp.Providers { /// /// Represents an immutable collection of methods that are associated with an operation . /// - public sealed class MethodProviderCollection : IReadOnlyList + public class MethodProviderCollection : IReadOnlyList { - private readonly IReadOnlyList _cSharpMethods; + private IReadOnlyList? _cSharpMethods; + protected readonly InputOperation _operation; + protected readonly TypeProvider _enclosingType; - private MethodProviderCollection(IEnumerable? methods) + public MethodProviderCollection(InputOperation operation, TypeProvider enclosingType) { - _cSharpMethods = methods?.ToList() ?? []; + _operation = operation; + _enclosingType = enclosingType; } - /// - /// Builds a default for the given - /// with a single method that creates a message. - /// - /// The to convert. - /// The that will contain the methods. - public static MethodProviderCollection DefaultCSharpMethodCollection(InputOperation operation, TypeProvider enclosingType) - { - var createMessageMethod = BuildCreateMessageMethod(operation, enclosingType); - var cSharpMethods = new List() { createMessageMethod }; - // TO-DO: Add Protocol and Convenience methods https://github.com/Azure/autorest.csharp/issues/4585, https://github.com/Azure/autorest.csharp/issues/4586 - return new MethodProviderCollection(cSharpMethods); - } + protected virtual IReadOnlyList BuildMethods() => []; + public IReadOnlyList MethodProviders => _cSharpMethods ??= BuildMethods(); public MethodProvider this[int index] { - get { return _cSharpMethods[index]; } + get { return MethodProviders[index]; } } public int Count { - get { return _cSharpMethods.Count; } - } - - private static MethodProvider BuildCreateMessageMethod(InputOperation operation, TypeProvider enclosingType) - { - // TO-DO: properly build method https://github.com/Azure/autorest.csharp/issues/4583 - List methodParameters = new(); - foreach (var inputParam in operation.Parameters) - { - methodParameters.Add(CodeModelPlugin.Instance.TypeFactory.CreateCSharpParam(inputParam)); - } - - var methodModifier = MethodSignatureModifiers.Internal; - var methodSignatureName = $"Create{operation.Name.ToCleanName()}Request"; - var methodSignature = new MethodSignature(methodSignatureName, FormattableStringHelpers.FromString(operation.Description), methodModifier, null, null, Parameters: methodParameters); - var methodBody = Snippet.Throw(Snippet.New.NotImplementedException(Snippet.Literal("Method not implemented."))); - - return new MethodProvider(methodSignature, methodBody, enclosingType); + get { return MethodProviders.Count; } } public IEnumerator GetEnumerator() { - return _cSharpMethods.GetEnumerator(); + return MethodProviders.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Mocks/MockTypeFactory.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Mocks/MockTypeFactory.cs index 94fa2ae7fd..04c0a19b83 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Mocks/MockTypeFactory.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/Mocks/MockTypeFactory.cs @@ -10,7 +10,7 @@ namespace Microsoft.Generator.CSharp.Tests { internal class MockTypeFactory : TypeFactory { - public override MethodProviderCollection? CreateMethodProviders(InputOperation operation, TypeProvider enclosingType) + public override MethodProviderCollection CreateMethodProviders(InputOperation operation, TypeProvider enclosingType) { throw new NotImplementedException(); } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/OutputTypes/TypeFactoryTests.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/OutputTypes/TypeFactoryTests.cs index e0dc535e03..987a059486 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/OutputTypes/TypeFactoryTests.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/OutputTypes/TypeFactoryTests.cs @@ -63,7 +63,7 @@ public override ParameterProvider CreateCSharpParam(InputParameter parameter) throw new NotImplementedException(); } - public override MethodProviderCollection? CreateMethodProviders(InputOperation operation, TypeProvider enclosingType) + public override MethodProviderCollection CreateMethodProviders(InputOperation operation, TypeProvider enclosingType) { throw new NotImplementedException(); } diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/UnbrandedTypeSpecClient.cs b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/UnbrandedTypeSpecClient.cs index 3ac4c09f9e..e35c2608f5 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/UnbrandedTypeSpecClient.cs +++ b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/src/Generated/UnbrandedTypeSpecClient.cs @@ -3,6 +3,8 @@ #nullable disable using System; +using System.Threading; +using System.Threading.Tasks; using UnbrandedTypeSpec.Models; namespace UnbrandedTypeSpec @@ -15,89 +17,435 @@ internal void CreateSayHiRequest(Uri unbrandedTypeSpecUrl, string headParameter, throw new NotImplementedException("Method not implemented."); } + /// Return hi. + /// + /// + /// + /// The cancellation token to use. + /// or is null. + public virtual void SayHi(string headParameter, string queryParameter, string optionalQuery, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(headParameter, nameof(headParameter)); + Argument.AssertNotNull(queryParameter, nameof(queryParameter)); + + } + + /// Return hi. + /// + /// + /// + /// The cancellation token to use. + /// or is null. + public virtual async void SayHiAsync(string headParameter, string queryParameter, string optionalQuery, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(headParameter, nameof(headParameter)); + Argument.AssertNotNull(queryParameter, nameof(queryParameter)); + + await Task.CompletedTask.ConfigureAwait(false); + } + internal void CreateHelloAgainRequest(Uri unbrandedTypeSpecUrl, string p1, string contentType, string p2, RoundTripModel action, string accept) { throw new NotImplementedException("Method not implemented."); } + /// Return hi again. + /// + /// + /// + /// The cancellation token to use. + /// , or is null. + public virtual void HelloAgain(string p1, string p2, RoundTripModel action, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(p1, nameof(p1)); + Argument.AssertNotNull(p2, nameof(p2)); + Argument.AssertNotNull(action, nameof(action)); + + } + + /// Return hi again. + /// + /// + /// + /// The cancellation token to use. + /// , or is null. + public virtual async void HelloAgainAsync(string p1, string p2, RoundTripModel action, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(p1, nameof(p1)); + Argument.AssertNotNull(p2, nameof(p2)); + Argument.AssertNotNull(action, nameof(action)); + + await Task.CompletedTask.ConfigureAwait(false); + } + internal void CreateNoContentTypeRequest(Uri unbrandedTypeSpecUrl, string p1, string p2, RoundTripModel action, string accept, string contentType) { throw new NotImplementedException("Method not implemented."); } + /// Return hi again. + /// + /// + /// + /// The cancellation token to use. + /// , or is null. + public virtual void NoContentType(string p1, string p2, RoundTripModel action, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(p1, nameof(p1)); + Argument.AssertNotNull(p2, nameof(p2)); + Argument.AssertNotNull(action, nameof(action)); + + } + + /// Return hi again. + /// + /// + /// + /// The cancellation token to use. + /// , or is null. + public virtual async void NoContentTypeAsync(string p1, string p2, RoundTripModel action, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(p1, nameof(p1)); + Argument.AssertNotNull(p2, nameof(p2)); + Argument.AssertNotNull(action, nameof(action)); + + await Task.CompletedTask.ConfigureAwait(false); + } + internal void CreateHelloDemo2Request(Uri unbrandedTypeSpecUrl, string accept) { throw new NotImplementedException("Method not implemented."); } + /// Return hi in demo2. + /// The cancellation token to use. + public virtual void HelloDemo2(CancellationToken cancellationToken = default) + { + } + + /// Return hi in demo2. + /// The cancellation token to use. + public virtual async void HelloDemo2Async(CancellationToken cancellationToken = default) + { + await Task.CompletedTask.ConfigureAwait(false); + } + internal void CreateCreateLiteralRequest(Uri unbrandedTypeSpecUrl, Thing body, string accept, string contentType) { throw new NotImplementedException("Method not implemented."); } + /// Create with literal value. + /// + /// The cancellation token to use. + /// is null. + public virtual void CreateLiteral(Thing body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(body, nameof(body)); + + } + + /// Create with literal value. + /// + /// The cancellation token to use. + /// is null. + public virtual async void CreateLiteralAsync(Thing body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(body, nameof(body)); + + await Task.CompletedTask.ConfigureAwait(false); + } + internal void CreateHelloLiteralRequest(Uri unbrandedTypeSpecUrl, string p1, int p2, bool p3, string accept) { throw new NotImplementedException("Method not implemented."); } + /// Send literal parameters. + /// The cancellation token to use. + public virtual void HelloLiteral(CancellationToken cancellationToken = default) + { + } + + /// Send literal parameters. + /// The cancellation token to use. + public virtual async void HelloLiteralAsync(CancellationToken cancellationToken = default) + { + await Task.CompletedTask.ConfigureAwait(false); + } + internal void CreateTopActionRequest(Uri unbrandedTypeSpecUrl, DateTimeOffset action, string accept) { throw new NotImplementedException("Method not implemented."); } + /// top level method. + /// + /// The cancellation token to use. + /// is null. + public virtual void TopAction(DateTimeOffset action, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(action, nameof(action)); + + } + + /// top level method. + /// + /// The cancellation token to use. + /// is null. + public virtual async void TopActionAsync(DateTimeOffset action, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(action, nameof(action)); + + await Task.CompletedTask.ConfigureAwait(false); + } + internal void CreateTopAction2Request(Uri unbrandedTypeSpecUrl, string accept) { throw new NotImplementedException("Method not implemented."); } + /// top level method2. + /// The cancellation token to use. + public virtual void TopAction2(CancellationToken cancellationToken = default) + { + } + + /// top level method2. + /// The cancellation token to use. + public virtual async void TopAction2Async(CancellationToken cancellationToken = default) + { + await Task.CompletedTask.ConfigureAwait(false); + } + internal void CreatePatchActionRequest(Uri unbrandedTypeSpecUrl, Thing body, string accept, string contentType) { throw new NotImplementedException("Method not implemented."); } + /// top level patch. + /// + /// The cancellation token to use. + /// is null. + public virtual void PatchAction(Thing body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(body, nameof(body)); + + } + + /// top level patch. + /// + /// The cancellation token to use. + /// is null. + public virtual async void PatchActionAsync(Thing body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(body, nameof(body)); + + await Task.CompletedTask.ConfigureAwait(false); + } + internal void CreateAnonymousBodyRequest(Uri unbrandedTypeSpecUrl, Thing Thing, string accept, string contentType) { throw new NotImplementedException("Method not implemented."); } + /// body parameter without body decorator. + /// A model with a few properties of literal types. + /// The cancellation token to use. + /// is null. + public virtual void AnonymousBody(Thing Thing, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(Thing, nameof(Thing)); + + } + + /// body parameter without body decorator. + /// A model with a few properties of literal types. + /// The cancellation token to use. + /// is null. + public virtual async void AnonymousBodyAsync(Thing Thing, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(Thing, nameof(Thing)); + + await Task.CompletedTask.ConfigureAwait(false); + } + internal void CreateFriendlyModelRequest(Uri unbrandedTypeSpecUrl, Friend Friend, string accept, string contentType) { throw new NotImplementedException("Method not implemented."); } + /// Model can have its friendly name. + /// this is not a friendly model but with a friendly name. + /// The cancellation token to use. + /// is null. + public virtual void FriendlyModel(Friend Friend, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(Friend, nameof(Friend)); + + } + + /// Model can have its friendly name. + /// this is not a friendly model but with a friendly name. + /// The cancellation token to use. + /// is null. + public virtual async void FriendlyModelAsync(Friend Friend, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(Friend, nameof(Friend)); + + await Task.CompletedTask.ConfigureAwait(false); + } + internal void CreateAddTimeHeaderRequest(Uri unbrandedTypeSpecUrl, DateTimeOffset repeatabilityFirstSent, string accept) { throw new NotImplementedException("Method not implemented."); } + /// addTimeHeader. + /// + /// The cancellation token to use. + public virtual void AddTimeHeader(DateTimeOffset repeatabilityFirstSent, CancellationToken cancellationToken = default) + { + } + + /// addTimeHeader. + /// + /// The cancellation token to use. + public virtual async void AddTimeHeaderAsync(DateTimeOffset repeatabilityFirstSent, CancellationToken cancellationToken = default) + { + await Task.CompletedTask.ConfigureAwait(false); + } + internal void CreateProjectedNameModelRequest(Uri unbrandedTypeSpecUrl, ProjectedModel ProjectedModel, string accept, string contentType) { throw new NotImplementedException("Method not implemented."); } + /// Model can have its projected name. + /// this is a model with a projected name. + /// The cancellation token to use. + /// is null. + public virtual void ProjectedNameModel(ProjectedModel ProjectedModel, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(ProjectedModel, nameof(ProjectedModel)); + + } + + /// Model can have its projected name. + /// this is a model with a projected name. + /// The cancellation token to use. + /// is null. + public virtual async void ProjectedNameModelAsync(ProjectedModel ProjectedModel, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(ProjectedModel, nameof(ProjectedModel)); + + await Task.CompletedTask.ConfigureAwait(false); + } + internal void CreateReturnsAnonymousModelRequest(Uri unbrandedTypeSpecUrl, string accept) { throw new NotImplementedException("Method not implemented."); } + /// return anonymous model. + /// The cancellation token to use. + public virtual void ReturnsAnonymousModel(CancellationToken cancellationToken = default) + { + } + + /// return anonymous model. + /// The cancellation token to use. + public virtual async void ReturnsAnonymousModelAsync(CancellationToken cancellationToken = default) + { + await Task.CompletedTask.ConfigureAwait(false); + } + internal void CreateGetUnknownValueRequest(Uri unbrandedTypeSpecUrl, string accept) { throw new NotImplementedException("Method not implemented."); } + /// get extensible enum. + /// The cancellation token to use. + public virtual void GetUnknownValue(CancellationToken cancellationToken = default) + { + } + + /// get extensible enum. + /// The cancellation token to use. + public virtual async void GetUnknownValueAsync(CancellationToken cancellationToken = default) + { + await Task.CompletedTask.ConfigureAwait(false); + } + internal void CreateInternalProtocolRequest(Uri unbrandedTypeSpecUrl, Thing body, string accept, string contentType) { throw new NotImplementedException("Method not implemented."); } + /// When set protocol false and convenient true, then the protocol method should be internal. + /// + /// The cancellation token to use. + /// is null. + public virtual void InternalProtocol(Thing body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(body, nameof(body)); + + } + + /// When set protocol false and convenient true, then the protocol method should be internal. + /// + /// The cancellation token to use. + /// is null. + public virtual async void InternalProtocolAsync(Thing body, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(body, nameof(body)); + + await Task.CompletedTask.ConfigureAwait(false); + } + internal void CreateStillConvenientRequest(Uri unbrandedTypeSpecUrl, string accept) { throw new NotImplementedException("Method not implemented."); } + /// When set protocol false and convenient true, the convenient method should be generated even it has the same signature as protocol one. + /// The cancellation token to use. + public virtual void StillConvenient(CancellationToken cancellationToken = default) + { + } + + /// When set protocol false and convenient true, the convenient method should be generated even it has the same signature as protocol one. + /// The cancellation token to use. + public virtual async void StillConvenientAsync(CancellationToken cancellationToken = default) + { + await Task.CompletedTask.ConfigureAwait(false); + } + internal void CreateHeadAsBooleanRequest(Uri unbrandedTypeSpecUrl, string id, string accept) { throw new NotImplementedException("Method not implemented."); } + + /// head as boolean. + /// + /// The cancellation token to use. + /// is null. + public virtual void HeadAsBoolean(string id, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(id, nameof(id)); + + } + + /// head as boolean. + /// + /// The cancellation token to use. + /// is null. + public virtual async void HeadAsBooleanAsync(string id, CancellationToken cancellationToken = default) + { + Argument.AssertNotNull(id, nameof(id)); + + await Task.CompletedTask.ConfigureAwait(false); + } } }