question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Intellisense suggesting code improvement not supported for the project's C# version

See original GitHub issue

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


[severity:It bothers me. A fix would be nice] I have this code:

public class MyClass { public int ResponseCode { get; set; } public IList<AnotherClass> ResponseArray { get; set; } public string ResponseString { get; set; } } MyClass instance = new MyClass(); VS Intellisense shows:

‘new’ expression can be simplified

and upon selecting that action, it changes new MyClass() to just new(), so that the line of code becomes: MyClass instance = new(); but then build fails with error code CS8181:

‘new’ cannot be used with tuple type. Use a tuple literal expression instead.

I think Intellisense has this bug where it’s recommending a code change that’s not supported for current C# version 6.0.

Microsoft Visual Studio Professional 2019 Version 16.11.7 .Net framework 4.6.1

[stackoverflow question] (https://stackoverflow.com/questions/70210593/visual-studio-intellisense-shows-new-expression-can-be-simplified-but-that-fa)


Original Comments

Feedback Bot on 12/5/2021, 06:44 PM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.


Original Solutions

(no solutions)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
sharwellcommented, Dec 28, 2021

@Sergio0694 Starting with #36924, CSharpUseRangeOperatorDiagnosticAnalyzer and CSharpUseIndexOperatorDiagnosticAnalyzer are gated on the existence of System.Range and System.Index, respectively.

0reactions
sharwellcommented, Dec 28, 2021

The original issue above is a duplicate of #52727. It’s impossible for the code fix to be offered in a project targeting C# 6, which means the file was included in more than one project and triggered from a project targeting C# 9 or newer. This is exactly the scenario described by #52727.

Read more comments on GitHub >

github_iconTop Results From Across the Web

IntelliSense in Visual Studio Code
The editor supports "tab completion" which inserts the best matching completion when pressing Tab. This works regardless of the suggest widget showing or...
Read more >
c# - Intellisense not automatically working VSCode
Obviously this path was corrupted. After updating the environment variables in registry settings, the VS code IntelliSense started working.
Read more >
Intellisense not working for Visual Studio Code
Opening c# script within the editor opens VSCode. However, VScode Doesn't automatically open a project folder. Programs and program versions: ...
Read more >
Visual Studio IntelliSense Not Working? What To Do.
Go to Tools -> Options -> Text Editor -> All Languages -> General. Make sure “Auto List Members” is checked. Also, make sure...
Read more >
IntelliSense in Visual Studio
IntelliSense is a code-completion aid that includes a number of features: List Members, Parameter Info, Quick Info, and Complete Word. These ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found