Metalama 1.0 / / Metalama 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() } CodeFixFactory --> ICodeFixBuilder : custom code fixes\nimplemented with CodeFixFactory --> CodeFix : creates CodeFix --> IDiagnostic: add to CodeFix --> IDiagnosticSink: suggest to IDiagnostic --> IDiagnosticSink: reports to

Namespace members

Classes

CodeFix

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.

CodeFixFactory

Creates instances of the CodeFix class.

Interfaces

ICodeActionBuilder

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

ICodeActionContext

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.