Roslyn: Incorrect errors reported, and broken intellisense for heavily overloaded method

Created on 27 Nov 2016  路  4Comments  路  Source: dotnet/roslyn

Version Used:
Visual C# 2017 RC
Steps to Reproduce:

_I am sorry if this is a duplicate but I didn't find anything that seemed to match it._

I have an API that exposes a method with 38 distinct overloads each varying by taking a generic delegate with a different number of type parameters (all of the System.Func and System.Action delegates taking more than a single argument and a few extra ones which are specified in precisely the same manner but go up to T20).
Ever since Visual Studio 15 Preview 5 and now up through 2017 RC, I get spurious errors at calls to these methods. The code builds, runs, and passes its unit tests, but the language service reports syntax errors that are erroneous. Furthermore, the IDE's quick info, tooltips, and Go To Definition command indicate an overload taking a delegate of lesser arity. This code was written in C# 5.0 and C# 6.0.
Example:
image

Note that in the above the tooling indicates that I am calling the overload taking a
```C#
System.Action

But the method actually called is one taking a 
```C#
System.Action<T1, T2, T3, T4, T5>

However where it gets weird is that if I simply edit the file the errors go away, but only temporarily, coming back at random as I navigate across the project.
Example:
image

Note that all I did was add a single blank space after the opening brace of the lambda expression. And this not only caused the errors to vanish but causes the right overload to be displayed.

For reference, all of the overloads are in the following class https://github.com/lasiproject/LASI/blob/master/LASI.Core/Analysis/Binding/Experimental/SequentialPatterns/SequenceMatchCaseClauses.cs

The errors re-appear whenever I close and re-open the file.
Expected Behavior:
No errors are reported.
Actual Behavior:
Spurious syntactic and semantic errors are displayed (builds and runs correctly)

Area-Compilers Bug

Most helpful comment

Thanks for reporting.
I believe this is a repro of #14649. The fix #14852 went into master.

All 4 comments

This looks almost identical to: https://github.com/dotnet/roslyn/issues/14981

A similar parsing issue with lambdas. And it only shows up some of the time.

Pinging @OmarTawfik about this.

@CyrusNajmabadi thank you for the prompt reply. I guess my search for existing issues was not as thorough as I had thought. As you say

This is fairly terrifying :)

Update:
I disabled FSA (and restarted VS for good measure) and I am still seeing this behavior.

Assigning to @OmarTawfik to investigate if this is a symptom of #14981

Thanks for reporting.
I believe this is a repro of #14649. The fix #14852 went into master.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

joshua-mng picture joshua-mng  路  3Comments

marler8997 picture marler8997  路  3Comments

OndrejPetrzilka picture OndrejPetrzilka  路  3Comments

AdamSpeight2008 picture AdamSpeight2008  路  3Comments

DavidArno picture DavidArno  路  3Comments