Roslyn: "var foo = (null," autocompletes "null" to Nullable

Created on 18 Oct 2018  路  15Comments  路  Source: dotnet/roslyn

The intellisense autocompletion (set to its default state) for C# projects does not handle tuples with null as a value correctly.

Typing in the following

var foo = (null,

causes null to be changed to Nullable as soon as the , is typed in.

_This issue has been moved from https://developercommunity.visualstudio.com/content/problem/325201/var-foo-null-autocompletes-null-to-nullable.html

Area-IDE Bug Developer Community

All 15 comments

var foo = (null can't start a legal statement. That's because the compiler will not allow 'null' there as there's no type to convert it to.

_I filed this via the visual studio feedback_

You are correct that it's not legal, that was an incorrect, contrived case of the bug I was experiencing and a poor attempt at simplifying it.

At any rate, I can't reproduce it under 15.9 Preview 3, so yay!

Edit: see below

Thanks @CyrusNajmabadi
@mqudsi glad your concern is addressed, closing this issue

using System;
public class C {
    public void M() {
        var data = (null, null);
    }
}

public class var {
    public static implicit operator var((Object, Object) details) { throw null; }
}

@sharwell

At any rate, I can't reproduce it under 15.9 Preview 3, so yay!

image

@Neme12 Ah, thanks. Thread moved ahead while I was typing the example.

@sharwell 's case is clearly not realistically going to happen :) Though the pedantry is appreciated :D

I'm sorry, I was too hasty.

I rgd through my codebase and was able to reproduce it after all:

image

The definition of CurrentElement:

        private (Control Control, Note Note) CurrentElement;

@mqudsi Can you please make a minimum repro that we can look at?
I still cannot reproduce this:
image
Thanks

@Neme12 is it possible because of hte next line? It may be that his code is getting parsed as a cast. and thus only showing types within it.

Paging @jcouv

Yes, you're right. It's the next line:
image

I repro this as well:

image

Likely due to parsing as a cast.

@mqudsi Definitely a bug. And definitely a realistic user scenario that should be addressed. @jinujoseph to assign/milestone according.

Thanks for the report!

Thanks for figuring it out, @CyrusNajmabadi.

Was this page helpful?
0 / 5 - 0 ratings