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
3 changes: 3 additions & 0 deletions src/NetEvolve.Analyzer/Documentation/UseLangwordSuppressor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@
[DiagnosticAnalyzer(LanguageNames.CSharp)]
internal sealed class UseLangwordSuppressor : NetEvolveSuppressorBase
{
// Stryker disable all : static initializer, not killable under the MTP runner (Stryker 5.0.0)
internal static readonly SuppressionDescriptor Suppression = new(
id: DiagnosticIds.NES0001,
suppressedDiagnosticId: "MA0154",
justification: "NE0007 already reports this <c>/<code> keyword usage; suppressed to avoid a duplicate "
+ "diagnostic from Meziantou.Analyzer."
);

// Stryker restore all

/// <inheritdoc />
public override ImmutableArray<SuppressionDescriptor> SupportedSuppressions { get; } =
ImmutableArray.Create(Suppression);
Expand Down
14 changes: 14 additions & 0 deletions src/NetEvolve.Analyzer/Helpers/CSharpKeywords.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ internal static class CSharpKeywords
/// denotes the absence of a return type rather than an actual type, and is commonly referenced the
/// same way as <see langword="true"/>/<see langword="false"/>/<see langword="null"/>.
/// </summary>
// Stryker disable all : static initializer, not killable under the MTP runner (Stryker 5.0.0)
public static readonly ImmutableHashSet<string> ReservedKeywords = ImmutableHashSet.Create(
StringComparer.Ordinal,
"abstract",
Expand Down Expand Up @@ -85,12 +86,15 @@ internal static class CSharpKeywords
"while"
);

// Stryker restore all

/// <summary>
/// Keywords that carry special meaning only in specific syntactic contexts (query clauses, patterns,
/// declarations); the same spelling is a valid identifier everywhere else. Native type names
/// (<see cref="nint"/>, <see cref="nuint"/>) are intentionally excluded for the same reason as in
/// <see cref="ReservedKeywords"/>.
/// </summary>
// Stryker disable all : static initializer, not killable under the MTP runner (Stryker 5.0.0)
public static readonly ImmutableHashSet<string> ContextualKeywords = ImmutableHashSet.Create(
StringComparer.Ordinal,
"add",
Expand Down Expand Up @@ -136,12 +140,15 @@ internal static class CSharpKeywords
"yield"
);

// Stryker restore all

/// <summary>
/// Native/predefined C# type names, deliberately excluded from <see cref="ReservedKeywords"/> and
/// <see cref="ContextualKeywords"/>. <see langword="void"/> is intentionally excluded here too — it denotes the
/// absence of a return type rather than an actual type, and stays classified under
/// <see cref="ReservedKeywords"/>.
/// </summary>
// Stryker disable all : static initializer, not killable under the MTP runner (Stryker 5.0.0)
public static readonly ImmutableHashSet<string> NativeTypeKeywords = ImmutableHashSet.Create(
StringComparer.Ordinal,
"bool",
Expand All @@ -164,6 +171,8 @@ internal static class CSharpKeywords
"nuint"
);

// Stryker restore all

/// <summary>
/// Common BCL value types that, like <see cref="NativeTypeKeywords"/>, are frequently misdocumented as
/// <c>&lt;c&gt;type&lt;/c&gt;</c> instead of <c>&lt;see cref="type"/&gt;</c>. These are ordinary types, not
Expand All @@ -172,6 +181,7 @@ internal static class CSharpKeywords
/// see <see cref="ConditionalBclTypeMinimumVersions"/> — since they only exist on the target frameworks
/// that ship them.
/// </summary>
// Stryker disable all : static initializer, not killable under the MTP runner (Stryker 5.0.0)
public static readonly ImmutableHashSet<string> WellKnownBclTypeNames = ImmutableHashSet.Create(
StringComparer.Ordinal,
"Guid",
Expand All @@ -180,6 +190,8 @@ internal static class CSharpKeywords
"TimeSpan"
);

// Stryker restore all

/// <summary>
/// BCL value types that, unlike <see cref="WellKnownBclTypeNames"/>, are not available on every target
/// framework the analyzer itself must run on (<c>netstandard2.0</c>) — each key maps to the lowest unified
Expand All @@ -190,8 +202,10 @@ internal static class CSharpKeywords
/// unconditionally. Different entries are free to name different minimum versions — nothing here assumes
/// they all shipped together.
/// </summary>
// Stryker disable all : static initializer, not killable under the MTP runner (Stryker 5.0.0)
public static readonly ImmutableDictionary<string, int> ConditionalBclTypeMinimumVersions = ImmutableDictionary
.Create<string, int>(StringComparer.Ordinal)
.Add("DateOnly", 6)
.Add("TimeOnly", 6);
// Stryker restore all
}
3 changes: 3 additions & 0 deletions src/NetEvolve.Analyzer/Helpers/CancellationTokenCallSites.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ LocalFunctionStatementSyntax localFunction
return HasUsableCancellationToken(semanticModel, localFunction.Body, localFunction.ExpressionBody?.Expression);
}

