Apply CS0282 to entire struct if applied to partial #53357
-
We have been using source generators avidly to rework a lot of our more brittle codegen (and they are fantastic btw). We use value types as much as possible in our codebase, and one issue we have run into is CS0282 warnings when we augment a partial struct with a source-generated one: Our options are as follows:
The third option seems by far the best. Unfortunately Roslyn does not seem to apply this to the entire struct when it is place on one partial type of it. Would it be possible to change the behavior to allow this? Seems like the behavior that is most desirable from developers in any case and makes source generators more applicable for modifying partial struct types (attributes work this way already). Let me know if this sounds amenable. Happy to look into a PR from our side. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
I think I'm sympathetic to wanting to enable source generators suppress warnings that they are "responsible" for. It feels like we would want to do a pass over the existing warnings that can apply to partial types and methods to decide if any others should get a similar treatment. Perhaps we could make /cc @dotnet/roslyn-compiler for thoughts. |
Beta Was this translation helpful? Give feedback.
-
This seems like it'd be a good candidate for creating a diagnostic suppressor. (That documentation and sample are from before the feature shipped, but I believe the API stayed the same.) |
Beta Was this translation helpful? Give feedback.
This seems like it'd be a good candidate for creating a diagnostic suppressor. (That documentation and sample are from before the feature shipped, but I believe the API stayed the same.)