Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,31 @@ public class Test_DiagnosticMetadata
/// </summary>
private static readonly Regex Placeholder = new(@"\{\d+\s*(?:,\s*-?\d+\s*)?(?::[^}]*)?\}");

/// <summary>
/// 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.
/// </summary>
/// <remarks>
/// 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.
/// </remarks>
[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));
}

/// <summary>
/// Two diagnostics sharing a title means at least one of them is named after the other.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,32 @@ public class DiagnosticMetadataTests
/// </summary>
private static readonly Regex Placeholder = new(@"\{\d+\s*(?:,\s*-?\d+\s*)?(?::[^}]*)?\}");

/// <summary>
/// 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.
/// </summary>
/// <remarks>
/// 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.
/// </remarks>
[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));
}

/// <summary>
/// Two diagnostics sharing a title means at least one of them is named after the other.
/// </summary>
Expand Down
Loading