// Stryker disable all : static initializer, not killable under the MTP runner (Stryker 5.0.0)
private static readonly string[] SupportedAsyncReturnTypeMetadataNames =
{
"System.Threading.Tasks.Task",
Expand All @@ -183,6 +184,8 @@ LocalFunctionStatementSyntax localFunction
"System.Collections.Generic.IAsyncEnumerable`1",
};

// Stryker restore all

private static bool IsSupportedAsyncReturnType(ITypeSymbol returnType)
{
if (returnType is not INamedTypeSymbol namedType)
Expand Down
3 changes: 3 additions & 0 deletions src/NetEvolve.Analyzer/Helpers/TargetFrameworkMonikers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@ internal static class TargetFrameworkMonikers
// — ".NETFramework" ("net472", "net48"), ".NETStandard" ("netstandard2.0", "netstandard2.1"), and
// ".NETCoreApp" ("netcoreapp3.1") — never match: each has a non-digit character glued right after "net",
// where this pattern requires a digit.
// Stryker disable all : static initializer, not killable under the MTP runner (Stryker 5.0.0)
private static readonly Regex UnifiedTfmPattern = new(
@"^net(?<major>\d+)\.\d+",
RegexOptions.IgnoreCase | RegexOptions.CultureInvariant,
TimeSpan.FromSeconds(1)
);

// Stryker restore all

/// <summary>
/// Splits a comma-separated target framework list — <c>BuildProperty.TargetFrameworks</c>'s re-joined
/// form of MSBuild's semicolon-separated <c>$(TargetFrameworks)</c> (see there for why) — into its
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ private static bool IsDeferredScope(SyntaxNode node) =>

// Exact-type match, not interface implementation: a subclass overriding 'ClearItems()' also implements
// 'ICollection<T>' but its 'Clear()' can carry side effects this rule must not delete.
// Stryker disable all : static initializer, not killable under the MTP runner (Stryker 5.0.0)
private static readonly string[] AllowedCollectionMetadataNames = new[]
{
"System.Collections.ArrayList",
Expand All @@ -240,6 +241,8 @@ private static bool IsDeferredScope(SyntaxNode node) =>
"System.Collections.ObjectModel.ObservableCollection`1",
};

// Stryker restore all

private static bool IsAllowedCollectionType(ITypeSymbol type, Compilation compilation) =>
AllowedCollectionMetadataNames
.Select(compilation.GetTypeByMetadataName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@ namespace NetEvolve.Analyzer.Style;
[DiagnosticAnalyzer(LanguageNames.CSharp)]
internal sealed class RequireNumericLiteralSuffixSuppressor : NetEvolveSuppressorBase
{
// Stryker disable all : static initializer, not killable under the MTP runner (Stryker 5.0.0)
internal static readonly SuppressionDescriptor Suppression = new(
id: DiagnosticIds.NES0002,
suppressedDiagnosticId: "S818",
justification: "NE0012 already reports this numeric literal; suppressed to avoid a duplicate, "
+ "conflicting diagnostic from SonarAnalyzer.CSharp."
);

// Stryker restore all

/// <inheritdoc />
public override ImmutableArray<SuppressionDescriptor> SupportedSuppressions { get; } =
ImmutableArray.Create(Suppression);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ CancellationToken cancellationToken
// Span<T>/ReadOnlySpan<T>. Array types are handled separately (any element type, any rank). This is a
// pragmatic subset, not the full collection-expression conversion spec (custom [CollectionBuilder] types are
// not recognized), but covers what a guard-clause return is realistically going to need.
// Stryker disable all : static initializer, not killable under the MTP runner (Stryker 5.0.0)
private static readonly ImmutableHashSet<(string Namespace, string Name)> CollectionExpressionTargetTypes =
ImmutableHashSet.Create(
("System.Collections.Generic", "List"),
Expand Down Expand Up @@ -338,6 +339,8 @@ CancellationToken cancellationToken
("System", "ReadOnlySpan")
);

// Stryker restore all

// 'yield break;' is required (and the only legal early-exit) in an iterator method — 'return value;' does
// not compile there at all, regardless of return type. 'return;' is legal for a void-returning method, and
// also for an async method returning (non-generic) Task or ValueTask. For a real T, an async method
Expand Down
Loading