From feaa321a16753ef91f9fe22c3b3f7781ad215d1d Mon Sep 17 00:00:00 2001 From: Jan Trejbal Date: Mon, 17 Aug 2020 16:03:36 +0200 Subject: [PATCH 1/3] Disposable method for disposable interface --- .../InterfaceStubGenerator.cs | 19 ++++++-- Refit.Tests/GitHubApi.cs | 6 +++ Refit.Tests/InterfaceStubGenerator.cs | 23 ++++++++- Refit.Tests/RefitStubs.Net46.cs | 48 +++++++++++++++++++ Refit.Tests/RefitStubs.NetCore2.cs | 48 +++++++++++++++++++ Refit.Tests/RefitStubs.NetCore3.cs | 48 +++++++++++++++++++ 6 files changed, 187 insertions(+), 5 deletions(-) diff --git a/InterfaceStubGenerator.Core/InterfaceStubGenerator.cs b/InterfaceStubGenerator.Core/InterfaceStubGenerator.cs index 84dcf464e..cdcf2aa1a 100644 --- a/InterfaceStubGenerator.Core/InterfaceStubGenerator.cs +++ b/InterfaceStubGenerator.Core/InterfaceStubGenerator.cs @@ -13,7 +13,7 @@ namespace Refit.Generator { - // * Search for all Interfaces, find the method definitions + // * Search for all Interfaces, find the method definitions // and make sure there's at least one Refit attribute on one // * Generate the data we need for the template based on interface method // defn's @@ -70,7 +70,7 @@ public List FindInterfacesToGenerate(SyntaxTree tree { var nodes = tree.GetRoot().DescendantNodes().ToList(); - // Make sure this file imports Refit. If not, we're not going to + // Make sure this file imports Refit. If not, we're not going to // find any Refit interfaces // NB: This falls down in the tests unless we add an explicit "using Refit;", // but we can rely on this being there in any other file @@ -170,6 +170,19 @@ public ClassTemplateInfo GenerateClassInfoForInterface(InterfaceDeclarationSynta return mti; }) .ToList(); + + if (ret.BaseClasses?.Any(x => x.Name == nameof(IDisposable)) == true) + { + ret.MethodList.Add(new MethodTemplateInfo + { + Name = nameof(IDisposable.Dispose), + ReturnTypeInfo = new TypeInfo {Name = "void"}, + ArgumentListInfo = new List(), + IsRefitMethod = false, + InterfaceName = nameof(IDisposable), + }); + } + return ret; } @@ -345,7 +358,7 @@ public void GenerateWarnings(List interfacesToGenera public bool HasRefitHttpMethodAttribute(MethodDeclarationSyntax method) { - // We could also verify that the single argument is a string, + // We could also verify that the single argument is a string, // but what if somebody is dumb and uses a constant? // Could be turtles all the way down. return method.AttributeLists.SelectMany(a => a.Attributes) diff --git a/Refit.Tests/GitHubApi.cs b/Refit.Tests/GitHubApi.cs index fd5c02e20..0ec46e327 100644 --- a/Refit.Tests/GitHubApi.cs +++ b/Refit.Tests/GitHubApi.cs @@ -93,6 +93,12 @@ public interface IGitHubApi Task> CreateUserWithMetadata(User user); } + public interface IGitHubApiDisposable : IDisposable + { + [Get("whatever")] + Task RefitMethod(); + } + public class TestNested { [Headers("User-Agent: Refit Integration Tests")] diff --git a/Refit.Tests/InterfaceStubGenerator.cs b/Refit.Tests/InterfaceStubGenerator.cs index 1190583aa..d5807249d 100644 --- a/Refit.Tests/InterfaceStubGenerator.cs +++ b/Refit.Tests/InterfaceStubGenerator.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading.Tasks; @@ -9,7 +10,6 @@ using Refit; // InterfaceStubGenerator looks for this using Refit.Generator; - using Xunit; using Task = System.Threading.Tasks.Task; @@ -95,6 +95,25 @@ public void GenerateClassInfoForInterfaceSmokeTest() Assert.Equal("IGitHubApi", result.GeneratedClassSuffix); } + [Fact] + public void GenerateClassInfoForDisposableInterfaceSmokeTest() + { + var file = CSharpSyntaxTree.ParseText(File.ReadAllText(IntegrationTestHelper.GetPath("GitHubApi.cs"))); + var fixture = new InterfaceStubGenerator(); + + var input = file.GetRoot().DescendantNodes() + .OfType() + .First(x => x.Identifier.ValueText == "IGitHubApiDisposable"); + + var result = fixture.GenerateClassInfoForInterface(input); + + Assert.Equal(2, result.MethodList.Count); + Assert.Equal("RefitMethod", result.MethodList[0].Name); + Assert.Equal("Dispose", result.MethodList[1].Name); + Assert.Equal("IGitHubApiDisposable", result.InterfaceName); + Assert.Equal("IGitHubApiDisposable", result.GeneratedClassSuffix); + } + [Fact] public void GenerateClassInfoForNestedInterfaceSmokeTest() { diff --git a/Refit.Tests/RefitStubs.Net46.cs b/Refit.Tests/RefitStubs.Net46.cs index ba07815ff..b8687ee84 100644 --- a/Refit.Tests/RefitStubs.Net46.cs +++ b/Refit.Tests/RefitStubs.Net46.cs @@ -41,6 +41,7 @@ namespace Refit.Tests using global::Microsoft.CodeAnalysis.CSharp.Syntax; using global::Refit; using global::Refit.Generator; + using global::System; using global::Xunit; using Task = global::System.Threading.Tasks.Task; @@ -705,6 +706,7 @@ namespace Refit.Tests using global::Microsoft.CodeAnalysis.CSharp.Syntax; using global::Refit; using global::Refit.Generator; + using global::System; using global::Xunit; using Task = global::System.Threading.Tasks.Task; @@ -1659,6 +1661,51 @@ Task> IGitHubApi.CreateUserWithMetadata(User user) } } +namespace Refit.Tests +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::System.Net.Http; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Refit; + using static global::System.Math; + + /// + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + [global::System.Diagnostics.DebuggerNonUserCode] + [Preserve] + [global::System.Reflection.Obfuscation(Exclude=true)] + partial class AutoGeneratedIGitHubApiDisposable : IGitHubApiDisposable + { + /// + public HttpClient Client { get; protected set; } + readonly IRequestBuilder requestBuilder; + + /// + public AutoGeneratedIGitHubApiDisposable(HttpClient client, IRequestBuilder requestBuilder) + { + Client = client; + this.requestBuilder = requestBuilder; + } + + /// + Task IGitHubApiDisposable.RefitMethod() + { + var arguments = new object[] { }; + var func = requestBuilder.BuildRestResultFuncForMethod("RefitMethod", new Type[] { }); + return (Task)func(Client, arguments); + } + + /// + void IDisposable.Dispose() + { + throw new NotImplementedException("Either this method has no Refit HTTP method attribute or you've used something other than a string literal for the 'path' argument."); + } + } +} + namespace Refit.Tests { using global::System; @@ -2109,6 +2156,7 @@ namespace Refit.Tests using global::Microsoft.CodeAnalysis.CSharp.Syntax; using global::Refit; using global::Refit.Generator; + using global::System; using global::Xunit; using Task = global::System.Threading.Tasks.Task; diff --git a/Refit.Tests/RefitStubs.NetCore2.cs b/Refit.Tests/RefitStubs.NetCore2.cs index ba07815ff..b8687ee84 100644 --- a/Refit.Tests/RefitStubs.NetCore2.cs +++ b/Refit.Tests/RefitStubs.NetCore2.cs @@ -41,6 +41,7 @@ namespace Refit.Tests using global::Microsoft.CodeAnalysis.CSharp.Syntax; using global::Refit; using global::Refit.Generator; + using global::System; using global::Xunit; using Task = global::System.Threading.Tasks.Task; @@ -705,6 +706,7 @@ namespace Refit.Tests using global::Microsoft.CodeAnalysis.CSharp.Syntax; using global::Refit; using global::Refit.Generator; + using global::System; using global::Xunit; using Task = global::System.Threading.Tasks.Task; @@ -1659,6 +1661,51 @@ Task> IGitHubApi.CreateUserWithMetadata(User user) } } +namespace Refit.Tests +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::System.Net.Http; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Refit; + using static global::System.Math; + + /// + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + [global::System.Diagnostics.DebuggerNonUserCode] + [Preserve] + [global::System.Reflection.Obfuscation(Exclude=true)] + partial class AutoGeneratedIGitHubApiDisposable : IGitHubApiDisposable + { + /// + public HttpClient Client { get; protected set; } + readonly IRequestBuilder requestBuilder; + + /// + public AutoGeneratedIGitHubApiDisposable(HttpClient client, IRequestBuilder requestBuilder) + { + Client = client; + this.requestBuilder = requestBuilder; + } + + /// + Task IGitHubApiDisposable.RefitMethod() + { + var arguments = new object[] { }; + var func = requestBuilder.BuildRestResultFuncForMethod("RefitMethod", new Type[] { }); + return (Task)func(Client, arguments); + } + + /// + void IDisposable.Dispose() + { + throw new NotImplementedException("Either this method has no Refit HTTP method attribute or you've used something other than a string literal for the 'path' argument."); + } + } +} + namespace Refit.Tests { using global::System; @@ -2109,6 +2156,7 @@ namespace Refit.Tests using global::Microsoft.CodeAnalysis.CSharp.Syntax; using global::Refit; using global::Refit.Generator; + using global::System; using global::Xunit; using Task = global::System.Threading.Tasks.Task; diff --git a/Refit.Tests/RefitStubs.NetCore3.cs b/Refit.Tests/RefitStubs.NetCore3.cs index ba07815ff..b8687ee84 100644 --- a/Refit.Tests/RefitStubs.NetCore3.cs +++ b/Refit.Tests/RefitStubs.NetCore3.cs @@ -41,6 +41,7 @@ namespace Refit.Tests using global::Microsoft.CodeAnalysis.CSharp.Syntax; using global::Refit; using global::Refit.Generator; + using global::System; using global::Xunit; using Task = global::System.Threading.Tasks.Task; @@ -705,6 +706,7 @@ namespace Refit.Tests using global::Microsoft.CodeAnalysis.CSharp.Syntax; using global::Refit; using global::Refit.Generator; + using global::System; using global::Xunit; using Task = global::System.Threading.Tasks.Task; @@ -1659,6 +1661,51 @@ Task> IGitHubApi.CreateUserWithMetadata(User user) } } +namespace Refit.Tests +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::System.Net.Http; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Refit; + using static global::System.Math; + + /// + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + [global::System.Diagnostics.DebuggerNonUserCode] + [Preserve] + [global::System.Reflection.Obfuscation(Exclude=true)] + partial class AutoGeneratedIGitHubApiDisposable : IGitHubApiDisposable + { + /// + public HttpClient Client { get; protected set; } + readonly IRequestBuilder requestBuilder; + + /// + public AutoGeneratedIGitHubApiDisposable(HttpClient client, IRequestBuilder requestBuilder) + { + Client = client; + this.requestBuilder = requestBuilder; + } + + /// + Task IGitHubApiDisposable.RefitMethod() + { + var arguments = new object[] { }; + var func = requestBuilder.BuildRestResultFuncForMethod("RefitMethod", new Type[] { }); + return (Task)func(Client, arguments); + } + + /// + void IDisposable.Dispose() + { + throw new NotImplementedException("Either this method has no Refit HTTP method attribute or you've used something other than a string literal for the 'path' argument."); + } + } +} + namespace Refit.Tests { using global::System; @@ -2109,6 +2156,7 @@ namespace Refit.Tests using global::Microsoft.CodeAnalysis.CSharp.Syntax; using global::Refit; using global::Refit.Generator; + using global::System; using global::Xunit; using Task = global::System.Threading.Tasks.Task; From 6eaaf0e436c67f81698416f4e3d62522bc83a52f Mon Sep 17 00:00:00 2001 From: Jan Trejbal Date: Mon, 17 Aug 2020 16:15:33 +0200 Subject: [PATCH 2/3] Update GeneratedInterfaceStubTemplate.mustache to support Dispose method --- .../GeneratedInterfaceStubTemplate.mustache | 7 +++++-- InterfaceStubGenerator.Core/InterfaceStubGenerator.cs | 3 +++ Refit.Tests/RefitStubs.Net46.cs | 8 ++++---- Refit.Tests/RefitStubs.NetCore2.cs | 8 ++++---- Refit.Tests/RefitStubs.NetCore3.cs | 8 ++++---- 5 files changed, 20 insertions(+), 14 deletions(-) diff --git a/InterfaceStubGenerator.Core/GeneratedInterfaceStubTemplate.mustache b/InterfaceStubGenerator.Core/GeneratedInterfaceStubTemplate.mustache index 7e3d5f129..4c516b624 100644 --- a/InterfaceStubGenerator.Core/GeneratedInterfaceStubTemplate.mustache +++ b/InterfaceStubGenerator.Core/GeneratedInterfaceStubTemplate.mustache @@ -70,9 +70,12 @@ namespace {{Namespace}} var func = requestBuilder.BuildRestResultFuncForMethod("{{Name}}", new Type[] { {{ArgumentTypesList}} }{{#MethodTypeParameterList}}, new Type[] { {{.}} }{{/MethodTypeParameterList}}); return ({{ReturnType}})func(Client, arguments); {{/IsRefitMethod}} - {{^IsRefitMethod}} + {{#IsDispose}} + Client?.Dispose(); + {{/IsDispose}} + {{#UnsupportedMethod}} throw new NotImplementedException("Either this method has no Refit HTTP method attribute or you've used something other than a string literal for the 'path' argument."); - {{/IsRefitMethod}} + {{/UnsupportedMethod}} } {{/MethodList}} {{#HasAnyMethodsWithNullableArguments}} diff --git a/InterfaceStubGenerator.Core/InterfaceStubGenerator.cs b/InterfaceStubGenerator.Core/InterfaceStubGenerator.cs index cdcf2aa1a..f58d01833 100644 --- a/InterfaceStubGenerator.Core/InterfaceStubGenerator.cs +++ b/InterfaceStubGenerator.Core/InterfaceStubGenerator.cs @@ -179,6 +179,7 @@ public ClassTemplateInfo GenerateClassInfoForInterface(InterfaceDeclarationSynta ReturnTypeInfo = new TypeInfo {Name = "void"}, ArgumentListInfo = new List(), IsRefitMethod = false, + IsDispose = true, InterfaceName = nameof(IDisposable), }); } @@ -450,6 +451,8 @@ public class MethodTemplateInfo public string ArgumentListWithTypes => ArgumentListInfo != null ? string.Join(", ", ArgumentListInfo.Select(y => $"{y.TypeInfo} {y.Name}")) : null; public string ArgumentTypesList => ArgumentListInfo != null ? string.Join(", ", ArgumentListInfo.Select(y => y.TypeInfo.ToString() is var typeName && typeName.EndsWith("?") ? $"ToNullable(typeof({typeName.Remove(typeName.Length - 1)}))" : $"typeof({typeName})")) : null; public bool IsRefitMethod { get; set; } + public bool IsDispose { get; set; } + public bool UnsupportedMethod => !IsRefitMethod && !IsDispose; public string Name { get; set; } public TypeInfo ReturnTypeInfo { get; set; } public string ReturnType => ReturnTypeInfo.ToString(); diff --git a/Refit.Tests/RefitStubs.Net46.cs b/Refit.Tests/RefitStubs.Net46.cs index b8687ee84..824fa21e4 100644 --- a/Refit.Tests/RefitStubs.Net46.cs +++ b/Refit.Tests/RefitStubs.Net46.cs @@ -32,6 +32,7 @@ sealed class PreserveAttribute : Attribute #pragma warning disable CS8669 // The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. Auto-generated code requires an explicit '#nullable' directive in source. namespace Refit.Tests { + using global::System; using global::System.Collections.Generic; using global::System.IO; using global::System.Linq; @@ -41,7 +42,6 @@ namespace Refit.Tests using global::Microsoft.CodeAnalysis.CSharp.Syntax; using global::Refit; using global::Refit.Generator; - using global::System; using global::Xunit; using Task = global::System.Threading.Tasks.Task; @@ -697,6 +697,7 @@ Task IBodylessApi.Head() namespace Refit.Tests { + using global::System; using global::System.Collections.Generic; using global::System.IO; using global::System.Linq; @@ -706,7 +707,6 @@ namespace Refit.Tests using global::Microsoft.CodeAnalysis.CSharp.Syntax; using global::Refit; using global::Refit.Generator; - using global::System; using global::Xunit; using Task = global::System.Threading.Tasks.Task; @@ -1701,7 +1701,7 @@ Task IGitHubApiDisposable.RefitMethod() /// void IDisposable.Dispose() { - throw new NotImplementedException("Either this method has no Refit HTTP method attribute or you've used something other than a string literal for the 'path' argument."); + Client?.Dispose(); } } } @@ -2147,6 +2147,7 @@ Task IAmInterfaceF_RequireUsing.Get(List guids) namespace Refit.Tests { + using global::System; using global::System.Collections.Generic; using global::System.IO; using global::System.Linq; @@ -2156,7 +2157,6 @@ namespace Refit.Tests using global::Microsoft.CodeAnalysis.CSharp.Syntax; using global::Refit; using global::Refit.Generator; - using global::System; using global::Xunit; using Task = global::System.Threading.Tasks.Task; diff --git a/Refit.Tests/RefitStubs.NetCore2.cs b/Refit.Tests/RefitStubs.NetCore2.cs index b8687ee84..824fa21e4 100644 --- a/Refit.Tests/RefitStubs.NetCore2.cs +++ b/Refit.Tests/RefitStubs.NetCore2.cs @@ -32,6 +32,7 @@ sealed class PreserveAttribute : Attribute #pragma warning disable CS8669 // The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. Auto-generated code requires an explicit '#nullable' directive in source. namespace Refit.Tests { + using global::System; using global::System.Collections.Generic; using global::System.IO; using global::System.Linq; @@ -41,7 +42,6 @@ namespace Refit.Tests using global::Microsoft.CodeAnalysis.CSharp.Syntax; using global::Refit; using global::Refit.Generator; - using global::System; using global::Xunit; using Task = global::System.Threading.Tasks.Task; @@ -697,6 +697,7 @@ Task IBodylessApi.Head() namespace Refit.Tests { + using global::System; using global::System.Collections.Generic; using global::System.IO; using global::System.Linq; @@ -706,7 +707,6 @@ namespace Refit.Tests using global::Microsoft.CodeAnalysis.CSharp.Syntax; using global::Refit; using global::Refit.Generator; - using global::System; using global::Xunit; using Task = global::System.Threading.Tasks.Task; @@ -1701,7 +1701,7 @@ Task IGitHubApiDisposable.RefitMethod() /// void IDisposable.Dispose() { - throw new NotImplementedException("Either this method has no Refit HTTP method attribute or you've used something other than a string literal for the 'path' argument."); + Client?.Dispose(); } } } @@ -2147,6 +2147,7 @@ Task IAmInterfaceF_RequireUsing.Get(List guids) namespace Refit.Tests { + using global::System; using global::System.Collections.Generic; using global::System.IO; using global::System.Linq; @@ -2156,7 +2157,6 @@ namespace Refit.Tests using global::Microsoft.CodeAnalysis.CSharp.Syntax; using global::Refit; using global::Refit.Generator; - using global::System; using global::Xunit; using Task = global::System.Threading.Tasks.Task; diff --git a/Refit.Tests/RefitStubs.NetCore3.cs b/Refit.Tests/RefitStubs.NetCore3.cs index b8687ee84..824fa21e4 100644 --- a/Refit.Tests/RefitStubs.NetCore3.cs +++ b/Refit.Tests/RefitStubs.NetCore3.cs @@ -32,6 +32,7 @@ sealed class PreserveAttribute : Attribute #pragma warning disable CS8669 // The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. Auto-generated code requires an explicit '#nullable' directive in source. namespace Refit.Tests { + using global::System; using global::System.Collections.Generic; using global::System.IO; using global::System.Linq; @@ -41,7 +42,6 @@ namespace Refit.Tests using global::Microsoft.CodeAnalysis.CSharp.Syntax; using global::Refit; using global::Refit.Generator; - using global::System; using global::Xunit; using Task = global::System.Threading.Tasks.Task; @@ -697,6 +697,7 @@ Task IBodylessApi.Head() namespace Refit.Tests { + using global::System; using global::System.Collections.Generic; using global::System.IO; using global::System.Linq; @@ -706,7 +707,6 @@ namespace Refit.Tests using global::Microsoft.CodeAnalysis.CSharp.Syntax; using global::Refit; using global::Refit.Generator; - using global::System; using global::Xunit; using Task = global::System.Threading.Tasks.Task; @@ -1701,7 +1701,7 @@ Task IGitHubApiDisposable.RefitMethod() /// void IDisposable.Dispose() { - throw new NotImplementedException("Either this method has no Refit HTTP method attribute or you've used something other than a string literal for the 'path' argument."); + Client?.Dispose(); } } } @@ -2147,6 +2147,7 @@ Task IAmInterfaceF_RequireUsing.Get(List guids) namespace Refit.Tests { + using global::System; using global::System.Collections.Generic; using global::System.IO; using global::System.Linq; @@ -2156,7 +2157,6 @@ namespace Refit.Tests using global::Microsoft.CodeAnalysis.CSharp.Syntax; using global::Refit; using global::Refit.Generator; - using global::System; using global::Xunit; using Task = global::System.Threading.Tasks.Task; From f84e53f4e3d3c46b9bdf39f2bb9264cb8fa91237 Mon Sep 17 00:00:00 2001 From: Claire Novotny Date: Mon, 23 Nov 2020 09:43:22 -0500 Subject: [PATCH 3/3] Fix interface count and code generation for net5 --- Refit.Tests/InterfaceStubGenerator.cs | 2 +- Refit.Tests/RefitStubs.Net5.cs | 48 +++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/Refit.Tests/InterfaceStubGenerator.cs b/Refit.Tests/InterfaceStubGenerator.cs index ab178b7b8..f75f9a689 100644 --- a/Refit.Tests/InterfaceStubGenerator.cs +++ b/Refit.Tests/InterfaceStubGenerator.cs @@ -41,7 +41,7 @@ public void FindInterfacesSmokeTest() var fixture = new InterfaceStubGenerator(); var result = fixture.FindInterfacesToGenerate(CSharpSyntaxTree.ParseText(File.ReadAllText(input))); - Assert.Equal(2, result.Count); + Assert.Equal(3, result.Count); Assert.Contains(result, x => x.Identifier.ValueText == "IGitHubApi"); input = IntegrationTestHelper.GetPath("InterfaceStubGenerator.cs"); diff --git a/Refit.Tests/RefitStubs.Net5.cs b/Refit.Tests/RefitStubs.Net5.cs index b8629b29a..c98aa3bfe 100644 --- a/Refit.Tests/RefitStubs.Net5.cs +++ b/Refit.Tests/RefitStubs.Net5.cs @@ -32,6 +32,7 @@ sealed class PreserveAttribute : Attribute #pragma warning disable CS8669 // The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. Auto-generated code requires an explicit '#nullable' directive in source. namespace Refit.Tests { + using global::System; using global::System.Collections.Generic; using global::System.IO; using global::System.Linq; @@ -696,6 +697,7 @@ Task IBodylessApi.Head() namespace Refit.Tests { + using global::System; using global::System.Collections.Generic; using global::System.IO; using global::System.Linq; @@ -1659,6 +1661,51 @@ Task> IGitHubApi.CreateUserWithMetadata(User user) } } +namespace Refit.Tests +{ + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::System.Net.Http; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Refit; + using static global::System.Math; + + /// + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + [global::System.Diagnostics.DebuggerNonUserCode] + [Preserve] + [global::System.Reflection.Obfuscation(Exclude=true)] + partial class AutoGeneratedIGitHubApiDisposable : IGitHubApiDisposable + { + /// + public HttpClient Client { get; protected set; } + readonly IRequestBuilder requestBuilder; + + /// + public AutoGeneratedIGitHubApiDisposable(HttpClient client, IRequestBuilder requestBuilder) + { + Client = client; + this.requestBuilder = requestBuilder; + } + + /// + Task IGitHubApiDisposable.RefitMethod() + { + var arguments = new object[] { }; + var func = requestBuilder.BuildRestResultFuncForMethod("RefitMethod", new Type[] { }); + return (Task)func(Client, arguments); + } + + /// + void IDisposable.Dispose() + { + Client?.Dispose(); + } + } +} + namespace Refit.Tests { using global::System; @@ -2146,6 +2193,7 @@ Task IAmInterfaceF_RequireUsing.Get(List guids) namespace Refit.Tests { + using global::System; using global::System.Collections.Generic; using global::System.IO; using global::System.Linq;