Skip to content
Open
Show file tree
Hide file tree
Changes from 4 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
6 changes: 3 additions & 3 deletions SharpTools.Tools/Mcp/ToolHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}
}

Expand All @@ -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.";
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to keep all nameof expressions when referencing code in strings, to maintain a compile time guarantee that the name is correct. If I were to rename one of the tools, then all strings which use its name must be updated.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restored the code to what they were before.

private const string FqnHelpMessage = $" Try `{ToolHelpers.SharpToolPrefix}SearchDefinitions`, `{ToolHelpers.SharpToolPrefix}GetMembers`, or `{ToolHelpers.SharpToolPrefix}ReadTypesFromRoslynDocument` to find what you need.";
public static async Task<ISymbol> GetRoslynSymbolOrThrowAsync(
ISolutionManager solutionManager,
string fullyQualifiedSymbolName,
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 SharpTools.Tools.Mcp;
using System.Xml.Linq;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using System.Xml;

// 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 = LegacyNuGetPackageReader.GetAllPackages(project.FilePath);
foreach (var package in packages) {
packageRefs.Add($"{package.PackageId} ({package.Version})");
}
Expand Down Expand Up @@ -517,7 +514,7 @@ public static async Task<object> LoadProject(
}
}

return $"<typeTree note=\"Use {ToolHelpers.SharpToolPrefix}{nameof(AnalysisTools.GetMembers)} for more detailed information about specific types.\">" +
return $"<typeTree note=\"Use {ToolHelpers.SharpToolPrefix}GetMembers for more detailed information about specific types.\">" +
output +
"\n</typeTree>";

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
Loading