This project uses the Roslyn compiler platform to analyze C# code and extract all ununsed variables, classes and functions and also you can comment it out. The analysis results are also exported to Excel using EPPlus there is one sample code added for saving it in excel for unused classes.
- Load and analyze a C# Solution or Project using
MSBuildWorkspace - find all unused variables, functions and classes.
- comment out all unused code.
- Export analyzed data to Excel (
.xlsx) using EPPlus - Supports both CLI-based and extensible Roslyn workflows
- .NET SDK (6/7/8)
- Roslyn (
Microsoft.CodeAnalysis) - EPPlus (Excel file generation)
- MSBuild Workspace support (
Microsoft.Build.Locator)
Make sure the following NuGet packages are installed:
dotnet add package Microsoft.Build.Locator
dotnet add package Microsoft.CodeAnalysis.Workspaces.MSBuild
dotnet add package Microsoft.CodeAnalysis.CSharp.Workspaces
dotnet add package Microsoft.CodeAnalysis.FindSymbols
dotnet add package EPPlusgit clone https://github.com/your-username/roslyn-analyzer.git
cd roslyn-analyzerdotnet buildUpdate the path to your .sln or .csproj in Program.cs and excel file path, then:
dotnet runThe output Excel file will be saved to the project directory.
This project uses EPPlus under its Polyform Noncommercial License. You must set the license context:
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;Feel free to fork, improve, and submit PRs. Open issues for bugs or feature requests!
Made with ❤️ using .NET and Roslyn