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 make sense for top-level statements #33297

Closed
1 of 3 tasks
PClavier70 opened this issue Jan 3, 2023 · 4 comments
Closed
1 of 3 tasks

CA1852 doesn't make sense for top-level statements #33297

PClavier70 opened this issue Jan 3, 2023 · 4 comments
Assignees

Comments

@PClavier70
Copy link

Description

with the addition/recent change to CA1852 it is flagging that the program class needs to be sealed but if we are using Top-Level Statements there is no program class. Thus we have to add a pragma ignore for this new warning.

Version

.NET 7

Previous behavior

no warning

New behavior

warning

Type of breaking change

  • Binary incompatible: Existing binaries may encounter a breaking change in behavior, such as failure to load or execute, and if so, require recompilation.
  • Source incompatible: When recompiled using the new SDK or component or to target the new runtime, existing source code may require source changes to compile successfully.
  • Behavioral change: Existing binaries may behave differently at run time.

Reason for change

no idea

Recommended action

either fix top level statement hidden classes to be sealed or not based on this rule or fix the rule to recognize top level statements.

Feature area

C#, Code analysis

Affected APIs

No response

@PClavier70 PClavier70 added breaking-change Indicates a .NET Core breaking change doc-idea labels Jan 3, 2023
@dotnet-bot dotnet-bot added the ⌚ Not Triaged Not triaged label Jan 3, 2023
@gewarren gewarren changed the title [Breaking change]: CA1852 doesn't make sense for top-level statements Jan 4, 2023
@gewarren
Copy link
Contributor

gewarren commented Jan 4, 2023

@mavasani I think this should be transferred to the roslyn-analyzers repo. It looks like CA1852 is enabled with the "Recommended" rules for .NET 7.

@mavasani
Copy link
Contributor

mavasani commented Jan 5, 2023

@Youssef1313 I think this was fixed recently, do you recall?

@mavasani
Copy link
Contributor

mavasani commented Jan 5, 2023

Ah this is fixed with dotnet/roslyn-analyzers#6278

@mavasani mavasani closed this as completed Jan 5, 2023
@dotnet-bot dotnet-bot removed the ⌚ Not Triaged Not triaged label Jan 5, 2023
@gewarren
Copy link
Contributor

gewarren commented Jan 5, 2023

Thanks @mavasani. Can you edit the title of dotnet/roslyn-analyzers#6141 to say CA1852 instead of CS1852 so it comes up in a search?

@gewarren gewarren added product-feedback and removed doc-idea breaking-change Indicates a .NET Core breaking change labels Jan 5, 2023
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

4 participants