Skip to content

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

@PClavier70

Description

@PClavier70

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions