2
Vote

AdditionalLocations Does Not Seem To Work

description

I've created a diagnostic analyzer, and I want to have more than one code fix related to the diagnostic. So I tried to pass in additional locations in the Diagnostic.Create() call via the additionalLocations parameter, but in the code fix class, the AdditionalLocations property is always an empty list. I've attached a sample diagnostic project.
  • Uncomment lines 75-77 in IsOneWayOperationAnalyzer.cs, and comment out lines 73 and 74.
  • Put a breakpoint on line 28 in IsOneWayOperationMakeIsOneWayFalseCodeFix.cs.
  • Run the app under the debugger, and create a project in the new VS instance.
  • Reference System.ServiceModel
  • Make this class:

    public class MyService
    {
    [OperationContractAttribute(IsOneWay = false)]
    public string MyOperation() { return null; }
    }
  • Change false to true for IsOneWay. Eventually you should see the red squiggle
  • When you click on the squiggle, you should hit the breakpoint. If you look at AdditionalLocations for diagnostic, it's empty.

file attachments

comments

manishv wrote Apr 7 at 10:33 PM

Thank you for reporting this issue. This seems like a bug in the Roslyn IDE layer (not OSS) and I have created an internal bug to track this issue. Once an updated Roslyn End User Preview with the fix is available, we will post an update here.
Thank you again for the valuable feedback/report, really appreciate your help!