From a3e049faebb13da2a777374615d69ad9d03fd9e1 Mon Sep 17 00:00:00 2001 From: AmirMS <104940545+AmelBawa-msft@users.noreply.github.com> Date: Mon, 27 Jul 2026 11:40:38 -0700 Subject: [PATCH] Address warnings --- .../Commands/DscCommands/BaseDscCommand.cs | 1 + src/WingetCreateCLI/Commands/NewCommand.cs | 3 +- src/WingetCreateCore/Common/PackageParser.cs | 36 +++++++++---------- src/WingetCreateCore/Models/PublisherApp.cs | 12 ------- .../Models/PublisherAppVersion.cs | 13 +++++++ .../Models/PublisherAppVersionContent.cs | 11 ++++++ .../WingetCreateTestExeInstaller.csproj | 2 +- .../UnitTests/GitHubTestsBase.cs | 4 ++- .../UnitTests/TokenCommandTests.cs | 3 ++ 9 files changed, 52 insertions(+), 33 deletions(-) create mode 100644 src/WingetCreateCore/Models/PublisherAppVersion.cs create mode 100644 src/WingetCreateCore/Models/PublisherAppVersionContent.cs diff --git a/src/WingetCreateCLI/Commands/DscCommands/BaseDscCommand.cs b/src/WingetCreateCLI/Commands/DscCommands/BaseDscCommand.cs index 5f25db86..38ec3d99 100644 --- a/src/WingetCreateCLI/Commands/DscCommands/BaseDscCommand.cs +++ b/src/WingetCreateCLI/Commands/DscCommands/BaseDscCommand.cs @@ -89,6 +89,7 @@ public static List GetAvailableCommands() /// Creates a Json schema for a DSC resource object. /// /// The type of the resource object. + /// The name of the DSC command used as the schema title. /// A Json object representing the schema. protected JObject CreateSchema(string commandName) where T : BaseResourceObject, new() diff --git a/src/WingetCreateCLI/Commands/NewCommand.cs b/src/WingetCreateCLI/Commands/NewCommand.cs index 2d47212b..829fc237 100644 --- a/src/WingetCreateCLI/Commands/NewCommand.cs +++ b/src/WingetCreateCLI/Commands/NewCommand.cs @@ -264,8 +264,9 @@ public override async Task Execute() } } } - else // Not a Zip package archive. + else { + // Not a Zip package archive. // Set the manifest root type. There is only one file here so it can only be Font or Manifests. var rootTypeForInstaller = PackageParser.GetManifestRootTypeForInstallerPaths([packageFile]); diff --git a/src/WingetCreateCore/Common/PackageParser.cs b/src/WingetCreateCore/Common/PackageParser.cs index d64d617b..316e4edd 100644 --- a/src/WingetCreateCore/Common/PackageParser.cs +++ b/src/WingetCreateCore/Common/PackageParser.cs @@ -64,25 +64,8 @@ public static class PackageParser }, }; - private enum MachineType - { - X86 = 0x014c, - X64 = 0x8664, - Arm = 0x01c0, - Armv7 = 0x01c4, - Arm64 = 0xaa64, - } - - private enum CompatibilitySet - { - None, - Exe, - Msi, - Msix, - } - /// - /// Manifest Root Type Enum + /// Manifest Root Type Enum. /// public enum ManifestRootType { @@ -102,6 +85,23 @@ public enum ManifestRootType Fonts, } + private enum MachineType + { + X86 = 0x014c, + X64 = 0x8664, + Arm = 0x01c0, + Armv7 = 0x01c4, + Arm64 = 0xaa64, + } + + private enum CompatibilitySet + { + None, + Exe, + Msi, + Msix, + } + /// /// Gets or sets the path in the %TEMP% directory where installers are downloaded to. /// diff --git a/src/WingetCreateCore/Models/PublisherApp.cs b/src/WingetCreateCore/Models/PublisherApp.cs index 59f61875..76dfc43a 100644 --- a/src/WingetCreateCore/Models/PublisherApp.cs +++ b/src/WingetCreateCore/Models/PublisherApp.cs @@ -9,16 +9,4 @@ namespace Microsoft.WingetCreateCore.Models /// A representation of an OWC publisher app. /// public record PublisherApp(string Publisher, string App, string Id); - - /// - /// A representation of an OWC publisher app with a defined version. - /// - public record PublisherAppVersion(string Publisher, string App, string Id, string Version, [property: JsonIgnore] string Path) - : PublisherApp(Publisher, App, Id); - - /// - /// A representation of an OWC publisher app with a defined content and version. - /// - public record PublisherAppVersionContent(string Publisher, string App, string Id, string Version, string Path, string Content) - : PublisherAppVersion(Publisher, App, Id, Version, Path); } diff --git a/src/WingetCreateCore/Models/PublisherAppVersion.cs b/src/WingetCreateCore/Models/PublisherAppVersion.cs new file mode 100644 index 00000000..54a57dfb --- /dev/null +++ b/src/WingetCreateCore/Models/PublisherAppVersion.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. + +namespace Microsoft.WingetCreateCore.Models +{ + using Newtonsoft.Json; + + /// + /// A representation of an OWC publisher app with a defined version. + /// + public record PublisherAppVersion(string Publisher, string App, string Id, string Version, [property: JsonIgnore] string Path) + : PublisherApp(Publisher, App, Id); +} diff --git a/src/WingetCreateCore/Models/PublisherAppVersionContent.cs b/src/WingetCreateCore/Models/PublisherAppVersionContent.cs new file mode 100644 index 00000000..8a0e5190 --- /dev/null +++ b/src/WingetCreateCore/Models/PublisherAppVersionContent.cs @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. + +namespace Microsoft.WingetCreateCore.Models +{ + /// + /// A representation of an OWC publisher app with a defined content and version. + /// + public record PublisherAppVersionContent(string Publisher, string App, string Id, string Version, string Path, string Content) + : PublisherAppVersion(Publisher, App, Id, Version, Path); +} diff --git a/src/WingetCreateTests/WingetCreateTestExeInstaller/WingetCreateTestExeInstaller.csproj b/src/WingetCreateTests/WingetCreateTestExeInstaller/WingetCreateTestExeInstaller.csproj index 0434aa0e..1a9b22db 100644 --- a/src/WingetCreateTests/WingetCreateTestExeInstaller/WingetCreateTestExeInstaller.csproj +++ b/src/WingetCreateTests/WingetCreateTestExeInstaller/WingetCreateTestExeInstaller.csproj @@ -5,7 +5,7 @@ Microsoft Corporation Microsoft Copyright Exe - net6.0 + net9.0 Test exe installer for WingetCreateCLI Microsoft Corporation Microsoft Corporation diff --git a/src/WingetCreateTests/WingetCreateTests/UnitTests/GitHubTestsBase.cs b/src/WingetCreateTests/WingetCreateTests/UnitTests/GitHubTestsBase.cs index 5e323e76..d5c28046 100644 --- a/src/WingetCreateTests/WingetCreateTests/UnitTests/GitHubTestsBase.cs +++ b/src/WingetCreateTests/WingetCreateTests/UnitTests/GitHubTestsBase.cs @@ -80,7 +80,7 @@ private async Task ConfigureForPipelineTestsAsync(string gitHubAppPrivateKey) /// /// Configures the tests to run locally. /// - private async Task ConfigureForLocalTestsAsync() + private Task ConfigureForLocalTestsAsync() { TestContext.Progress.WriteLine("Running locally, using GitHub token for tests"); if (TokenHelper.TryRead(out string token)) @@ -94,6 +94,8 @@ private async Task ConfigureForLocalTestsAsync() ">> Please run 'wingetcreate token -s'\n" + ">> Or set the 'WINGET_CREATE_GITHUB_TOKEN' environment variable to a valid GitHub token."); } + + return Task.CompletedTask; } } } diff --git a/src/WingetCreateTests/WingetCreateTests/UnitTests/TokenCommandTests.cs b/src/WingetCreateTests/WingetCreateTests/UnitTests/TokenCommandTests.cs index 9193556b..45ae8982 100644 --- a/src/WingetCreateTests/WingetCreateTests/UnitTests/TokenCommandTests.cs +++ b/src/WingetCreateTests/WingetCreateTests/UnitTests/TokenCommandTests.cs @@ -50,6 +50,7 @@ public void TearDown() /// /// Test case for verifying that the "token" can be read from the environment variable after clearing the token cache. /// + /// A representing the asynchronous operation. [Test] public async Task TokenClearAndReadFromEnvironmentVariable() { @@ -63,6 +64,7 @@ public async Task TokenClearAndReadFromEnvironmentVariable() /// /// Test case for verifying that the "token --clear" command is working as expected. /// + /// A representing the asynchronous operation. [Test] public async Task TokenClearCommand() { @@ -74,6 +76,7 @@ public async Task TokenClearCommand() /// /// Test case for verifying that the "token --store" command is working as expected. /// + /// A representing the asynchronous operation. [Test] public async Task TokenStoreCommand() {