Skip to content

Commit

Permalink
Merge pull request #927 from microsoft/libtemplateUpdate
Browse files Browse the repository at this point in the history
Merge latest Library.Template
  • Loading branch information
AArnott authored May 1, 2023
2 parents 2b7f234 + 6155f4d commit cb9bd93
Show file tree
Hide file tree
Showing 17 changed files with 212 additions and 96 deletions.
30 changes: 30 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"version": 1,
"isRoot": true,
"tools": {
"powershell": {
"version": "7.3.4",
"commands": [
"pwsh"
]
},
"dotnet-format": {
"version": "5.1.250801",
"commands": [
"dotnet-format"
]
},
"dotnet-coverage": {
"version": "17.7.0",
"commands": [
"dotnet-coverage"
]
},
"nbgv": {
"version": "3.6.128",
"commands": [
"nbgv"
]
}
}
}
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -185,5 +185,8 @@ dotnet_diagnostic.DOC108.severity = warning
dotnet_diagnostic.DOC200.severity = warning
dotnet_diagnostic.DOC202.severity = warning

# CA1062: Validate arguments of public methods
dotnet_diagnostic.CA1062.severity = warning

[*.sln]
indent_style = tab
3 changes: 1 addition & 2 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.SourceGenerators.Testing.XUnit" Version="1.1.2-beta1.23251.2" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="$(CodeAnalysisVersion)" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="$(CodeAnalysisVersion)" />
<PackageVersion Include="Microsoft.CodeCoverage" Version="17.5.0" />
<!-- <PackageVersion Include="Microsoft.Dia.Win32Metadata" Version="0.2.185-preview-g7e1e6a442c" /> -->
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageVersion Include="Microsoft.Win32.Registry" Version="5.0.0" />
Expand All @@ -44,7 +43,7 @@
<ItemGroup>
<GlobalPackageReference Include="CSharpIsNullAnalyzer" Version="0.1.329" />
<GlobalPackageReference Include="DotNetAnalyzers.DocumentationAnalyzers" Version="1.0.0-beta.59" />
<GlobalPackageReference Include="Nerdbank.GitVersioning" Version="3.5.119" />
<GlobalPackageReference Include="Nerdbank.GitVersioning" Version="3.6.128" />
<GlobalPackageReference Include="Nullable" Version="1.3.1" />
<GlobalPackageReference Include="StyleCop.Analyzers.Unstable" Version="1.2.0.435" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines/Archive-SourceCode.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ if (!$RepoUrl) {
}

Push-Location $PSScriptRoot
$versionsObj = & (& "$PSScriptRoot/Get-nbgv.ps1") get-version -f json | ConvertFrom-Json
$versionsObj = dotnet tool run nbgv get-version -f json | ConvertFrom-Json
Pop-Location

$ReleaseDateString = $ReleaseDate.ToShortDateString()
Expand Down
24 changes: 0 additions & 24 deletions azure-pipelines/Get-nbgv.ps1

This file was deleted.

46 changes: 23 additions & 23 deletions azure-pipelines/Merge-CodeCoverage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,32 @@ Param(
)

$RepoRoot = [string](Resolve-Path $PSScriptRoot/..)

if (!(Test-Path $RepoRoot/obj/dotnet-coverage*)) {
dotnet tool install --tool-path $RepoRoot/obj dotnet-coverage --version 17.4.3 --configfile $PSScriptRoot/justnugetorg.nuget.config
}

Write-Verbose "Searching $Path for *.cobertura.xml files"
$reports = Get-ChildItem -Recurse $Path -Filter *.cobertura.xml

