Skip to content

Repository Quality: Roslyn Analyzer Suppression HygieneΒ #16367

Description

@github-actions

🎯 Repository Quality Improvement Report β€” Roslyn Analyzer Suppression Hygiene

Analysis Date: 2026-08-17 | Strategy Type: Custom

Executive Summary

The codebase contains 297 #pragma warning disable directives (238 in src/) and ~40 SuppressMessage/NoWarn entries. Most are justified, but five categories are actionable:

  1. Global CA1416 suppression in Directory.Build.props silences all platform-compatibility warnings repo-wide β€” vstest is cross-platform, so this hidden safety net is dangerous.
  2. 11 CS8618 suppressions in [DataContract] serialization constructors that can be removed using C# 11 required modifier or nullable field annotations.
  3. 2 IDE0060 suppressions tagged with explicit TODO comments that were never resolved.
  4. TestServiceLocator.cs β€” #if DEBUG scaffolding with RS0016+RS0037 suppressions and stale TODOs leaked into the ObjectModel NuGet's debug build.
  5. Global RS0037 suppression means PublicAPI.Shipped.txt entries across all projects lack nullability annotations.

πŸ€– Suggested Improvement Tasks

Task 1: Remove global CA1416 suppression; add per-callsite platform guards

Priority: High | Effort: Medium

Remove CA1416 from Directory.Build.props line 39 (<NoWarn>$(NoWarn);CA1416;RS0037</NoWarn>). Rebuild; annotate each reported violation with [SupportedOSPlatform("windows")] or guard with if (OperatingSystem.IsWindows()).


Task 2: Replace CS8618 pragma blocks with required or nullable annotations

Priority: High | Effort: Medium

All 11 suppressions follow the DataContract parameterless-constructor pattern. Apply C# 11 required modifier to fields that must be set, or change field type to nullable where they are genuinely optional. Affected files include TestCase.cs, TestProperty.cs, Framework.cs, DiscoveryCriteria.cs, TestRunCompleteEventArgs.cs, TestRunStatistics.cs, DataCollectionEventArgs.cs, TestCaseEvents.cs, and DataCollectionEnvironmentContext.cs.


Task 3: Resolve two stale TODO + IDE0060 suppressions

Priority: Medium | Effort: Small

  • TestRequestSender.cs:850 β€” ConvertToAttachDebuggerInfo has unused message and protocolVersion parameters. The comment says "There is nothing to do differently based on those versions." Remove the unused parameters and update call sites.
  • VersionAttribute.cs β€” Store the unused version parameter: public int Version { get; } = version; β€” eliminates both the pragma and the TODO.

Task 4: Delete or graduate TestServiceLocator.cs

Priority: Medium | Effort: Small

src/Microsoft.TestPlatform.ObjectModel/TestServiceLocator.cs is #if DEBUG-only scaffolding shipping in the ObjectModel NuGet debug build. It suppresses RS0016 and RS0037, and carries two unresolved TODOs (// TODO: Make this internal, // TODO: Add enable flag). Either convert it to a proper internal service locator with tests, or delete it.


Task 5: Per-project RS0037 remediation starting with ObjectModel

Priority: Low | Effort: Large

Remove the global RS0037 suppression from Directory.Build.props incrementally by enabling it per project. Start with Microsoft.TestPlatform.ObjectModel β€” annotate PublicAPI.Shipped.txt entries with ? where applicable. This makes the public API tracker fully exploit C# nullability.


πŸ“Š Historical Context (last 5 runs)

Date Focus Area Type
2026-08-14 argument-validation-consistency-and-modern-guard-adoption Custom
2026-08-13 test-asset-project-hygiene-centralized-property-adoption Custom
2026-08-12 reflection-anti-patterns-private-setter-bypass Custom
2026-08-11 conditional-compilation-dead-code-and-legacy-symbol-hygiene Custom
2026-08-10 permanently-ignored-test-coverage-debt Custom

Next analysis: 2026-08-18

Generated by Repository Quality Improver Β· 54.6 AIC Β· βŒ– 6.53 AIC Β· ⊞ 8.9K Β· β—·

  • expires on Aug 19, 2026, 4:04 AM UTC

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions