Skip to content

Commit

Permalink
Merge pull request #1275 from microsoft/libtemplateUpdate
Browse files Browse the repository at this point in the history
Merge latest Library.Template
  • Loading branch information
AArnott authored Sep 9, 2024
2 parents db04c21 + e08b06d commit 6736a5d
Show file tree
Hide file tree
Showing 18 changed files with 81 additions and 41 deletions.
6 changes: 3 additions & 3 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
"isRoot": true,
"tools": {
"powershell": {
"version": "7.4.3",
"version": "7.4.5",
"commands": [
"pwsh"
]
},
"dotnet-coverage": {
"version": "17.11.3",
"version": "17.12.3",
"commands": [
"dotnet-coverage"
]
},
"nbgv": {
"version": "3.6.139",
"version": "3.6.143",
"commands": [
"nbgv"
]
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Refer to https://hub.docker.com/_/microsoft-dotnet-sdk for available versions
FROM mcr.microsoft.com/dotnet/sdk:8.0.300-jammy
FROM mcr.microsoft.com/dotnet/sdk:8.0.400-jammy

# Installing mono makes `dotnet test` work without errors even for net472.
# But installing it takes a long time, so it's excluded by default.
Expand Down
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -198,5 +198,8 @@ dotnet_diagnostic.CA1062.severity = suggestion
dotnet_diagnostic.MsgPack001.severity = error
dotnet_diagnostic.MsgPack002.severity = error

# CA2016: Forward the CancellationToken parameter
dotnet_diagnostic.CA2016.severity = warning

[*.sln]
indent_style = tab
6 changes: 3 additions & 3 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>

<MicroBuildVersion>2.0.162</MicroBuildVersion>
<MicroBuildVersion>2.0.165</MicroBuildVersion>
<MetadataVersion>61.0.15-preview</MetadataVersion>
<WDKMetadataVersion>0.12.8-experimental</WDKMetadataVersion>
<!-- <DiaMetadataVersion>0.2.185-preview-g7e1e6a442c</DiaMetadataVersion> -->
Expand All @@ -23,7 +23,7 @@
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="$(CodeAnalysisVersion)" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="$(CodeAnalysisVersion)" />
<!-- <PackageVersion Include="Microsoft.Dia.Win32Metadata" Version="0.2.185-preview-g7e1e6a442c" /> -->
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageVersion Include="Microsoft.VisualStudio.Internal.MicroBuild.NonShipping" Version="$(MicroBuildVersion)" />
<PackageVersion Include="Microsoft.Win32.Registry" Version="5.0.0" />
<PackageVersion Include="Microsoft.Windows.SDK.Win32Docs" Version="$(ApiDocsVersion)" />
Expand Down Expand Up @@ -51,7 +51,7 @@
<GlobalPackageReference Include="CSharpIsNullAnalyzer" Version="0.1.593" />
<GlobalPackageReference Include="DotNetAnalyzers.DocumentationAnalyzers" Version="1.0.0-beta.59" />
<GlobalPackageReference Include="Microsoft.VisualStudio.Internal.MicroBuild.VisualStudio" Version="$(MicroBuildVersion)" />
<GlobalPackageReference Include="Nerdbank.GitVersioning" Version="3.6.139" />
<GlobalPackageReference Include="Nerdbank.GitVersioning" Version="3.6.143" />
<GlobalPackageReference Include="Nullable" Version="1.3.1" />
<GlobalPackageReference Include="StyleCop.Analyzers.Unstable" Version="1.2.0.556" />
</ItemGroup>
Expand Down
5 changes: 4 additions & 1 deletion azure-pipelines/OptProf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ variables:
value: false # avoid using nice version since we're building a preliminary/unoptimized package
- name: IsOptProf
value: true
- name: MicroBuild_NuPkgSigningEnabled
value: false # test-signed nuget packages fail to restore in the VS insertion PR validations. Just don't sign them *at all*.

stages:
- stage: Library
Expand All @@ -40,12 +42,13 @@ stages:
- template: build.yml
parameters:
Is1ESPT: false
RealSign: true
RealSign: false
windowsPool: VSEngSS-MicroBuild2022-1ES
EnableMacOSBuild: false
ShouldSkipOptimize: ${{ parameters.ShouldSkipOptimize }}
IsOptProf: true
RunTests: false
SkipCodesignVerify: true
- stage: QueueVSBuild
jobs:
- job: QueueOptProf
Expand Down
6 changes: 6 additions & 0 deletions azure-pipelines/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ parameters:
type: boolean
default: true

# Whether this is a special one-off build for inserting into VS for a validation insertion PR (that will never be merged).
- name: SkipCodesignVerify
type: boolean
default: false

- name: EnableAPIScan
type: boolean
default: false
Expand Down Expand Up @@ -193,6 +198,7 @@ jobs:
parameters:
EnableOptProf: ${{ parameters.EnableOptProf }}
IsOptProf: ${{ parameters.IsOptProf }}
SkipCodesignVerify: ${{ parameters.SkipCodesignVerify }}

- ${{ if not(parameters.IsOptProf) }}:
- ${{ if parameters.EnableLinuxBuild }}:
Expand Down
15 changes: 9 additions & 6 deletions azure-pipelines/microbuild.after.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@ parameters:
- name: IsOptProf
type: boolean
default: false
- name: SkipCodesignVerify
type: boolean

steps:
- task: MicroBuildCodesignVerify@3
displayName: 🔍 Verify Signed Files
inputs:
TargetFolders: |
$(Build.SourcesDirectory)/bin/Packages/$(BuildConfiguration)
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
- ${{ if not(parameters.SkipCodesignVerify) }}: # skip CodesignVerify on validation builds because we don't even test-sign nupkg's.
- task: MicroBuildCodesignVerify@3
displayName: 🔍 Verify Signed Files
inputs:
TargetFolders: |
$(Build.SourcesDirectory)/bin/Packages/$(BuildConfiguration)
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))

