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

CA1852 doesn't show in Visual Studio; only shows in CLI build #7511

Open
segevfiner opened this issue Dec 18, 2024 · 1 comment
Open

CA1852 doesn't show in Visual Studio; only shows in CLI build #7511

segevfiner opened this issue Dec 18, 2024 · 1 comment

Comments

@segevfiner
Copy link

Analyzer

Diagnostic ID: CA1852: Seal internal types

Analyzer source

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

Version: SDK 9.0.101

Describe the bug

Rule CA1852 shows up on CLI build. but doesn't show in Visual Studi.

Steps To Reproduce

  1. Try this code on a blank new Console App .NET 8/9 SDK project:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    internal class Foo
    {
        private FileStream _bla;

        public Foo()
        {
            _bla = new FileStream(@"c:\temp.txt", FileMode.Open);
        }
    }
}
  1. On Visual Studio you will see a CA1001 warning but no CA1852.
  2. On a CLI build you will see both warnings.

Expected behavior

You get both warnings in both scenarios.

Actual behavior

You don't get CA1852 in Visual Studio. Only CA1001.

Additional context

Windows 11 10.0.22631.0 x64
Visual Studio 2022 17.12.3

Visual Studio Screenshot
CLI Screenshot

@marco-carvalho
Copy link

I have a project with at least +1000 warnings of CA1852, but I can't auto fix it (like I can with CA1805, CA1825, CA1872). There is a way to apply a autofix to resolve all CA1852 in a solution?

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

2 participants