Repository navigation
Description
Problem
Related: microsoft/testfx#12528.
When CA1515 (Consider making public types internal) is explicitly enabled, it flags public MSTest test classes in executable test projects. MSTest's default discovery requires these classes to be public, so following the diagnostic can prevent tests from being discovered. Users enabling all analyzer rules, especially with warnings treated as errors, currently need to suppress the diagnostic themselves.
MSTest does support opting into internal test discovery with [assembly: DiscoverInternals], but existing projects should not have to change their discovery configuration just to follow this diagnostic. This request is about CA1515 when enabled, not changing its default severity.
The current rule implementation filters by output kind and reports public named types without a test-class exception.
Request
Could CA1515 recognize MSTest test classes and avoid recommending an accessibility change that conflicts with their discovery requirements? The concrete case is a public class marked with Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute in an executable test project.
Ideally, unrelated public helper/application types would remain analyzable rather than disabling CA1515 for the entire project.
Cross-framework policy and alternative
Special-casing only MSTest in an SDK-shipped analyzer would give it preferential treatment over other test frameworks. Please consider whether an upstream exemption should follow a consistent policy for all test frameworks with public-visibility requirements, or whether framework-aware suppression should remain the responsibility of each framework's analyzers.
We are keeping microsoft/testfx#12528 open to consider a targeted DiagnosticSuppressor in MSTest.Analyzers, independently of the SDK decision. That approach can also help users of existing SDK/analyzer versions.
Prior discussion
dotnet/roslyn-analyzers#7192 (CA1515 should ignore test projects) already discusses this across frameworks, including MSTest. That repository is now archived; this issue brings the MSTest request and the cross-framework ownership question to the current analyzer repository.
Activity
github-actions commentedon Nov 19, 2026
🎯 Agentic Issue Triage
Triage Assessment:
@krwq| @dotnet/dotnet-analyzershigh- The issue directly concerns analyzer rule CA1515 in the NetAnalyzers area.Similar issues: none
➡️ Summary: The issue asks CA1515 to avoid flagging public MSTest test classes that must stay public, raising a cross-framework policy question. The team should decide whether to exempt test frameworks generally or leave it to framework suppressors.