- ${{ if parameters.IsOptProf }}:
- task: ms-vscs-artifact.build-tasks.artifactDropTask-1.artifactDropTask@0
Expand Down
23 changes: 15 additions & 8 deletions azure-pipelines/prepare-insertion-stages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ parameters:
stages:
- stage: release
displayName: Publish
condition: and(succeeded(), eq('${{ parameters.RealSign }}', 'true'))
jobs:
- ${{ if parameters.ArchiveSymbols }}:
- job: symbol_archive
Expand All @@ -34,7 +33,10 @@ stages:

- ${{ if true }}: # Switch to true to enable, but leave the condition to avoid merge conflicts later.
- job: push
displayName: azure-public/winsdk feed
${{ if parameters.RealSign }}:
displayName: azure-public/winsdk feed
${{ else }}:
displayName: devdiv/vs-impl feed # Leave this as-is, since non-signed builds must not be pushed to public feeds.
${{ if parameters.ArchiveSymbols }}:
dependsOn: symbol_archive
pool:
Expand All @@ -49,8 +51,12 @@ stages:
packagesToPush: '$(Pipeline.Workspace)/deployables-Windows/NuGet/*.nupkg'
packageParentPath: $(Pipeline.Workspace)/deployables-Windows/NuGet
allowPackageConflicts: true
nuGetFeedType: external
publishFeedCredentials: azure-public/winsdk/CI
${{ if parameters.RealSign }}:
nuGetFeedType: external
publishFeedCredentials: azure-public/winsdk/CI
${{ else }}:
nuGetFeedType: internal
publishVstsFeed: vs-impl # Leave this as-is, since non-signed builds must not be pushed to public feeds.
steps:
- checkout: none
- download: current
Expand All @@ -61,7 +67,8 @@ stages:
- download: current
artifact: deployables-Windows
displayName: 🔻 Download deployables-Windows artifact
- template: WIFtoPATauth.yml
parameters:
wifServiceConnectionName: azure-public/vside package push
deadPATServiceConnectionId: 9c66bbfe-03da-40f0-8ed7-23f599039d5d # azure-public/winsdk/CI
- ${{ if parameters.RealSign }}:
- template: WIFtoPATauth.yml
parameters:
wifServiceConnectionName: azure-public/vside package push
deadPATServiceConnectionId: 9c66bbfe-03da-40f0-8ed7-23f599039d5d # azure-public/winsdk/CI
3 changes: 1 addition & 2 deletions azure-pipelines/publish-codecoverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ steps:
continueOnError: true
- powershell: azure-pipelines/Merge-CodeCoverage.ps1 -Path '$(Pipeline.Workspace)' -OutputFile coveragereport/merged.cobertura.xml -Format Cobertura -Verbose
displayName: ⚙ Merge coverage
- task: PublishCodeCoverageResults@1
- task: PublishCodeCoverageResults@2
displayName: 📢 Publish code coverage results to Azure DevOps
inputs:
codeCoverageTool: cobertura
summaryFileLocation: coveragereport/merged.cobertura.xml
failIfCoverageEmpty: true
21 changes: 17 additions & 4 deletions azure-pipelines/vs-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ resources:

