Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CA1515 code fix should not fix suppressed warnings #7546

Open
dnperfors opened this issue Jan 24, 2025 · 0 comments
Open

CA1515 code fix should not fix suppressed warnings #7546

dnperfors opened this issue Jan 24, 2025 · 0 comments

Comments

@dnperfors
Copy link
Contributor

Analyzer

Diagnostic ID: CA1515: Consider making public types internal

Analyzer source

SDK: Built-in CA analyzers in .NET 9 SDK or later

Version: SDK 9.0.102

Describe the bug

When opening our test project with .NET 9, several warnings appear saying that test classes need to be internal, instead of public. We use XUnit where this is not the case. Using xunit.analyzers we are able to suppress the warnings for the testclasses.
In the test project there are other classes that could be made internal, and when we use the code fix "Make the public type internal" on the whole project or solutions all types are marked as internal, even the test classes that no longer showed the warning.

Steps To Reproduce

  1. Create a test project with xunit and xunit.analyzers
  2. Add a test in a public class
  3. Add a helper class and make it public
  4. Build the project and notice that the helper class gets the warning
  5. Run "Make the public type internal" code fix on the whole project

Expected behavior

The test classes that have CA1515 suppressed should not be fixed by the code fix

Actual behavior

The test classes that have CA1515 suppressed are 'fixed' by the code fix, but will now throw an error from xunit saying that test classes should be public.

Additional context

Additional libraries used:

  • xunit 2.9.3
  • xunit.analyzers 1.19.0

Related to #7192

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant