What's wrong
DiagnosticCatalog.Add (SourceGeneratorToolkit/DiagnosticCatalog.cs:~56-68) formats {prefix}{number:000} without checking whether that number is already in use.
Reproduction (ran)
var catalog = new DiagnosticCatalog("X", "c");
catalog.Warning(1, "a", "a");
catalog.Error(1, "b", "b");
Both descriptors get the ID X001, with different titles, severities and messages, and both appear in Descriptors.
Why it matters
The catalog exists so that IDs can't drift or collide. With duplicates:
- a
.editorconfig severity override or #pragma suppression meant for one diagnostic silently applies to the other;
- the docs and the analyzer release tracking see two different rules under one ID;
- a test that walks
Descriptors doesn't flag it.
Suggested fix / acceptance criteria
- Track the numbers already used (a
HashSet<int>) and throw ArgumentException from Add when a number is reused.
- Add a test: registering the same number twice throws.
What's wrong
DiagnosticCatalog.Add(SourceGeneratorToolkit/DiagnosticCatalog.cs:~56-68) formats{prefix}{number:000}without checking whether that number is already in use.Reproduction (ran)
Both descriptors get the ID
X001, with different titles, severities and messages, and both appear inDescriptors.Why it matters
The catalog exists so that IDs can't drift or collide. With duplicates:
.editorconfigseverity override or#pragmasuppression meant for one diagnostic silently applies to the other;Descriptorsdoesn't flag it.Suggested fix / acceptance criteria
HashSet<int>) and throwArgumentExceptionfromAddwhen a number is reused.