-
-
Notifications
You must be signed in to change notification settings - Fork 746
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added more snapshot
InterfaceTests
(#1802)
- Loading branch information
1 parent
f77f0f3
commit 47ce83e
Showing
18 changed files
with
751 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
namespace Refit.GeneratorTests; | ||
|
||
public class InterfaceTests | ||
{ | ||
[Fact] | ||
public Task ContainedInterfaceTest() | ||
{ | ||
return Fixture.VerifyForType( | ||
""" | ||
public class ContainerType | ||
{ | ||
public interface IContainedInterface | ||
{ | ||
[Get("/users")] | ||
Task<string> Get(); | ||
} | ||
} | ||
"""); | ||
} | ||
|
||
[Fact] | ||
public Task DerivedRefitInterfaceTest() | ||
{ | ||
return Fixture.VerifyForType( | ||
""" | ||
public interface IGeneratedInterface : IBaseInterface | ||
{ | ||
[Get("/users")] | ||
Task<string> Get(); | ||
} | ||
public interface IBaseInterface | ||
{ | ||
[Get("/posts")] | ||
Task<string> GetPosts(); | ||
} | ||
"""); | ||
} | ||
|
||
[Fact] | ||
public Task DerivedNonRefitInterfaceTest() | ||
{ | ||
return Fixture.VerifyForType( | ||
""" | ||
public interface IGeneratedInterface : IBaseInterface | ||
{ | ||
[Get("/users")] | ||
Task<string> Get(); | ||
} | ||
public interface IBaseInterface | ||
{ | ||
void NonRefitMethod(); | ||
} | ||
"""); | ||
} | ||
|
||
[Fact] | ||
public Task NestedNamespaceTest() | ||
{ | ||
return Fixture.VerifyForDeclaration( | ||
""" | ||
namespace Nested.RefitGeneratorTest; | ||
public interface IGeneratedInterface | ||
{ | ||
[Get("/users")] | ||
Task<string> Get(); | ||
} | ||
"""); | ||
} | ||
|
||
[Fact] | ||
public Task GlobalNamespaceTest() | ||
{ | ||
return Fixture.VerifyForDeclaration( | ||
""" | ||
public interface IGeneratedInterface | ||
{ | ||
[Get("/users")] | ||
Task<string> Get(); | ||
} | ||
"""); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...t.GeneratorTests/_snapshots/InterfaceTests.ContainedInterfaceTest#Generated.g.verified.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//HintName: Generated.g.cs | ||
|
||
#pragma warning disable | ||
namespace Refit.Implementation | ||
{ | ||
|
||
/// <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)] | ||
internal static partial class Generated | ||
{ | ||
#if NET5_0_OR_GREATER | ||
[System.Runtime.CompilerServices.ModuleInitializer] | ||
[System.Diagnostics.CodeAnalysis.DynamicDependency(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All, typeof(global::Refit.Implementation.Generated))] | ||
public static void Initialize() | ||
{ | ||
} | ||
#endif | ||
} | ||
} | ||
#pragma warning restore |
66 changes: 66 additions & 0 deletions
66
...rTests/_snapshots/InterfaceTests.ContainedInterfaceTest#IContainedInterface.g.verified.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
//HintName: IContainedInterface.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 RefitGeneratorTestContainerTypeIContainedInterface | ||
: global::RefitGeneratorTest.ContainerType.IContainedInterface | ||
|
||
{ | ||
/// <inheritdoc /> | ||
public global::System.Net.Http.HttpClient Client { get; } | ||
readonly global::Refit.IRequestBuilder requestBuilder; | ||
|
||
/// <inheritdoc /> | ||
public RefitGeneratorTestContainerTypeIContainedInterface(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>() ); | ||
try | ||
{ | ||
return await ((global::System.Threading.Tasks.Task<string>)______func(this.Client, ______arguments)).ConfigureAwait(false); | ||
} | ||
catch (global::System.Exception ______ex) | ||
{ | ||
throw ______ex; | ||
} | ||
} | ||
|
||
/// <inheritdoc /> | ||
async global::System.Threading.Tasks.Task<string> global::RefitGeneratorTest.ContainerType.IContainedInterface.Get() | ||
{ | ||
var ______arguments = global::System.Array.Empty<object>(); | ||
var ______func = requestBuilder.BuildRestResultFuncForMethod("Get", global::System.Array.Empty<global::System.Type>() ); | ||
try | ||
{ | ||
return await ((global::System.Threading.Tasks.Task<string>)______func(this.Client, ______arguments)).ConfigureAwait(false); | ||
} | ||
catch (global::System.Exception ______ex) | ||
{ | ||
throw ______ex; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
#pragma warning restore |
19 changes: 19 additions & 0 deletions
19
...torTests/_snapshots/InterfaceTests.ContainedInterfaceTest#PreserveAttribute.g.verified.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
//HintName: PreserveAttribute.g.cs | ||
|
||
#pragma warning disable | ||
namespace RefitInternalGenerated | ||
{ | ||
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] | ||
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] | ||
[global::System.AttributeUsage (global::System.AttributeTargets.Class | global::System.AttributeTargets.Struct | global::System.AttributeTargets.Enum | global::System.AttributeTargets.Constructor | global::System.AttributeTargets.Method | global::System.AttributeTargets.Property | global::System.AttributeTargets.Field | global::System.AttributeTargets.Event | global::System.AttributeTargets.Interface | global::System.AttributeTargets.Delegate)] | ||
sealed class PreserveAttribute : global::System.Attribute | ||
{ | ||
// | ||
// Fields | ||
// | ||
public bool AllMembers; | ||
|
||
public bool Conditional; | ||
} | ||
} | ||
#pragma warning restore |
24 changes: 24 additions & 0 deletions
24
...ratorTests/_snapshots/InterfaceTests.DerivedNonRefitInterfaceTest#Generated.g.verified.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//HintName: Generated.g.cs | ||
|
||
#pragma warning disable | ||
namespace Refit.Implementation | ||
{ | ||
|
||
/// <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)] | ||
internal static partial class Generated | ||
{ | ||
#if NET5_0_OR_GREATER | ||
[System.Runtime.CompilerServices.ModuleInitializer] | ||
[System.Diagnostics.CodeAnalysis.DynamicDependency(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All, typeof(global::Refit.Implementation.Generated))] | ||
public static void Initialize() | ||
{ | ||
} | ||
#endif | ||
} | ||
} | ||
#pragma warning restore |
66 changes: 66 additions & 0 deletions
66
.../_snapshots/InterfaceTests.DerivedNonRefitInterfaceTest#IGeneratedInterface.g.verified.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
//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 RefitGeneratorTestIGeneratedInterface | ||
: global::RefitGeneratorTest.IGeneratedInterface | ||
|
||
{ | ||
/// <inheritdoc /> | ||
public global::System.Net.Http.HttpClient Client { get; } | ||
readonly global::Refit.IRequestBuilder requestBuilder; | ||
|
||
/// <inheritdoc /> | ||
public RefitGeneratorTestIGeneratedInterface(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>() ); | ||
try | ||
{ | ||
return await ((global::System.Threading.Tasks.Task<string>)______func(this.Client, ______arguments)).ConfigureAwait(false); | ||
} | ||
catch (global::System.Exception ______ex) | ||
{ | ||
throw ______ex; | ||
} | ||
} | ||
|
||
/// <inheritdoc /> | ||
async global::System.Threading.Tasks.Task<string> global::RefitGeneratorTest.IGeneratedInterface.Get() | ||
{ | ||
var ______arguments = global::System.Array.Empty<object>(); | ||
var ______func = requestBuilder.BuildRestResultFuncForMethod("Get", global::System.Array.Empty<global::System.Type>() ); | ||
try | ||
{ | ||
return await ((global::System.Threading.Tasks.Task<string>)______func(this.Client, ______arguments)).ConfigureAwait(false); | ||
} | ||
catch (global::System.Exception ______ex) | ||
{ | ||
throw ______ex; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
#pragma warning restore |
19 changes: 19 additions & 0 deletions
19
...ts/_snapshots/InterfaceTests.DerivedNonRefitInterfaceTest#PreserveAttribute.g.verified.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
//HintName: PreserveAttribute.g.cs | ||
|
||
#pragma warning disable | ||
namespace RefitInternalGenerated | ||
{ | ||
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] | ||
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] | ||
[global::System.AttributeUsage (global::System.AttributeTargets.Class | global::System.AttributeTargets.Struct | global::System.AttributeTargets.Enum | global::System.AttributeTargets.Constructor | global::System.AttributeTargets.Method | global::System.AttributeTargets.Property | global::System.AttributeTargets.Field | global::System.AttributeTargets.Event | global::System.AttributeTargets.Interface | global::System.AttributeTargets.Delegate)] | ||
sealed class PreserveAttribute : global::System.Attribute | ||
{ | ||
// | ||
// Fields | ||
// | ||
public bool AllMembers; | ||
|
||
public bool Conditional; | ||
} | ||
} | ||
#pragma warning restore |
24 changes: 24 additions & 0 deletions
24
...eneratorTests/_snapshots/InterfaceTests.DerivedRefitInterfaceTest#Generated.g.verified.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//HintName: Generated.g.cs | ||
|
||
#pragma warning disable | ||
namespace Refit.Implementation | ||
{ | ||
|
||
/// <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)] | ||
internal static partial class Generated | ||
{ | ||
#if NET5_0_OR_GREATER | ||
[System.Runtime.CompilerServices.ModuleInitializer] | ||
[System.Diagnostics.CodeAnalysis.DynamicDependency(System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes.All, typeof(global::Refit.Implementation.Generated))] | ||
public static void Initialize() | ||
{ | ||
} | ||
#endif | ||
} | ||
} | ||
#pragma warning restore |
Oops, something went wrong.