Skip to content

Commit e845aea

Browse files
committed
Major change:
prevent StackOverflow exceptions in Visual Studio 2026 for users who have ExtensionManager installed: fixed the assembly resolver to prevent recursion and version mismatches Minor changes: update dependencies, error handling, and code clarity - Add Community.VisualStudio.Toolkit.15, MessagePack, Microsoft.IO.Redist, and update System.Text.Json to 8.0.5 in all projects - Refactor generator method names for clarity and consistency - Wrap InstallExportDialogViewModel.OnOk in try-catch; suppress VSTHRD100 warning - Update VSIX project files for consistent package versions
1 parent edaa5cb commit e845aea

File tree

15 files changed

+126
-18
lines changed

15 files changed

+126
-18
lines changed

src/ExtensionManager.Manifest/ExtensionManager.Manifest.csproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<ItemGroup>
4+
<PackageReference Include="Community.VisualStudio.Toolkit.15" Version="15.0.507" />
5+
<PackageReference Include="MessagePack" Version="2.5.187" />
6+
<PackageReference Include="Microsoft.IO.Redist" Version="6.0.1" />
47
<PackageReference Include="Nullable" Version="1.3.1" PrivateAssets="all" />
58
<PackageReference Include="IsExternalInit" Version="1.0.3" PrivateAssets="all" />
69
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
7-
<PackageReference Include="System.Text.Json" Version="8.0.4" />
10+
<PackageReference Include="System.Text.Json" Version="8.0.5" />
811
</ItemGroup>
912

1013
<ItemGroup>

src/ExtensionManager.UI/ExtensionManager.UI.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@
55
</PropertyGroup>
66

77
<ItemGroup>
8+
<PackageReference Include="Community.VisualStudio.Toolkit.15" Version="15.0.507" />
9+
<PackageReference Include="MessagePack" Version="2.5.187" />
10+
<PackageReference Include="Microsoft.IO.Redist" Version="6.0.1" />
811
<PackageReference Include="Nullable" Version="1.3.1" PrivateAssets="all" />
912
<PackageReference Include="IsExternalInit" Version="1.0.3" PrivateAssets="all" />
1013
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
14+
<PackageReference Include="System.Text.Json" Version="8.0.5" />
1115
</ItemGroup>
1216

1317
<ItemGroup>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// This file is used by Code Analysis to maintain SuppressMessage
2+
// attributes that are applied to this project.
3+
// Project-level suppressions either have no target or are given
4+
// a specific target and scoped to a namespace, type, member, etc.
5+
6+
using System.Diagnostics.CodeAnalysis;
7+
8+
[assembly: SuppressMessage("Usage", "VSTHRD100:Avoid async void methods", Justification = "<Pending>", Scope = "member", Target = "~M:ExtensionManager.UI.ViewModels.InstallExportDialogViewModel`1.OnOk")]