variables:
- template: GlobalVariables.yml
- name: MicroBuild_NuPkgSigningEnabled
value: false # test-signed nuget packages fail to restore in the VS insertion PR validations. Just don't sign them *at all*.

extends:
template: azure-pipelines/MicroBuild.1ES.Unofficial.yml@MicroBuildTemplate
Expand All @@ -27,21 +29,31 @@ extends:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
NUGET_PACKAGES: $(Agent.TempDirectory)/.nuget/packages/
BuildConfiguration: Release
ValidationBuild: true
SkipCodesignVerify: true

jobs:
- template: /azure-pipelines/build.yml@self
parameters:
Is1ESPT: true
RealSign: true
RealSign: false
windowsPool: VSEngSS-MicroBuild2022-1ES
linuxPool:
name: AzurePipelines-EO
demands:
- ImageOverride -equals 1ESPT-Ubuntu22.04
os: Linux
macOSPool:
name: Azure Pipelines
vmImage: macOS-12
os: macOS
EnableMacOSBuild: false
RunTests: false
SkipCodesignVerify: true

- template: /azure-pipelines/prepare-insertion-stages.yml@self
parameters:
ArchiveSymbols: false
RealSign: true
RealSign: false

- stage: insertion
displayName: VS insertion
Expand Down Expand Up @@ -73,12 +85,13 @@ extends:
inputs:
TeamName: $(TeamName)
TeamEmail: $(TeamEmail)
InsertionPayloadName: $(Build.Repository.Name) VALIDATION BUILD $(Build.BuildNumber) ($(Build.SourceBranch)) [Skip-SymbolCheck]
InsertionPayloadName: $(Build.Repository.Name) VALIDATION BUILD $(Build.BuildNumber) ($(Build.SourceBranch)) [Skip-SymbolCheck] [Skip-HashCheck] [Skip-SignCheck]
InsertionDescription: |
This PR is for **validation purposes only** for !$(System.PullRequest.PullRequestId). **Do not complete**.
CustomScriptExecutionCommand: src/VSSDK/NuGet/AllowUnstablePackages.ps1
InsertionBuildPolicy: Request Perf DDRITs
InsertionReviewers: $(Build.RequestedFor)
DraftPR: false # set to true and update InsertionBuildPolicy when we can specify all the validations we want to run (https://dev.azure.com/devdiv/DevDiv/_workitems/edit/2224288)
AutoCompletePR: false
ShallowClone: true
- powershell: |
Expand Down
6 changes: 6 additions & 0 deletions azurepipelines-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# https://learn.microsoft.com/azure/devops/pipelines/test/codecoverage-for-pullrequests?view=azure-devops
coverage:
status:
comments: on # add comment to PRs reporting diff in coverage of modified files
diff: # diff coverage is code coverage only for the lines changed in a pull request.
target: 70% # set this to a desired %. Default is 70%
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "8.0.300",
"version": "8.0.400",
"rollForward": "patch",
"allowPrerelease": false
},
Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.Windows.CsWin32/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -829,13 +829,13 @@ nsContents.Key is object
throw new GenerationFailedException($"Failed to get template for \"{WinRTCustomMarshalerClass}\".");
}

SyntaxTree? marshalerContents = SyntaxFactory.ParseSyntaxTree(marshalerText);
SyntaxTree? marshalerContents = SyntaxFactory.ParseSyntaxTree(marshalerText, cancellationToken: cancellationToken);
if (marshalerContents == null)
{
throw new GenerationFailedException($"Failed adding \"{WinRTCustomMarshalerClass}\".");
}

CompilationUnitSyntax? compilationUnit = ((CompilationUnitSyntax)marshalerContents.GetRoot())
CompilationUnitSyntax? compilationUnit = ((CompilationUnitSyntax)marshalerContents.GetRoot(cancellationToken))
.WithLeadingTrivia(ParseLeadingTrivia(AutoGeneratedHeader));

