diff --git a/tests/ComputeWeave.D2D1.Tests.SourceGenerators/Test_DiagnosticMetadata.cs b/tests/ComputeWeave.D2D1.Tests.SourceGenerators/Test_DiagnosticMetadata.cs index f67550a17..ac7fa84d4 100644 --- a/tests/ComputeWeave.D2D1.Tests.SourceGenerators/Test_DiagnosticMetadata.cs +++ b/tests/ComputeWeave.D2D1.Tests.SourceGenerators/Test_DiagnosticMetadata.cs @@ -32,6 +32,31 @@ public class Test_DiagnosticMetadata /// private static readonly Regex Placeholder = new(@"\{\d+\s*(?:,\s*-?\d+\s*)?(?::[^}]*)?\}"); + /// + /// Two diagnostics sharing an identifier are one rule to everything that reads the identifier, from a + /// suppression to the release notes, so the second declared reports under the name of the first. + /// + /// + /// The identifiers on this side are taken the same way as on the compute side, the next free one at the time + /// a pull request is written, so two pull requests written at the same time take the same one. The release + /// tracking analyzer asks only that the identifier be listed in a release, and the counts the documents state + /// are of distinct identifiers, so the duplicate is refused here or nowhere. + /// + [TestMethod] + public void NoTwoDiagnosticsShareAnIdentifier() + { + string[] shared = + [ + .. Declared() + .GroupBy(static descriptor => descriptor.Id, StringComparer.Ordinal) + .Where(static group => group.Count() > 1) + .Select(static group => $"{group.Key}: {string.Join(" / ", group.Select(static descriptor => descriptor.Title.ToString()).Order())}") + .Order() + ]; + + Assert.AreEqual(0, shared.Length, string.Join(" | ", shared)); + } + /// /// Two diagnostics sharing a title means at least one of them is named after the other. /// diff --git a/tests/ComputeWeave.Tests.SourceGenerators/Diagnostics/DiagnosticMetadataTests.cs b/tests/ComputeWeave.Tests.SourceGenerators/Diagnostics/DiagnosticMetadataTests.cs index 929036e67..ffd259185 100644 --- a/tests/ComputeWeave.Tests.SourceGenerators/Diagnostics/DiagnosticMetadataTests.cs +++ b/tests/ComputeWeave.Tests.SourceGenerators/Diagnostics/DiagnosticMetadataTests.cs @@ -31,6 +31,32 @@ public class DiagnosticMetadataTests /// private static readonly Regex Placeholder = new(@"\{\d+\s*(?:,\s*-?\d+\s*)?(?::[^}]*)?\}"); + /// + /// Two diagnostics sharing an identifier are one rule to everything that reads the identifier, from a + /// suppression to the release notes, so the second declared reports under the name of the first. + /// + /// + /// Nothing else refuses it. The release tracking analyzer asks only that each identifier be listed in a + /// release, which the one row both declarations point at satisfies, and the counts the documents state + /// are counts of distinct identifiers. Where one comes from is two pull requests each taking the next + /// free identifier: the two merge without a textual conflict, so the duplicate reaches the default branch + /// with every check green. + /// + [TestMethod] + public void NoTwoDiagnosticsShareAnIdentifier() + { + string[] shared = + [ + .. Declared() + .GroupBy(static descriptor => descriptor.Id, StringComparer.Ordinal) + .Where(static group => group.Count() > 1) + .Select(static group => $"{group.Key}: {string.Join(" / ", group.Select(static descriptor => descriptor.Title.ToString()).Order())}") + .Order() + ]; + + Assert.AreEqual(0, shared.Length, string.Join(" | ", shared)); + } + /// /// Two diagnostics sharing a title means at least one of them is named after the other. ///