Metalama / / API Documentation / Aspect API / Metalama.​Framework.​Code­Fixes

Namespace Metalama.Framework.CodeFixes

This namespace allows you to suggest code fixes and code refactorings, i.e. changes to source code that appear in the lightbulb or screwdriver menu of your IDE.

Code fixes can be instantiated using the static methods of the CodeFixFactory class.

To add code fixes to a diagnostic, use the IDiagnostic.WithCodeFixes method.

To suggest a code refactoring without reporting a diagnostic, use the Suggesttext=IDiagnosticSink.Suggest> method.

Class diagram

classDiagram class IDiagnosticSink { Report() Suppress() Suggest() } class IDiagnostic { CodeFixes WithCodeFixes(CodeFixes[]) } class CodeFix { Id Title } class CodeFixFactory { ApplyAspect()$ AddAttribute()$ RemoteAttribute()$ CreateCustomCodeFix(Func~ICodeFixBuilder,Task~)$ } class ICodeFixBuilder { ApplyAspectAsync() AddAttributeAsync() RemoteAttributeAsync() } ICodeFixBuilder <-- CodeFixFactory : custom code fixes\nimplemented with CodeFix <-- CodeFixFactory : creates IDiagnostic <-- CodeFix: add to IDiagnosticSink <-- CodeFix: suggest to IDiagnosticSink <-- IDiagnostic: reports to

Namespace members



Represents a modification of the current solution, including the Title of transformation. To instantiate a single-step code fix, use CodeFixFactory. To instantiate a more complex code fix, use the constructor.


Creates instances of the CodeFix class.



Argument of the delegate passed to CodeFix constructor. Exposes methods that allow to modify the current solution.


Gets the context in which a code action executes. Exposed by ICodeActionBuilder. If you implement your own code action using the Metalama SDK, you should cast this interface to ISdkCodeActionContext.