Roslyn: CS0121 (ambiguous invocation) thrown when enabling nullable reference types for parts of solution

Created on 27 Nov 2019  路  5Comments  路  Source: dotnet/roslyn

Version Used: VS 2019 (16.3.10)

Steps to Reproduce:
Open unit test in attachment: AmbiguityRepro.zip
Try compiling the code.

Expected Behavior:
The compilation works without issues.

Actual Behavior:
CS0121 is returned in Output pane (not in Error List pane). The compiler thinks the call to ExecuteAsync is ambiguous (apparently to itself, since there is no other method).

Explanation I can guess at
This has something to do with setting <Nullable>enable</Nullable> on the Infrastructure project and keeping it disabled on the Implementation project. Then it errors out. If I keep nullable reference types disabled on both projects, the solution compiles. If I enable NRT on both, it compiles as well.

Could someone explain why this is happening? I came across this behavior when experimentally enabling NRT on our production code (on a few projects at a time). Also, sorry for weird naming, I just threw together the fastest repro I could, it kinda reflects our code organization.

4 - In Review Area-Compilers Bug New Language Feature - Nullable Reference Types

Most helpful comment

Fix is in for 16.5p3

All 5 comments

Sorry, we've not been able to take a look at this yet. Would it be possible to provide a self-contained repro, for example as a link to a sharplab repro or snippet?

As far as I understand the problem it requires multiple projects in a solution to interact. One of them is nullable enable and one is not. I don't think I can minimize it more than the repro in the attachment above.

Ah, makes sense. Thanks

Took me several hours to figure out that I had the same issue on a private project and then found this issue.
https://github.com/BlowaXD/csharp-nullable-weird-behavior

Hope this helps.

Thanks

Fix is in for 16.5p3

Was this page helpful?
0 / 5 - 0 ratings