-
-
Notifications
You must be signed in to change notification settings - Fork 783
fix: do not emit RF001 for methods from plain non-refit base interfaces #2072
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -37,11 +37,6 @@ public RefitGeneratorTestIGeneratedInterface(global::System.Net.Http.HttpClient | |||||||||||||
| return await ((global::System.Threading.Tasks.Task<string>)______func(this.Client, ______arguments)).ConfigureAwait(false); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
|
||||||||||||||
| void global::RefitGeneratorTest.IBaseInterface.NonRefitMethod() | |
| { | |
| throw new global::System.NotImplementedException(); | |
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| namespace Refit.Tests | ||
| { | ||
| public interface IBaseApi | ||
| { | ||
| string GetBaseUri(); | ||
| } | ||
|
|
||
| public interface IMyRefitApi : IBaseApi | ||
| { | ||
| [Get("/users")] | ||
| Task<List<string>> GetUsers(); | ||
| } | ||
|
Comment on lines
+8
to
+12
|
||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -70,4 +70,10 @@ | |||||
| <ItemGroup> | ||||||
| <Folder Include="_snapshots\" /> | ||||||
| </ItemGroup> | ||||||
|
|
||||||
| <ItemGroup> | ||||||
| <Compile Remove="IInterfaceInheritingNonRefit.cs" /> | ||||||
|
||||||
| <Compile Remove="IInterfaceInheritingNonRefit.cs" /> | |
| <None Include="IInterfaceInheritingNonRefit.cs" /> |
| 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 |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,43 @@ | ||||||||||||||||||
| //HintName: IMyRefitApi.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 RefitTestsIMyRefitApi | ||||||||||||||||||
| : global::Refit.Tests.IMyRefitApi | ||||||||||||||||||
| { | ||||||||||||||||||
| /// <inheritdoc /> | ||||||||||||||||||
| public global::System.Net.Http.HttpClient Client { get; } | ||||||||||||||||||
| readonly global::Refit.IRequestBuilder requestBuilder; | ||||||||||||||||||
|
|
||||||||||||||||||
| /// <inheritdoc /> | ||||||||||||||||||
| public RefitTestsIMyRefitApi(global::System.Net.Http.HttpClient client, global::Refit.IRequestBuilder requestBuilder) | ||||||||||||||||||
| { | ||||||||||||||||||
| Client = client; | ||||||||||||||||||
| this.requestBuilder = requestBuilder; | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
| /// <inheritdoc /> | ||||||||||||||||||
|
||||||||||||||||||
| /// <inheritdoc /> | |
| /// <inheritdoc /> | |
| public global::System.Uri GetBaseUri() | |
| { | |
| return this.Client.BaseAddress; | |
| } | |
| /// <inheritdoc /> |
| 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new filter on
derivedNonRefitMethodsremoves inherited non‑Refit members from processing entirely.derivedNonRefitMethodsis later used to generate explicit interface implementations (viaParseNonRefitMethod/WriteNonRefitMethod) that are required for the generated client class to compile when the Refit interface inherits a base interface containing non‑Refit members. If the intent is only to suppress RF001 for methods coming from “plain” base interfaces, keep generating the stub methods but conditionally suppress the diagnostic emission (e.g., add a flag toParseNonRefitMethodto skipDiagnosticDescriptors.InvalidRefitMemberfor those members).