diff --git a/src/CodingWithCalvin.MCPServer.Server/CodingWithCalvin.MCPServer.Server.csproj b/src/CodingWithCalvin.MCPServer.Server/CodingWithCalvin.MCPServer.Server.csproj index 804839a..d814bd4 100644 --- a/src/CodingWithCalvin.MCPServer.Server/CodingWithCalvin.MCPServer.Server.csproj +++ b/src/CodingWithCalvin.MCPServer.Server/CodingWithCalvin.MCPServer.Server.csproj @@ -14,9 +14,9 @@ - + - + diff --git a/src/CodingWithCalvin.MCPServer.Server/Program.cs b/src/CodingWithCalvin.MCPServer.Server/Program.cs index f73330e..ae9f87c 100644 --- a/src/CodingWithCalvin.MCPServer.Server/Program.cs +++ b/src/CodingWithCalvin.MCPServer.Server/Program.cs @@ -57,6 +57,7 @@ static async Task RunServerAsync(string pipeName, string host, int port, string serverName, string logLevel) { +#pragma warning disable VSTHRD103 // Console.Error.WriteLine is appropriate in console app context // Parse log level var msLogLevel = logLevel switch { @@ -117,4 +118,5 @@ static async Task RunServerAsync(string pipeName, string host, int port, string await app.RunAsync(); Console.Error.WriteLine("Server shutdown complete"); +#pragma warning restore VSTHRD103 } diff --git a/src/CodingWithCalvin.MCPServer.Server/RpcClient.cs b/src/CodingWithCalvin.MCPServer.Server/RpcClient.cs index 98a68e7..0194885 100644 --- a/src/CodingWithCalvin.MCPServer.Server/RpcClient.cs +++ b/src/CodingWithCalvin.MCPServer.Server/RpcClient.cs @@ -96,8 +96,10 @@ public Task> GetAvailableToolsAsync() public Task ShutdownAsync() { +#pragma warning disable VSTHRD103 // Console.Error.WriteLine is fine in console app context Console.Error.WriteLine("Shutdown requested via RPC"); _shutdownCts.Cancel(); +#pragma warning restore VSTHRD103 return Task.CompletedTask; } diff --git a/src/CodingWithCalvin.MCPServer/CodingWithCalvin.MCPServer.csproj b/src/CodingWithCalvin.MCPServer/CodingWithCalvin.MCPServer.csproj index df769f7..991f5f6 100644 --- a/src/CodingWithCalvin.MCPServer/CodingWithCalvin.MCPServer.csproj +++ b/src/CodingWithCalvin.MCPServer/CodingWithCalvin.MCPServer.csproj @@ -5,6 +5,8 @@ latest enable CodingWithCalvin.MCPServer + + $(NoWarn);VSTHRD002;VSTHRD003;VSTHRD010;VSTHRD110;VSSDK007 diff --git a/src/CodingWithCalvin.MCPServer/Commands/ServerCommands.cs b/src/CodingWithCalvin.MCPServer/Commands/ServerCommands.cs index 3fd5913..64d0c59 100644 --- a/src/CodingWithCalvin.MCPServer/Commands/ServerCommands.cs +++ b/src/CodingWithCalvin.MCPServer/Commands/ServerCommands.cs @@ -154,6 +154,11 @@ private static void OnShowTools(object sender, EventArgs e) { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); + if (MCPServerPackage.Instance == null) + { + return; + } + if (MCPServerPackage.RpcServer == null || !MCPServerPackage.RpcServer.IsConnected) { VsShellUtilities.ShowMessageBox( diff --git a/src/CodingWithCalvin.MCPServer/Services/VisualStudioService.cs b/src/CodingWithCalvin.MCPServer/Services/VisualStudioService.cs index 919839e..5efd6ca 100644 --- a/src/CodingWithCalvin.MCPServer/Services/VisualStudioService.cs +++ b/src/CodingWithCalvin.MCPServer/Services/VisualStudioService.cs @@ -16,10 +16,8 @@ using Microsoft.VisualStudio.Shell; using Microsoft.VisualStudio.Shell.Interop; using Microsoft.VisualStudio.Shell.TableManager; -using Microsoft.VisualStudio.Text.Editor; - using Microsoft.VisualStudio.Shell.TableControl; -using Microsoft.VisualStudio.Shell.TableManager; +using Microsoft.VisualStudio.Text.Editor; namespace CodingWithCalvin.MCPServer.Services; @@ -400,7 +398,7 @@ public async Task ReplaceTextAsync(string oldText, string newText) var count = 0; var searchPoint = textDoc.StartPoint.CreateEditPoint(); - EditPoint matchEnd = null; + EditPoint? matchEnd = null; while (searchPoint.FindPattern(oldText, (int)vsFindOptions.vsFindOptionsMatchCase, ref matchEnd)) { @@ -410,7 +408,7 @@ public async Task ReplaceTextAsync(string oldText, string newText) if (count > 0) { - TextRanges tags = null; + TextRanges? tags = null; textDoc.ReplacePattern(oldText, newText, (int)vsFindOptions.vsFindOptionsMatchCase, ref tags); } @@ -1539,7 +1537,7 @@ public async Task GetErrorListAsync(string? severity = null, in } // Cast to IErrorList to access the TableControl - IErrorList errorList = errorListService as IErrorList; + IErrorList? errorList = errorListService as IErrorList; if (errorList == null) { result.Items.Add(new ErrorItemInfo @@ -1731,7 +1729,7 @@ public async Task ReadOutputPaneAsync(string paneIdentifier) } // Find the matching pane by name (works for both well-known and custom panes) - EnvDTE.OutputWindowPane targetPane = null; + EnvDTE.OutputWindowPane? targetPane = null; foreach (EnvDTE.OutputWindowPane outputPane in dte.ToolWindows.OutputWindow.OutputWindowPanes) { diff --git a/src/Directory.Build.props b/src/Directory.Build.props new file mode 100644 index 0000000..4c83226 --- /dev/null +++ b/src/Directory.Build.props @@ -0,0 +1,7 @@ + + + + true + + +