Skip to content

Behavior of "var" quickinfo and nullable reference types #63959

@ryzngard

Description

@ryzngard

We have had a few reports spread across feedback tools. I'd like to create a specific issue to track the discussion and user impact. This is strongly related to discussion in #53078 and user feedbacks such as https://developercommunity.visualstudio.com/t/Incorrect-type-deduction-tooltip-for-var/

This is specifically on why we show string? in cases where using var is assigned from a string value. For example:

var x = "Split";
var splitString = x.ToString();

This does not apply only to string, but any reference type assignment. Current IDE behavior is captured below:

9d83b9e5-db08-430d-b66f-91c2adbbfe10

A few important things about this issue:

  1. Method Returns string[] But var types as string[]? #53078 does a great job of the discussion on why the behavior exists, and the thought put into this as it adheres to language design. This is not a proposal to change the language design here, but rather how we as a tooling team can help users understand the design better.
  2. This will be a good issue for tracking any confusion/feature requests in this area. That way we can gauge user interest in wanting this feature for prioritization.

I will mark this as "Needs Proposal" to signify that there is not a clear design moving forward, and we will see track closely user feedback to help us prioritizing coming up with a design to help users.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Complete

Relationships

None yet

Development

No branches or pull requests

Issue actions