From 8173af0731c72e8d2725a107892bfe1ba09ad72a Mon Sep 17 00:00:00 2001 From: Timothy Makkison Date: Thu, 16 Nov 2023 18:35:36 +0000 Subject: [PATCH] feat: add `private static` type arrays for `typeParameter` --- .../InterfaceStubGenerator.cs | 111 ++++++++++-- Refit.Tests/InterfaceStubGenerator.cs | 162 ++++++++++++------ 2 files changed, 202 insertions(+), 71 deletions(-) diff --git a/InterfaceStubGenerator.Shared/InterfaceStubGenerator.cs b/InterfaceStubGenerator.Shared/InterfaceStubGenerator.cs index ee9a0c356..6fb96a739 100644 --- a/InterfaceStubGenerator.Shared/InterfaceStubGenerator.cs +++ b/InterfaceStubGenerator.Shared/InterfaceStubGenerator.cs @@ -23,6 +23,8 @@ public class InterfaceStubGeneratorV2 : IIncrementalGenerator public class InterfaceStubGenerator : ISourceGenerator #endif { + private const string TypeParameterVariableName = "_typeParameters"; + #pragma warning disable RS2008 // Enable analyzer release tracking static readonly DiagnosticDescriptor InvalidRefitMember = new( @@ -357,7 +359,7 @@ partial class {ns}{classDeclaration} Client = client; this.requestBuilder = requestBuilder; }} - + " ); // Get any other methods on the refit interfaces. We'll need to generate something for them and warn @@ -396,15 +398,17 @@ partial class {ns}{classDeclaration} .Cast() .ToList(); + var memberNames = new HashSet(interfaceSymbol.GetMembers().Select(x => x.Name)); + // Handle Refit Methods foreach (var method in refitMethods) { - ProcessRefitMethod(source, method, true); + ProcessRefitMethod(source, method, true, memberNames); } foreach (var method in refitMethods.Concat(derivedRefitMethods)) { - ProcessRefitMethod(source, method, false); + ProcessRefitMethod(source, method, false, memberNames); } // Handle non-refit Methods that aren't static or properties or have a method body @@ -445,8 +449,20 @@ partial class {ns}{classDeclaration} /// /// /// True if directly from the type we're generating for, false for methods found on base interfaces - void ProcessRefitMethod(StringBuilder source, IMethodSymbol methodSymbol, bool isTopLevel) + /// Contains the unique member names in the interface scope. + void ProcessRefitMethod( + StringBuilder source, + IMethodSymbol methodSymbol, + bool isTopLevel, + HashSet memberNames + ) { + var parameterTypesExpression = GenerateTypeParameterExpression( + source, + methodSymbol, + memberNames + ); + var returnType = methodSymbol.ReturnType.ToDisplayString( SymbolDisplayFormat.FullyQualifiedFormat ); @@ -466,15 +482,6 @@ void ProcessRefitMethod(StringBuilder source, IMethodSymbol methodSymbol, bool i argList.Add($"@{param.MetadataName}"); } - // List of types. - var typeList = new List(); - foreach (var param in methodSymbol.Parameters) - { - typeList.Add( - $"typeof({param.Type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)})" - ); - } - // List of generic arguments var genericList = new List(); foreach (var typeParam in methodSymbol.TypeParameters) @@ -489,11 +496,6 @@ void ProcessRefitMethod(StringBuilder source, IMethodSymbol methodSymbol, bool i ? "global::System.Array.Empty()" : $"new object[] {{ {string.Join(", ", argList)} }}"; - var parameterTypesArrayString = - typeList.Count == 0 - ? "global::System.Array.Empty()" - : $"new global::System.Type[] {{ {string.Join(", ", typeList)} }}"; - var genericString = genericList.Count > 0 ? $", new global::System.Type[] {{ {string.Join(", ", genericList)} }}" @@ -502,7 +504,7 @@ void ProcessRefitMethod(StringBuilder source, IMethodSymbol methodSymbol, bool i source.Append( @$" var ______arguments = {argumentsArrayString}; - var ______func = requestBuilder.BuildRestResultFuncForMethod(""{methodSymbol.Name}"", {parameterTypesArrayString}{genericString} ); + var ______func = requestBuilder.BuildRestResultFuncForMethod(""{methodSymbol.Name}"", {parameterTypesExpression}{genericString} ); try {{ {@return}({returnType})______func(this.Client, ______arguments){configureAwait}; @@ -628,6 +630,63 @@ IMethodSymbol methodSymbol } } + static string GenerateTypeParameterExpression( + StringBuilder source, + IMethodSymbol methodSymbol, + HashSet memberNames + ) + { + // use Array.Empty if method has no parameters. + if (methodSymbol.Parameters.Length == 0) + return "global::System.Array.Empty()"; + + // if one of the parameters is/contains a type parameter then it cannot be cached as it will change type between calls. + if (methodSymbol.Parameters.Any(x => ContainsTypeParameter(x.Type))) + { + var typeEnumerable = methodSymbol.Parameters.Select( + param => + $"typeof({param.Type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)})" + ); + return $"new global::System.Type[] {{ {string.Join(", ", typeEnumerable)} }}"; + } + + // find a name and generate field declaration. + var typeParameterFieldName = UniqueName(TypeParameterVariableName, memberNames); + var types = string.Join( + ", ", + methodSymbol.Parameters.Select( + x => + $"typeof({x.Type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)})" + ) + ); + source.Append( + $$""" + + + private static readonly global::System.Type[] {{typeParameterFieldName}} = new global::System.Type[] {{{types}} }; + """ + ); + + return typeParameterFieldName; + + static bool ContainsTypeParameter(ITypeSymbol symbol) + { + if (symbol is ITypeParameterSymbol) + return true; + + if (symbol is not INamedTypeSymbol { TypeParameters.Length: > 0 } namedType) + return false; + + foreach (var typeArg in namedType.TypeArguments) + { + if (ContainsTypeParameter(typeArg)) + return true; + } + + return false; + } + } + void WriteMethodOpening( StringBuilder source, IMethodSymbol methodSymbol, @@ -680,6 +739,20 @@ void WriteMethodOpening( void WriteMethodClosing(StringBuilder source) => source.Append(@" }"); + static string UniqueName(string name, HashSet methodNames) + { + var candidateName = name; + var counter = 0; + while (methodNames.Contains(candidateName)) + { + candidateName = $"{name}{counter}"; + counter++; + } + + methodNames.Add(candidateName); + return candidateName; + } + bool IsRefitMethod(IMethodSymbol? methodSymbol, INamedTypeSymbol httpMethodAttibute) { return methodSymbol diff --git a/Refit.Tests/InterfaceStubGenerator.cs b/Refit.Tests/InterfaceStubGenerator.cs index b4d12d4e1..0e2895ede 100644 --- a/Refit.Tests/InterfaceStubGenerator.cs +++ b/Refit.Tests/InterfaceStubGenerator.cs @@ -178,8 +178,8 @@ internal static partial class Generated #pragma warning restore "; - var output2 = - @"#nullable disable + var output2 = """ +#nullable disable #pragma warning disable namespace Refit.Implementation { @@ -207,14 +207,16 @@ public RefitTestsIGitHubApi(global::System.Net.Http.HttpClient client, global::R Client = client; this.requestBuilder = requestBuilder; } - + + private static readonly global::System.Type[] _typeParameters = new global::System.Type[] {typeof(string) }; + /// public async global::System.Threading.Tasks.Task GetUser(string @userName) { var ______arguments = new object[] { @userName }; - var ______func = requestBuilder.BuildRestResultFuncForMethod(""GetUser"", new global::System.Type[] { typeof(string) } ); + var ______func = requestBuilder.BuildRestResultFuncForMethod("GetUser", _typeParameters ); try { return await ((global::System.Threading.Tasks.Task)______func(this.Client, ______arguments)).ConfigureAwait(false); @@ -225,11 +227,13 @@ public RefitTestsIGitHubApi(global::System.Net.Http.HttpClient client, global::R } } + private static readonly global::System.Type[] _typeParameters0 = new global::System.Type[] {typeof(string) }; + /// public global::System.IObservable GetUserObservable(string @userName) { var ______arguments = new object[] { @userName }; - var ______func = requestBuilder.BuildRestResultFuncForMethod(""GetUserObservable"", new global::System.Type[] { typeof(string) } ); + var ______func = requestBuilder.BuildRestResultFuncForMethod("GetUserObservable", _typeParameters0 ); try { return (global::System.IObservable)______func(this.Client, ______arguments); @@ -240,11 +244,13 @@ public RefitTestsIGitHubApi(global::System.Net.Http.HttpClient client, global::R } } + private static readonly global::System.Type[] _typeParameters1 = new global::System.Type[] {typeof(string) }; + /// public global::System.IObservable GetUserCamelCase(string @userName) { var ______arguments = new object[] { @userName }; - var ______func = requestBuilder.BuildRestResultFuncForMethod(""GetUserCamelCase"", new global::System.Type[] { typeof(string) } ); + var ______func = requestBuilder.BuildRestResultFuncForMethod("GetUserCamelCase", _typeParameters1 ); try { return (global::System.IObservable)______func(this.Client, ______arguments); @@ -255,11 +261,13 @@ public RefitTestsIGitHubApi(global::System.Net.Http.HttpClient client, global::R } } + private static readonly global::System.Type[] _typeParameters2 = new global::System.Type[] {typeof(string), typeof(global::System.Threading.CancellationToken) }; + /// public async global::System.Threading.Tasks.Task> GetOrgMembers(string @orgName, global::System.Threading.CancellationToken @cancellationToken) { var ______arguments = new object[] { @orgName, @cancellationToken }; - var ______func = requestBuilder.BuildRestResultFuncForMethod(""GetOrgMembers"", new global::System.Type[] { typeof(string), typeof(global::System.Threading.CancellationToken) } ); + var ______func = requestBuilder.BuildRestResultFuncForMethod("GetOrgMembers", _typeParameters2 ); try { return await ((global::System.Threading.Tasks.Task>)______func(this.Client, ______arguments)).ConfigureAwait(false); @@ -270,11 +278,13 @@ public RefitTestsIGitHubApi(global::System.Net.Http.HttpClient client, global::R } } + private static readonly global::System.Type[] _typeParameters3 = new global::System.Type[] {typeof(string) }; + /// public async global::System.Threading.Tasks.Task FindUsers(string @q) { var ______arguments = new object[] { @q }; - var ______func = requestBuilder.BuildRestResultFuncForMethod(""FindUsers"", new global::System.Type[] { typeof(string) } ); + var ______func = requestBuilder.BuildRestResultFuncForMethod("FindUsers", _typeParameters3 ); try { return await ((global::System.Threading.Tasks.Task)______func(this.Client, ______arguments)).ConfigureAwait(false); @@ -289,7 +299,7 @@ public RefitTestsIGitHubApi(global::System.Net.Http.HttpClient client, global::R public async global::System.Threading.Tasks.Task GetIndex() { var ______arguments = global::System.Array.Empty(); - var ______func = requestBuilder.BuildRestResultFuncForMethod(""GetIndex"", global::System.Array.Empty() ); + var ______func = requestBuilder.BuildRestResultFuncForMethod("GetIndex", global::System.Array.Empty() ); try { return await ((global::System.Threading.Tasks.Task)______func(this.Client, ______arguments)).ConfigureAwait(false); @@ -304,7 +314,7 @@ public RefitTestsIGitHubApi(global::System.Net.Http.HttpClient client, global::R public global::System.IObservable GetIndexObservable() { var ______arguments = global::System.Array.Empty(); - var ______func = requestBuilder.BuildRestResultFuncForMethod(""GetIndexObservable"", global::System.Array.Empty() ); + var ______func = requestBuilder.BuildRestResultFuncForMethod("GetIndexObservable", global::System.Array.Empty() ); try { return (global::System.IObservable)______func(this.Client, ______arguments); @@ -319,7 +329,7 @@ public RefitTestsIGitHubApi(global::System.Net.Http.HttpClient client, global::R public async global::System.Threading.Tasks.Task NothingToSeeHere() { var ______arguments = global::System.Array.Empty(); - var ______func = requestBuilder.BuildRestResultFuncForMethod(""NothingToSeeHere"", global::System.Array.Empty() ); + var ______func = requestBuilder.BuildRestResultFuncForMethod("NothingToSeeHere", global::System.Array.Empty() ); try { return await ((global::System.Threading.Tasks.Task)______func(this.Client, ______arguments)).ConfigureAwait(false); @@ -334,7 +344,7 @@ public RefitTestsIGitHubApi(global::System.Net.Http.HttpClient client, global::R public async global::System.Threading.Tasks.Task> NothingToSeeHereWithMetadata() { var ______arguments = global::System.Array.Empty(); - var ______func = requestBuilder.BuildRestResultFuncForMethod(""NothingToSeeHereWithMetadata"", global::System.Array.Empty() ); + var ______func = requestBuilder.BuildRestResultFuncForMethod("NothingToSeeHereWithMetadata", global::System.Array.Empty() ); try { return await ((global::System.Threading.Tasks.Task>)______func(this.Client, ______arguments)).ConfigureAwait(false); @@ -345,11 +355,13 @@ public RefitTestsIGitHubApi(global::System.Net.Http.HttpClient client, global::R } } + private static readonly global::System.Type[] _typeParameters4 = new global::System.Type[] {typeof(string) }; + /// public async global::System.Threading.Tasks.Task> GetUserWithMetadata(string @userName) { var ______arguments = new object[] { @userName }; - var ______func = requestBuilder.BuildRestResultFuncForMethod(""GetUserWithMetadata"", new global::System.Type[] { typeof(string) } ); + var ______func = requestBuilder.BuildRestResultFuncForMethod("GetUserWithMetadata", _typeParameters4 ); try { return await ((global::System.Threading.Tasks.Task>)______func(this.Client, ______arguments)).ConfigureAwait(false); @@ -360,11 +372,13 @@ public RefitTestsIGitHubApi(global::System.Net.Http.HttpClient client, global::R } } + private static readonly global::System.Type[] _typeParameters5 = new global::System.Type[] {typeof(string) }; + /// public global::System.IObservable> GetUserObservableWithMetadata(string @userName) { var ______arguments = new object[] { @userName }; - var ______func = requestBuilder.BuildRestResultFuncForMethod(""GetUserObservableWithMetadata"", new global::System.Type[] { typeof(string) } ); + var ______func = requestBuilder.BuildRestResultFuncForMethod("GetUserObservableWithMetadata", _typeParameters5 ); try { return (global::System.IObservable>)______func(this.Client, ______arguments); @@ -375,11 +389,13 @@ public RefitTestsIGitHubApi(global::System.Net.Http.HttpClient client, global::R } } + private static readonly global::System.Type[] _typeParameters6 = new global::System.Type[] {typeof(global::Refit.Tests.User) }; + /// public async global::System.Threading.Tasks.Task CreateUser(global::Refit.Tests.User @user) { var ______arguments = new object[] { @user }; - var ______func = requestBuilder.BuildRestResultFuncForMethod(""CreateUser"", new global::System.Type[] { typeof(global::Refit.Tests.User) } ); + var ______func = requestBuilder.BuildRestResultFuncForMethod("CreateUser", _typeParameters6 ); try { return await ((global::System.Threading.Tasks.Task)______func(this.Client, ______arguments)).ConfigureAwait(false); @@ -390,11 +406,13 @@ public RefitTestsIGitHubApi(global::System.Net.Http.HttpClient client, global::R } } + private static readonly global::System.Type[] _typeParameters7 = new global::System.Type[] {typeof(global::Refit.Tests.User) }; + /// public async global::System.Threading.Tasks.Task> CreateUserWithMetadata(global::Refit.Tests.User @user) { var ______arguments = new object[] { @user }; - var ______func = requestBuilder.BuildRestResultFuncForMethod(""CreateUserWithMetadata"", new global::System.Type[] { typeof(global::Refit.Tests.User) } ); + var ______func = requestBuilder.BuildRestResultFuncForMethod("CreateUserWithMetadata", _typeParameters7 ); try { return await ((global::System.Threading.Tasks.Task>)______func(this.Client, ______arguments)).ConfigureAwait(false); @@ -405,11 +423,13 @@ public RefitTestsIGitHubApi(global::System.Net.Http.HttpClient client, global::R } } + private static readonly global::System.Type[] _typeParameters8 = new global::System.Type[] {typeof(string) }; + /// async global::System.Threading.Tasks.Task global::Refit.Tests.IGitHubApi.GetUser(string @userName) { var ______arguments = new object[] { @userName }; - var ______func = requestBuilder.BuildRestResultFuncForMethod(""GetUser"", new global::System.Type[] { typeof(string) } ); + var ______func = requestBuilder.BuildRestResultFuncForMethod("GetUser", _typeParameters8 ); try { return await ((global::System.Threading.Tasks.Task)______func(this.Client, ______arguments)).ConfigureAwait(false); @@ -420,11 +440,13 @@ public RefitTestsIGitHubApi(global::System.Net.Http.HttpClient client, global::R } } + private static readonly global::System.Type[] _typeParameters9 = new global::System.Type[] {typeof(string) }; + /// global::System.IObservable global::Refit.Tests.IGitHubApi.GetUserObservable(string @userName) { var ______arguments = new object[] { @userName }; - var ______func = requestBuilder.BuildRestResultFuncForMethod(""GetUserObservable"", new global::System.Type[] { typeof(string) } ); + var ______func = requestBuilder.BuildRestResultFuncForMethod("GetUserObservable", _typeParameters9 ); try { return (global::System.IObservable)______func(this.Client, ______arguments); @@ -435,11 +457,13 @@ public RefitTestsIGitHubApi(global::System.Net.Http.HttpClient client, global::R } } + private static readonly global::System.Type[] _typeParameters10 = new global::System.Type[] {typeof(string) }; + /// global::System.IObservable global::Refit.Tests.IGitHubApi.GetUserCamelCase(string @userName) { var ______arguments = new object[] { @userName }; - var ______func = requestBuilder.BuildRestResultFuncForMethod(""GetUserCamelCase"", new global::System.Type[] { typeof(string) } ); + var ______func = requestBuilder.BuildRestResultFuncForMethod("GetUserCamelCase", _typeParameters10 ); try { return (global::System.IObservable)______func(this.Client, ______arguments); @@ -450,11 +474,13 @@ public RefitTestsIGitHubApi(global::System.Net.Http.HttpClient client, global::R } } + private static readonly global::System.Type[] _typeParameters11 = new global::System.Type[] {typeof(string), typeof(global::System.Threading.CancellationToken) }; + /// async global::System.Threading.Tasks.Task> global::Refit.Tests.IGitHubApi.GetOrgMembers(string @orgName, global::System.Threading.CancellationToken @cancellationToken) { var ______arguments = new object[] { @orgName, @cancellationToken }; - var ______func = requestBuilder.BuildRestResultFuncForMethod(""GetOrgMembers"", new global::System.Type[] { typeof(string), typeof(global::System.Threading.CancellationToken) } ); + var ______func = requestBuilder.BuildRestResultFuncForMethod("GetOrgMembers", _typeParameters11 ); try { return await ((global::System.Threading.Tasks.Task>)______func(this.Client, ______arguments)).ConfigureAwait(false); @@ -465,11 +491,13 @@ public RefitTestsIGitHubApi(global::System.Net.Http.HttpClient client, global::R } } + private static readonly global::System.Type[] _typeParameters12 = new global::System.Type[] {typeof(string) }; + /// async global::System.Threading.Tasks.Task global::Refit.Tests.IGitHubApi.FindUsers(string @q) { var ______arguments = new object[] { @q }; - var ______func = requestBuilder.BuildRestResultFuncForMethod(""FindUsers"", new global::System.Type[] { typeof(string) } ); + var ______func = requestBuilder.BuildRestResultFuncForMethod("FindUsers", _typeParameters12 ); try { return await ((global::System.Threading.Tasks.Task)______func(this.Client, ______arguments)).ConfigureAwait(false); @@ -484,7 +512,7 @@ public RefitTestsIGitHubApi(global::System.Net.Http.HttpClient client, global::R async global::System.Threading.Tasks.Task global::Refit.Tests.IGitHubApi.GetIndex() { var ______arguments = global::System.Array.Empty(); - var ______func = requestBuilder.BuildRestResultFuncForMethod(""GetIndex"", global::System.Array.Empty() ); + var ______func = requestBuilder.BuildRestResultFuncForMethod("GetIndex", global::System.Array.Empty() ); try { return await ((global::System.Threading.Tasks.Task)______func(this.Client, ______arguments)).ConfigureAwait(false); @@ -499,7 +527,7 @@ public RefitTestsIGitHubApi(global::System.Net.Http.HttpClient client, global::R global::System.IObservable global::Refit.Tests.IGitHubApi.GetIndexObservable() { var ______arguments = global::System.Array.Empty(); - var ______func = requestBuilder.BuildRestResultFuncForMethod(""GetIndexObservable"", global::System.Array.Empty() ); + var ______func = requestBuilder.BuildRestResultFuncForMethod("GetIndexObservable", global::System.Array.Empty() ); try { return (global::System.IObservable)______func(this.Client, ______arguments); @@ -514,7 +542,7 @@ public RefitTestsIGitHubApi(global::System.Net.Http.HttpClient client, global::R async global::System.Threading.Tasks.Task global::Refit.Tests.IGitHubApi.NothingToSeeHere() { var ______arguments = global::System.Array.Empty(); - var ______func = requestBuilder.BuildRestResultFuncForMethod(""NothingToSeeHere"", global::System.Array.Empty() ); + var ______func = requestBuilder.BuildRestResultFuncForMethod("NothingToSeeHere", global::System.Array.Empty() ); try { return await ((global::System.Threading.Tasks.Task)______func(this.Client, ______arguments)).ConfigureAwait(false); @@ -529,7 +557,7 @@ public RefitTestsIGitHubApi(global::System.Net.Http.HttpClient client, global::R async global::System.Threading.Tasks.Task> global::Refit.Tests.IGitHubApi.NothingToSeeHereWithMetadata() { var ______arguments = global::System.Array.Empty(); - var ______func = requestBuilder.BuildRestResultFuncForMethod(""NothingToSeeHereWithMetadata"", global::System.Array.Empty() ); + var ______func = requestBuilder.BuildRestResultFuncForMethod("NothingToSeeHereWithMetadata", global::System.Array.Empty() ); try { return await ((global::System.Threading.Tasks.Task>)______func(this.Client, ______arguments)).ConfigureAwait(false); @@ -540,11 +568,13 @@ public RefitTestsIGitHubApi(global::System.Net.Http.HttpClient client, global::R } } + private static readonly global::System.Type[] _typeParameters13 = new global::System.Type[] {typeof(string) }; + /// async global::System.Threading.Tasks.Task> global::Refit.Tests.IGitHubApi.GetUserWithMetadata(string @userName) { var ______arguments = new object[] { @userName }; - var ______func = requestBuilder.BuildRestResultFuncForMethod(""GetUserWithMetadata"", new global::System.Type[] { typeof(string) } ); + var ______func = requestBuilder.BuildRestResultFuncForMethod("GetUserWithMetadata", _typeParameters13 ); try { return await ((global::System.Threading.Tasks.Task>)______func(this.Client, ______arguments)).ConfigureAwait(false); @@ -555,11 +585,13 @@ public RefitTestsIGitHubApi(global::System.Net.Http.HttpClient client, global::R } } + private static readonly global::System.Type[] _typeParameters14 = new global::System.Type[] {typeof(string) }; + /// global::System.IObservable> global::Refit.Tests.IGitHubApi.GetUserObservableWithMetadata(string @userName) { var ______arguments = new object[] { @userName }; - var ______func = requestBuilder.BuildRestResultFuncForMethod(""GetUserObservableWithMetadata"", new global::System.Type[] { typeof(string) } ); + var ______func = requestBuilder.BuildRestResultFuncForMethod("GetUserObservableWithMetadata", _typeParameters14 ); try { return (global::System.IObservable>)______func(this.Client, ______arguments); @@ -570,11 +602,13 @@ public RefitTestsIGitHubApi(global::System.Net.Http.HttpClient client, global::R } } + private static readonly global::System.Type[] _typeParameters15 = new global::System.Type[] {typeof(global::Refit.Tests.User) }; + /// async global::System.Threading.Tasks.Task global::Refit.Tests.IGitHubApi.CreateUser(global::Refit.Tests.User @user) { var ______arguments = new object[] { @user }; - var ______func = requestBuilder.BuildRestResultFuncForMethod(""CreateUser"", new global::System.Type[] { typeof(global::Refit.Tests.User) } ); + var ______func = requestBuilder.BuildRestResultFuncForMethod("CreateUser", _typeParameters15 ); try { return await ((global::System.Threading.Tasks.Task)______func(this.Client, ______arguments)).ConfigureAwait(false); @@ -585,11 +619,13 @@ public RefitTestsIGitHubApi(global::System.Net.Http.HttpClient client, global::R } } + private static readonly global::System.Type[] _typeParameters16 = new global::System.Type[] {typeof(global::Refit.Tests.User) }; + /// async global::System.Threading.Tasks.Task> global::Refit.Tests.IGitHubApi.CreateUserWithMetadata(global::Refit.Tests.User @user) { var ______arguments = new object[] { @user }; - var ______func = requestBuilder.BuildRestResultFuncForMethod(""CreateUserWithMetadata"", new global::System.Type[] { typeof(global::Refit.Tests.User) } ); + var ______func = requestBuilder.BuildRestResultFuncForMethod("CreateUserWithMetadata", _typeParameters16 ); try { return await ((global::System.Threading.Tasks.Task>)______func(this.Client, ______arguments)).ConfigureAwait(false); @@ -604,7 +640,8 @@ public RefitTestsIGitHubApi(global::System.Net.Http.HttpClient client, global::R } #pragma warning restore -"; + +"""; var output3 = @"#nullable disable #pragma warning disable @@ -634,7 +671,7 @@ public RefitTestsIGitHubApiDisposable(global::System.Net.Http.HttpClient client, Client = client; this.requestBuilder = requestBuilder; } - + /// @@ -678,8 +715,8 @@ public RefitTestsIGitHubApiDisposable(global::System.Net.Http.HttpClient client, #pragma warning restore "; - var output4 = - @"#nullable disable + var output4 = """ +#nullable disable #pragma warning disable namespace Refit.Implementation { @@ -707,14 +744,16 @@ public RefitTestsTestNestedINestedGitHubApi(global::System.Net.Http.HttpClient c Client = client; this.requestBuilder = requestBuilder; } - + + private static readonly global::System.Type[] _typeParameters = new global::System.Type[] {typeof(string) }; + /// public async global::System.Threading.Tasks.Task GetUser(string @userName) { var ______arguments = new object[] { @userName }; - var ______func = requestBuilder.BuildRestResultFuncForMethod(""GetUser"", new global::System.Type[] { typeof(string) } ); + var ______func = requestBuilder.BuildRestResultFuncForMethod("GetUser", _typeParameters ); try { return await ((global::System.Threading.Tasks.Task)______func(this.Client, ______arguments)).ConfigureAwait(false); @@ -725,11 +764,13 @@ public RefitTestsTestNestedINestedGitHubApi(global::System.Net.Http.HttpClient c } } + private static readonly global::System.Type[] _typeParameters0 = new global::System.Type[] {typeof(string) }; + /// public global::System.IObservable GetUserObservable(string @userName) { var ______arguments = new object[] { @userName }; - var ______func = requestBuilder.BuildRestResultFuncForMethod(""GetUserObservable"", new global::System.Type[] { typeof(string) } ); + var ______func = requestBuilder.BuildRestResultFuncForMethod("GetUserObservable", _typeParameters0 ); try { return (global::System.IObservable)______func(this.Client, ______arguments); @@ -740,11 +781,13 @@ public RefitTestsTestNestedINestedGitHubApi(global::System.Net.Http.HttpClient c } } + private static readonly global::System.Type[] _typeParameters1 = new global::System.Type[] {typeof(string) }; + /// public global::System.IObservable GetUserCamelCase(string @userName) { var ______arguments = new object[] { @userName }; - var ______func = requestBuilder.BuildRestResultFuncForMethod(""GetUserCamelCase"", new global::System.Type[] { typeof(string) } ); + var ______func = requestBuilder.BuildRestResultFuncForMethod("GetUserCamelCase", _typeParameters1 ); try { return (global::System.IObservable)______func(this.Client, ______arguments); @@ -755,11 +798,13 @@ public RefitTestsTestNestedINestedGitHubApi(global::System.Net.Http.HttpClient c } } + private static readonly global::System.Type[] _typeParameters2 = new global::System.Type[] {typeof(string) }; + /// public async global::System.Threading.Tasks.Task> GetOrgMembers(string @orgName) { var ______arguments = new object[] { @orgName }; - var ______func = requestBuilder.BuildRestResultFuncForMethod(""GetOrgMembers"", new global::System.Type[] { typeof(string) } ); + var ______func = requestBuilder.BuildRestResultFuncForMethod("GetOrgMembers", _typeParameters2 ); try { return await ((global::System.Threading.Tasks.Task>)______func(this.Client, ______arguments)).ConfigureAwait(false); @@ -770,11 +815,13 @@ public RefitTestsTestNestedINestedGitHubApi(global::System.Net.Http.HttpClient c } } + private static readonly global::System.Type[] _typeParameters3 = new global::System.Type[] {typeof(string) }; + /// public async global::System.Threading.Tasks.Task FindUsers(string @q) { var ______arguments = new object[] { @q }; - var ______func = requestBuilder.BuildRestResultFuncForMethod(""FindUsers"", new global::System.Type[] { typeof(string) } ); + var ______func = requestBuilder.BuildRestResultFuncForMethod("FindUsers", _typeParameters3 ); try { return await ((global::System.Threading.Tasks.Task)______func(this.Client, ______arguments)).ConfigureAwait(false); @@ -789,7 +836,7 @@ public RefitTestsTestNestedINestedGitHubApi(global::System.Net.Http.HttpClient c public async global::System.Threading.Tasks.Task GetIndex() { var ______arguments = global::System.Array.Empty(); - var ______func = requestBuilder.BuildRestResultFuncForMethod(""GetIndex"", global::System.Array.Empty() ); + var ______func = requestBuilder.BuildRestResultFuncForMethod("GetIndex", global::System.Array.Empty() ); try { return await ((global::System.Threading.Tasks.Task)______func(this.Client, ______arguments)).ConfigureAwait(false); @@ -804,7 +851,7 @@ public RefitTestsTestNestedINestedGitHubApi(global::System.Net.Http.HttpClient c public global::System.IObservable GetIndexObservable() { var ______arguments = global::System.Array.Empty(); - var ______func = requestBuilder.BuildRestResultFuncForMethod(""GetIndexObservable"", global::System.Array.Empty() ); + var ______func = requestBuilder.BuildRestResultFuncForMethod("GetIndexObservable", global::System.Array.Empty() ); try { return (global::System.IObservable)______func(this.Client, ______arguments); @@ -819,7 +866,7 @@ public RefitTestsTestNestedINestedGitHubApi(global::System.Net.Http.HttpClient c public async global::System.Threading.Tasks.Task NothingToSeeHere() { var ______arguments = global::System.Array.Empty(); - var ______func = requestBuilder.BuildRestResultFuncForMethod(""NothingToSeeHere"", global::System.Array.Empty() ); + var ______func = requestBuilder.BuildRestResultFuncForMethod("NothingToSeeHere", global::System.Array.Empty() ); try { await ((global::System.Threading.Tasks.Task)______func(this.Client, ______arguments)).ConfigureAwait(false); @@ -830,11 +877,13 @@ public RefitTestsTestNestedINestedGitHubApi(global::System.Net.Http.HttpClient c } } + private static readonly global::System.Type[] _typeParameters4 = new global::System.Type[] {typeof(string) }; + /// async global::System.Threading.Tasks.Task global::Refit.Tests.TestNested.INestedGitHubApi.GetUser(string @userName) { var ______arguments = new object[] { @userName }; - var ______func = requestBuilder.BuildRestResultFuncForMethod(""GetUser"", new global::System.Type[] { typeof(string) } ); + var ______func = requestBuilder.BuildRestResultFuncForMethod("GetUser", _typeParameters4 ); try { return await ((global::System.Threading.Tasks.Task)______func(this.Client, ______arguments)).ConfigureAwait(false); @@ -845,11 +894,13 @@ public RefitTestsTestNestedINestedGitHubApi(global::System.Net.Http.HttpClient c } } + private static readonly global::System.Type[] _typeParameters5 = new global::System.Type[] {typeof(string) }; + /// global::System.IObservable global::Refit.Tests.TestNested.INestedGitHubApi.GetUserObservable(string @userName) { var ______arguments = new object[] { @userName }; - var ______func = requestBuilder.BuildRestResultFuncForMethod(""GetUserObservable"", new global::System.Type[] { typeof(string) } ); + var ______func = requestBuilder.BuildRestResultFuncForMethod("GetUserObservable", _typeParameters5 ); try { return (global::System.IObservable)______func(this.Client, ______arguments); @@ -860,11 +911,13 @@ public RefitTestsTestNestedINestedGitHubApi(global::System.Net.Http.HttpClient c } } + private static readonly global::System.Type[] _typeParameters6 = new global::System.Type[] {typeof(string) }; + /// global::System.IObservable global::Refit.Tests.TestNested.INestedGitHubApi.GetUserCamelCase(string @userName) { var ______arguments = new object[] { @userName }; - var ______func = requestBuilder.BuildRestResultFuncForMethod(""GetUserCamelCase"", new global::System.Type[] { typeof(string) } ); + var ______func = requestBuilder.BuildRestResultFuncForMethod("GetUserCamelCase", _typeParameters6 ); try { return (global::System.IObservable)______func(this.Client, ______arguments); @@ -875,11 +928,13 @@ public RefitTestsTestNestedINestedGitHubApi(global::System.Net.Http.HttpClient c } } + private static readonly global::System.Type[] _typeParameters7 = new global::System.Type[] {typeof(string) }; + /// async global::System.Threading.Tasks.Task> global::Refit.Tests.TestNested.INestedGitHubApi.GetOrgMembers(string @orgName) { var ______arguments = new object[] { @orgName }; - var ______func = requestBuilder.BuildRestResultFuncForMethod(""GetOrgMembers"", new global::System.Type[] { typeof(string) } ); + var ______func = requestBuilder.BuildRestResultFuncForMethod("GetOrgMembers", _typeParameters7 ); try { return await ((global::System.Threading.Tasks.Task>)______func(this.Client, ______arguments)).ConfigureAwait(false); @@ -890,11 +945,13 @@ public RefitTestsTestNestedINestedGitHubApi(global::System.Net.Http.HttpClient c } } + private static readonly global::System.Type[] _typeParameters8 = new global::System.Type[] {typeof(string) }; + /// async global::System.Threading.Tasks.Task global::Refit.Tests.TestNested.INestedGitHubApi.FindUsers(string @q) { var ______arguments = new object[] { @q }; - var ______func = requestBuilder.BuildRestResultFuncForMethod(""FindUsers"", new global::System.Type[] { typeof(string) } ); + var ______func = requestBuilder.BuildRestResultFuncForMethod("FindUsers", _typeParameters8 ); try { return await ((global::System.Threading.Tasks.Task)______func(this.Client, ______arguments)).ConfigureAwait(false); @@ -909,7 +966,7 @@ public RefitTestsTestNestedINestedGitHubApi(global::System.Net.Http.HttpClient c async global::System.Threading.Tasks.Task global::Refit.Tests.TestNested.INestedGitHubApi.GetIndex() { var ______arguments = global::System.Array.Empty(); - var ______func = requestBuilder.BuildRestResultFuncForMethod(""GetIndex"", global::System.Array.Empty() ); + var ______func = requestBuilder.BuildRestResultFuncForMethod("GetIndex", global::System.Array.Empty() ); try { return await ((global::System.Threading.Tasks.Task)______func(this.Client, ______arguments)).ConfigureAwait(false); @@ -924,7 +981,7 @@ public RefitTestsTestNestedINestedGitHubApi(global::System.Net.Http.HttpClient c global::System.IObservable global::Refit.Tests.TestNested.INestedGitHubApi.GetIndexObservable() { var ______arguments = global::System.Array.Empty(); - var ______func = requestBuilder.BuildRestResultFuncForMethod(""GetIndexObservable"", global::System.Array.Empty() ); + var ______func = requestBuilder.BuildRestResultFuncForMethod("GetIndexObservable", global::System.Array.Empty() ); try { return (global::System.IObservable)______func(this.Client, ______arguments); @@ -939,7 +996,7 @@ public RefitTestsTestNestedINestedGitHubApi(global::System.Net.Http.HttpClient c async global::System.Threading.Tasks.Task global::Refit.Tests.TestNested.INestedGitHubApi.NothingToSeeHere() { var ______arguments = global::System.Array.Empty(); - var ______func = requestBuilder.BuildRestResultFuncForMethod(""NothingToSeeHere"", global::System.Array.Empty() ); + var ______func = requestBuilder.BuildRestResultFuncForMethod("NothingToSeeHere", global::System.Array.Empty() ); try { await ((global::System.Threading.Tasks.Task)______func(this.Client, ______arguments)).ConfigureAwait(false); @@ -954,7 +1011,8 @@ public RefitTestsTestNestedINestedGitHubApi(global::System.Net.Http.HttpClient c } #pragma warning restore -"; + +"""; await new VerifyCS.Test { @@ -1067,7 +1125,7 @@ public IServiceWithoutNamespace(global::System.Net.Http.HttpClient client, globa Client = client; this.requestBuilder = requestBuilder; } - + ///