-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Add example that reports diagnostics #46717
Conversation
@dotnet/roslyn-compiler for review please. |
public class MyXmlGenerator : ISourceGenerator | ||
{ | ||
|
||
private static readonly DiagnosticDescriptor InvalidXmlWarning = new DiagnosticDescriptor(id: "MYXMLGEN001", |
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.
MYXMLGEN [](start = 99, length = 8)
just curious, are some diagnostic prefixes disallowed as we do in analyzers in general? (for example "CS")
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.
As far as I know, we don't actually disallow prefixes, but we do have an analyzer that warns it shouldn't be used. I've confirmed that the analyzer issues the warnings for the generator in the above case.
@mavasani to confirm the expected behavior.
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.
Yep, see dotnet/roslyn-analyzers#1727 and #25748 for more context. We attempted to restrict prefixes in the compiler, but that caused a breaking change, so we reverted it and instead implemented an analyzer that warns when using well-known/reserved prefixes such as CS, BC or CA.
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.
LGTM Thanks (iteration 1)
For expediency I am not including this in the preview2 snap this afternoon. Please let me know if you have concerns. |
No description provided.