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
5 changes: 5 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ updates:
- "Svg.Skia"
nuget:
patterns: ["*"]
ignore:
# The shipped analyzer targets Roslyn 4.8 so .NET SDK 8.0.100 can load it.
# Dependabot also discovers its project through winapp.sln. Keep compiler
# reference updates manual so test dependencies cannot lift that baseline.
- dependency-name: "Microsoft.CodeAnalysis.CSharp"
schedule:
interval: "weekly"
cooldown:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System;
using Microsoft.WindowsAppSDK.Analyzers.Rules;
using Xunit;

namespace Microsoft.WindowsAppSDK.Analyzers.Tests;

public sealed class AnalyzerCompatibilityTests
{
[Theory]
[InlineData("Microsoft.CodeAnalysis")]
[InlineData("Microsoft.CodeAnalysis.CSharp")]
public void ShippedAnalyzerReferencesOldestSupportedCompiler(string assemblyName)
{
// Inspect the shipped assembly's references, not the newer Roslyn loaded by the test host.
var reference = Assert.Single(
typeof(UwpApiAnalyzer).Assembly.GetReferencedAssemblies(),
reference => reference.Name == assemblyName);

Assert.Equal(new Version(4, 8, 0, 0), reference.Version);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.6.0" />
<PackageReference Include="xunit.v3" Version="3.2.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.12.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.10.0" />
<PackageReference Include="xunit.v3" Version="4.0.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="4.0.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="5.9.0" />
<PackageReference Include="coverlet.collector" Version="10.0.1" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
stable analyzer/SyntaxKind APIs, so 4.8 is sufficient.
-->
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="5.3.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="5.9.0" PrivateAssets="all" />
</ItemGroup>

<!-- Package-root content (also satisfies NuGet's non-empty-package check, NU5017). -->
Expand Down
2 changes: 1 addition & 1 deletion src/winapp-CLI/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="10.0.5" />
<PackageVersion Include="Spectre.Console" Version="0.54.0" />
<PackageVersion Include="Spectre.Console.Testing" Version="0.54.0" />
<PackageVersion Include="Microsoft.Windows.CsWin32" Version="0.3.269" />
<PackageVersion Include="Microsoft.Windows.CsWin32" Version="0.3.333" />
<PackageVersion Include="System.CommandLine" Version="2.0.5" />
<PackageVersion Include="System.Diagnostics.EventLog" Version="10.0.5" />
<PackageVersion Include="Microsoft.Telemetry.Inbox.Managed" Version="10.0.25148.1001-220626-1600.rs-fun-deploy-dev5" />
Expand Down
33 changes: 15 additions & 18 deletions src/winapp-CLI/WinApp.Cli.Tests/ShellIconTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,34 +27,31 @@ public void GetJumboIcon_NonexistentPath_ReturnsNull()
}

[TestMethod]
public void GetJumboIcon_RealExecutable_ReturnsUsableIconOrIsInconclusive()
public void GetJumboIcon_RealExecutable_ReturnsUsableIcon()
{
// Exercises the full public shell image-list path against a real, icon-bearing executable.
// Deterministic branch coverage of the resolve/short-circuit/failure arms comes from the
// GetJumboIconCore seam tests below; here we require that when the shell host DOES produce an
// icon it is a usable, positively-sized handle, and otherwise mark the test inconclusive
// rather than passing silently on a null (which would not prove the success path ran).
if (!Environment.UserInteractive)
{
Assert.Inconclusive("A shell icon requires an interactive desktop session.");
}

var exe = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "notepad.exe");
if (!File.Exists(exe))
{
exe = Environment.ProcessPath!;
}

Icon? icon = ShellIcon.GetJumboIcon(exe);
try
// Repeat acquisition to exercise COM wrapper lifetime as well as the returned HICON.
for (var i = 0; i < 3; i++)
{
if (icon is null)
{
Assert.Inconclusive(
"The shell host did not produce a jumbo icon for a real executable; the native " +
"success path is not verifiable in this environment.");
}
using var icon = ShellIcon.GetJumboIcon(exe);
Assert.IsNotNull(icon, "Native shell acquisition must not silently fall back after a marshalling failure.");

Assert.IsTrue(icon.Width > 0 && icon.Height > 0, "A resolved icon must have positive dimensions.");
}
finally
{
icon?.Dispose();
using var stream = new MemoryStream();
icon.Save(stream);
stream.Position = 0;
using var restored = new Icon(stream);
Assert.AreEqual(icon.Size, restored.Size, "The cloned icon must remain usable after native handles are released.");
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/winapp-CLI/WinApp.Cli/Helpers/ShellIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public static class ShellIcon
/// </summary>
private static (bool Failed, object? PpvObj) AcquireJumboImageList()
{
var hr = PInvoke.SHGetImageList((int)PInvoke.SHIL_JUMBO, typeof(IImageList2).GUID, out object ppvObj);
var hr = PInvoke.SHGetImageList((int)PInvoke.SHIL_JUMBO, out IImageList2 ppvObj);
return (hr.Failed, ppvObj);
}
}
Loading