Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 1 addition & 15 deletions SharpTools.SseServer/Program.cs
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
12 changes: 12 additions & 0 deletions SharpTools.SseServer/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"profiles": {
"SharpTools.SseServer": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:56278;http://localhost:56279"
}
}
}
8 changes: 1 addition & 7 deletions SharpTools.StdioServer/Program.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
5 changes: 0 additions & 5 deletions SharpTools.Tools/Extensions/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
4 changes: 1 addition & 3 deletions SharpTools.Tools/Extensions/SyntaxTreeExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Microsoft.CodeAnalysis;
using System.Linq;


namespace SharpTools.Tools.Extensions;

public static class SyntaxTreeExtensions
Expand Down
1 change: 0 additions & 1 deletion SharpTools.Tools/Interfaces/ICodeModificationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ public interface ICodeModificationService {
Task<Solution> ReplaceAllReferencesAsync(ISymbol symbol, string replacementText, CancellationToken cancellationToken, Func<SyntaxNode, bool>? predicateFilter = null);
Task<Document> FormatDocumentAsync(Document document, CancellationToken cancellationToken);
Task ApplyChangesAsync(Solution newSolution, CancellationToken cancellationToken, string commitMessage, IEnumerable<string>? additionalFilePaths = null);

Task<(bool success, string message)> UndoLastChangeAsync(CancellationToken cancellationToken);
Task<Solution> FindAndReplaceAsync(string targetString, string regexPattern, string replacementText, CancellationToken cancellationToken, RegexOptions options = RegexOptions.Multiline);
}
4 changes: 0 additions & 4 deletions SharpTools.Tools/Interfaces/IComplexityAnalysisService.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
using Microsoft.CodeAnalysis;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;

namespace SharpTools.Tools.Interfaces;

Expand Down
4 changes: 0 additions & 4 deletions SharpTools.Tools/Interfaces/ISemanticSimilarityService.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@

using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;

namespace SharpTools.Tools.Interfaces {

public interface ISemanticSimilarityService {
Expand Down
3 changes: 0 additions & 3 deletions SharpTools.Tools/Interfaces/ISourceResolutionService.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using Microsoft.CodeAnalysis;
using System.Threading;
using System.Threading.Tasks;

namespace SharpTools.Tools.Interfaces {
public class SourceResult {
Expand Down
2 changes: 0 additions & 2 deletions SharpTools.Tools/Mcp/ContextInjectors.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
5 changes: 0 additions & 5 deletions SharpTools.Tools/Mcp/ErrorHandlingHelpers.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
1 change: 0 additions & 1 deletion SharpTools.Tools/Mcp/Tools/AnalysisTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using DiffPlex.DiffBuilder.Model;
using ModelContextProtocol;
using SharpTools.Tools.Services;
using System.Text.Json;

namespace SharpTools.Tools.Mcp.Tools;

Expand Down
8 changes: 0 additions & 8 deletions SharpTools.Tools/Mcp/Tools/DocumentTools.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
2 changes: 0 additions & 2 deletions SharpTools.Tools/Mcp/Tools/MemberAnalysisHelper.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 0 additions & 2 deletions SharpTools.Tools/Mcp/Tools/MiscTools.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using ModelContextProtocol;
using SharpTools.Tools.Services;
using System.Text.Json;

namespace SharpTools.Tools.Mcp.Tools;

Expand Down
22 changes: 1 addition & 21 deletions SharpTools.Tools/Mcp/Tools/ModificationTools.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
2 changes: 0 additions & 2 deletions SharpTools.Tools/Mcp/Tools/PackageTools.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
11 changes: 4 additions & 7 deletions SharpTools.Tools/Mcp/Tools/SolutionTools.cs
Original file line number Diff line number Diff line change
@@ -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<T> category specific to SolutionTools
public class SolutionToolsLogCategory { }
Expand Down Expand Up @@ -167,7 +164,7 @@ private static async Task<object> 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})");
}
Expand Down
1 change: 0 additions & 1 deletion SharpTools.Tools/Services/ClassSemanticFeatures.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Collections.Generic;

namespace SharpTools.Tools.Services;

Expand Down
1 change: 0 additions & 1 deletion SharpTools.Tools/Services/ClassSimilarityResult.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Collections.Generic;

namespace SharpTools.Tools.Services;

Expand Down
20 changes: 3 additions & 17 deletions SharpTools.Tools/Services/CodeModificationService.cs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
12 changes: 1 addition & 11 deletions SharpTools.Tools/Services/ComplexityAnalysisService.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
7 changes: 0 additions & 7 deletions SharpTools.Tools/Services/DocumentOperationsService.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
6 changes: 0 additions & 6 deletions SharpTools.Tools/Services/EmbeddedSourceReader.cs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
13 changes: 0 additions & 13 deletions SharpTools.Tools/Services/FuzzyFqnLookupService.cs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
1 change: 0 additions & 1 deletion SharpTools.Tools/Services/GitService.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using LibGit2Sharp;
using System.Text;

namespace SharpTools.Tools.Services;

Expand Down
1 change: 0 additions & 1 deletion SharpTools.Tools/Services/MethodSemanticFeatures.cs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
2 changes: 0 additions & 2 deletions SharpTools.Tools/Services/MethodSimilarityResult.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@

using System.Collections.Generic;

namespace SharpTools.Tools.Services {
public class MethodSimilarityResult {
public List<MethodSemanticFeatures> SimilarMethods { get; }
Expand Down
15 changes: 3 additions & 12 deletions SharpTools.Tools/Services/SemanticSimilarityService.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -762,7 +753,7 @@ await Parallel.ForEachAsync(documents, parallelOptions, async (document, docCt)
totalLinesOfCode,
classMethodFeatures
);
}
}

private List<ClassSimilarityResult> CompareClassFeatures(
List<ClassSemanticFeatures> allClassFeatures,
Expand Down Expand Up @@ -933,6 +924,6 @@ private void AddTypeAndNamespaceIfExternal(
if (typeSymbol is IPointerTypeSymbol pointerTypeSymbol) {
AddTypeAndNamespaceIfExternal(pointerTypeSymbol.PointedAtType, containingClassSymbol, externalTypeFqns, usedNamespaceFqns);
}
}
}
}
}
2 changes: 0 additions & 2 deletions SharpTools.Tools/Services/SolutionManager.cs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
Loading