From 658e4e51e75dd5985125d2b5fefdb3d772cd13f4 Mon Sep 17 00:00:00 2001 From: Westin Musser <127992899+westin-m@users.noreply.github.com> Date: Wed, 13 Nov 2024 17:10:12 -0800 Subject: [PATCH 1/3] Prevent inlining to guarantee stack frames in test (#3002) * Prevent inlining to guarantee stack frames --- .../Validation/ValidationErrorTests.cs | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/test/Microsoft.IdentityModel.Tokens.Tests/Validation/ValidationErrorTests.cs b/test/Microsoft.IdentityModel.Tokens.Tests/Validation/ValidationErrorTests.cs index c1151641f8..03915c766c 100644 --- a/test/Microsoft.IdentityModel.Tokens.Tests/Validation/ValidationErrorTests.cs +++ b/test/Microsoft.IdentityModel.Tokens.Tests/Validation/ValidationErrorTests.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +using System.Runtime.CompilerServices; using Xunit; namespace Microsoft.IdentityModel.Tokens.Tests @@ -10,29 +11,33 @@ public class ValidationErrorTests [Fact] public void ExceptionCreatedFromValidationError_ContainsTheRightStackTrace() { - var validationError = new ValidationErrorReturningClass().firstMethod(); + var validationError = new ValidationErrorReturningClass().FirstMethod(); Assert.NotNull(validationError); Assert.NotNull(validationError.StackFrames); Assert.Equal(3, validationError.StackFrames.Count); Assert.NotNull(validationError.GetException()); Assert.NotNull(validationError.GetException().StackTrace); - Assert.Equal("thirdMethod", validationError.StackFrames[0].GetMethod().Name); - Assert.Equal("secondMethod", validationError.StackFrames[1].GetMethod().Name); - Assert.Equal("firstMethod", validationError.StackFrames[2].GetMethod().Name); + Assert.Equal("ThirdMethod", validationError.StackFrames[0].GetMethod().Name); + Assert.Equal("SecondMethod", validationError.StackFrames[1].GetMethod().Name); + Assert.Equal("FirstMethod", validationError.StackFrames[2].GetMethod().Name); } + class ValidationErrorReturningClass { - public ValidationError firstMethod() + [MethodImpl(MethodImplOptions.NoInlining)] + public ValidationError FirstMethod() { - return secondMethod().AddCurrentStackFrame(); + return SecondMethod().AddCurrentStackFrame(); } - public ValidationError secondMethod() + [MethodImpl(MethodImplOptions.NoInlining)] + public ValidationError SecondMethod() { - return thirdMethod().AddCurrentStackFrame(); + return ThirdMethod().AddCurrentStackFrame(); } - public ValidationError thirdMethod() + [MethodImpl(MethodImplOptions.NoInlining)] + public ValidationError ThirdMethod() { return new ValidationError( new MessageDetail("This is a test error"), From f604488aba411d76bd59f9590bbc2385e0d9e6fa Mon Sep 17 00:00:00 2001 From: Peter <34331512+pmaytak@users.noreply.github.com> Date: Thu, 14 Nov 2024 02:17:51 -0800 Subject: [PATCH 2/3] Update to .NET 9 GA. Update some test dependencies. (#2990) * Update to .NET 9 GA. Update some test dependencies. * Remove installing extra SDKs in YAML. * Add TargetNetNext flag. * Update template-Build-run-tests-sign.yml * Nit. * Update aot-check.yml * Update yaml. * Fix AOT test. * Add strong name bypass --- .github/workflows/aot-check.yml | 7 +++- .github/workflows/dotnetcore.yml | 37 ++++++++----------- .../Microsoft.IdentityModel.Benchmarks.csproj | 4 +- build/common.props | 2 +- build/dependenciesTest.props | 8 ++-- build/targets.props | 6 +-- build/targetsTest.props | 8 ++-- build/template-Build-run-tests-sign.yml | 23 +----------- build/test-aot.ps1 | 2 +- ...ntityModel.AotCompatibility.TestApp.csproj | 4 +- .../AotCompatibilityTests.cs | 8 +++- ...dentityModel.AotCompatibility.Tests.csproj | 4 +- 12 files changed, 50 insertions(+), 63 deletions(-) diff --git a/.github/workflows/aot-check.yml b/.github/workflows/aot-check.yml index b9f684dca1..911da7f712 100644 --- a/.github/workflows/aot-check.yml +++ b/.github/workflows/aot-check.yml @@ -14,7 +14,7 @@ on: jobs: analyze: runs-on: windows-latest - name: Wilson GitHub AOT check + name: "AOT check" steps: - name: Checkout repository @@ -22,6 +22,11 @@ jobs: with: fetch-depth: 1 + - name: Setup .NET 9.0.x + uses: actions/setup-dotnet@v4.1.0 + with: + dotnet-version: 9.0.x + - name: Runs powershell script id: aot-powershell run: build\test-aot.ps1 'net8.0' diff --git a/.github/workflows/dotnetcore.yml b/.github/workflows/dotnetcore.yml index 5f6b376481..cfef45dc72 100644 --- a/.github/workflows/dotnetcore.yml +++ b/.github/workflows/dotnetcore.yml @@ -1,4 +1,4 @@ -name: .NET Core +name: "Run unit tests" permissions: contents: read @@ -18,40 +18,35 @@ on: - dev env: - TargetNet9: True - TargetNet8: True + TargetNetNext: True jobs: build: runs-on: windows-latest - continue-on-error: true - name: Wilson GitHub Action Test + continue-on-error: false + name: "Build and run unit tests" steps: - name: Checkout repository uses: actions/checkout@v4.1.1 - - - name: Setup .NET 6.0.x - uses: actions/setup-dotnet@v4.0.0 - with: - dotnet-version: 6.0.x - - name: Setup .NET 8.0.x - uses: actions/setup-dotnet@v4.0.0 - with: - dotnet-version: 8.0.x - - name: Setup .NET 9.0.x - uses: actions/setup-dotnet@v4.0.0 + + - name: Setup .NET 9.x + uses: actions/setup-dotnet@v4.1.0 with: - dotnet-version: 9.0.100-rc.2.24474.11 + dotnet-version: 9.x + + - name: Strong name bypass + run: | + regedit /s .\build\strongNameBypass.reg - name: Run the tests run: dotnet test Wilson.sln --collect:"XPlat Code Coverage" --settings:./build/CodeCoverage.runsettings - name: Create code coverage report run: | - dotnet tool install -g dotnet-reportgenerator-globaltool + dotnet tool install -g dotnet-reportgenerator-globaltool --version 5.4.1 reportgenerator -reports:./**/coverage.cobertura.xml -targetdir:CodeCoverage -reporttypes:'MarkdownSummaryGithub;Cobertura' - - name: Write Coverage to Job Summary + - name: Write coverage to job summary shell: bash run: | cat CodeCoverage/SummaryGithub.md >> $GITHUB_STEP_SUMMARY @@ -59,7 +54,7 @@ jobs: echo $(cat CodeCoverage/SummaryGithub.md) >> $GITHUB_ENV echo "EOF" >> $GITHUB_ENV - - name: Comment Coverage in PR + - name: Comment coverage in PR uses: actions/github-script@v7 id: comment with: @@ -73,4 +68,4 @@ jobs: # Run baseline package validation - name: Pack - run: dotnet pack Product.proj --no-restore --no-build \ No newline at end of file + run: dotnet pack Product.proj --no-restore --no-build diff --git a/benchmark/Microsoft.IdentityModel.Benchmarks/Microsoft.IdentityModel.Benchmarks.csproj b/benchmark/Microsoft.IdentityModel.Benchmarks/Microsoft.IdentityModel.Benchmarks.csproj index ac1a985f5e..db8f7b2621 100644 --- a/benchmark/Microsoft.IdentityModel.Benchmarks/Microsoft.IdentityModel.Benchmarks.csproj +++ b/benchmark/Microsoft.IdentityModel.Benchmarks/Microsoft.IdentityModel.Benchmarks.csproj @@ -4,8 +4,8 @@ Microsoft.IdentityModel.Benchmarks Microsoft.IdentityModel.Benchmarks Exe - net6.0;net8.0 - $(TargetFrameworks); net9.0 + net6.0;net8.0;net9.0 + $(TargetFrameworks); True True $(MSBuildThisFileDirectory)..\..\build\35MSSharedLib1024.snk diff --git a/build/common.props b/build/common.props index b80be3698f..41be4bdb83 100644 --- a/build/common.props +++ b/build/common.props @@ -48,7 +48,7 @@ - + diff --git a/build/dependenciesTest.props b/build/dependenciesTest.props index 0cdd52d56f..65daedcf38 100644 --- a/build/dependenciesTest.props +++ b/build/dependenciesTest.props @@ -4,19 +4,19 @@ 3.3.4 2.1.30 3.0.5 - 17.11.0 + 17.11.1 2.0.3 13.0.3 4.3.4 4.3.0 8.0.5 4.3.1 - 2.9.0 + 2.9.2 2.8.2 - 2.9.0 + 2.9.2 2.3.24 - 3.0.0-pre.35 + 3.0.0-pre.49 diff --git a/build/targets.props b/build/targets.props index dc29e3024f..7706821787 100644 --- a/build/targets.props +++ b/build/targets.props @@ -1,7 +1,7 @@ - net462;net472;netstandard2.0;net6.0;net8.0 - netstandard2.0;net8.0 - $(SrcTargets);net9.0 + net462;net472;netstandard2.0;net6.0;net8.0;net9.0 + netstandard2.0;net8.0;net9.0 + $(SrcTargets); diff --git a/build/targetsTest.props b/build/targetsTest.props index 380ab3f7cd..3ce14d058e 100644 --- a/build/targetsTest.props +++ b/build/targetsTest.props @@ -1,7 +1,7 @@ - net462;net472;net6.0;net8.0 - net8.0 - $(TestTargets);net9.0 - + net462;net472;net6.0;net8.0;net9.0 + net8.0;net9.0 + $(TestTargets); + diff --git a/build/template-Build-run-tests-sign.yml b/build/template-Build-run-tests-sign.yml index e57c0ec81c..34660b298b 100644 --- a/build/template-Build-run-tests-sign.yml +++ b/build/template-Build-run-tests-sign.yml @@ -7,30 +7,11 @@ steps: - script: echo $(MicrosoftIdentityModelVersion) displayName: 'display MicrosoftIdentityModelVersion' -- task: UseDotNet@2 - displayName: 'Use .NET Core sdk 2.x' - inputs: - version: 2.x - installationPath: $(Agent.ToolsDirectory)/dotnet - -- task: UseDotNet@2 - displayName: 'Use .NET Core sdk 6.x' - inputs: - version: 6.x - installationPath: $(Agent.ToolsDirectory)/dotnet - -- task: UseDotNet@2 - displayName: 'Use .NET Core sdk 8.x' - inputs: - version: 8.x - installationPath: $(Agent.ToolsDirectory)/dotnet - - task: UseDotNet@2 displayName: 'Use .Net Core SDK 9.x' inputs: - version: 9.0.100-rc.2.24474.11 - includePreviewVersions: true - condition: eq(variables['TargetNet9'], 'True') + version: 9.x + installationPath: $(Agent.ToolsDirectory)/dotnet - task: DotNetCoreCLI@2 displayName: 'dotnet --list-sdks' diff --git a/build/test-aot.ps1 b/build/test-aot.ps1 index 9d2188e938..7afda6f861 100644 --- a/build/test-aot.ps1 +++ b/build/test-aot.ps1 @@ -2,7 +2,7 @@ param([string]$targetNetFramework) $projectName='Microsoft.IdentityModel.AotCompatibility.TestApp' $rootDirectory = Split-Path $PSScriptRoot -Parent -$publishOutput = dotnet publish $rootDirectory/test/$projectName/$projectName.csproj --self-contained -nodeReuse:false /p:UseSharedCompilation=false +$publishOutput = dotnet publish $rootDirectory/test/$projectName/$projectName.csproj --self-contained --framework $targetNetFramework -nodeReuse:false /p:UseSharedCompilation=false $actualWarningCount = 0 diff --git a/test/Microsoft.IdentityModel.AotCompatibility.TestApp/Microsoft.IdentityModel.AotCompatibility.TestApp.csproj b/test/Microsoft.IdentityModel.AotCompatibility.TestApp/Microsoft.IdentityModel.AotCompatibility.TestApp.csproj index 6e708ec2ac..2ffe0e3b28 100644 --- a/test/Microsoft.IdentityModel.AotCompatibility.TestApp/Microsoft.IdentityModel.AotCompatibility.TestApp.csproj +++ b/test/Microsoft.IdentityModel.AotCompatibility.TestApp/Microsoft.IdentityModel.AotCompatibility.TestApp.csproj @@ -1,8 +1,8 @@ - net8.0 - $(TargetFramework); net9.0 + net8.0;net9.0 + $(TargetFrameworks); Exe true full diff --git a/test/Microsoft.IdentityModel.AotCompatibility.Tests/AotCompatibilityTests.cs b/test/Microsoft.IdentityModel.AotCompatibility.Tests/AotCompatibilityTests.cs index b00cd4bc9f..1c5af61ae1 100644 --- a/test/Microsoft.IdentityModel.AotCompatibility.Tests/AotCompatibilityTests.cs +++ b/test/Microsoft.IdentityModel.AotCompatibility.Tests/AotCompatibilityTests.cs @@ -38,6 +38,12 @@ public void EnsureAotCompatibility() string testAppPath = Path.Combine("..", "..", "..", "..", "Microsoft.IdentityModel.AotCompatibility.TestApp"); string testAppProject = "Microsoft.IdentityModel.AotCompatibility.TestApp.csproj"; +#if NET9_0_OR_GREATER + string framework = "net9.0"; +#else + string framework = "net8.0"; +#endif + // ensure we run a clean publish every time DirectoryInfo testObjDir = new DirectoryInfo(Path.Combine(testAppPath, "obj")); if (testObjDir.Exists) @@ -47,7 +53,7 @@ public void EnsureAotCompatibility() var process = new Process(); // set '-nodereuse:false /p:UseSharedCompilation=false' so the MSBuild and Roslyn server processes don't hang around, which may hang the test in CI - process.StartInfo = new ProcessStartInfo("dotnet", $"publish {testAppProject} --self-contained -nodereuse:false /p:UseSharedCompilation=false") + process.StartInfo = new ProcessStartInfo("dotnet", $"publish {testAppProject} --self-contained --framework {framework} -nodereuse:false /p:UseSharedCompilation=false") { RedirectStandardOutput = true, UseShellExecute = false, diff --git a/test/Microsoft.IdentityModel.AotCompatibility.Tests/Microsoft.IdentityModel.AotCompatibility.Tests.csproj b/test/Microsoft.IdentityModel.AotCompatibility.Tests/Microsoft.IdentityModel.AotCompatibility.Tests.csproj index 07b2b77495..c72cdd01e8 100644 --- a/test/Microsoft.IdentityModel.AotCompatibility.Tests/Microsoft.IdentityModel.AotCompatibility.Tests.csproj +++ b/test/Microsoft.IdentityModel.AotCompatibility.Tests/Microsoft.IdentityModel.AotCompatibility.Tests.csproj @@ -4,8 +4,8 @@ - net8.0 - $(TargetFrameworks);net9.0 + net8.0;net9.0 + $(TargetFrameworks); 12 1.0.0-preview From 6dc806c6b913f0a363f70fbef0879dc25bed408d Mon Sep 17 00:00:00 2001 From: Peter <34331512+pmaytak@users.noreply.github.com> Date: Thu, 14 Nov 2024 12:31:25 -0800 Subject: [PATCH 3/3] Add Abstractions.Tests to strong name bypass file. (#3004) --- build/strongNameBypass.reg | Bin 17124 -> 17648 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/build/strongNameBypass.reg b/build/strongNameBypass.reg index 970e9a7471482435a88b8712f742a7954b75365c..322170a182d2633044590a8bd0f0764952ece733 100644 GIT binary patch delta 82 zcmaFT%J`v^al;L!$*&kCCQmcUo2vGWnls8<-YQF96Y-7qGd=f)s2PP<