2025-12-31 14:25:09 +08:00

2.1 KiB

Solution Cleanup Tool

A C# console application that systematically identifies and removes missing project references from Visual Studio solution files.

Project Structure

Core Components

  • Models/: Data models representing solution structure and analysis results

    • SolutionModel.cs - Represents a parsed Visual Studio solution
    • ProjectReference.cs - Represents a project reference within a solution
    • MissingProject.cs - Represents a missing project reference
    • CleanupResult.cs - Represents the result of cleanup operations
    • AnalysisResult.cs - Represents analysis results for project references
    • ValidationResult.cs - Represents validation results after cleanup
    • DependencyGraph.cs - Represents project dependency relationships
  • Interfaces/: Core service interfaces

    • ISolutionParser.cs - Interface for parsing solution files
    • IProjectReferenceAnalyzer.cs - Interface for analyzing project references
    • ICleanupEngine.cs - Interface for performing cleanup operations
    • IValidationEngine.cs - Interface for validating cleaned solutions

Dependencies

  • FsCheck - Property-based testing framework
  • Microsoft.Extensions.DependencyInjection - Dependency injection
  • Microsoft.Extensions.Logging - Logging framework
  • Xunit - Unit testing framework

Usage

SolutionCleanupTool <path-to-solution-file>

Example:

SolutionCleanupTool C:\MyProject\MySolution.sln

Development

The project follows a pipeline architecture with three main stages:

  1. Analysis Stage: Scans solution files to identify missing project references
  2. Cleanup Stage: Safely removes invalid references while preserving valid ones
  3. Validation Stage: Verifies solution integrity after cleanup

Testing

The project uses both unit tests and property-based tests:

  • Unit Tests: Verify specific examples and edge cases
  • Property Tests: Verify universal properties across all inputs using FsCheck
  • Integration Tests: Test end-to-end workflows with real file system operations

Run tests with:

dotnet test