-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
GeneratedCodeAttribute support is missing #1751
Comments
Food for thought: If an attribute was provided that allowed a code generator to exclude itself from custom analyzers, how would you write an analyzer that reported company policy violations inside generated code? As an active developer on a number of analyzers, the approach we're looking at right now is per-analyzer consideration of whether the input should be ignored based on conditions like an attribute or file header. I know there was another request for exposing a workspace service to answer questions about this state in a standard API, but I can't seem to find it now. |
@sharwell that's forward thinking which is interesting, yet my comment was about an existing feature that is provided by FxCop that still makes sense for non-compiler generated code. We also considered adjusting custom analyzers for specific exclusion rules, but it requires to handle all analyzer context registrations. This turns out to be inefficient to handle for some type of generated code (e.g. the InitializeComponent method for Xaml-compatible frameworks) and also does not apply to analyzers that do not comply with your exclusion rules, which is going to everything that comes from NuGet. For now, the approach we're taking is to alter the code generators to include custom SupressMessage attributes on generated classes, but that is clearly not an elegant solution and it does not work with closed-source generators. |
With FxCop, there was the ability to exclude specific types or members from analysis using the GeneratedCodeAttribute.
I'm seeing this issue with the IXamlTypeInfo implementation, as well as with any kind of tool that generates code as part of the node.
Having a support for GeneratedCodeAttribute would help a greatly for code generators and having their code excluded automatically.
The text was updated successfully, but these errors were encountered: