0

Team,

I need to identify & remove unused variables (arguments, local variables, class member variables), Libraries, and references that are unused in VS code.

I have also tried to find out some extensions or plugins or Nuget packages but no luck and also researched a lot but didn't find relevant links which can fulfill my need. I know someone from this community who can help me with this.

Please check below code sample for unused code and I want something to identify that are unused and want to remove those.

using System;
using System.Diagnostics; //unused
using Microsoft.AspNetCore.Mvc; //unused
using Microsoft.AspNetCore.Mvc.RazorPages; //unused

public class HelloWorld
{
    public string? RequestId { get; set; } //unused 
    private readonly ILogger<ErrorModel> _logger; //unused
    public static void Main(string[] args)
    {
        Console.WriteLine ("Hello Mono World");
    }
    public ErrorModel(ILogger<ErrorModel> logger) // This method is unused
    {
       //Some code here
    }

}
Chetan Sanghani
  • 2,058
  • 2
  • 21
  • 36
  • any language extension in particular that you're asking about? semantic highlighting has modifiers for unused things, but that requires the language extension to make use of the feature. similar story for textmate-grammar-based highlighting. – starball Aug 02 '23 at 23:05
  • @starball - I am looking for C# and Javascript code cleanup – Chetan Sanghani Aug 03 '23 at 05:32
  • can you share some minimal code for both those languages with comments to demonstrate what you expect to see? (see [mre]) – starball Aug 03 '23 at 06:01
  • yes, I saw, because I'm following this question. but you still didn't add for javascript. – starball Aug 03 '23 at 09:14
  • @starball- yes, you are right, I haven't added for Javascript because it's same like C# sample and need to unused code. – Chetan Sanghani Aug 03 '23 at 12:51

0 Answers0