Skip to content

Commit

Permalink
Cherry pick #4392 to 1.7 (#4402)
Browse files Browse the repository at this point in the history
  • Loading branch information
msftrubengu committed Apr 23, 2024
1 parent 36cf71e commit 83ec285
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
@@ -1,4 +1,4 @@
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// <copyright file="ModuleInit.cs" company="Microsoft Corporation">
// Copyright (c) Microsoft Corporation. Licensed under the MIT License.
// </copyright>
Expand All @@ -23,7 +23,7 @@ namespace Microsoft.WinGet.Resolver
/// </summary>
public class ModuleInit : IModuleAssemblyInitializer, IModuleAssemblyCleanup
{
private static readonly IEnumerable<Architecture> ValidArchs = new Architecture[] { Architecture.X86, Architecture.X64 };
private static readonly IEnumerable<Architecture> ValidArchs = new Architecture[] { Architecture.X86, Architecture.X64, Architecture.Arm64 };

/// <inheritdoc/>
public void OnImport()
Expand Down
@@ -1,4 +1,4 @@
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// <copyright file="OperationWithProgressBase.cs" company="Microsoft Corporation">
// Copyright (c) Microsoft Corporation. Licensed under the MIT License.
// </copyright>
Expand All @@ -7,6 +7,7 @@
namespace Microsoft.WinGet.Client.Engine.Helpers
{
using System;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Microsoft.WinGet.Common.Command;
using Microsoft.WinGet.Resources;
Expand All @@ -19,6 +20,24 @@ namespace Microsoft.WinGet.Client.Engine.Helpers
/// <typeparam name="TProgressData">Progress data.</typeparam>
internal abstract class OperationWithProgressBase<TOperationResult, TProgressData>
{
private static bool isProgressEnabled;

static OperationWithProgressBase()
{
// Progress on arm64 will produce an AV because there's an OS bug where marshaling structs over a certain size fail.
// Fix is in 10.0.26068.0, for build before that disable progress.
if (RuntimeInformation.ProcessArchitecture == Architecture.Arm64)
{
var minWindowsVersion = new Version(10, 0, 26068, 0);
var osVersion = Environment.OSVersion.Version;
isProgressEnabled = osVersion.CompareTo(minWindowsVersion) >= 0;
}
else
{
isProgressEnabled = true;
}
}

/// <summary>
/// Initializes a new instance of the <see cref="OperationWithProgressBase{TOperationResult, TProgressData}"/> class.
/// </summary>
Expand Down Expand Up @@ -64,7 +83,11 @@ internal abstract class OperationWithProgressBase<TOperationResult, TProgressDat
public async Task<TOperationResult> ExecuteAsync(Func<IAsyncOperationWithProgress<TOperationResult, TProgressData>> func)
{
var operation = func();
operation.Progress = this.Progress;

if (isProgressEnabled)
{
operation.Progress = this.Progress;
}

try
{
Expand Down
@@ -1,4 +1,4 @@
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// <copyright file="ConfigurationCommand.cs" company="Microsoft Corporation">
// Copyright (c) Microsoft Corporation. Licensed under the MIT License.
// </copyright>
Expand Down

0 comments on commit 83ec285

Please sign in to comment.