if ($reports) {
$reports |% { $_.FullName } |% {
# In addition to replacing {reporoot}, we also normalize on one kind of slash so that the report aggregates data for a file whether data was collected on Windows or not.
$xml = [xml](Get-Content -Path $_)
$xml.coverage.packages.package.classes.class |? { $_.filename} |% {
$_.filename = $_.filename.Replace('{reporoot}', $RepoRoot).Replace([IO.Path]::AltDirectorySeparatorChar, [IO.Path]::DirectorySeparatorChar)
Push-Location $RepoRoot
try {
Write-Verbose "Searching $Path for *.cobertura.xml files"
$reports = Get-ChildItem -Recurse $Path -Filter *.cobertura.xml

if ($reports) {
$reports |% { $_.FullName } |% {
# In addition to replacing {reporoot}, we also normalize on one kind of slash so that the report aggregates data for a file whether data was collected on Windows or not.
$xml = [xml](Get-Content -Path $_)
$xml.coverage.packages.package.classes.class |? { $_.filename} |% {
$_.filename = $_.filename.Replace('{reporoot}', $RepoRoot).Replace([IO.Path]::AltDirectorySeparatorChar, [IO.Path]::DirectorySeparatorChar)
}

$xml.Save($_)
}

$xml.Save($_)
}
$Inputs = $reports |% { Resolve-Path -relative $_.FullName }

$Inputs = $reports |% { Resolve-Path -relative $_.FullName }
if ((Split-Path $OutputFile) -and -not (Test-Path (Split-Path $OutputFile))) {
New-Item -Type Directory -Path (Split-Path $OutputFile) | Out-Null
}

if ((Split-Path $OutputFile) -and -not (Test-Path (Split-Path $OutputFile))) {
New-Item -Type Directory -Path (Split-Path $OutputFile) | Out-Null
& dotnet tool run dotnet-coverage merge $Inputs -o $OutputFile -f cobertura
} else {
Write-Error "No reports found to merge."
}

& "$RepoRoot/obj/dotnet-coverage" merge $Inputs -o $OutputFile -f cobertura
} else {
Write-Error "No reports found to merge."
} finally {
Pop-Location
}
6 changes: 6 additions & 0 deletions azure-pipelines/archive-sourcecode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ steps:
fetchDepth: 0
- powershell: tools/Install-DotNetSdk.ps1
displayName: ⚙ Install .NET SDK
- task: NuGetAuthenticate@1
displayName: 🔏 Authenticate NuGet feeds
inputs:
forceReinstallCredentialProvider: true
- script: dotnet tool restore
displayName: ⚙️ Restore CLI tools
- powershell: azure-pipelines/variables/_pipelines.ps1
failOnStderr: true
displayName: ⚙ Set pipeline variables based on source
Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:

- template: install-dependencies.yml

- powershell: '& (./azure-pipelines/Get-nbgv.ps1) cloud -ca'
- script: dotnet tool run nbgv cloud -ca
displayName: ⚙ Set build number

- template: dotnet.yml
Expand Down
5 changes: 5 additions & 0 deletions azure-pipelines/prepare-insertion-stages.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
parameters:
- name: ArchiveSymbols
type: boolean
default: true

stages:

- stage: azure_public_winsdk_feed
Expand Down
4 changes: 3 additions & 1 deletion azure-pipelines/vs-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ stages:
RunTests: false

- template: prepare-insertion-stages.yml
parameters:
ArchiveSymbols: false

- stage: insertion
displayName: VS insertion
Expand Down Expand Up @@ -60,7 +62,7 @@ stages:
inputs:
TeamName: $(TeamName)
TeamEmail: $(TeamEmail)
InsertionPayloadName: $(Build.Repository.Name) VALIDATION BUILD $(Build.BuildNumber) ($(Build.SourceBranch))
InsertionPayloadName: $(Build.Repository.Name) VALIDATION BUILD $(Build.BuildNumber) ($(Build.SourceBranch)) [Skip-SymbolCheck]
InsertionDescription: |
This PR is for **validation purposes only** for !$(System.PullRequest.PullRequestId). **Do not complete**.
CustomScriptExecutionCommand: src/VSSDK/NuGet/AllowUnstablePackages.ps1
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "7.0.101",
"version": "7.0.203",
"rollForward": "patch",
"allowPrerelease": false
}
Expand Down
11 changes: 11 additions & 0 deletions init.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
No effect if -NoPrerequisites is specified.
.PARAMETER NoRestore
Skips the package restore step.
.PARAMETER NoToolRestore
Skips the dotnet tool restore step.
.PARAMETER AccessToken
An optional access token for authenticating to Azure Artifacts authenticated feeds.
.PARAMETER Interactive
Expand All @@ -46,6 +48,8 @@ Param (
[Parameter()]
[switch]$NoRestore,
[Parameter()]
[switch]$NoToolRestore,
[Parameter()]
[string]$AccessToken,
[Parameter()]
[switch]$Interactive
Expand Down Expand Up @@ -93,6 +97,13 @@ try {
}
}

if (!$NoToolRestore -and $PSCmdlet.ShouldProcess("dotnet tool", "restore")) {
dotnet tool restore @RestoreArguments
if ($lastexitcode -ne 0) {
throw "Failure while restoring dotnet CLI tools."
}
}

& "$PSScriptRoot/tools/Set-EnvVars.ps1" -Variables $EnvVars -PrependPath $PrependPath | Out-Null
}
catch {
Expand Down
5 changes: 5 additions & 0 deletions src/Microsoft.Windows.CsWin32/Docs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ public static Docs Get(string docsPath)
/// <returns>An instance that contains all the docs provided. When <paramref name="docs"/> contains exactly one element, that element is returned.</returns>
public static Docs Merge(IReadOnlyList<Docs> docs)
{
if (docs is null)
{
throw new ArgumentNullException(nameof(docs));
}

if (docs.Count == 1)
{
// Nothing to merge.
Expand Down
10 changes: 10 additions & 0 deletions src/Microsoft.Windows.CsWin32/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ static Generator()
/// <param name="parseOptions">The parse options that will be used for the generated code.</param>
public Generator(string metadataLibraryPath, Docs? docs, GeneratorOptions options, CSharpCompilation? compilation = null, CSharpParseOptions? parseOptions = null)
{
if (options is null)
{
throw new ArgumentNullException(nameof(options));
}

this.InputAssemblyName = Path.GetFileNameWithoutExtension(metadataLibraryPath);
this.MetadataIndex = MetadataIndex.Get(metadataLibraryPath, compilation?.Options.Platform);
this.ApiDocs = docs;
Expand Down Expand Up @@ -238,6 +243,11 @@ ClassDeclarationSyntax DeclarePInvokeClass(string fileNameKey) => ClassDeclarati
/// <returns><see langword="true"/> if the string contains characters that are likely mistakenly included and causing a mismatch; <see langword="false"/> otherwise.</returns>
public static bool ContainsIllegalCharactersForAPIName(string apiName)
{
if (apiName is null)
{
throw new ArgumentNullException(nameof(apiName));
}

for (int i = 0; i < apiName.Length; i++)
{
char ch = apiName[i];
Expand Down
1 change: 0 additions & 1 deletion test/GenerationSandbox.props
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

<ItemGroup>
<PackageReference Include="Microsoft.Win32.Registry" />
<PackageReference Include="Microsoft.CodeCoverage" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" />
<PackageReference Include="xunit" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeCoverage" />
<PackageReference Include="MessagePack" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.SourceGenerators.Testing.XUnit" />
Expand Down
Loading

0 comments on commit cb9bd93

Please sign in to comment.