Visitar URL original
"Enable AOT" code fix for DapperAotNotEnabled throws NotImplementedException · Issue #234 · DapperLib/DapperAOT · GitHub
Skip to content

"Enable AOT" code fix for DapperAotNotEnabled throws NotImplementedException #234

Open

Description

@andrejskvorc

DapperCodeFixes (src/Dapper.AOT.Analyzers/CodeAnalysis/DapperCodeFixes.cs on main) registers an "Enable AOT" code fix for DapperAotNotEnabled, and the batch fixer also exposes it as a fix-all action. The action's body is a stub:

private static Task<Document> GlobalEnableAOT(CodeFixContext context, SyntaxToken syntax, CancellationToken cancellation)
{
    throw new NotImplementedException();
}

When a developer picks the light-bulb fix, the IDE reports an exception and the code is not changed. "Fix all in solution" does the same.

Suggested fix (either one):

  1. Implement it: add [module: DapperAot] to the document's compilation unit (after the usings, adding using Dapper; when it is missing, or using the fully qualified Dapper.DapperAot). Return the updated document. A CSharpCodeFixTest<DapperAnalyzer, DapperCodeFixes, DefaultVerifier> can check the result: the diagnostic is gone and the attribute is present once, with fix-all not adding duplicates.
  2. Until it is implemented, stop registering the fix (return early in RegisterCodeFixesAsync or remove the ID from FixableDiagnosticIds), so the IDE never offers an action that throws.

Happy to send a PR for option 1 with the code-fix test if that's the behaviour you want.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    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