Skip to content

Explicit cast options in intellisense in C # #46266

@vsfeedback

Description

@vsfeedback

This issue has been moved from a ticket on Developer Community.


It would be good to see explicit cast options in intellisense next to methods, properties, etc. For example:

I type:

var x = 22;
var ux = x.

Then intellisense would present options: (UInt32), (byte)...

After selecting (byte) option, then (byte) would be inserted before expression and dot would be removed.

var x = 22;
var ux = (byte)x

Another example:

var xDoc = XDocument.Load(...); 
var created = xDoc.RootElement.Attribute("create").

and intellisense would provide options: (int), (DateTime), (string), etc.

Reasoning

XAttribute and XElement provide explicit cast operators to read values from XML, e.g. numbers, date and time. And casting is the most correct way to read those values, because they conform to XML Schema standard. However, lot of people don't know this feature and they use int. Parse or similar. New intellisense option would make it more visible that there is another approach.


Original Comments

Feedback Bot on 7/20/2020, 10:39 PM:

Thank you for taking the time to provide your suggestion.  We will do some preliminary checks to make sure we can proceed further.  We'll provide an update once the issue has been triaged by the product team.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-IDEFeature Requesthelp wantedThe issue is "up for grabs" - add a comment if you are interested in working on it

    Type

    No type

    Projects

    Status

    Complete

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions