In this section, we will show you how to a write a custom FixAll code fix provider to batch fix diagnostics. We will use the code fix implemented in the first recipe of this chapter to Remove unused local
. As shown in that recipe, removal of an unused local might have different code fixes based on whether the enclosing local declaration statement declares a single or multiple variables. Additionally, we might have multiple unused locals declared in the single statement, and if all the locals declared in a statement are unused, the batch fix should remove the entire statement. Hence, we cannot use the well-known batch fixer. For example, for the following code, the batch fix should delete the entire first two local declaration statements, but only the declarator for d
in the third declaration statement:
public class MyClass { public static void M() { int a = 0; // CS0219 for 'a' int b = 1...