From 356224800c2197118080faee60a2d9778ca7bb7b Mon Sep 17 00:00:00 2001 From: routersys Date: Thu, 17 Sep 2026 09:28:57 +0900 Subject: [PATCH] =?UTF-8?q?=E8=A8=BA=E6=96=AD=E3=81=AE=E8=AD=98=E5=88=A5?= =?UTF-8?q?=E5=AD=90=E3=81=AE=E9=87=8D=E8=A4=87=E3=82=92=E7=A6=81=E3=81=98?= =?UTF-8?q?=E3=82=8B=E8=A9=A6=E9=A8=93=E3=82=92=E8=B6=B3=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Test_DiagnosticMetadata.cs | 25 ++++++++++++++++++ .../Diagnostics/DiagnosticMetadataTests.cs | 26 +++++++++++++++++++ 2 files changed, 51 insertions(+) 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. ///