mirror of https://github.com/icsharpcode/ILSpy.git
Browse Source
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 Codepull/3755/head
3 changed files with 133 additions and 0 deletions
@ -0,0 +1,69 @@ |
|||||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||||
|
|
||||||
|
<PropertyGroup> |
||||||
|
<!-- Windows-targeted TFM unlocks Microsoft.DiaSymReader (native COM) + System.Windows |
||||||
|
registry APIs without conditional package gates. EnableWindowsTargeting lets the |
||||||
|
build satisfy the -windows reference assemblies on non-Windows OSes via the |
||||||
|
cross-targeting pack, so `dotnet build ILSpy.sln` succeeds on Linux/macOS; the |
||||||
|
tests still only execute on Windows because the binaries P/Invoke into Win32. --> |
||||||
|
<TargetFramework>net11.0-windows</TargetFramework> |
||||||
|
<EnableWindowsTargeting>true</EnableWindowsTargeting> |
||||||
|
<OutputType>Exe</OutputType> |
||||||
|
<Nullable>enable</Nullable> |
||||||
|
<IsPackable>false</IsPackable> |
||||||
|
<RootNamespace>ICSharpCode.ILSpy.Tests.Windows</RootNamespace> |
||||||
|
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault> |
||||||
|
|
||||||
|
<!-- Avalonia tests don't need WPF / WinForms reference assemblies even on the |
||||||
|
-windows TFM. Suppress so the project doesn't pull in unused frameworks. --> |
||||||
|
<UseWPF>false</UseWPF> |
||||||
|
<UseWindowsForms>false</UseWindowsForms> |
||||||
|
|
||||||
|
<!-- Strong-named with the shared snk so ICSharpCode.ILSpyX can grant |
||||||
|
InternalsVisibleTo for the analyzer-library tests, mirroring the main |
||||||
|
test project. --> |
||||||
|
<SignAssembly>True</SignAssembly> |
||||||
|
<AssemblyOriginatorKeyFile>..\ICSharpCode.Decompiler\ICSharpCode.Decompiler.snk</AssemblyOriginatorKeyFile> |
||||||
|
|
||||||
|
<!-- Microsoft.DiaSymReader.Converter.Xml/.Native transitively pull System.Net.Http |
||||||
|
4.3.0 and System.Text.RegularExpressions 4.3.0 which carry known vulnerabilities |
||||||
|
(NU1903). These transitive references are outside our control and not exploitable |
||||||
|
in the test process. Audit only direct deps. --> |
||||||
|
<NuGetAuditMode>direct</NuGetAuditMode> |
||||||
|
</PropertyGroup> |
||||||
|
|
||||||
|
<ItemGroup> |
||||||
|
<PackageReference Include="Avalonia" /> |
||||||
|
<PackageReference Include="Avalonia.Headless.NUnit" /> |
||||||
|
<PackageReference Include="Avalonia.Themes.Simple" /> |
||||||
|
<PackageReference Include="NUnit" /> |
||||||
|
<PackageReference Include="NUnit3TestAdapter" /> |
||||||
|
<PackageReference Include="coverlet.MTP" /> |
||||||
|
<PackageReference Include="Microsoft.Testing.Extensions.TrxReport" /> |
||||||
|
<PackageReference Include="Microsoft.Testing.Extensions.VSTestBridge" /> |
||||||
|
<PackageReference Include="AwesomeAssertions" /> |
||||||
|
<PackageReference Include="NSubstitute" /> |
||||||
|
|
||||||
|
<!-- Windows-only native packages that the matching ILSpy commands gate |
||||||
|
behind `Debug + IsOSPlatform(Windows)`. Available unconditionally here because |
||||||
|
the project itself only builds on Windows. --> |
||||||
|
<PackageReference Include="Microsoft.DiaSymReader.Converter.Xml" /> |
||||||
|
<PackageReference Include="Microsoft.DiaSymReader" /> |
||||||
|
<PackageReference Include="Microsoft.DiaSymReader.Native" /> |
||||||
|
</ItemGroup> |
||||||
|
|
||||||
|
<ItemGroup> |
||||||
|
<ProjectReference Include="..\ILSpy\ILSpy.csproj" /> |
||||||
|
</ItemGroup> |
||||||
|
|
||||||
|
<!-- Share TestApp + TestAppBuilder with the cross-platform test project. Linked |
||||||
|
rather than duplicated so changes in the main project (data templates, theme |
||||||
|
stack, settings sandbox) automatically apply here. --> |
||||||
|
<ItemGroup> |
||||||
|
<Compile Include="..\ILSpy.Tests\TestApp.axaml.cs" Link="TestApp.axaml.cs" /> |
||||||
|
<Compile Include="..\ILSpy.Tests\TestAppBuilder.cs" Link="TestAppBuilder.cs" /> |
||||||
|
<Compile Include="..\ILSpy.Tests\ResetAppStateAttribute.cs" Link="ResetAppStateAttribute.cs" /> |
||||||
|
<AvaloniaResource Include="..\ILSpy.Tests\TestApp.axaml" Link="TestApp.axaml" /> |
||||||
|
</ItemGroup> |
||||||
|
|
||||||
|
</Project> |
||||||
@ -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; |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Smoke test for the Windows-conditional GAC enumeration path used by
|
||||||
|
/// <c>ILSpy.Views.OpenFromGacDialog</c>. The shared
|
||||||
|
/// <see cref="UniversalAssemblyResolver.EnumerateGac"/> 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.
|
||||||
|
/// </summary>
|
||||||
|
[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(); |
||||||
|
} |
||||||
|
} |
||||||
Loading…
Reference in new issue