Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ModelContextProtocol" Version="0.2.0-preview.2" />
<PackageReference Include="ModelContextProtocol" Version="0.8.0-preview.1" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageReference Include="ModelContextProtocol.AspNetCore" Version="0.2.0-preview.2" />
<PackageReference Include="ModelContextProtocol.AspNetCore" Version="0.8.0-preview.1" />
<PackageReference Include="StreamJsonRpc" Version="2.20.20" />
</ItemGroup>

Expand Down
2 changes: 2 additions & 0 deletions src/CodingWithCalvin.MCPServer.Server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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
}
2 changes: 2 additions & 0 deletions src/CodingWithCalvin.MCPServer.Server/RpcClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,10 @@ public Task<List<ToolInfo>> 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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<RootNamespace>CodingWithCalvin.MCPServer</RootNamespace>
<!-- Suppress VS-Threading analyzer warnings that are architectural decisions or false positives in VSIX context -->
<NoWarn>$(NoWarn);VSTHRD002;VSTHRD003;VSTHRD010;VSTHRD110;VSSDK007</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand Down
5 changes: 5 additions & 0 deletions src/CodingWithCalvin.MCPServer/Commands/ServerCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
12 changes: 5 additions & 7 deletions src/CodingWithCalvin.MCPServer/Services/VisualStudioService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -400,7 +398,7 @@ public async Task<int> 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))
{
Expand All @@ -410,7 +408,7 @@ public async Task<int> ReplaceTextAsync(string oldText, string newText)

if (count > 0)
{
TextRanges tags = null;
TextRanges? tags = null;
textDoc.ReplacePattern(oldText, newText, (int)vsFindOptions.vsFindOptionsMatchCase, ref tags);
}

Expand Down Expand Up @@ -1539,7 +1537,7 @@ public async Task<ErrorListResult> 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
Expand Down Expand Up @@ -1731,7 +1729,7 @@ public async Task<OutputReadResult> 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)
{
Expand Down
7 changes: 7 additions & 0 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Project>

<PropertyGroup>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

</Project>
Loading