src/ExtensionManager.UI/ViewModels/InstallExportDialogViewModel.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,18 @@ protected override bool CanOk()
2424
}
2525
protected override async void OnOk()
2626
{
27-
await RunWorkAsync();
27+
try
28+
{
29+
await RunWorkAsync();
2830

29-
RequestClose();
31+
RequestClose();
32+
}
33+
catch
34+
{
35+
// Safely show error to user
36+
}
3037
}
38+
3139
private async Task RunWorkAsync()
3240
{
3341
using var cts = new CancellationTokenSource();

src/ExtensionManager.VisualStudio.Abstractions/ExtensionManager.VisualStudio.Abstractions.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9+
<PackageReference Include="Community.VisualStudio.Toolkit.15" Version="15.0.507" />
10+
<PackageReference Include="MessagePack" Version="2.5.187" />
911
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
12+
<PackageReference Include="Microsoft.IO.Redist" Version="6.0.1" />
13+
<PackageReference Include="System.Text.Json" Version="8.0.5" />
1014
</ItemGroup>
1115

1216
</Project>

src/ExtensionManager.VisualStudio.Adapter.Abstractions/ExtensionManager.VisualStudio.Adapter.Abstractions.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44
<RootNamespace>ExtensionManager.VisualStudio.Adapter</RootNamespace>
55
</PropertyGroup>
66

7+
<ItemGroup>
8+
<PackageReference Include="Community.VisualStudio.Toolkit.15" Version="15.0.507" />
9+
<PackageReference Include="MessagePack" Version="2.5.187" />
10+
<PackageReference Include="Microsoft.IO.Redist" Version="6.0.1" />
11+
<PackageReference Include="System.Text.Json" Version="8.0.5" />
12+
</ItemGroup>
13+
714
<ItemGroup>
815
<ProjectReference Include="..\ExtensionManager.VisualStudio.Abstractions\ExtensionManager.VisualStudio.Abstractions.csproj" />
916
</ItemGroup>

src/ExtensionManager.VisualStudio.Adapter.Generator/ExtensionManager.VisualStudio.Adapter.Generator.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@
1010
</ItemGroup>
1111

1212
<ItemGroup>
13+
<PackageReference Include="Community.VisualStudio.Toolkit.15" Version="15.0.507" />
14+
<PackageReference Include="MessagePack" Version="2.5.187" />
15+
<PackageReference Include="Microsoft.IO.Redist" Version="6.0.1" />
1316
<PackageReference Include="Nullable" Version="1.3.1" PrivateAssets="all" />
1417
<PackageReference Include="System.Reflection.Emit" Version="4.7.0" />
18+
<PackageReference Include="System.Text.Json" Version="8.0.5" />
1519
</ItemGroup>
1620

1721
</Project>

src/ExtensionManager.VisualStudio.Adapter.Generator/Internal/GeneratorReflector.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ private MemberInfo GetMember(Type type, MemberTypes memberType, string name)
4848
public Type IVsExtensionRepository() => GetType("Microsoft.VisualStudio.ExtensionManager.IVsExtensionRepository");
4949
public Type SVsExtensionRepository() => GetType("Microsoft.VisualStudio.ExtensionManager.SVsExtensionRepository");
5050

51-
public MethodInfo VS_GetRequiredServiceAsync(Type serviceType, Type interfaceType)
51+
public MethodInfo VS_GetRequiredService(Type serviceType, Type interfaceType)
5252
{
5353
return GetType("Community.VisualStudio.Toolkit.VS")
5454
.GetMethodOrThrow("GetRequiredServiceAsync")

src/ExtensionManager.VisualStudio.Adapter.Generator/Types/Extensions/ExtensionManagerAdapterGenerator.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ public Type Emit(GeneratorContext context)
1818
{
1919
emit.Implement(context.Reflect.AdapterInterface());
2020

21-
emit.ImplementMethod(context.Reflect.Adapter_GetManagerAsync())
21+
emit.ImplementMethod(context.Reflect.Adapter_GetManager())
2222
.EmitIL(il =>
2323
{
24-
il.Emit(OpCodes.Call, context.Reflect.VS_GetManagerServiceAsync());
24+
il.Emit(OpCodes.Call, context.Reflect.VS_GetManagerService());
2525
il.Emit(OpCodes.Ret);
2626
});
2727

@@ -50,11 +50,11 @@ file static class Extensions
5050
{
5151
public static Type AdapterInterface(this GeneratorReflector reflect) => typeof(IVSExtensionManagerAdapter<,>).MakeGenericType(reflect.IVsExtensionManager(), reflect.IInstalledExtension());
5252

53-
public static MethodInfo Adapter_GetManagerAsync(this GeneratorReflector reflect) => reflect.AdapterInterface().GetMethod(nameof(IVSExtensionManagerAdapter<int, int>.GetManagerAsync));
53+
public static MethodInfo Adapter_GetManager(this GeneratorReflector reflect) => reflect.AdapterInterface().GetMethod(nameof(IVSExtensionManagerAdapter<int, int>.GetManagerAsync));
5454
public static MethodInfo Adapter_GetInstalledExtensions(this GeneratorReflector reflect) => reflect.AdapterInterface().GetMethod(nameof(IVSExtensionManagerAdapter<int, int>.GetInstalledExtensions));
5555
public static MethodInfo Adapter_CreateInstalledExtensionInfo(this GeneratorReflector reflect) => reflect.AdapterInterface().GetMethod(nameof(IVSExtensionManagerAdapter<int, int>.CreateInstalledExtensionInfo));
5656

57-
public static MethodInfo VS_GetManagerServiceAsync(this GeneratorReflector reflect) => reflect.VS_GetRequiredServiceAsync(reflect.SVsExtensionManager(), reflect.IVsExtensionManager());
57+
public static MethodInfo VS_GetManagerService(this GeneratorReflector reflect) => reflect.VS_GetRequiredService(reflect.SVsExtensionManager(), reflect.IVsExtensionManager());
5858

5959
public static MethodInfo Manager_GetInstalledExtensions(this GeneratorReflector reflect) => reflect.IVsExtensionManager().GetMethodOrThrow("GetInstalledExtensions");
6060
}

src/ExtensionManager.VisualStudio.Adapter.Generator/Types/Extensions/ExtensionRepositoryAdapterGenerator.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,14 @@ file static class Extensions
4545
{
4646
public static Type AdapterInterface(this GeneratorReflector reflect) => typeof(IVSExtensionRepositoryAdapter<>).MakeGenericType(reflect.IVsExtensionRepository());
4747

48+
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods
4849
public static MethodInfo Adapter_GetRepositoryAsync(this GeneratorReflector reflect) => reflect.AdapterInterface().GetMethod(nameof(IVSExtensionRepositoryAdapter<int>.GetRepositoryAsync));
50+
#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods
4951
public static MethodInfo Adapter_GetVSGalleryExtensions(this GeneratorReflector reflect) => reflect.AdapterInterface().GetMethod(nameof(IVSExtensionRepositoryAdapter<int>.GetVSGalleryExtensions));
5052

51-
public static MethodInfo VS_GetRepositoryServiceAsync(this GeneratorReflector reflect) => reflect.VS_GetRequiredServiceAsync(reflect.SVsExtensionRepository(), reflect.IVsExtensionRepository());
53+
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods
54+
public static MethodInfo VS_GetRepositoryServiceAsync(this GeneratorReflector reflect) => reflect.VS_GetRequiredService(reflect.SVsExtensionRepository(), reflect.IVsExtensionRepository());
55+
#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods
5256

5357
public static MethodInfo Repository_GetVSGalleryExtensions(this GeneratorReflector reflect, Type extensionType) => reflect.IVsExtensionRepository().GetMethodOrThrow("GetVSGalleryExtensions").MakeGenericMethod(extensionType);
5458
}

0 commit comments

Comments
 (0)