How it works...

Code fix providers are VS IDE extensions that can register code actions for fixing compiler or analyzer diagnostics of specified diagnostic IDs. The primary APIs on CodeFixProvider are:

  • FixableDiagnosticIds property (abstract): An immutable array of diagnostics IDs that the code fix provider can fix. Any compiler or analyzer diagnostic that is reported with one of the specified diagnostic IDs is a candidate for a code fix from the provider, and RegisterCodeFixesAsync is called with each such diagnostic.
  • RegisterCodeFixesAsync method (abstract): This is the method to register code actions for fixable diagnostics. This method is invoked by the code fix engine whenever it needs to compute the code actions for diagnostics reported ...

Get Roslyn Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.