Skip to content
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

Merged
merged 2 commits into from
Aug 11, 2020

Conversation

chsienki
Copy link
Contributor

No description provided.

@chsienki
Copy link
Contributor Author

@dotnet/roslyn-compiler for review please.

public class MyXmlGenerator : ISourceGenerator
{

private static readonly DiagnosticDescriptor InvalidXmlWarning = new DiagnosticDescriptor(id: "MYXMLGEN001",
Copy link
Member

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")

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Member

@jcouv jcouv left a 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)

@jcouv jcouv self-assigned this Aug 11, 2020
@chsienki chsienki merged commit 4ed61ff into dotnet:master Aug 11, 2020
@ghost ghost added this to the Next milestone Aug 11, 2020
@chsienki chsienki deleted the cookbook_diagnostics branch August 11, 2020 22:44
@RikkiGibson
Copy link
Contributor

For expediency I am not including this in the preview2 snap this afternoon. Please let me know if you have concerns.

@allisonchou allisonchou modified the milestones: Next, 16.8.P3 Aug 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants