Disable InterfaceStubGenerator #1764
-
|
Any way to disable InterfaceStubGenerator ? It generates broken code (missing method implementations) beacuse my interfaces come from another source generator but I also have partial code which extends these generated code. Sadly it's currently impossible to exclude this analyzer.... dotnet/sdk#1212 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
There is no global flag to turn the Refit source generator off, and you do not need one. The generator only emits an implementation for interfaces whose methods carry Refit HTTP attributes (Get, Post, etc.). It does not generate anything for arbitrary interfaces. If you are seeing broken/partial generated code, it is because some of those interfaces have Refit attributes on their methods, so Refit tries to implement them. To stop that:
Refit cannot selectively co-generate with another generator that targets the same interface, because both would emit members for the same type. Separation by attribute or by project is the supported way to control what Refit generates. If you have a concrete repro where an interface with no Refit attributes still gets generated, please open an issue with a minimal sample. |
Beta Was this translation helpful? Give feedback.
There is no global flag to turn the Refit source generator off, and you do not need one. The generator only emits an implementation for interfaces whose methods carry Refit HTTP attributes (Get, Post, etc.). It does not generate anything for arbitrary interfaces.
If you are seeing broken/partial generated code, it is because some of those interfaces have Refit attributes on their methods, so Refit tries to implement them. To stop that: