From 6496a7262a58169a5b7c59dfc7b12c0ebf964f4a Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Fri, 15 May 2026 08:58:33 +0200 Subject: [PATCH] ILSpy.Tests.Windows (net10.0-windows TFM for OS-gated tests) Splits Windows-only tests out of the cross-platform ILSpy.Avalonia.Tests project so the Pdb2Xml / OpenFromGac code paths (which compile only on Windows) can be exercised without conditional `#if WINDOWS` blocks inside the main test suite. Assisted-by: Claude:claude-opus-4-7:Claude Code --- .../ILSpy.Tests.Windows.csproj | 69 +++++++++++++++++++ ILSpy.Tests.Windows/OpenFromGacDialogTests.cs | 50 ++++++++++++++ ILSpy.sln | 14 ++++ 3 files changed, 133 insertions(+) create mode 100644 ILSpy.Tests.Windows/ILSpy.Tests.Windows.csproj create mode 100644 ILSpy.Tests.Windows/OpenFromGacDialogTests.cs diff --git a/ILSpy.Tests.Windows/ILSpy.Tests.Windows.csproj b/ILSpy.Tests.Windows/ILSpy.Tests.Windows.csproj new file mode 100644 index 000000000..3512f74fe --- /dev/null +++ b/ILSpy.Tests.Windows/ILSpy.Tests.Windows.csproj @@ -0,0 +1,69 @@ + + + + + net11.0-windows + true + Exe + enable + false + ICSharpCode.ILSpy.Tests.Windows + true + + + false + false + + + True + ..\ICSharpCode.Decompiler\ICSharpCode.Decompiler.snk + + + direct + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ILSpy.Tests.Windows/OpenFromGacDialogTests.cs b/ILSpy.Tests.Windows/OpenFromGacDialogTests.cs new file mode 100644 index 000000000..3123c7035 --- /dev/null +++ b/ILSpy.Tests.Windows/OpenFromGacDialogTests.cs @@ -0,0 +1,50 @@ +// Copyright (c) 2026 AlphaSierraPapa for the SharpDevelop Team +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files (the "Software"), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons +// to whom the Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all copies or +// substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +using System.Linq; + +using AwesomeAssertions; + +using ICSharpCode.Decompiler.Metadata; + +using NUnit.Framework; + +namespace ICSharpCode.ILSpy.Tests.Windows; + +/// +/// Smoke test for the Windows-conditional GAC enumeration path used by +/// ILSpy.Views.OpenFromGacDialog. The shared +/// only returns entries when run +/// on Windows with a populated GAC; this test validates the project plumbing more than +/// the GAC contents — i.e. the call returns without throwing and the project compiles +/// against Windows-only BCL APIs. +/// +[TestFixture] +public class OpenFromGacDialogTests +{ + [Test] + public void EnumerateGac_Returns_Without_Throwing_On_Windows() + { + // On a developer machine with .NET 4.x installed, this should also return a non-empty + // result. On a stripped CI runner the result may be empty; the test only asserts that + // the enumeration completes — that's enough to catch a regression where the call + // throws (e.g. registry permission change, native-method signature drift). + var result = UniversalAssemblyResolver.EnumerateGac().ToList(); + result.Should().NotBeNull(); + } +} diff --git a/ILSpy.sln b/ILSpy.sln index 06ff2bb8a..954caa09e 100644 --- a/ILSpy.sln +++ b/ILSpy.sln @@ -36,6 +36,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ILSpy", "ILSpy\ILSpy.csproj EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ILSpy.Tests", "ILSpy.Tests\ILSpy.Tests.csproj", "{818CA2D4-175F-4DC1-9C83-189D2CA74ABA}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ILSpy.Tests.Windows", "ILSpy.Tests.Windows\ILSpy.Tests.Windows.csproj", "{20AF56FB-DC0F-4048-B75D-83FEE0D669B2}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -154,6 +156,18 @@ Global {818CA2D4-175F-4DC1-9C83-189D2CA74ABA}.Release|x64.Build.0 = Release|Any CPU {818CA2D4-175F-4DC1-9C83-189D2CA74ABA}.Release|x86.ActiveCfg = Release|Any CPU {818CA2D4-175F-4DC1-9C83-189D2CA74ABA}.Release|x86.Build.0 = Release|Any CPU + {20AF56FB-DC0F-4048-B75D-83FEE0D669B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {20AF56FB-DC0F-4048-B75D-83FEE0D669B2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {20AF56FB-DC0F-4048-B75D-83FEE0D669B2}.Debug|x64.ActiveCfg = Debug|Any CPU + {20AF56FB-DC0F-4048-B75D-83FEE0D669B2}.Debug|x64.Build.0 = Debug|Any CPU + {20AF56FB-DC0F-4048-B75D-83FEE0D669B2}.Debug|x86.ActiveCfg = Debug|Any CPU + {20AF56FB-DC0F-4048-B75D-83FEE0D669B2}.Debug|x86.Build.0 = Debug|Any CPU + {20AF56FB-DC0F-4048-B75D-83FEE0D669B2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {20AF56FB-DC0F-4048-B75D-83FEE0D669B2}.Release|Any CPU.Build.0 = Release|Any CPU + {20AF56FB-DC0F-4048-B75D-83FEE0D669B2}.Release|x64.ActiveCfg = Release|Any CPU + {20AF56FB-DC0F-4048-B75D-83FEE0D669B2}.Release|x64.Build.0 = Release|Any CPU + {20AF56FB-DC0F-4048-B75D-83FEE0D669B2}.Release|x86.ActiveCfg = Release|Any CPU + {20AF56FB-DC0F-4048-B75D-83FEE0D669B2}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE