From b075d90222c887521db9068b8b2e28d975ce9197 Mon Sep 17 00:00:00 2001 From: Shizhong Yu Date: Sat, 19 Jul 2025 08:31:32 -0400 Subject: [PATCH 1/5] Some clean up in the namespace and using statements. --- SharpTools.SseServer/Program.cs | 16 +--------------- .../Properties/launchSettings.json | 12 ++++++++++++ SharpTools.StdioServer/Program.cs | 8 +------- .../Interfaces/ICodeModificationService.cs | 1 - .../Services/CodeModificationService.cs | 16 +--------------- 5 files changed, 15 insertions(+), 38 deletions(-) create mode 100644 SharpTools.SseServer/Properties/launchSettings.json diff --git a/SharpTools.SseServer/Program.cs b/SharpTools.SseServer/Program.cs index b4ceb74..9cb5b42 100644 --- a/SharpTools.SseServer/Program.cs +++ b/SharpTools.SseServer/Program.cs @@ -1,27 +1,13 @@ -using SharpTools.Tools.Services; using SharpTools.Tools.Interfaces; using SharpTools.Tools.Mcp.Tools; using SharpTools.Tools.Extensions; using System.CommandLine; -using System.CommandLine.Builder; using System.CommandLine.Parsing; using Microsoft.AspNetCore.HttpLogging; using Serilog; using ModelContextProtocol.Protocol; -using System.Reflection; -namespace SharpTools.SseServer; - -using SharpTools.Tools.Services; -using SharpTools.Tools.Interfaces; -using SharpTools.Tools.Mcp.Tools; -using System.CommandLine; -using System.CommandLine.Builder; -using System.CommandLine.Parsing; -using Microsoft.AspNetCore.HttpLogging; -using Serilog; -using ModelContextProtocol.Protocol; -using System.Reflection; +namespace SharpTools.SseServer; public class Program { // --- Application --- public const string ApplicationName = "SharpToolsMcpSseServer"; diff --git a/SharpTools.SseServer/Properties/launchSettings.json b/SharpTools.SseServer/Properties/launchSettings.json new file mode 100644 index 0000000..df52d22 --- /dev/null +++ b/SharpTools.SseServer/Properties/launchSettings.json @@ -0,0 +1,12 @@ +{ + "profiles": { + "SharpTools.SseServer": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "applicationUrl": "https://localhost:56278;http://localhost:56279" + } + } +} \ No newline at end of file diff --git a/SharpTools.StdioServer/Program.cs b/SharpTools.StdioServer/Program.cs index 7b66f39..fc54bee 100644 --- a/SharpTools.StdioServer/Program.cs +++ b/SharpTools.StdioServer/Program.cs @@ -1,19 +1,13 @@ -using SharpTools.Tools.Services; -using SharpTools.Tools.Interfaces; +using SharpTools.Tools.Interfaces; using SharpTools.Tools.Mcp.Tools; using SharpTools.Tools.Extensions; using Serilog; using System.CommandLine; using System.CommandLine.Parsing; -using System.Reflection; using ModelContextProtocol.Protocol; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Microsoft.Extensions.DependencyInjection; -using System.IO; -using System; -using System.Threading.Tasks; -using System.Threading; namespace SharpTools.StdioServer; diff --git a/SharpTools.Tools/Interfaces/ICodeModificationService.cs b/SharpTools.Tools/Interfaces/ICodeModificationService.cs index 3f36fba..2e38ab3 100644 --- a/SharpTools.Tools/Interfaces/ICodeModificationService.cs +++ b/SharpTools.Tools/Interfaces/ICodeModificationService.cs @@ -7,7 +7,6 @@ public interface ICodeModificationService { Task ReplaceAllReferencesAsync(ISymbol symbol, string replacementText, CancellationToken cancellationToken, Func? predicateFilter = null); Task FormatDocumentAsync(Document document, CancellationToken cancellationToken); Task ApplyChangesAsync(Solution newSolution, CancellationToken cancellationToken, string commitMessage, IEnumerable? additionalFilePaths = null); - Task<(bool success, string message)> UndoLastChangeAsync(CancellationToken cancellationToken); Task FindAndReplaceAsync(string targetString, string regexPattern, string replacementText, CancellationToken cancellationToken, RegexOptions options = RegexOptions.Multiline); } \ No newline at end of file diff --git a/SharpTools.Tools/Services/CodeModificationService.cs b/SharpTools.Tools/Services/CodeModificationService.cs index 4ea41c1..0642a31 100644 --- a/SharpTools.Tools/Services/CodeModificationService.cs +++ b/SharpTools.Tools/Services/CodeModificationService.cs @@ -1,21 +1,7 @@ -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp; -using Microsoft.CodeAnalysis.CSharp.Syntax; -using Microsoft.CodeAnalysis.FindSymbols; -using Microsoft.CodeAnalysis.Text; using Microsoft.Extensions.FileSystemGlobbing; -using Microsoft.Extensions.Logging; using ModelContextProtocol; -using SharpTools.Tools.Interfaces; using SharpTools.Tools.Mcp; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Text.RegularExpressions; -using System.Threading; -using System.Threading.Tasks; + namespace SharpTools.Tools.Services; public class CodeModificationService : ICodeModificationService { From 7939e2d2840fbb0bd1c87cdc7374f9be604367a7 Mon Sep 17 00:00:00 2001 From: Shizhong Yu Date: Sat, 19 Jul 2025 09:57:23 -0400 Subject: [PATCH 2/5] Cleaned up some unused using statements from the project. --- .../Extensions/ServiceCollectionExtensions.cs | 1 - SharpTools.Tools/Mcp/ContextInjectors.cs | 2 -- SharpTools.Tools/Mcp/ErrorHandlingHelpers.cs | 2 -- SharpTools.Tools/Mcp/ToolHelpers.cs | 6 ++--- SharpTools.Tools/Mcp/Tools/AnalysisTools.cs | 1 - SharpTools.Tools/Mcp/Tools/DocumentTools.cs | 1 - .../Mcp/Tools/MemberAnalysisHelper.cs | 2 -- .../Mcp/Tools/ModificationTools.cs | 22 +------------------ SharpTools.Tools/Mcp/Tools/SolutionTools.cs | 11 ++++------ .../Services/ClassSemanticFeatures.cs | 1 - .../Services/ClassSimilarityResult.cs | 1 - .../Services/CodeModificationService.cs | 4 ++-- .../Services/ComplexityAnalysisService.cs | 12 +--------- .../Services/DocumentOperationsService.cs | 8 +------ .../Services/FuzzyFqnLookupService.cs | 12 ---------- .../Services/SemanticSimilarityService.cs | 15 +++---------- SharpTools.Tools/Services/SolutionManager.cs | 2 -- 17 files changed, 15 insertions(+), 88 deletions(-) diff --git a/SharpTools.Tools/Extensions/ServiceCollectionExtensions.cs b/SharpTools.Tools/Extensions/ServiceCollectionExtensions.cs index f7a8774..cedf246 100644 --- a/SharpTools.Tools/Extensions/ServiceCollectionExtensions.cs +++ b/SharpTools.Tools/Extensions/ServiceCollectionExtensions.cs @@ -1,5 +1,4 @@ using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; using SharpTools.Tools.Interfaces; using SharpTools.Tools.Services; using System.Reflection; diff --git a/SharpTools.Tools/Mcp/ContextInjectors.cs b/SharpTools.Tools/Mcp/ContextInjectors.cs index 68e2ec0..e98d0fc 100644 --- a/SharpTools.Tools/Mcp/ContextInjectors.cs +++ b/SharpTools.Tools/Mcp/ContextInjectors.cs @@ -1,8 +1,6 @@ using System.Text; -using System.Text.RegularExpressions; using DiffPlex.DiffBuilder; using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.Text; using Microsoft.Extensions.Logging; using SharpTools.Tools.Interfaces; using SharpTools.Tools.Mcp.Tools; diff --git a/SharpTools.Tools/Mcp/ErrorHandlingHelpers.cs b/SharpTools.Tools/Mcp/ErrorHandlingHelpers.cs index bbde2db..9d1a14d 100644 --- a/SharpTools.Tools/Mcp/ErrorHandlingHelpers.cs +++ b/SharpTools.Tools/Mcp/ErrorHandlingHelpers.cs @@ -1,9 +1,7 @@ using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.Diagnostics; using ModelContextProtocol; using SharpTools.Tools.Services; using System.Runtime.CompilerServices; -using System.Text; namespace SharpTools.Tools.Mcp; diff --git a/SharpTools.Tools/Mcp/ToolHelpers.cs b/SharpTools.Tools/Mcp/ToolHelpers.cs index b90707f..2859c34 100644 --- a/SharpTools.Tools/Mcp/ToolHelpers.cs +++ b/SharpTools.Tools/Mcp/ToolHelpers.cs @@ -10,7 +10,7 @@ internal static class ToolHelpers { public static void EnsureSolutionLoaded(ISolutionManager solutionManager) { if (!solutionManager.IsSolutionLoaded) { - throw new McpException($"No solution is currently loaded. Please use '{SharpToolPrefix}{nameof(Tools.SolutionTools.LoadSolution)}' first."); + throw new McpException($"No solution is currently loaded. Please use '{SharpToolPrefix}LoadSolution' first."); } } @@ -20,10 +20,10 @@ public static void EnsureSolutionLoaded(ISolutionManager solutionManager) { public static void EnsureSolutionLoadedWithDetails(ISolutionManager solutionManager, ILogger logger, string operationName) { if (!solutionManager.IsSolutionLoaded) { logger.LogError("Attempted to execute {Operation} without a loaded solution", operationName); - throw new McpException($"No solution is currently loaded. Please use '{SharpToolPrefix}{nameof(Tools.SolutionTools.LoadSolution)}' before calling '{operationName}'."); + throw new McpException($"No solution is currently loaded. Please use '{SharpToolPrefix}LoadSolution' before calling '{operationName}'."); } } - private const string FqnHelpMessage = $" Try `{ToolHelpers.SharpToolPrefix}{nameof(Tools.AnalysisTools.SearchDefinitions)}`, `{ToolHelpers.SharpToolPrefix}{nameof(Tools.AnalysisTools.GetMembers)}`, or `{ToolHelpers.SharpToolPrefix}{nameof(Tools.DocumentTools.ReadTypesFromRoslynDocument)}` to find what you need."; + private const string FqnHelpMessage = $" Try `{ToolHelpers.SharpToolPrefix}SearchDefinitions`, `{ToolHelpers.SharpToolPrefix}GetMembers`, or `{ToolHelpers.SharpToolPrefix}ReadTypesFromRoslynDocument` to find what you need."; public static async Task GetRoslynSymbolOrThrowAsync( ISolutionManager solutionManager, string fullyQualifiedSymbolName, diff --git a/SharpTools.Tools/Mcp/Tools/AnalysisTools.cs b/SharpTools.Tools/Mcp/Tools/AnalysisTools.cs index b73a245..e026a79 100644 --- a/SharpTools.Tools/Mcp/Tools/AnalysisTools.cs +++ b/SharpTools.Tools/Mcp/Tools/AnalysisTools.cs @@ -2,7 +2,6 @@ using DiffPlex.DiffBuilder.Model; using ModelContextProtocol; using SharpTools.Tools.Services; -using System.Text.Json; namespace SharpTools.Tools.Mcp.Tools; diff --git a/SharpTools.Tools/Mcp/Tools/DocumentTools.cs b/SharpTools.Tools/Mcp/Tools/DocumentTools.cs index b8a359e..1d8b7e1 100644 --- a/SharpTools.Tools/Mcp/Tools/DocumentTools.cs +++ b/SharpTools.Tools/Mcp/Tools/DocumentTools.cs @@ -2,7 +2,6 @@ using ModelContextProtocol; using SharpTools.Tools.Services; using SharpTools.Tools.Mcp; -using SharpTools.Tools.Mcp.Tools; using System.Security; using System.Text; using DiffPlex.DiffBuilder; diff --git a/SharpTools.Tools/Mcp/Tools/MemberAnalysisHelper.cs b/SharpTools.Tools/Mcp/Tools/MemberAnalysisHelper.cs index 7a97f90..51071ff 100644 --- a/SharpTools.Tools/Mcp/Tools/MemberAnalysisHelper.cs +++ b/SharpTools.Tools/Mcp/Tools/MemberAnalysisHelper.cs @@ -1,8 +1,6 @@ using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.Extensions.Logging; using SharpTools.Tools.Interfaces; -using SharpTools.Tools.Services; using System.Collections.Generic; using System.Linq; using System.Threading; diff --git a/SharpTools.Tools/Mcp/Tools/ModificationTools.cs b/SharpTools.Tools/Mcp/Tools/ModificationTools.cs index c3d27f9..a80a087 100644 --- a/SharpTools.Tools/Mcp/Tools/ModificationTools.cs +++ b/SharpTools.Tools/Mcp/Tools/ModificationTools.cs @@ -1,25 +1,5 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.IO; -using System.Linq; -using System.Text; -using System.Text.RegularExpressions; -using System.Threading; -using System.Threading.Tasks; -using DiffPlex.DiffBuilder; -using DiffPlex.DiffBuilder.Model; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp; -using Microsoft.CodeAnalysis.CSharp.Syntax; -using Microsoft.CodeAnalysis.Editing; -using Microsoft.CodeAnalysis.FindSymbols; -using Microsoft.Extensions.FileSystemGlobbing; -using Microsoft.Extensions.Logging; using ModelContextProtocol; -using SharpTools.Tools.Interfaces; -using SharpTools.Tools.Mcp; -using SharpTools.Tools.Services; +using Microsoft.Extensions.FileSystemGlobbing; namespace SharpTools.Tools.Mcp.Tools; diff --git a/SharpTools.Tools/Mcp/Tools/SolutionTools.cs b/SharpTools.Tools/Mcp/Tools/SolutionTools.cs index a295c40..1fa43f0 100644 --- a/SharpTools.Tools/Mcp/Tools/SolutionTools.cs +++ b/SharpTools.Tools/Mcp/Tools/SolutionTools.cs @@ -1,11 +1,8 @@ using ModelContextProtocol; using SharpTools.Tools.Services; - -namespace SharpTools.Tools.Mcp.Tools; - -using System.Xml; +using SharpTools.Tools.Mcp; using System.Xml.Linq; -using Microsoft.CodeAnalysis.CSharp.Syntax; +using System.Xml; // Marker class for ILogger category specific to SolutionTools public class SolutionToolsLogCategory { } @@ -167,7 +164,7 @@ private static async Task GetProjectStructure( try { if (!string.IsNullOrEmpty(project.FilePath) && File.Exists(project.FilePath)) { // Get all packages - var packages = Services.LegacyNuGetPackageReader.GetAllPackages(project.FilePath); + var packages = LegacyNuGetPackageReader.GetAllPackages(project.FilePath); foreach (var package in packages) { packageRefs.Add($"{package.PackageId} ({package.Version})"); } @@ -517,7 +514,7 @@ public static async Task LoadProject( } } - return $"" + + return $"" + output + "\n"; diff --git a/SharpTools.Tools/Services/ClassSemanticFeatures.cs b/SharpTools.Tools/Services/ClassSemanticFeatures.cs index 9bed679..da5b006 100644 --- a/SharpTools.Tools/Services/ClassSemanticFeatures.cs +++ b/SharpTools.Tools/Services/ClassSemanticFeatures.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; namespace SharpTools.Tools.Services; diff --git a/SharpTools.Tools/Services/ClassSimilarityResult.cs b/SharpTools.Tools/Services/ClassSimilarityResult.cs index bbef790..0719546 100644 --- a/SharpTools.Tools/Services/ClassSimilarityResult.cs +++ b/SharpTools.Tools/Services/ClassSimilarityResult.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; namespace SharpTools.Tools.Services; diff --git a/SharpTools.Tools/Services/CodeModificationService.cs b/SharpTools.Tools/Services/CodeModificationService.cs index 0642a31..5168524 100644 --- a/SharpTools.Tools/Services/CodeModificationService.cs +++ b/SharpTools.Tools/Services/CodeModificationService.cs @@ -1,6 +1,6 @@ -using Microsoft.Extensions.FileSystemGlobbing; -using ModelContextProtocol; using SharpTools.Tools.Mcp; +using ModelContextProtocol; +using Microsoft.Extensions.FileSystemGlobbing; namespace SharpTools.Tools.Services; diff --git a/SharpTools.Tools/Services/ComplexityAnalysisService.cs b/SharpTools.Tools/Services/ComplexityAnalysisService.cs index ae697dc..e232882 100644 --- a/SharpTools.Tools/Services/ComplexityAnalysisService.cs +++ b/SharpTools.Tools/Services/ComplexityAnalysisService.cs @@ -1,14 +1,4 @@ -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp; -using Microsoft.CodeAnalysis.CSharp.Syntax; -using Microsoft.Extensions.Logging; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using SharpTools.Tools.Extensions; -using SharpTools.Tools.Services; +using SharpTools.Tools.Extensions; using ModelContextProtocol; namespace SharpTools.Tools.Services; diff --git a/SharpTools.Tools/Services/DocumentOperationsService.cs b/SharpTools.Tools/Services/DocumentOperationsService.cs index c05a448..efc3843 100644 --- a/SharpTools.Tools/Services/DocumentOperationsService.cs +++ b/SharpTools.Tools/Services/DocumentOperationsService.cs @@ -1,11 +1,5 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using System.Xml; using Microsoft.CodeAnalysis.Text; +using System.Xml; namespace SharpTools.Tools.Services; diff --git a/SharpTools.Tools/Services/FuzzyFqnLookupService.cs b/SharpTools.Tools/Services/FuzzyFqnLookupService.cs index 4b7a40b..8e74411 100644 --- a/SharpTools.Tools/Services/FuzzyFqnLookupService.cs +++ b/SharpTools.Tools/Services/FuzzyFqnLookupService.cs @@ -1,15 +1,3 @@ -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp; -using Microsoft.CodeAnalysis.CSharp.Syntax; -using SharpTools.Tools.Interfaces; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text.RegularExpressions; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.Extensions.Logging; using SharpTools.Tools.Mcp; namespace SharpTools.Tools.Services { diff --git a/SharpTools.Tools/Services/SemanticSimilarityService.cs b/SharpTools.Tools/Services/SemanticSimilarityService.cs index 1b842cd..c3a0dea 100644 --- a/SharpTools.Tools/Services/SemanticSimilarityService.cs +++ b/SharpTools.Tools/Services/SemanticSimilarityService.cs @@ -1,22 +1,13 @@ -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.FlowAnalysis; using Microsoft.CodeAnalysis.Operations; -using Microsoft.Extensions.Logging; using SharpTools.Tools.Extensions; using SharpTools.Tools.Mcp; -using System; -using System.Collections.Concurrent; // Added -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; namespace SharpTools.Tools.Services { public class SemanticSimilarityService : ISemanticSimilarityService { private static class Tuning { - public static readonly int MaxDegreesOfParallelism = Math.Max(1, Environment.ProcessorCount / 2); + public static readonly int MaxDegreesOfParallelism = Math.Max(1, Environment.ProcessorCount / 2); public const int MethodLineCountFilter = 10; public const double DefaultSimilarityThreshold = 0.7; @@ -762,7 +753,7 @@ await Parallel.ForEachAsync(documents, parallelOptions, async (document, docCt) totalLinesOfCode, classMethodFeatures ); - } + } private List CompareClassFeatures( List allClassFeatures, @@ -933,6 +924,6 @@ private void AddTypeAndNamespaceIfExternal( if (typeSymbol is IPointerTypeSymbol pointerTypeSymbol) { AddTypeAndNamespaceIfExternal(pointerTypeSymbol.PointedAtType, containingClassSymbol, externalTypeFqns, usedNamespaceFqns); } - } + } } } diff --git a/SharpTools.Tools/Services/SolutionManager.cs b/SharpTools.Tools/Services/SolutionManager.cs index 3b4b297..4d4c3c4 100644 --- a/SharpTools.Tools/Services/SolutionManager.cs +++ b/SharpTools.Tools/Services/SolutionManager.cs @@ -1,7 +1,5 @@ using System.Runtime.InteropServices; -using System.Xml.Linq; using ModelContextProtocol; -using SharpTools.Tools.Mcp.Tools; namespace SharpTools.Tools.Services; public sealed class SolutionManager : ISolutionManager { From 223652a97e4bbcaa020f686348789396420d3c35 Mon Sep 17 00:00:00 2001 From: Shizhong Yu Date: Sat, 19 Jul 2025 09:59:06 -0400 Subject: [PATCH 3/5] More clean up after claude pass. --- SharpTools.Tools/Mcp/ErrorHandlingHelpers.cs | 3 --- SharpTools.Tools/Services/DocumentOperationsService.cs | 1 - SharpTools.Tools/Services/EmbeddedSourceReader.cs | 6 ------ SharpTools.Tools/Services/FuzzyFqnLookupService.cs | 1 - SharpTools.Tools/Services/GitService.cs | 1 - SharpTools.Tools/Services/MethodSemanticFeatures.cs | 1 - SharpTools.Tools/Services/MethodSimilarityResult.cs | 2 -- SharpTools.Tools/Services/SourceResolutionService.cs | 9 --------- 8 files changed, 24 deletions(-) diff --git a/SharpTools.Tools/Mcp/ErrorHandlingHelpers.cs b/SharpTools.Tools/Mcp/ErrorHandlingHelpers.cs index 9d1a14d..4f0a0a3 100644 --- a/SharpTools.Tools/Mcp/ErrorHandlingHelpers.cs +++ b/SharpTools.Tools/Mcp/ErrorHandlingHelpers.cs @@ -1,7 +1,4 @@ -using Microsoft.CodeAnalysis; using ModelContextProtocol; -using SharpTools.Tools.Services; -using System.Runtime.CompilerServices; namespace SharpTools.Tools.Mcp; diff --git a/SharpTools.Tools/Services/DocumentOperationsService.cs b/SharpTools.Tools/Services/DocumentOperationsService.cs index efc3843..1f51713 100644 --- a/SharpTools.Tools/Services/DocumentOperationsService.cs +++ b/SharpTools.Tools/Services/DocumentOperationsService.cs @@ -1,4 +1,3 @@ -using Microsoft.CodeAnalysis.Text; using System.Xml; namespace SharpTools.Tools.Services; diff --git a/SharpTools.Tools/Services/EmbeddedSourceReader.cs b/SharpTools.Tools/Services/EmbeddedSourceReader.cs index 569fc90..e00cbfa 100644 --- a/SharpTools.Tools/Services/EmbeddedSourceReader.cs +++ b/SharpTools.Tools/Services/EmbeddedSourceReader.cs @@ -1,12 +1,6 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; using System.Reflection.Metadata; using System.Reflection.PortableExecutable; -using System.Text; using System.IO.Compression; -using Microsoft.CodeAnalysis; namespace SharpTools.Tools.Services { public class EmbeddedSourceReader { diff --git a/SharpTools.Tools/Services/FuzzyFqnLookupService.cs b/SharpTools.Tools/Services/FuzzyFqnLookupService.cs index 8e74411..d339f84 100644 --- a/SharpTools.Tools/Services/FuzzyFqnLookupService.cs +++ b/SharpTools.Tools/Services/FuzzyFqnLookupService.cs @@ -1,4 +1,3 @@ -using SharpTools.Tools.Mcp; namespace SharpTools.Tools.Services { public class FuzzyFqnLookupService : IFuzzyFqnLookupService { diff --git a/SharpTools.Tools/Services/GitService.cs b/SharpTools.Tools/Services/GitService.cs index f3659ed..8867a4f 100644 --- a/SharpTools.Tools/Services/GitService.cs +++ b/SharpTools.Tools/Services/GitService.cs @@ -1,5 +1,4 @@ using LibGit2Sharp; -using System.Text; namespace SharpTools.Tools.Services; diff --git a/SharpTools.Tools/Services/MethodSemanticFeatures.cs b/SharpTools.Tools/Services/MethodSemanticFeatures.cs index bb2339a..4f6e373 100644 --- a/SharpTools.Tools/Services/MethodSemanticFeatures.cs +++ b/SharpTools.Tools/Services/MethodSemanticFeatures.cs @@ -1,6 +1,5 @@ using Microsoft.CodeAnalysis; // Keep for potential future use, but not strictly needed for current properties -using System.Collections.Generic; namespace SharpTools.Tools.Services { public class MethodSemanticFeatures { diff --git a/SharpTools.Tools/Services/MethodSimilarityResult.cs b/SharpTools.Tools/Services/MethodSimilarityResult.cs index 68be07d..9da0977 100644 --- a/SharpTools.Tools/Services/MethodSimilarityResult.cs +++ b/SharpTools.Tools/Services/MethodSimilarityResult.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; - namespace SharpTools.Tools.Services { public class MethodSimilarityResult { public List SimilarMethods { get; } diff --git a/SharpTools.Tools/Services/SourceResolutionService.cs b/SharpTools.Tools/Services/SourceResolutionService.cs index a124ae5..c0b67b5 100644 --- a/SharpTools.Tools/Services/SourceResolutionService.cs +++ b/SharpTools.Tools/Services/SourceResolutionService.cs @@ -1,16 +1,7 @@ -using System.IO; -using System.Net.Http; -using System.Reflection; using System.Reflection.Metadata; -using System.Reflection.PortableExecutable; -using System.Text; using ICSharpCode.Decompiler; using ICSharpCode.Decompiler.CSharp; using ICSharpCode.Decompiler.TypeSystem; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp; -using Microsoft.Extensions.Logging; -using SharpTools.Tools.Interfaces; namespace SharpTools.Tools.Services { public class SourceResolutionService : ISourceResolutionService { From c265027a2f3df20088e667700ecdde6a1a829adc Mon Sep 17 00:00:00 2001 From: Shizhong Yu Date: Sat, 19 Jul 2025 17:59:20 -0400 Subject: [PATCH 4/5] Cleaned up the using statements. --- SharpTools.Tools/Extensions/ServiceCollectionExtensions.cs | 4 ---- SharpTools.Tools/Extensions/SyntaxTreeExtensions.cs | 4 +--- SharpTools.Tools/Interfaces/IComplexityAnalysisService.cs | 4 ---- SharpTools.Tools/Interfaces/ISemanticSimilarityService.cs | 4 ---- SharpTools.Tools/Interfaces/ISourceResolutionService.cs | 3 --- SharpTools.Tools/Mcp/Tools/DocumentTools.cs | 7 ------- SharpTools.Tools/Mcp/Tools/MiscTools.cs | 2 -- SharpTools.Tools/Mcp/Tools/PackageTools.cs | 2 -- 8 files changed, 1 insertion(+), 29 deletions(-) diff --git a/SharpTools.Tools/Extensions/ServiceCollectionExtensions.cs b/SharpTools.Tools/Extensions/ServiceCollectionExtensions.cs index cedf246..1e11b58 100644 --- a/SharpTools.Tools/Extensions/ServiceCollectionExtensions.cs +++ b/SharpTools.Tools/Extensions/ServiceCollectionExtensions.cs @@ -1,7 +1,3 @@ -using Microsoft.Extensions.DependencyInjection; -using SharpTools.Tools.Interfaces; -using SharpTools.Tools.Services; -using System.Reflection; namespace SharpTools.Tools.Extensions; diff --git a/SharpTools.Tools/Extensions/SyntaxTreeExtensions.cs b/SharpTools.Tools/Extensions/SyntaxTreeExtensions.cs index 2fd8eb6..a7cf0ac 100644 --- a/SharpTools.Tools/Extensions/SyntaxTreeExtensions.cs +++ b/SharpTools.Tools/Extensions/SyntaxTreeExtensions.cs @@ -1,6 +1,4 @@ -using Microsoft.CodeAnalysis; -using System.Linq; - + namespace SharpTools.Tools.Extensions; public static class SyntaxTreeExtensions diff --git a/SharpTools.Tools/Interfaces/IComplexityAnalysisService.cs b/SharpTools.Tools/Interfaces/IComplexityAnalysisService.cs index 6056a88..82de07a 100644 --- a/SharpTools.Tools/Interfaces/IComplexityAnalysisService.cs +++ b/SharpTools.Tools/Interfaces/IComplexityAnalysisService.cs @@ -1,7 +1,3 @@ -using Microsoft.CodeAnalysis; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; namespace SharpTools.Tools.Interfaces; diff --git a/SharpTools.Tools/Interfaces/ISemanticSimilarityService.cs b/SharpTools.Tools/Interfaces/ISemanticSimilarityService.cs index caa672c..24b8418 100644 --- a/SharpTools.Tools/Interfaces/ISemanticSimilarityService.cs +++ b/SharpTools.Tools/Interfaces/ISemanticSimilarityService.cs @@ -1,8 +1,4 @@ -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; - namespace SharpTools.Tools.Interfaces { public interface ISemanticSimilarityService { diff --git a/SharpTools.Tools/Interfaces/ISourceResolutionService.cs b/SharpTools.Tools/Interfaces/ISourceResolutionService.cs index 69db29c..65af2ee 100644 --- a/SharpTools.Tools/Interfaces/ISourceResolutionService.cs +++ b/SharpTools.Tools/Interfaces/ISourceResolutionService.cs @@ -1,6 +1,3 @@ -using Microsoft.CodeAnalysis; -using System.Threading; -using System.Threading.Tasks; namespace SharpTools.Tools.Interfaces { public class SourceResult { diff --git a/SharpTools.Tools/Mcp/Tools/DocumentTools.cs b/SharpTools.Tools/Mcp/Tools/DocumentTools.cs index 1d8b7e1..3cf2f89 100644 --- a/SharpTools.Tools/Mcp/Tools/DocumentTools.cs +++ b/SharpTools.Tools/Mcp/Tools/DocumentTools.cs @@ -1,11 +1,4 @@ -using Microsoft.CodeAnalysis; using ModelContextProtocol; -using SharpTools.Tools.Services; -using SharpTools.Tools.Mcp; -using System.Security; -using System.Text; -using DiffPlex.DiffBuilder; -using DiffPlex.DiffBuilder.Model; namespace SharpTools.Tools.Mcp.Tools; diff --git a/SharpTools.Tools/Mcp/Tools/MiscTools.cs b/SharpTools.Tools/Mcp/Tools/MiscTools.cs index bcdcd4f..9cf2aeb 100644 --- a/SharpTools.Tools/Mcp/Tools/MiscTools.cs +++ b/SharpTools.Tools/Mcp/Tools/MiscTools.cs @@ -1,6 +1,4 @@ using ModelContextProtocol; -using SharpTools.Tools.Services; -using System.Text.Json; namespace SharpTools.Tools.Mcp.Tools; diff --git a/SharpTools.Tools/Mcp/Tools/PackageTools.cs b/SharpTools.Tools/Mcp/Tools/PackageTools.cs index fd64aa6..88f2a62 100644 --- a/SharpTools.Tools/Mcp/Tools/PackageTools.cs +++ b/SharpTools.Tools/Mcp/Tools/PackageTools.cs @@ -1,10 +1,8 @@ -using Microsoft.Extensions.Logging; using ModelContextProtocol; using NuGet.Common; using NuGet.Protocol; using NuGet.Protocol.Core.Types; using NuGet.Versioning; -using SharpTools.Tools.Services; using System.Xml.Linq; namespace SharpTools.Tools.Mcp.Tools; From aa30099ae2e64e48225cc850a7b1887c66fda248 Mon Sep 17 00:00:00 2001 From: Shizhong Yu Date: Sat, 19 Jul 2025 21:39:05 -0400 Subject: [PATCH 5/5] Restored most of nameOf changes. --- SharpTools.Tools/Mcp/ToolHelpers.cs | 6 +++--- SharpTools.Tools/Mcp/Tools/SolutionTools.cs | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/SharpTools.Tools/Mcp/ToolHelpers.cs b/SharpTools.Tools/Mcp/ToolHelpers.cs index 2859c34..b90707f 100644 --- a/SharpTools.Tools/Mcp/ToolHelpers.cs +++ b/SharpTools.Tools/Mcp/ToolHelpers.cs @@ -10,7 +10,7 @@ internal static class ToolHelpers { public static void EnsureSolutionLoaded(ISolutionManager solutionManager) { if (!solutionManager.IsSolutionLoaded) { - throw new McpException($"No solution is currently loaded. Please use '{SharpToolPrefix}LoadSolution' first."); + throw new McpException($"No solution is currently loaded. Please use '{SharpToolPrefix}{nameof(Tools.SolutionTools.LoadSolution)}' first."); } } @@ -20,10 +20,10 @@ public static void EnsureSolutionLoaded(ISolutionManager solutionManager) { public static void EnsureSolutionLoadedWithDetails(ISolutionManager solutionManager, ILogger logger, string operationName) { if (!solutionManager.IsSolutionLoaded) { logger.LogError("Attempted to execute {Operation} without a loaded solution", operationName); - throw new McpException($"No solution is currently loaded. Please use '{SharpToolPrefix}LoadSolution' before calling '{operationName}'."); + throw new McpException($"No solution is currently loaded. Please use '{SharpToolPrefix}{nameof(Tools.SolutionTools.LoadSolution)}' before calling '{operationName}'."); } } - private const string FqnHelpMessage = $" Try `{ToolHelpers.SharpToolPrefix}SearchDefinitions`, `{ToolHelpers.SharpToolPrefix}GetMembers`, or `{ToolHelpers.SharpToolPrefix}ReadTypesFromRoslynDocument` to find what you need."; + private const string FqnHelpMessage = $" Try `{ToolHelpers.SharpToolPrefix}{nameof(Tools.AnalysisTools.SearchDefinitions)}`, `{ToolHelpers.SharpToolPrefix}{nameof(Tools.AnalysisTools.GetMembers)}`, or `{ToolHelpers.SharpToolPrefix}{nameof(Tools.DocumentTools.ReadTypesFromRoslynDocument)}` to find what you need."; public static async Task GetRoslynSymbolOrThrowAsync( ISolutionManager solutionManager, string fullyQualifiedSymbolName, diff --git a/SharpTools.Tools/Mcp/Tools/SolutionTools.cs b/SharpTools.Tools/Mcp/Tools/SolutionTools.cs index 1fa43f0..e75ea07 100644 --- a/SharpTools.Tools/Mcp/Tools/SolutionTools.cs +++ b/SharpTools.Tools/Mcp/Tools/SolutionTools.cs @@ -1,8 +1,8 @@ +using System.Xml; +using System.Xml.Linq; using ModelContextProtocol; -using SharpTools.Tools.Services; using SharpTools.Tools.Mcp; -using System.Xml.Linq; -using System.Xml; +using SharpTools.Tools.Mcp.Tools; // Marker class for ILogger category specific to SolutionTools public class SolutionToolsLogCategory { } @@ -164,7 +164,7 @@ private static async Task GetProjectStructure( try { if (!string.IsNullOrEmpty(project.FilePath) && File.Exists(project.FilePath)) { // Get all packages - var packages = LegacyNuGetPackageReader.GetAllPackages(project.FilePath); + var packages = SharpTools.Tools.Services.LegacyNuGetPackageReader.GetAllPackages(project.FilePath); foreach (var package in packages) { packageRefs.Add($"{package.PackageId} ({package.Version})"); } @@ -514,7 +514,7 @@ public static async Task LoadProject( } } - return $"" + + return $"" + output + "\n";