Skip to content

ExportCodeFixProvider should be marked as Inherited = false #69809

@mavasani

Description

@mavasani

Originally reported by @bradwilson, related to dotnet/roslyn-analyzers#6903

I placed this attribute on a base class:

[ExportCodeFixProvider(LanguageNames.CSharp)]
public abstract class CSharpCodeFixProvider : CodeFixProvider
{
    // ...
}

And then removed it from the derived classes:

[Shared]
public class ActualFixer : CSharpCodeFixProvider
{
    // ...
}

Tests using Microsoft.CodeAnalysis.CSharp.CodeFix.Testing now shifted from passing to failing because the fixer did not run.

It appears this attribute does not support inheritance, despite being listed as inheritance being permitted (or perhaps the issue is with the testing library, I'm not sure at this point).

As such, I recommend you mark this attribute as Inherited = false so that developers will know that the mechanism for discovering this attribute does not check inherited classes.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions