Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Highlight unused variables in the editor #1324

Closed
jchannon opened this issue Mar 14, 2017 · 10 comments · Fixed by #3733
Closed

Highlight unused variables in the editor #1324

jchannon opened this issue Mar 14, 2017 · 10 comments · Fixed by #3733

Comments

@jchannon
Copy link
Contributor

Environment data

dotnet --info output:

.NET Command Line Tools (1.0.0-preview2-1-003177)

Product Information:
 Version:            1.0.0-preview2-1-003177
 Commit SHA-1 hash:  a2df9c2576

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.11
 OS Platform: Darwin
 RID:         osx.10.11-x64

VS Code version: 1.10.2
C# Extension version:1.8.0

Steps to reproduce

Create a variable and assign it a value. Don't use that variable.

Expected behavior

A highlighted or slightly greyed out variable name

Actual behavior

Nothing

@DustinCampbell
Copy link
Member

@Pilchie: Is there an equivalent request for roslyn?

@Pilchie
Copy link
Member

Pilchie commented Mar 14, 2017

No - the compiler already issues a warning, so there should be a squiggle (maybe not if it's initialized to an expression that might have side-effects though).

We did just take a PR to support a code fix to remove unused variables with that warning though.

@DustinCampbell
Copy link
Member

That's what I was thinking. Also, we don't have the ability to fade things out in VS Code. FWIW, it'd be great if Roslyn marked that particular diagnostic with an Unnecessary tag. Any chance we could get @CyrusNajmabadi to do that? 😄

@jchannon
Copy link
Contributor Author

jchannon commented May 2, 2017

👀

@blogcraft
Copy link

blogcraft commented Mar 10, 2020

I have this line in C#:

        List<IndicadorConFecha> indicadores = await _tipoCambio.GetIndicadores(desde, hasta);

The variable indicadores gets assigned by an asynchronous method. But never gets used.

Why I don't get a warning or a squiggle?

@cartermp
Copy link

This should light up once analyzers are moved over to the .NET SDK

@marcospgp
Copy link

Any ETA on this? Thanks guys!

@suadev
Copy link

suadev commented Apr 20, 2020

knock knock

@CyrusNajmabadi
Copy link
Member

I don't believe there's been any progress on this. I imagine a PR would be accepted to enable that behavior if someone wanted to contribute it.

@cartermp
Copy link

@CyrusNajmabadi See here :) #3733

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants