I have a source generator which creates a warning, I know how this warning would be fixed and could apply this fix automatically if given the opportunity.
https://github.com/dotnet/roslyn/blob/main/docs/features/source-generators.md seems to suggest it is possible or was at least in consideration at some point:
This works in the same way as analyzers and codefix testing. You add a class like the following:
Another hint that this should work is here https://devblogs.microsoft.com/dotnet/introducing-c-source-generators/
How do I ship my own Source Generator?
Source Generators can be shipped as NuGet packages, just like Analyzers today. In fact, they use the same “plumbing” as Analyzers. If you’ve ever shipped an Analyzer, then you can easily ship a Source Generator.
If you then read Visual Studio's documentation: https://learn.microsoft.com/en-us/visualstudio/code-quality/use-roslyn-analyzers?view=vs-2019
Hidden' severity versus 'None' severity
Hidden severity rules that are enabled by default differ from disabled or None severity rules in certain aspects.
- If any code fix is registered for a Hidden severity rule, Visual Studio offers the fix as a light bulb code-refactoring action even if the hidden diagnostic isn't visible to the user. The fix isn't offered
- if the severity rule is disabled as None. Hidden severity rules can be bulk configured by entries that set rule severity of multiple analyzer rules at once in an EditorConfig file. None severity rules can’t be configured this way. Instead, they must be configured through entries that set rule severity in an EditorConfig file for each rule ID.
Both of these bits of information about Visual Studios codefix's suggest you should be able to take a second diagnostic that includes the autocorrect replacement text but I can't find any information about how that is done as there would need to be some metadata to link them together?
Does anyone have more information on how this could be done?