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/Extensions/ServiceCollectionExtensions.cs b/SharpTools.Tools/Extensions/ServiceCollectionExtensions.cs index f7a8774..1e11b58 100644 --- a/SharpTools.Tools/Extensions/ServiceCollectionExtensions.cs +++ b/SharpTools.Tools/Extensions/ServiceCollectionExtensions.cs @@ -1,8 +1,3 @@ -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; -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/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/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/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..4f0a0a3 100644 --- a/SharpTools.Tools/Mcp/ErrorHandlingHelpers.cs +++ b/SharpTools.Tools/Mcp/ErrorHandlingHelpers.cs @@ -1,9 +1,4 @@ -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/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..3cf2f89 100644 --- a/SharpTools.Tools/Mcp/Tools/DocumentTools.cs +++ b/SharpTools.Tools/Mcp/Tools/DocumentTools.cs @@ -1,12 +1,4 @@ -using Microsoft.CodeAnalysis; using ModelContextProtocol; -using SharpTools.Tools.Services; -using SharpTools.Tools.Mcp; -using SharpTools.Tools.Mcp.Tools; -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/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/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/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/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; diff --git a/SharpTools.Tools/Mcp/Tools/SolutionTools.cs b/SharpTools.Tools/Mcp/Tools/SolutionTools.cs index a295c40..e75ea07 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 System.Xml.Linq; -using Microsoft.CodeAnalysis.CSharp.Syntax; +using ModelContextProtocol; +using SharpTools.Tools.Mcp; +using SharpTools.Tools.Mcp.Tools; // 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 = SharpTools.Tools.Services.LegacyNuGetPackageReader.GetAllPackages(project.FilePath); foreach (var package in packages) { packageRefs.Add($"{package.PackageId} ({package.Version})"); } 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 4ea41c1..5168524 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; +using ModelContextProtocol; +using Microsoft.Extensions.FileSystemGlobbing; + namespace SharpTools.Tools.Services; public class CodeModificationService : ICodeModificationService { 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..1f51713 100644 --- a/SharpTools.Tools/Services/DocumentOperationsService.cs +++ b/SharpTools.Tools/Services/DocumentOperationsService.cs @@ -1,11 +1,4 @@ -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; 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 4b7a40b..d339f84 100644 --- a/SharpTools.Tools/Services/FuzzyFqnLookupService.cs +++ b/SharpTools.Tools/Services/FuzzyFqnLookupService.cs @@ -1,16 +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 { 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/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 { 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 {