Skip to content

Commit

Permalink
feat: add IDisposable test (#1855)
Browse files Browse the repository at this point in the history
  • Loading branch information
TimothyMakkison authored Oct 2, 2024
1 parent 040ecc6 commit d03121d
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Refit.GeneratorTests/InterfaceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,17 @@ public interface IGeneratedInterface
}
""");
}

[Fact]
public Task DisposableTest()
{
return Fixture.VerifyForDeclaration(
"""
public interface IGeneratedInterface : IDisposable
{
[Get("/users")]
Task<string> Get();
}
""");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
//HintName: IGeneratedInterface.g.cs
#nullable disable
#pragma warning disable
namespace Refit.Implementation
{

partial class Generated
{

/// <inheritdoc />
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
[global::System.Diagnostics.DebuggerNonUserCode]
[global::RefitInternalGenerated.PreserveAttribute]
[global::System.Reflection.Obfuscation(Exclude=true)]
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
partial class IGeneratedInterface
: global::IGeneratedInterface

{
/// <inheritdoc />
public global::System.Net.Http.HttpClient Client { get; }
readonly global::Refit.IRequestBuilder requestBuilder;

/// <inheritdoc />
public IGeneratedInterface(global::System.Net.Http.HttpClient client, global::Refit.IRequestBuilder requestBuilder)
{
Client = client;
this.requestBuilder = requestBuilder;
}


/// <inheritdoc />
public async global::System.Threading.Tasks.Task<string> Get()
{
var ______arguments = global::System.Array.Empty<object>();
var ______func = requestBuilder.BuildRestResultFuncForMethod("Get", global::System.Array.Empty<global::System.Type>() );

return await ((global::System.Threading.Tasks.Task<string>)______func(this.Client, ______arguments)).ConfigureAwait(false);
}

/// <inheritdoc />
async global::System.Threading.Tasks.Task<string> global::IGeneratedInterface.Get()
{
var ______arguments = global::System.Array.Empty<object>();
var ______func = requestBuilder.BuildRestResultFuncForMethod("Get", global::System.Array.Empty<global::System.Type>() );

return await ((global::System.Threading.Tasks.Task<string>)______func(this.Client, ______arguments)).ConfigureAwait(false);
}

/// <inheritdoc />
void global::System.IDisposable.Dispose()
{
Client?.Dispose();
}
}
}
}

#pragma warning restore

0 comments on commit d03121d

Please sign in to comment.