normalizedResults.Add(
Expand Down
2 changes: 1 addition & 1 deletion test/GenerationSandbox.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Import Project="CsWin32User.props" />

<PropertyGroup>
<TargetFrameworks>net7.0-windows7.0;net6.0-windows7.0;net472</TargetFrameworks>
<TargetFrameworks>net8.0-windows7.0;net6.0-windows7.0;net472</TargetFrameworks>
<RootNamespace />
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
Expand Down
8 changes: 4 additions & 4 deletions test/Microsoft.Windows.CsWin32.Tests/COMTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ public void OptionalInPointerParameterExposedAsPointer()
[Fact]
public void EnvironmentFailFast()
{
this.compilation = this.starterCompilations["net7.0"];
this.compilation = this.starterCompilations["net8.0"];
this.generator = this.CreateGenerator(DefaultTestGeneratorOptions with { AllowMarshaling = false });

// Emit something into the Environment namespace, to invite collisions.
Expand Down Expand Up @@ -363,7 +363,7 @@ public void IStream_ProducesPopulateVTable()
[Fact]
public void IPersistFile_DerivesFromIComIID()
{
this.compilation = this.starterCompilations["net7.0"];
this.compilation = this.starterCompilations["net8.0"];
const string typeName = "IPersistFile";
this.generator = this.CreateGenerator(DefaultTestGeneratorOptions with { AllowMarshaling = false });
this.GenerateApi(typeName);
Expand Down Expand Up @@ -396,7 +396,7 @@ public void ReferencesToStructWithFlexibleArrayAreAlwaysPointers()
public void COMInterfaceIIDInterfaceOnAppropriateTFMs(
bool allowMarshaling,
[CombinatorialValues(LanguageVersion.CSharp10, LanguageVersion.CSharp11)] LanguageVersion langVersion,
[CombinatorialValues("net6.0", "net7.0")] string tfm)
[CombinatorialValues("net6.0", "net8.0")] string tfm)
{
const string structName = "IEnumBstr";
this.compilation = this.starterCompilations[tfm];
Expand All @@ -410,7 +410,7 @@ public void COMInterfaceIIDInterfaceOnAppropriateTFMs(

// Static interface members requires C# 11 and .NET 7.
// And COM *interfaces* are not allowed to have them, so assert we only generate them on structs.
if (tfm == "net7.0" && langVersion >= LanguageVersion.CSharp11 && type is StructDeclarationSyntax)
if (tfm == "net8.0" && langVersion >= LanguageVersion.CSharp11 && type is StructDeclarationSyntax)
{
Assert.Contains(actual, predicate);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public FullGenerationTests(ITestOutputHelper logger)
[Fact]
public void Everything_NoFriendlyOverloads()
{
this.TestHelper(new GeneratorOptions { FriendlyOverloads = new() { Enabled = false } }, Platform.X64, "net7.0", generator => generator.GenerateAll(CancellationToken.None));
this.TestHelper(new GeneratorOptions { FriendlyOverloads = new() { Enabled = false } }, Platform.X64, "net8.0", generator => generator.GenerateAll(CancellationToken.None));
}

[Trait("TestCategory", "FailsInCloudTest")] // these take ~4GB of memory to run.
Expand Down
6 changes: 3 additions & 3 deletions test/Microsoft.Windows.CsWin32.Tests/GeneratorTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public enum MarshalingOptions
new object[] { "net472" },
new object[] { "netstandard2.0" },
new object[] { "net6.0" },
new object[] { "net7.0" },
new object[] { "net8.0" },
};

public static IEnumerable<object[]> TFMDataNoNetFx35MemberData => TFMDataNoNetFx35.Select(tfm => new object[] { tfm }).ToArray();
Expand All @@ -57,7 +57,7 @@ public enum MarshalingOptions
"net472",
"netstandard2.0",
"net6.0",
"net7.0",
"net8.0",
};

public static Platform[] SpecificCpuArchitectures =>
Expand Down Expand Up @@ -87,7 +87,7 @@ public async Task InitializeAsync()
this.starterCompilations.Add("net6.0", await this.CreateCompilationAsync(MyReferenceAssemblies.Net.Net60));
this.starterCompilations.Add("net6.0-x86", await this.CreateCompilationAsync(MyReferenceAssemblies.Net.Net60, Platform.X86));
this.starterCompilations.Add("net6.0-x64", await this.CreateCompilationAsync(MyReferenceAssemblies.Net.Net60, Platform.X64));
this.starterCompilations.Add("net7.0", await this.CreateCompilationAsync(MyReferenceAssemblies.Net.Net70));
this.starterCompilations.Add("net8.0", await this.CreateCompilationAsync(MyReferenceAssemblies.Net.Net70));

foreach (string tfm in this.starterCompilations.Keys)
{
Expand Down
2 changes: 1 addition & 1 deletion test/Microsoft.Windows.CsWin32.Tests/GeneratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void SimplestMethod(string tfm)
this.AssertNoDiagnostics();

var generatedMethod = this.FindGeneratedMethod(methodName).Single();
if (tfm is "net6.0" or "net7.0")
if (tfm is "net6.0" or "net8.0")
{
Assert.Contains(generatedMethod.AttributeLists, al => IsAttributePresent(al, "SupportedOSPlatform"));
}
Expand Down

0 comments on commit 6736a5d

Please sign in to comment.