diff --git a/.editorconfig b/.editorconfig index 0e47235a0d7..7ec890bee91 100644 --- a/.editorconfig +++ b/.editorconfig @@ -172,10 +172,14 @@ dotnet_code_quality.ca1822.api_surface = private, internal dotnet_code_quality.ca2208.api_surface = public dotnet_diagnostic.CS1591.severity = suggestion dotnet_analyzer_diagnostic.category-Style.severity = warning +#Name can be simplified +dotnet_diagnostic.IDE0002.severity = suggestion #Use explicit type instead of var dotnet_diagnostic.IDE0008.severity = suggestion #Add missing cases to switch statement dotnet_diagnostic.IDE0010.severity = suggestion +#Simplify LINQ expression +dotnet_diagnostic.IDE0120.severity = suggestion #Use expression body for constructors dotnet_diagnostic.IDE0021.severity = suggestion #Use expression body for methods @@ -186,6 +190,10 @@ dotnet_diagnostic.IDE0028.severity = suggestion dotnet_diagnostic.IDE0032.severity = suggestion #Use conditional expression for return dotnet_diagnostic.IDE0046.severity = suggestion +#Remove unused private member +dotnet_diagnostic.IDE0051.severity = suggestion +#Remove unread private member +dotnet_diagnostic.IDE0052.severity = suggestion #Remove unnecessary expression value dotnet_diagnostic.IDE0058.severity = suggestion #Add missing cases to switch expression @@ -206,6 +214,10 @@ dotnet_diagnostic.IDE0300.severity = suggestion dotnet_diagnostic.IDE0301.severity = suggestion #Collection initialization can be simplified dotnet_diagnostic.IDE0305.severity = suggestion +#Simplify collection initialization +dotnet_diagnostic.IDE0306.severity = suggestion +#Lambda expression can be simplified +dotnet_diagnostic.IDE0350.severity = suggestion # License header file_header_template = Licensed to the .NET Foundation under one or more agreements.\nThe .NET Foundation licenses this file to you under the MIT license. @@ -215,6 +227,9 @@ file_header_template = Licensed to the .NET Foundation under one or more agreeme # Ensure minimum API surface is respected dotnet_diagnostic.BCL0001.severity = warning +# Don't require explicit access modifiers for interface members (conflicts with IDE0040) +dotnet_diagnostic.SA1400.severity = none + # AppContext default value expected to be true dotnet_diagnostic.BCL0010.severity = warning diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 5404e2f4768..414ab2e46db 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -17,9 +17,9 @@ - + https://github.com/dotnet/arcade - 4bd1c6c93b5a3b8bc864d2863469c3f2e489d0af + 6544413e02741855b701468aa8afc6cf8ca62c72 diff --git a/eng/Versions.props b/eng/Versions.props index 328e899f3ee..05f46389fef 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -4,7 +4,7 @@ true true - 8.0.415 + 8.0.416 true release diff --git a/eng/common/post-build/nuget-validation.ps1 b/eng/common/post-build/nuget-validation.ps1 index dab3534ab53..22b1c4dfe4a 100644 --- a/eng/common/post-build/nuget-validation.ps1 +++ b/eng/common/post-build/nuget-validation.ps1 @@ -2,20 +2,13 @@ # tool: https://github.com/NuGet/NuGetGallery/tree/jver-verify/src/VerifyMicrosoftPackage param( - [Parameter(Mandatory=$true)][string] $PackagesPath, # Path to where the packages to be validated are - [Parameter(Mandatory=$true)][string] $ToolDestinationPath # Where the validation tool should be downloaded to + [Parameter(Mandatory=$true)][string] $PackagesPath # Path to where the packages to be validated are ) try { . $PSScriptRoot\post-build-utils.ps1 - $url = 'https://raw.githubusercontent.com/NuGet/NuGetGallery/3e25ad135146676bcab0050a516939d9958bfa5d/src/VerifyMicrosoftPackage/verify.ps1' - - New-Item -ItemType 'directory' -Path ${ToolDestinationPath} -Force - - Invoke-WebRequest $url -OutFile ${ToolDestinationPath}\verify.ps1 - - & ${ToolDestinationPath}\verify.ps1 ${PackagesPath}\*.nupkg + & $PSScriptRoot\nuget-verification.ps1 ${PackagesPath}\*.nupkg } catch { Write-Host $_.ScriptStackTrace diff --git a/eng/common/post-build/nuget-verification.ps1 b/eng/common/post-build/nuget-verification.ps1 new file mode 100644 index 00000000000..8467dbf8e7c --- /dev/null +++ b/eng/common/post-build/nuget-verification.ps1 @@ -0,0 +1,121 @@ +<# +.SYNOPSIS + Verifies that Microsoft NuGet packages have proper metadata. +.DESCRIPTION + Downloads a verification tool and runs metadata validation on the provided NuGet packages. This script writes an + error if any of the provided packages fail validation. All arguments provided to this PowerShell script that do not + match PowerShell parameters are passed on to the verification tool downloaded during the execution of this script. +.PARAMETER NuGetExePath + The path to the nuget.exe binary to use. If not provided, nuget.exe will be downloaded into the -DownloadPath + directory. +.PARAMETER PackageSource + The package source to use to download the verification tool. If not provided, nuget.org will be used. +.PARAMETER DownloadPath + The directory path to download the verification tool and nuget.exe to. If not provided, + %TEMP%\NuGet.VerifyNuGetPackage will be used. +.PARAMETER args + Arguments that will be passed to the verification tool. +.EXAMPLE + PS> .\verify.ps1 *.nupkg + Verifies the metadata of all .nupkg files in the currect working directory. +.EXAMPLE + PS> .\verify.ps1 --help + Displays the help text of the downloaded verifiction tool. +.LINK + https://github.com/NuGet/NuGetGallery/blob/master/src/VerifyMicrosoftPackage/README.md +#> + +# This script was copied from https://github.com/NuGet/NuGetGallery/blob/3e25ad135146676bcab0050a516939d9958bfa5d/src/VerifyMicrosoftPackage/verify.ps1 + +[CmdletBinding(PositionalBinding = $false)] +param( + [string]$NuGetExePath, + [string]$PackageSource = "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json", + [string]$DownloadPath, + [Parameter(ValueFromRemainingArguments = $true)] + [string[]]$args +) + +# The URL to download nuget.exe. +$nugetExeUrl = "https://dist.nuget.org/win-x86-commandline/v4.9.4/nuget.exe" + +# The package ID of the verification tool. +$packageId = "NuGet.VerifyMicrosoftPackage" + +# The location that nuget.exe and the verification tool will be downloaded to. +if (!$DownloadPath) { + $DownloadPath = (Join-Path $env:TEMP "NuGet.VerifyMicrosoftPackage") +} + +$fence = New-Object -TypeName string -ArgumentList '=', 80 + +# Create the download directory, if it doesn't already exist. +if (!(Test-Path $DownloadPath)) { + New-Item -ItemType Directory $DownloadPath | Out-Null +} +Write-Host "Using download path: $DownloadPath" + +if ($NuGetExePath) { + $nuget = $NuGetExePath +} else { + $downloadedNuGetExe = Join-Path $DownloadPath "nuget.exe" + + # Download nuget.exe, if it doesn't already exist. + if (!(Test-Path $downloadedNuGetExe)) { + Write-Host "Downloading nuget.exe from $nugetExeUrl..." + $ProgressPreference = 'SilentlyContinue' + try { + Invoke-WebRequest $nugetExeUrl -OutFile $downloadedNuGetExe + $ProgressPreference = 'Continue' + } catch { + $ProgressPreference = 'Continue' + Write-Error $_ + Write-Error "nuget.exe failed to download." + exit + } + } + + $nuget = $downloadedNuGetExe +} + +Write-Host "Using nuget.exe path: $nuget" +Write-Host " " + +# Download the latest version of the verification tool. +Write-Host "Downloading the latest version of $packageId from $packageSource..." +Write-Host $fence +& $nuget install $packageId ` + -Prerelease ` + -OutputDirectory $DownloadPath ` + -Source $PackageSource +Write-Host $fence +Write-Host " " + +if ($LASTEXITCODE -ne 0) { + Write-Error "nuget.exe failed to fetch the verify tool." + exit +} + +# Find the most recently downloaded tool +Write-Host "Finding the most recently downloaded verification tool." +$verifyProbePath = Join-Path $DownloadPath "$packageId.*" +$verifyPath = Get-ChildItem -Path $verifyProbePath -Directory ` + | Sort-Object -Property LastWriteTime -Descending ` + | Select-Object -First 1 +$verify = Join-Path $verifyPath "tools\NuGet.VerifyMicrosoftPackage.exe" +Write-Host "Using verification tool: $verify" +Write-Host " " + +# Execute the verification tool. +Write-Host "Executing the verify tool..." +Write-Host $fence +& $verify $args +Write-Host $fence +Write-Host " " + +# Respond to the exit code. +if ($LASTEXITCODE -ne 0) { + Write-Error "The verify tool found some problems." +} else { + Write-Output "The verify tool succeeded." +} \ No newline at end of file diff --git a/eng/common/templates-official/post-build/post-build.yml b/eng/common/templates-official/post-build/post-build.yml index 9fef8103991..817e2d80dea 100644 --- a/eng/common/templates-official/post-build/post-build.yml +++ b/eng/common/templates-official/post-build/post-build.yml @@ -134,8 +134,7 @@ stages: displayName: Validate inputs: filePath: $(System.DefaultWorkingDirectory)/eng/common/post-build/nuget-validation.ps1 - arguments: -PackagesPath $(Build.ArtifactStagingDirectory)/PackageArtifacts/ - -ToolDestinationPath $(Agent.BuildDirectory)/Extract/ + arguments: -PackagesPath $(Build.ArtifactStagingDirectory)/PackageArtifacts/ - job: displayName: Signing Validation diff --git a/eng/common/templates/post-build/post-build.yml b/eng/common/templates/post-build/post-build.yml index 6e5722dc2e1..ea1785a8aa2 100644 --- a/eng/common/templates/post-build/post-build.yml +++ b/eng/common/templates/post-build/post-build.yml @@ -132,7 +132,6 @@ stages: inputs: filePath: $(System.DefaultWorkingDirectory)/eng/common/post-build/nuget-validation.ps1 arguments: -PackagesPath $(Build.ArtifactStagingDirectory)/PackageArtifacts/ - -ToolDestinationPath $(Agent.BuildDirectory)/Extract/ - job: displayName: Signing Validation diff --git a/global.json b/global.json index 85ee98517eb..68d090ad64d 100644 --- a/global.json +++ b/global.json @@ -1,8 +1,8 @@ { "tools": { - "dotnet": "8.0.120" + "dotnet": "8.0.121" }, "msbuild-sdks": { - "Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.25465.1" + "Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.25515.1" } } diff --git a/src/Microsoft.TemplateEngine.Abstractions/Components/IBindSymbolSource.cs b/src/Microsoft.TemplateEngine.Abstractions/Components/IBindSymbolSource.cs index 7f47292f9e5..c9f0a2a0286 100644 --- a/src/Microsoft.TemplateEngine.Abstractions/Components/IBindSymbolSource.cs +++ b/src/Microsoft.TemplateEngine.Abstractions/Components/IBindSymbolSource.cs @@ -15,17 +15,17 @@ public interface IBindSymbolSource : IPrioritizedComponent /// /// The user friendly name of the component. /// - public string DisplayName { get; } + string DisplayName { get; } /// /// Prefix that is used in binding to refernece the component. /// - public string? SourcePrefix { get; } + string? SourcePrefix { get; } /// /// If set to true, the component required exact prefix match to be used. /// - public bool RequiresPrefixMatch { get; } + bool RequiresPrefixMatch { get; } /// /// Gets the value corresponding to . @@ -34,6 +34,6 @@ public interface IBindSymbolSource : IPrioritizedComponent /// the value to retrieve (without prefix). /// cancellation token. /// - public Task GetBoundValueAsync(IEngineEnvironmentSettings settings, string bindname, CancellationToken cancellationToken); + Task GetBoundValueAsync(IEngineEnvironmentSettings settings, string bindname, CancellationToken cancellationToken); } } diff --git a/src/Microsoft.TemplateEngine.Abstractions/Components/ISdkInfoProvider.cs b/src/Microsoft.TemplateEngine.Abstractions/Components/ISdkInfoProvider.cs index 65c33a0536c..25bc7e6c8fc 100644 --- a/src/Microsoft.TemplateEngine.Abstractions/Components/ISdkInfoProvider.cs +++ b/src/Microsoft.TemplateEngine.Abstractions/Components/ISdkInfoProvider.cs @@ -17,14 +17,14 @@ public interface ISdkInfoProvider : IIdentifiedComponent /// /// /// SDK version. - public Task GetCurrentVersionAsync(CancellationToken cancellationToken); + Task GetCurrentVersionAsync(CancellationToken cancellationToken); /// /// All installed SDK installations semver version strings. /// /// /// SDK version strings. - public Task> GetInstalledVersionsAsync(CancellationToken cancellationToken); + Task> GetInstalledVersionsAsync(CancellationToken cancellationToken); /// /// Provides localized suggestion on action to be taken so that constraints requiring specified workloads can be met. @@ -35,6 +35,6 @@ public interface ISdkInfoProvider : IIdentifiedComponent /// SDK versions required by a constraint (in an 'OR' relationship). /// SDK versions installed, that can meet the constraint - instructions should be provided to switch to any of those. /// Localized string with remedy suggestion specific to current host. - public string ProvideConstraintRemedySuggestion(IReadOnlyList supportedVersions, IReadOnlyList viableInstalledVersions); + string ProvideConstraintRemedySuggestion(IReadOnlyList supportedVersions, IReadOnlyList viableInstalledVersions); } } diff --git a/src/Microsoft.TemplateEngine.Abstractions/Components/IWorkloadsInfoProvider.cs b/src/Microsoft.TemplateEngine.Abstractions/Components/IWorkloadsInfoProvider.cs index a582e8872f4..405fb4db52c 100644 --- a/src/Microsoft.TemplateEngine.Abstractions/Components/IWorkloadsInfoProvider.cs +++ b/src/Microsoft.TemplateEngine.Abstractions/Components/IWorkloadsInfoProvider.cs @@ -17,7 +17,7 @@ public interface IWorkloadsInfoProvider : IIdentifiedComponent /// /// /// Set of installed workloads. - public Task> GetInstalledWorkloadsAsync(CancellationToken token); + Task> GetInstalledWorkloadsAsync(CancellationToken token); /// /// Provides localized suggestion on action to be taken so that constraints requiring specified workloads can be met. @@ -27,6 +27,6 @@ public interface IWorkloadsInfoProvider : IIdentifiedComponent /// /// Workloads required by a constraint (in an 'OR' relationship). /// Localized string with remedy suggestion specific to current host. - public string ProvideConstraintRemedySuggestion(IReadOnlyList supportedWorkloads); + string ProvideConstraintRemedySuggestion(IReadOnlyList supportedWorkloads); } } diff --git a/src/Microsoft.TemplateEngine.Abstractions/IValidationEntry.cs b/src/Microsoft.TemplateEngine.Abstractions/IValidationEntry.cs index 30bacbccb2c..f82b0ecf6c9 100644 --- a/src/Microsoft.TemplateEngine.Abstractions/IValidationEntry.cs +++ b/src/Microsoft.TemplateEngine.Abstractions/IValidationEntry.cs @@ -11,7 +11,7 @@ public interface IValidationEntry /// /// Error severity. /// - public enum SeverityLevel + enum SeverityLevel { None, Info, @@ -42,7 +42,7 @@ public enum SeverityLevel /// /// Details of the error location. /// - public readonly struct ErrorLocation + readonly struct ErrorLocation { /// /// Gets the filename where the error occurred. diff --git a/src/Microsoft.TemplateSearch.Common/Abstractions/ITemplatePackageInfo.cs b/src/Microsoft.TemplateSearch.Common/Abstractions/ITemplatePackageInfo.cs index 2b8107be1bf..ea9f4d5b84c 100644 --- a/src/Microsoft.TemplateSearch.Common/Abstractions/ITemplatePackageInfo.cs +++ b/src/Microsoft.TemplateSearch.Common/Abstractions/ITemplatePackageInfo.cs @@ -13,23 +13,23 @@ public interface ITemplatePackageInfo /// /// Gets template package name. /// - public string Name { get; } + string Name { get; } /// /// Gets template package version. /// - public string? Version { get; } + string? Version { get; } /// /// Gets total number of downloads for the package. /// Optional, might be 0 in case search provider cannot provide number of downloads. /// - public long TotalDownloads { get; } + long TotalDownloads { get; } /// /// Gets the list of template package owners. /// - public IReadOnlyList Owners { get; } + IReadOnlyList Owners { get; } /// /// Gets the indication if the package is verified. @@ -37,16 +37,16 @@ public interface ITemplatePackageInfo /// /// For NuGet.org 'verified' means that package ID is under reserved namespaces, see . /// - public bool Reserved { get; } + bool Reserved { get; } /// /// Gets the NuGet package description. /// - public string? Description { get; } + string? Description { get; } /// /// Gets the URL to the package icon. /// - public string? IconUrl { get; } + string? IconUrl { get; } } }