Skip to content

Commit 76a6c27

Browse files
authored
chore(quality): code quality improvements (#41)
1 parent 958ed5f commit 76a6c27

7 files changed

Lines changed: 25 additions & 9 deletions

File tree

src/CodingWithCalvin.MCPServer.Server/CodingWithCalvin.MCPServer.Server.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
</PropertyGroup>
1515

1616
<ItemGroup>
17-
<PackageReference Include="ModelContextProtocol" Version="0.2.0-preview.2" />
17+
<PackageReference Include="ModelContextProtocol" Version="0.8.0-preview.1" />
1818
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
19-
<PackageReference Include="ModelContextProtocol.AspNetCore" Version="0.2.0-preview.2" />
19+
<PackageReference Include="ModelContextProtocol.AspNetCore" Version="0.8.0-preview.1" />
2020
<PackageReference Include="StreamJsonRpc" Version="2.20.20" />
2121
</ItemGroup>
2222

src/CodingWithCalvin.MCPServer.Server/Program.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757

5858
static async Task RunServerAsync(string pipeName, string host, int port, string serverName, string logLevel)
5959
{
60+
#pragma warning disable VSTHRD103 // Console.Error.WriteLine is appropriate in console app context
6061
// Parse log level
6162
var msLogLevel = logLevel switch
6263
{
@@ -117,4 +118,5 @@ static async Task RunServerAsync(string pipeName, string host, int port, string
117118
await app.RunAsync();
118119

119120
Console.Error.WriteLine("Server shutdown complete");
121+
#pragma warning restore VSTHRD103
120122
}

src/CodingWithCalvin.MCPServer.Server/RpcClient.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,10 @@ public Task<List<ToolInfo>> GetAvailableToolsAsync()
9696

9797
public Task ShutdownAsync()
9898
{
99+
#pragma warning disable VSTHRD103 // Console.Error.WriteLine is fine in console app context
99100
Console.Error.WriteLine("Shutdown requested via RPC");
100101
_shutdownCts.Cancel();
102+
#pragma warning restore VSTHRD103
101103
return Task.CompletedTask;
102104
}
103105

src/CodingWithCalvin.MCPServer/CodingWithCalvin.MCPServer.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
<LangVersion>latest</LangVersion>
66
<Nullable>enable</Nullable>
77
<RootNamespace>CodingWithCalvin.MCPServer</RootNamespace>
8+
<!-- Suppress VS-Threading analyzer warnings that are architectural decisions or false positives in VSIX context -->
9+
<NoWarn>$(NoWarn);VSTHRD002;VSTHRD003;VSTHRD010;VSTHRD110;VSSDK007</NoWarn>
810
</PropertyGroup>
911

1012
<ItemGroup>

src/CodingWithCalvin.MCPServer/Commands/ServerCommands.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,11 @@ private static void OnShowTools(object sender, EventArgs e)
154154
{
155155
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
156156

157+
if (MCPServerPackage.Instance == null)
158+
{
159+
return;
160+
}
161+
157162
if (MCPServerPackage.RpcServer == null || !MCPServerPackage.RpcServer.IsConnected)
158163
{
159164
VsShellUtilities.ShowMessageBox(

src/CodingWithCalvin.MCPServer/Services/VisualStudioService.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@
1616
using Microsoft.VisualStudio.Shell;
1717
using Microsoft.VisualStudio.Shell.Interop;
1818
using Microsoft.VisualStudio.Shell.TableManager;
19-
using Microsoft.VisualStudio.Text.Editor;
20-
2119
using Microsoft.VisualStudio.Shell.TableControl;
22-
using Microsoft.VisualStudio.Shell.TableManager;
20+
using Microsoft.VisualStudio.Text.Editor;
2321

2422
namespace CodingWithCalvin.MCPServer.Services;
2523

@@ -400,7 +398,7 @@ public async Task<int> ReplaceTextAsync(string oldText, string newText)
400398

401399
var count = 0;
402400
var searchPoint = textDoc.StartPoint.CreateEditPoint();
403-
EditPoint matchEnd = null;
401+
EditPoint? matchEnd = null;
404402

405403
while (searchPoint.FindPattern(oldText, (int)vsFindOptions.vsFindOptionsMatchCase, ref matchEnd))
406404
{
@@ -410,7 +408,7 @@ public async Task<int> ReplaceTextAsync(string oldText, string newText)
410408

411409
if (count > 0)
412410
{
413-
TextRanges tags = null;
411+
TextRanges? tags = null;
414412
textDoc.ReplacePattern(oldText, newText, (int)vsFindOptions.vsFindOptionsMatchCase, ref tags);
415413
}
416414

@@ -1539,7 +1537,7 @@ public async Task<ErrorListResult> GetErrorListAsync(string? severity = null, in
15391537
}
15401538

15411539
// Cast to IErrorList to access the TableControl
1542-
IErrorList errorList = errorListService as IErrorList;
1540+
IErrorList? errorList = errorListService as IErrorList;
15431541
if (errorList == null)
15441542
{
15451543
result.Items.Add(new ErrorItemInfo
@@ -1731,7 +1729,7 @@ public async Task<OutputReadResult> ReadOutputPaneAsync(string paneIdentifier)
17311729
}
17321730

17331731
// Find the matching pane by name (works for both well-known and custom panes)
1734-
EnvDTE.OutputWindowPane targetPane = null;
1732+
EnvDTE.OutputWindowPane? targetPane = null;
17351733

17361734
foreach (EnvDTE.OutputWindowPane outputPane in dte.ToolWindows.OutputWindow.OutputWindowPanes)
17371735
{

src/Directory.Build.props

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<Project>
2+
3+
<PropertyGroup>
4+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
5+
</PropertyGroup>
6+
7+
</Project>

0 commit comments

Comments
 (0)