Repository navigation
feat: add analyzer diagnostics for invalid Refit interfaces - #2220
Merged
Merged
Conversation
- RF011: flag Refit methods that declare more than one [Body] parameter - RF012: flag [Multipart] methods that also declare a [Body] parameter Both are Warning severity, so existing builds are unaffected unless warnings are treated as errors. Closes #1885
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2220 +/- ##
=======================================
Coverage 99.70% 99.70%
=======================================
Files 176 176
Lines 9136 9180 +44
Branches 1701 1710 +9
=======================================
+ Hits 9109 9153 +44
Misses 8 8
Partials 19 19 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
glennawatson
marked this pull request as ready for review
July 14, 2026 14:43
ChrisPulman
approved these changes
Jul 14, 2026
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



What kind of change does this PR introduce?
Feature - two new Refit interface analyzer diagnostics (no runtime behavior change).
What is the new behavior?
The Refit analyzer now flags two more invalid interface shapes at compile time:
[Body]parameter. Message:Method {0}.{1} has more than one Body parameter.[Multipart]method that also declares a[Body]parameter. Message:Method {0}.{1} is multipart and cannot declare a Body parameter.Both are Warning severity, so they surface the mistake in the editor and build output without failing the build unless the consumer opts into treat-warnings-as-errors. Both are documented in the README analyzer list.
What is the current behavior?
These interface mistakes were not diagnosed. A method with two
[Body]parameters, or a multipart method that also carries a[Body]parameter, was only caught (if at all) at request-build time, and produced no analyzer signal.Closes #1885
What might this PR break?
Nothing by default. The new diagnostics are Warning severity and add no public API (the descriptors and IDs are internal). Consumers who run treat-warnings-as-errors and already have one of these invalid shapes will see a new build warning surface as an error - which is the intended signal.
Checklist
mainbranchAdditional information
src/Refit.Analyzers.Shared, mirroring the existing per-method / per-parameter diagnostics (RF004, RF008, RF009). RF011 slots into the parameter-shape counter loop next to the existing CancellationToken / HeaderCollection / Authorize counters; RF012 is a pure attribute check on the method.RefitInterfaceAnalyzerTests, net8.0). No public API changes (internal descriptors/IDs).IReturnTypeAdapterimplementations (viaRefitSettings.ReturnTypeAdapters) that can make an otherwise-unrecognized return type - even a closed adapter overstring/int- valid at runtime. The analyzer cannot see runtime-registered adapters, and the source generator itself never rejects an unknown return type (it falls back to the reflection request builder, already surfaced by RF006). A return-type diagnostic would therefore risk false positives on valid adapter-backed methods, so it was left out.