diff --git a/.editorconfig b/.editorconfig index e4afa19..ba40f0c 100644 --- a/.editorconfig +++ b/.editorconfig @@ -307,6 +307,7 @@ dotnet_diagnostic.CA1812.severity = warning dotnet_diagnostic.CA1821.severity = warning dotnet_diagnostic.CA1823.severity = warning dotnet_diagnostic.CA1848.severity = suggestion +dotnet_diagnostic.CA1861.severity = suggestion dotnet_diagnostic.CA1900.severity = warning dotnet_diagnostic.CA1901.severity = warning dotnet_diagnostic.CA2002.severity = warning diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 83ec0a7..18a9a8e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -24,7 +24,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 7.0.x + dotnet-version: 8.0.x - name: Install and Configure Keyring if: ${{ matrix.os == 'ubuntu-latest' }} run: | @@ -90,13 +90,13 @@ jobs: include: - os: windows-latest dotnet-os: win - dotnet-framework: net7.0-windows10.0.17763.0 + dotnet-framework: net8.0-windows10.0.17763.0 - os: ubuntu-latest dotnet-os: linux - dotnet-framework: net7.0 + dotnet-framework: net8.0 - os: macos-latest dotnet-os: osx.12 - dotnet-framework: net7.0 + dotnet-framework: net8.0 runs-on: ${{ matrix.os }} name: Build CLI - ${{ matrix.dotnet-os }}-${{ matrix.dotnet-arch }} @@ -108,7 +108,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 7.0.x + dotnet-version: 8.0.x - name: Add msbuild to PATH if: ${{ matrix.os == 'windows-latest' }} uses: microsoft/setup-msbuild@v1.3 diff --git a/.pipelines/build.yml b/.pipelines/build.yml index ca0e8b2..86be119 100644 --- a/.pipelines/build.yml +++ b/.pipelines/build.yml @@ -39,7 +39,7 @@ jobs: - task: UseDotNet@2 displayName: Setup .NET 7 inputs: - version: 7.0.x + version: 8.0.x - script: mv -f ./.pipelines/release-nuget.config ./nuget.config displayName: Add release package source - task: NuGetAuthenticate@0 diff --git a/.pipelines/release.yml b/.pipelines/release.yml index 933a815..7f27d52 100644 --- a/.pipelines/release.yml +++ b/.pipelines/release.yml @@ -44,7 +44,7 @@ stages: - task: UseDotNet@2 displayName: Setup .NET 7 inputs: - version: 7.0.x + version: 8.0.x - ${{ if eq(parameters.DoEsrp, 'true') }}: - task: UseDotNet@2 displayName: Setup .NET 6.0 (For ESRP Task) @@ -83,7 +83,7 @@ stages: InputType: 'Basic' Function: 'analyze' TargetPattern: guardianGlob - AnalyzeTargetGlob: 'MSStore.API\bin\$(dotnet_configuration)\net7.0\MSStore.API.dll' + AnalyzeTargetGlob: 'MSStore.API\bin\$(dotnet_configuration)\net8.0\MSStore.API.dll' AnalyzeVerbose: true toolVersion: 'Latest' - task: PoliCheck@2 @@ -120,19 +120,19 @@ stages: ${{ dotnet_config }}_windows_${{ platform }}: os: windows-latest dotnet_runtime: win - dotnet_framework: net7.0-windows10.0.17763.0 + dotnet_framework: net8.0-windows10.0.17763.0 dotnet_arch: ${{ platform }} dotnet_configuration: ${{ dotnet_config }} ${{ dotnet_config }}_linux_${{ platform }}: os: ubuntu-latest dotnet_runtime: linux - dotnet_framework: net7.0 + dotnet_framework: net8.0 dotnet_arch: ${{ platform }} dotnet_configuration: ${{ dotnet_config }} ${{ dotnet_config }}_macos_${{ platform }}: os: macos-latest dotnet_runtime: osx.12 - dotnet_framework: net7.0 + dotnet_framework: net8.0 dotnet_arch: ${{ platform }} dotnet_configuration: ${{ dotnet_config }} pool: @@ -146,7 +146,7 @@ stages: - task: UseDotNet@2 displayName: Setup .NET 7 inputs: - version: 7.0.x + version: 8.0.x - ${{ if eq(parameters.DoEsrp, 'true') }}: - task: UseDotNet@2 displayName: Setup .NET 6.0 (For ESRP Task) diff --git a/.pipelines/templates/after-build.yaml b/.pipelines/templates/after-build.yaml index c9b01d8..411ba6f 100644 --- a/.pipelines/templates/after-build.yaml +++ b/.pipelines/templates/after-build.yaml @@ -27,7 +27,7 @@ steps: InputType: 'Basic' Function: 'analyze' TargetPattern: guardianGlob - AnalyzeTargetGlob: '$(System.DefaultWorkingDirectory)\MSStore.API\bin\${{ parameters.dotnet_configuration }}\net7.0\MSStore.API.dll' + AnalyzeTargetGlob: '$(System.DefaultWorkingDirectory)\MSStore.API\bin\${{ parameters.dotnet_configuration }}\net8.0\MSStore.API.dll' AnalyzeVerbose: true toolVersion: 'Latest' - task: PoliCheck@2 diff --git a/.pipelines/templates/build-nuget.yaml b/.pipelines/templates/build-nuget.yaml index 1db6901..9b1c7ad 100644 --- a/.pipelines/templates/build-nuget.yaml +++ b/.pipelines/templates/build-nuget.yaml @@ -63,7 +63,7 @@ steps: condition: startsWith(variables.AgentOS, 'Linux') inputs: ConnectedServiceName: 'MSStoreCLI - ESRP Code Signing' - FolderPath: '$(System.DefaultWorkingDirectory)/MSStore.API/bin/${{ parameters.dotnet_configuration }}/net7.0' + FolderPath: '$(System.DefaultWorkingDirectory)/MSStore.API/bin/${{ parameters.dotnet_configuration }}/net8.0' Pattern: 'MSStore.API.dll' signConfigType: inlineSignParams inlineOperation: | diff --git a/.pipelines/templates/pack-nuget.yaml b/.pipelines/templates/pack-nuget.yaml index a269bc0..eb35b98 100644 --- a/.pipelines/templates/pack-nuget.yaml +++ b/.pipelines/templates/pack-nuget.yaml @@ -50,7 +50,7 @@ steps: displayName: 'Copy Artifacts - NuGet DLLs' condition: startsWith(variables.AgentOS, 'Linux') inputs: - contents: '$(System.DefaultWorkingDirectory)/MSStore.API/bin/${{ parameters.dotnet_configuration }}/net7.0/*' + contents: '$(System.DefaultWorkingDirectory)/MSStore.API/bin/${{ parameters.dotnet_configuration }}/net8.0/*' flattenFolders: true targetFolder: '$(Build.ArtifactStagingDirectory)/NuGetDLLs' - task: PublishPipelineArtifact@1 diff --git a/MSStore.API/MSStore.API.csproj b/MSStore.API/MSStore.API.csproj index 5e33b8b..b868d7d 100644 --- a/MSStore.API/MSStore.API.csproj +++ b/MSStore.API/MSStore.API.csproj @@ -1,7 +1,7 @@ - net7.0 + net8.0 $(NoWarn);CS1591 MIT @@ -20,9 +20,9 @@ - - - + + + diff --git a/MSStore.API/MSStoreException.cs b/MSStore.API/MSStoreException.cs index b50e270..ac1700f 100644 --- a/MSStore.API/MSStoreException.cs +++ b/MSStore.API/MSStoreException.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.Runtime.Serialization; namespace MSStore.API { @@ -21,10 +20,5 @@ public MSStoreException(string? message, Exception? innerException) : base(message, innerException) { } - - protected MSStoreException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } } } diff --git a/MSStore.API/Packaged/StorePackagedAPI.cs b/MSStore.API/Packaged/StorePackagedAPI.cs index 400d980..a8382b2 100644 --- a/MSStore.API/Packaged/StorePackagedAPI.cs +++ b/MSStore.API/Packaged/StorePackagedAPI.cs @@ -6,6 +6,7 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Net.Http; +using System.Text; using System.Text.Json; using System.Threading; using System.Threading.Tasks; @@ -18,14 +19,14 @@ namespace MSStore.API.Packaged public class StorePackagedAPI : IStorePackagedAPI, IDisposable { private static readonly string DevCenterVersion = "1.0"; - private static readonly string DevCenterApplicationsTemplate = "/v{0}/my/applications?skip={1}&top={2}"; - private static readonly string DevCenterApplicationTemplate = "/v{0}/my/applications/{1}"; - private static readonly string DevCenterGetSubmissionTemplate = "/v{0}/my/applications/{1}/submissions/{2}"; - private static readonly string DevCenterPutSubmissionTemplate = "/v{0}/my/applications/{1}/submissions/{2}"; - private static readonly string DevCenterCreateSubmissionTemplate = "/v{0}/my/applications/{1}/submissions?isMinimalResponse=true"; - private static readonly string DevCenterDeleteSubmissionTemplate = "/v{0}/my/applications/{1}/submissions/{2}"; - private static readonly string DevCenterCommitSubmissionTemplate = "/v{0}/my/applications/{1}/submissions/{2}/Commit"; - private static readonly string DevCenterSubmissionStatusTemplate = "/v{0}/my/applications/{1}/submissions/{2}/status"; + private static readonly CompositeFormat DevCenterApplicationsTemplate = CompositeFormat.Parse("/v{0}/my/applications?skip={1}&top={2}"); + private static readonly CompositeFormat DevCenterApplicationTemplate = CompositeFormat.Parse("/v{0}/my/applications/{1}"); + private static readonly CompositeFormat DevCenterGetSubmissionTemplate = CompositeFormat.Parse("/v{0}/my/applications/{1}/submissions/{2}"); + private static readonly CompositeFormat DevCenterPutSubmissionTemplate = CompositeFormat.Parse("/v{0}/my/applications/{1}/submissions/{2}"); + private static readonly CompositeFormat DevCenterCreateSubmissionTemplate = CompositeFormat.Parse("/v{0}/my/applications/{1}/submissions?isMinimalResponse=true"); + private static readonly CompositeFormat DevCenterDeleteSubmissionTemplate = CompositeFormat.Parse("/v{0}/my/applications/{1}/submissions/{2}"); + private static readonly CompositeFormat DevCenterCommitSubmissionTemplate = CompositeFormat.Parse("/v{0}/my/applications/{1}/submissions/{2}/Commit"); + private static readonly CompositeFormat DevCenterSubmissionStatusTemplate = CompositeFormat.Parse("/v{0}/my/applications/{1}/submissions/{2}/status"); private SubmissionClient? _devCenterClient; diff --git a/MSStore.API/StoreAPI.cs b/MSStore.API/StoreAPI.cs index 4a8a0dd..7e029fc 100644 --- a/MSStore.API/StoreAPI.cs +++ b/MSStore.API/StoreAPI.cs @@ -8,6 +8,7 @@ using System.Globalization; using System.Linq; using System.Net.Http; +using System.Text; using System.Text.Json; using System.Threading; using System.Threading.Tasks; @@ -19,17 +20,17 @@ namespace MSStore.API public class StoreAPI : IStoreAPI, IDisposable { private static readonly string Version = "1"; - private static readonly string PackagesUrlTemplate = "/submission/v{0}/product/{1}/packages"; + private static readonly CompositeFormat PackagesUrlTemplate = CompositeFormat.Parse("/submission/v{0}/product/{1}/packages"); /* private static readonly string PackageByIdUrlTemplate = "/submission/v{0}/product/{1}/packages/{2}"; */ - private static readonly string PackagesCommitUrlTemplate = "/submission/v{0}/product/{1}/packages/commit"; - private static readonly string AppMetadataUrlTemplate = "/submission/v{0}/product/{1}/metadata"; - private static readonly string AppModuleFetchMetadataUrlTemplate = "/submission/v{0}/product/{1}/metadata/{2}?languages={3}"; - private static readonly string ListingAssetsUrlTemplate = "/submission/v{0}/product/{1}/listings/assets?languages={2}"; + private static readonly CompositeFormat PackagesCommitUrlTemplate = CompositeFormat.Parse("/submission/v{0}/product/{1}/packages/commit"); + private static readonly CompositeFormat AppMetadataUrlTemplate = CompositeFormat.Parse("/submission/v{0}/product/{1}/metadata"); + private static readonly CompositeFormat AppModuleFetchMetadataUrlTemplate = CompositeFormat.Parse("/submission/v{0}/product/{1}/metadata/{2}?languages={3}"); + private static readonly CompositeFormat ListingAssetsUrlTemplate = CompositeFormat.Parse("/submission/v{0}/product/{1}/listings/assets?languages={2}"); /* private static readonly string ListingAssetsCreateUrlTemplate = "/submission/v{0}/product/{1}/listings/assets/create"; private static readonly string ListingAssetsCommitUrlTemplate = "/submission/v{0}/product/{1}/listings/assets/commit"; */ - private static readonly string ProductDraftStatusPollingUrlTemplate = "/submission/v{0}/product/{1}/status"; - private static readonly string CreateSubmissionUrlTemplate = "/submission/v{0}/product/{1}/submit"; - private static readonly string SubmissionStatusPollingUrlTemplate = "/submission/v{0}/product/{1}/submission/{2}/status"; + private static readonly CompositeFormat ProductDraftStatusPollingUrlTemplate = CompositeFormat.Parse("/submission/v{0}/product/{1}/status"); + private static readonly CompositeFormat CreateSubmissionUrlTemplate = CompositeFormat.Parse("/submission/v{0}/product/{1}/submit"); + private static readonly CompositeFormat SubmissionStatusPollingUrlTemplate = CompositeFormat.Parse("/submission/v{0}/product/{1}/submission/{2}/status"); private SubmissionClient? _client; diff --git a/MSStore.API/SubmissionClient.cs b/MSStore.API/SubmissionClient.cs index 66a0cfa..453aab1 100644 --- a/MSStore.API/SubmissionClient.cs +++ b/MSStore.API/SubmissionClient.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; using System.Net.Http; using System.Net.Http.Headers; using System.Text; @@ -66,7 +65,7 @@ public SubmissionClient(AuthenticationResult accessToken, string serviceUrl, Htt } this.accessToken = accessToken; - if(httpClient != null) + if (httpClient != null) { this.httpClient = httpClient; httpClientIsInternal = false; @@ -237,7 +236,7 @@ public async Task InvokeAsync( { var errors = (List?)errorsProp.GetValue(resource); var isSuccess = (bool?)isSuccessProp.GetValue(resource); - if (errors?.Any() == true + if (errors?.Count > 0 && isSuccess == false) { if (resource is T t) diff --git a/MSStore.CLI.UnitTests/GraphClientTests.cs b/MSStore.CLI.UnitTests/GraphClientTests.cs index 3fcfd6f..1bbabde 100644 --- a/MSStore.CLI.UnitTests/GraphClientTests.cs +++ b/MSStore.CLI.UnitTests/GraphClientTests.cs @@ -13,7 +13,7 @@ namespace MSStore.CLI.UnitTests public class GraphClientTests { private Mock mockTokenManager = null!; - private IGraphClient _graphClient = null!; + private GraphClient _graphClient = null!; private Mock _httpMessageHandler = null!; [TestInitialize] diff --git a/MSStore.CLI.UnitTests/MSStore.CLI.UnitTests.csproj b/MSStore.CLI.UnitTests/MSStore.CLI.UnitTests.csproj index 875ea8e..f65bbf5 100644 --- a/MSStore.CLI.UnitTests/MSStore.CLI.UnitTests.csproj +++ b/MSStore.CLI.UnitTests/MSStore.CLI.UnitTests.csproj @@ -1,8 +1,8 @@ - net7.0;net7.0-windows10.0.17763.0 - net7.0 + net8.0;net8.0-windows10.0.17763.0 + net8.0 enable enable @@ -12,7 +12,7 @@ - + @@ -22,10 +22,10 @@ - + - + diff --git a/MSStore.CLI.UnitTests/PackageCommandUnitTests.cs b/MSStore.CLI.UnitTests/PackageCommandUnitTests.cs index 8c8eb0c..03115fd 100644 --- a/MSStore.CLI.UnitTests/PackageCommandUnitTests.cs +++ b/MSStore.CLI.UnitTests/PackageCommandUnitTests.cs @@ -263,7 +263,7 @@ public async Task PackageCommandForMauiAppsShouldCallMSBuildIfWindows() ExternalCommandExecutor .Setup(x => x.RunAsync( It.Is(s => s == "dotnet"), - It.Is(s => s.Contains("publish -f net7.0-windows10.0.19041.0 -r win10-x64 --self-contained /p:Configuration=Release")), + It.Is(s => s.Contains("publish -f net8.0-windows10.0.19041.0 -r win10-x64 --self-contained /p:Configuration=Release")), It.Is(s => s == dirInfo.FullName), It.IsAny())) .ReturnsAsync(new Services.ExternalCommandExecutionResult @@ -305,7 +305,7 @@ public async Task PackageCommandForMauiAppsShouldCallMSBuildWithOutputParameterI ExternalCommandExecutor .Setup(x => x.RunAsync( It.Is(s => s == "dotnet"), - It.Is(s => s.Contains("publish -f net7.0-windows10.0.19041.0 -r win10-x64 --self-contained /p:Configuration=Release") + It.Is(s => s.Contains("publish -f net8.0-windows10.0.19041.0 -r win10-x64 --self-contained /p:Configuration=Release") && s.Contains($"AppxPackageDir={customPath}\\;") && s.EndsWith($"AppxPackageTestDir={customPath}\\MauiProject_1.0.0.0_X64_Test\\")), It.Is(s => s == dirInfo.FullName), diff --git a/MSStore.CLI.UnitTests/ProjectConfiguratorFactoryTests.cs b/MSStore.CLI.UnitTests/ProjectConfiguratorFactoryTests.cs index ff956e7..c2dec74 100644 --- a/MSStore.CLI.UnitTests/ProjectConfiguratorFactoryTests.cs +++ b/MSStore.CLI.UnitTests/ProjectConfiguratorFactoryTests.cs @@ -24,7 +24,7 @@ public class ProjectConfiguratorFactoryTests : BaseCommandLineTest public async Task ProjectConfiguratorFactoryFindsURLProperly(string pathOrUrl, Type expectedProjectConfiguratorType, params string[] testDataProjectSubPath) { string? path = null; - if (testDataProjectSubPath != null && testDataProjectSubPath.Any()) + if (testDataProjectSubPath != null && testDataProjectSubPath.Length != 0) { path = CopyFilesRecursively(Path.Combine(testDataProjectSubPath)); @@ -40,7 +40,7 @@ await RunTestAsync(async (context) => var host = context.GetHost(); var projectConfiguratorFactory = host.Services.GetService()!; - if (testDataProjectSubPath != null && testDataProjectSubPath.Any() && path != null) + if (testDataProjectSubPath != null && testDataProjectSubPath.Length != 0 && path != null) { SetupBasedOnTestDataProjectSubPath(new DirectoryInfo(path), testDataProjectSubPath); } diff --git a/MSStore.CLI.UnitTests/TestData/MauiProject/MauiApp.csproj.template b/MSStore.CLI.UnitTests/TestData/MauiProject/MauiApp.csproj.template index b62dade..1367bb7 100644 --- a/MSStore.CLI.UnitTests/TestData/MauiProject/MauiApp.csproj.template +++ b/MSStore.CLI.UnitTests/TestData/MauiProject/MauiApp.csproj.template @@ -1,7 +1,7 @@ - net7.0-android;net7.0-ios;net7.0-maccatalyst - $(TargetFrameworks);net7.0-windows10.0.19041.0 + net8.0-android;net8.0-ios;net8.0-maccatalyst + $(TargetFrameworks);net8.0-windows10.0.19041.0 00000000-0000-0000-0000-000000000000 AppTitle true diff --git a/MSStore.CLI/Commands/Apps/ListCommand.cs b/MSStore.CLI/Commands/Apps/ListCommand.cs index d00a840..3f2fcd9 100644 --- a/MSStore.CLI/Commands/Apps/ListCommand.cs +++ b/MSStore.CLI/Commands/Apps/ListCommand.cs @@ -5,7 +5,6 @@ using System.CommandLine; using System.CommandLine.Invocation; using System.Globalization; -using System.Linq; using System.Threading.Tasks; using Microsoft.ApplicationInsights; using Microsoft.Extensions.Logging; @@ -55,7 +54,7 @@ await AnsiConsole.Status().StartAsync("Retrieving Managed Applications", async c ctx.SuccessStatus("[bold green]Retrieved Managed Applications[/]"); - if (appList?.Any() == true) + if (appList?.Count > 0) { var table = new Table(); table.AddColumns(string.Empty, "ProductId", "Display Name", "PackageId"); diff --git a/MSStore.CLI/Commands/InitCommand.cs b/MSStore.CLI/Commands/InitCommand.cs index 42ec9fe..f22d4e0 100644 --- a/MSStore.CLI/Commands/InitCommand.cs +++ b/MSStore.CLI/Commands/InitCommand.cs @@ -371,7 +371,7 @@ public async Task InvokeAsync(InvocationContext context) return null; } - if (appList.Any() != true) + if (appList.Count == 0) { AnsiConsole.WriteLine("Your account has no registered apps yet."); AnsiConsole.MarkupLine("[b]Let's create one![/]"); diff --git a/MSStore.CLI/Helpers/DevCenterErrorExtensions.cs b/MSStore.CLI/Helpers/DevCenterErrorExtensions.cs index 169c210..7072246 100644 --- a/MSStore.CLI/Helpers/DevCenterErrorExtensions.cs +++ b/MSStore.CLI/Helpers/DevCenterErrorExtensions.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System.Linq; using MSStore.API.Packaged.Models; namespace MSStore.CLI.Helpers @@ -16,7 +15,7 @@ public static string ToErrorMessage(this DevCenterError error) message += $"Error Target: {error.Target}{System.Environment.NewLine}"; message += $"Error Data:{System.Environment.NewLine}"; - if (error.Data?.Any() == true) + if (error.Data?.Count > 0) { foreach (var data in error.Data) { @@ -30,7 +29,7 @@ public static string ToErrorMessage(this DevCenterError error) message += $"Error Details:{System.Environment.NewLine}"; - if (error.Details?.Any() == true) + if (error.Details?.Count > 0) { foreach (var detail in error.Details) { diff --git a/MSStore.CLI/Helpers/IProjectConfiguratorExtensions.cs b/MSStore.CLI/Helpers/IProjectConfiguratorExtensions.cs index 95c031e..2994a38 100644 --- a/MSStore.CLI/Helpers/IProjectConfiguratorExtensions.cs +++ b/MSStore.CLI/Helpers/IProjectConfiguratorExtensions.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.Logging; @@ -16,11 +15,11 @@ internal static class IProjectConfiguratorExtensions internal static async Task ValidateImagesAsync(this IProjectConfigurator configurator, string pathOrUrl, IImageConverter imageConverter, ILogger logger, CancellationToken ct) { var appImages = await configurator.GetAppImagesAsync(pathOrUrl, ct); - if (appImages?.Any() == true) + if (appImages?.Count > 0) { var projectSpecificDefaultImages = await configurator.GetDefaultImagesAsync(pathOrUrl, ct); var defaultImages = ProjectImagesHelper.GetDefaultImagesUsedByApp(appImages, projectSpecificDefaultImages, imageConverter, logger); - if (defaultImages.Any()) + if (defaultImages.Count > 0) { AnsiConsole.MarkupLine($"[bold yellow]The following images are using the default values and should be updated:[/]"); foreach (var image in defaultImages) diff --git a/MSStore.CLI/Helpers/IStorePackagedAPIExtensions.cs b/MSStore.CLI/Helpers/IStorePackagedAPIExtensions.cs index ffb0bff..54e9560 100644 --- a/MSStore.CLI/Helpers/IStorePackagedAPIExtensions.cs +++ b/MSStore.CLI/Helpers/IStorePackagedAPIExtensions.cs @@ -110,8 +110,8 @@ private static async IAsyncEnumerable Enumera yield return submissionStatus; } while ("CommitStarted".Equals(submissionStatus.Status, StringComparison.Ordinal) - && submissionStatus.StatusDetails?.Errors?.Any() != true - && submissionStatus.StatusDetails?.CertificationReports?.Any() != true); + && submissionStatus.StatusDetails?.Errors.IsNullOrEmpty() == true + && submissionStatus.StatusDetails?.CertificationReports.IsNullOrEmpty() == true); } public static async Task PollSubmissionStatusAsync(this IStorePackagedAPI storePackagedAPI, string productId, string submissionId, bool waitFirst, ILogger? logger, CancellationToken ct = default) @@ -489,7 +489,7 @@ public static async Task PublishAsync(this IStorePackagedAPI storePackagedA var tasks = new List>(); foreach (var listing in submission.Listings) { - if (listing.Value?.BaseListing?.Images?.Any() == true) + if (listing.Value?.BaseListing?.Images?.Count > 0) { var imagesToDownload = listing.Value.BaseListing.Images.Where(i => i.FileStatus == FileStatus.PendingUpload && @@ -589,7 +589,7 @@ private static async Task FulfillApplicationAsync(DevCenterApplication app, DevC } } - if (submission.Listings?.Any() != true) + if (submission.Listings.IsNullOrEmpty()) { submission.Listings = new Dictionary(); @@ -646,7 +646,7 @@ private static async Task FulfillApplicationAsync(DevCenterApplication app, DevC } }; - if (listing.BaseListing.Images?.Any() != true) + if (listing.BaseListing.Images.IsNullOrEmpty()) { listing.BaseListing.Images = new List(); diff --git a/MSStore.CLI/Helpers/ListExtensions.cs b/MSStore.CLI/Helpers/ListExtensions.cs new file mode 100644 index 0000000..02bb531 --- /dev/null +++ b/MSStore.CLI/Helpers/ListExtensions.cs @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Collections.Generic; + +namespace MSStore.CLI.Helpers +{ + internal static class ListExtensions + { + public static bool IsNullOrEmpty(this List? list) + { + return list == null || list.Count == 0; + } + + public static bool IsNullOrEmpty(this Dictionary? dict) + where TKey : notnull + { + return dict == null || dict.Count == 0; + } + } +} diff --git a/MSStore.CLI/Helpers/StatusDetailsExtensions.cs b/MSStore.CLI/Helpers/StatusDetailsExtensions.cs index 890d4de..5bc0a24 100644 --- a/MSStore.CLI/Helpers/StatusDetailsExtensions.cs +++ b/MSStore.CLI/Helpers/StatusDetailsExtensions.cs @@ -23,7 +23,7 @@ public static void PrintAllTables(this StatusDetails statusDetails, string produ PrintErrorsTable(statusDetails.Errors); } - if (statusDetails.Warnings?.Any() == true) + if (statusDetails.Warnings?.Count > 0) { var onlyLogCodes = new List() { @@ -52,7 +52,7 @@ public static void PrintAllTables(this StatusDetails statusDetails, string produ } } - if (statusDetails.CertificationReports?.Any() == true) + if (statusDetails.CertificationReports?.Count > 0) { var table = new Table { diff --git a/MSStore.CLI/MSStore.CLI.csproj b/MSStore.CLI/MSStore.CLI.csproj index 8839f13..4021bce 100644 --- a/MSStore.CLI/MSStore.CLI.csproj +++ b/MSStore.CLI/MSStore.CLI.csproj @@ -2,8 +2,8 @@ Exe - net7.0;net7.0-windows10.0.17763.0 - net7.0 + net8.0;net8.0-windows10.0.17763.0 + net8.0 false msstore true @@ -14,10 +14,10 @@ true - + - + @@ -27,24 +27,24 @@ - - - - - - - + + + + + + + - + - + diff --git a/MSStore.CLI/ProjectConfigurators/FileProjectConfigurator.cs b/MSStore.CLI/ProjectConfigurators/FileProjectConfigurator.cs index efc3bbe..5626620 100644 --- a/MSStore.CLI/ProjectConfigurators/FileProjectConfigurator.cs +++ b/MSStore.CLI/ProjectConfigurators/FileProjectConfigurator.cs @@ -73,7 +73,7 @@ public virtual Task CanConfigureAsync(string pathOrUrl, CancellationToken try { DirectoryInfo directoryPath = new DirectoryInfo(pathOrUrl); - return Task.FromResult(SupportedProjectPattern.Any(y => directoryPath.GetFiles(y).Any())); + return Task.FromResult(SupportedProjectPattern.Any(y => directoryPath.GetFiles(y).Length != 0)); } catch { @@ -116,7 +116,7 @@ protected static FileInfo FindFile(DirectoryInfo projectRootPath, string searchP } } - if (!files.Any()) + if (files.Count == 0) { throw new InvalidOperationException($"No '{searchPattern}' file found."); } diff --git a/MSStore.CLI/ProjectConfigurators/NodeBaseProjectConfigurator.cs b/MSStore.CLI/ProjectConfigurators/NodeBaseProjectConfigurator.cs index 9f91ced..0db7c86 100644 --- a/MSStore.CLI/ProjectConfigurators/NodeBaseProjectConfigurator.cs +++ b/MSStore.CLI/ProjectConfigurators/NodeBaseProjectConfigurator.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.Logging; @@ -28,7 +27,7 @@ protected NodeBaseProjectConfigurator(IExternalCommandExecutor externalCommandEx protected static bool IsYarn(DirectoryInfo projectRootPath) { - return projectRootPath.GetFiles("yarn.lock", SearchOption.TopDirectoryOnly).Any(); + return projectRootPath.GetFiles("yarn.lock", SearchOption.TopDirectoryOnly).Length != 0; } private static Dictionary _npmInstallExecuted = new Dictionary(); diff --git a/MSStore.CLI/ProjectConfigurators/PWAProjectConfigurator.cs b/MSStore.CLI/ProjectConfigurators/PWAProjectConfigurator.cs index 6543616..0c21f37 100644 --- a/MSStore.CLI/ProjectConfigurators/PWAProjectConfigurator.cs +++ b/MSStore.CLI/ProjectConfigurators/PWAProjectConfigurator.cs @@ -82,7 +82,7 @@ private static bool ContainsPWAAppInfoJson(string pathOrUrl) try { DirectoryInfo directoryPath = new DirectoryInfo(pathOrUrl); - return directoryPath.GetFiles("pwaAppInfo.json").Any(); + return directoryPath.GetFiles("pwaAppInfo.json").Length != 0; } catch { @@ -429,7 +429,7 @@ public async Task PublishAsync(string pathOrUrl, DevCenterApplication? app, return ("Could not fetch webmanifest description.", images); } - if (_webManifest.Screenshots?.Any() == true) + if (_webManifest.Screenshots?.Count > 0) { foreach (var screenShot in _webManifest.Screenshots) { @@ -440,7 +440,7 @@ public async Task PublishAsync(string pathOrUrl, DevCenterApplication? app, } } - if (_webManifest.Icons?.Any() == true) + if (_webManifest.Icons?.Count > 0) { // Order by size _webManifest.Icons.Sort((a, b) => a.GetSize().LengthSquared().CompareTo(b.GetSize().LengthSquared())); diff --git a/MSStore.CLI/Services/AppXManifestManager.cs b/MSStore.CLI/Services/AppXManifestManager.cs index 6177fdc..b9e11f1 100644 --- a/MSStore.CLI/Services/AppXManifestManager.cs +++ b/MSStore.CLI/Services/AppXManifestManager.cs @@ -467,7 +467,7 @@ private static List GetAllImagesFiles(string imageNodeText, FileInfo app AnsiConsole.WriteLine(ex.ToString()); } - if (!imagePaths.Any()) + if (imagePaths.Count == 0) { string imageFile = Path.Combine(appxManifest.Directory?.FullName ?? string.Empty, imageNodeText); if (File.Exists(imageFile)) diff --git a/MSStore.CLI/Services/TokenManager/MSALTokenManager.cs b/MSStore.CLI/Services/TokenManager/MSALTokenManager.cs index 5a603d5..472797b 100644 --- a/MSStore.CLI/Services/TokenManager/MSALTokenManager.cs +++ b/MSStore.CLI/Services/TokenManager/MSALTokenManager.cs @@ -184,7 +184,7 @@ public async Task ClearAllCacheAsync() accounts = (await app.GetAccountsAsync()).ToList(); // clear the cache - while (accounts.Any()) + while (accounts.Count != 0) { await app.RemoveAsync(accounts.First()); accounts = (await app.GetAccountsAsync()).ToList();