The DiagnosticDescriptor constructor takes an id parameter that sets the Id property.

A unique identifier for the diagnostic. For example, code analysis diagnostic ID "CA1001".

That's the documentation in its entirety. We're left to assume that "CA" stands for "code analysis", suggesting that we should follow some similar pattern when developing our own analyzers and source generators.

What mechanisms exist for ensuring the uniqueness of the ID? What would the consequences be if multiple third party tools used the same IDs? Are there any best practices for avoiding collisions, analogous to using a domain or company name as a namespace?

  • I'd suggest checking the documentation or support for whichever tools you are using to find out what they say on this topic (which would always be the authority for any tool, not some external 3rd party source). Standards and conventions are likely irrelevant and a waste of time if your chosen toolset doesn't use them. Aug 3 at 6:30
  • @BenCottrell I literally quoted all of the documentation in the question. Aug 3 at 16:02


Browse other questions tagged or ask your own question.