Skip to content

Check that [Virtual] is not used on sealed/abstract/static classes#6486

Open
Tayrtahn wants to merge 1 commit intospace-wizards:masterfrom
Tayrtahn:analyzer/explicit-virtual-exclusive
Open

Check that [Virtual] is not used on sealed/abstract/static classes#6486
Tayrtahn wants to merge 1 commit intospace-wizards:masterfrom
Tayrtahn:analyzer/explicit-virtual-exclusive

Conversation

@Tayrtahn
Copy link
Member

Expands the ExplicitVirtualAnalyzer to also check that the [Virtual] attribute is not used in combination with sealed, abstract, or static. Doing so is now reported as an error.

Resolves #6412.

Also slightly tweaked the analyzer to more efficiently lookup the attribute symbol and reduce code duplication by using an existing helper method to check for the attribute.

Also includes tests to verify both the new and original diagnostic rules.

@Tayrtahn Tayrtahn added T: New Feature Type: New feature Priority: 3-Not Required A: Roslyn Components Roslyn analyzers, source generators, code fixes labels Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A: Roslyn Components Roslyn analyzers, source generators, code fixes Priority: 3-Not Required T: New Feature Type: New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

using [Virtual] on a sealed/uninstantiable class should be an error

1 participant