Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions .azure-pipelines/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ extends:
os: windows
demands:
- msbuild
- vstest
customBuildTags:
- ES365AIMigrationTooling
stages:
Expand Down Expand Up @@ -81,7 +80,7 @@ extends:
version: 8.x

- task: UseDotNet@2
displayName: 'Use .NET 10 for hidi tests'
displayName: 'Use .NET 10 for Microsoft.Testing.Platform'
inputs:
version: 10.x

Expand Down Expand Up @@ -114,19 +113,20 @@ extends:
projects: '$(Build.SourcesDirectory)\Microsoft.OpenApi.OData.sln'
arguments: '--configuration $(BuildConfiguration) --no-incremental'

# Both test projects are in the solution, but SDK10 cannot run MTP via VSTest.
# Keep OData on VSTest and invoke the hidi MTP executable separately.
- task: DotNetCoreCLI@2
displayName: 'test'
inputs:
command: test
projects: '$(Build.SourcesDirectory)\test\Microsoft.OpenAPI.OData.Reader.Tests\Microsoft.OpenAPI.OData.Reader.Tests.csproj'
arguments: '--configuration $(BuildConfiguration) --no-build'

- pwsh: |
dotnet run --project test\Microsoft.OpenApi.Hidi.Tests\Microsoft.OpenApi.Hidi.Tests.csproj -c $(buildConfiguration) --no-build -- --minimum-expected-tests 1
dotnet test --solution Microsoft.OpenApi.OData.sln -c $(buildConfiguration) --no-build --results-directory '$(Agent.TempDirectory)\TestResults' -- --minimum-expected-tests 1 --report-trx --report-azdo
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
displayName: 'Test hidi (Microsoft.Testing.Platform)'
displayName: 'Test solution (Microsoft.Testing.Platform)'

- task: PublishTestResults@2
displayName: 'Publish solution test results'
condition: succeededOrFailed()
inputs:
testResultsFormat: VSTest
testResultsFiles: '$(Agent.TempDirectory)\TestResults\*.trx'
mergeTestResults: true
failTaskOnFailedTests: true
failTaskOnMissingResultsFile: true

- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@5
displayName: 'ESRP CodeSigning'
Expand Down
17 changes: 15 additions & 2 deletions .azure-pipelines/hidi-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,29 @@ extends:
- pwsh: |
dotnet build src\Microsoft.OpenApi.Hidi\Microsoft.OpenApi.Hidi.csproj -c $(buildConfiguration) -p:GeneratePackageOnBuild=false
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
dotnet run --project test\Microsoft.OpenApi.Hidi.Tests\Microsoft.OpenApi.Hidi.Tests.csproj -c $(buildConfiguration) -- --minimum-expected-tests 1
displayName: Build hidi
- pwsh: |
dotnet test --solution Microsoft.OpenApi.OData.sln -c $(buildConfiguration) --results-directory '$(Agent.TempDirectory)\TestResults' -- --minimum-expected-tests 1 --report-trx --report-azdo
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
displayName: Test solution (Microsoft.Testing.Platform)
- task: PublishTestResults@2
displayName: Publish solution test results
condition: succeededOrFailed()
inputs:
testResultsFormat: VSTest
testResultsFiles: '$(Agent.TempDirectory)\TestResults\*.trx'
mergeTestResults: true
failTaskOnFailedTests: true
failTaskOnMissingResultsFile: true
- pwsh: |
dotnet publish src\Microsoft.OpenApi.Hidi\Microsoft.OpenApi.Hidi.csproj -c $(buildConfiguration) -r win-x64 --self-contained true -p:PublishSingleFile=true -p:PackAsTool=false -p:GeneratePackageOnBuild=false -o artifacts\hidi\win-x64
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
& .\artifacts\hidi\win-x64\Microsoft.OpenApi.Hidi.exe --help
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
New-Item -ItemType Directory -Force artifacts\hidi\signing | Out-Null
Copy-Item src\Microsoft.OpenApi.Hidi\bin\$(buildConfiguration)\net8.0\Microsoft.OpenApi.Hidi.dll artifacts\hidi\signing
Copy-Item artifacts\hidi\win-x64\Microsoft.OpenApi.Hidi.exe artifacts\hidi\signing
displayName: Build, test and stage hidi binaries
displayName: Stage hidi binaries
- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@5
displayName: Sign hidi DLL and Windows executable
inputs:
Expand Down
23 changes: 10 additions & 13 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,21 +88,18 @@ jobs:
id: run_unit_tests
shell: pwsh
run: |
$testProjectsArray = @(
'.\test\Microsoft.OpenAPI.OData.Reader.Tests\Microsoft.OpenAPI.OData.Reader.Tests.csproj'
)

$testProjectsArray | ForEach-Object {
dotnet test $PSItem `
-c Release
}

- name: Run hidi tests (Microsoft.Testing.Platform)
shell: pwsh
run: |
dotnet run --project .\test\Microsoft.OpenApi.Hidi.Tests\Microsoft.OpenApi.Hidi.Tests.csproj -c Release -- --minimum-expected-tests 1
$resultsDirectory = Join-Path $PWD 'artifacts' 'test-results'
dotnet test --solution Microsoft.OpenApi.OData.sln -c Release -p:EnableWindowsTargeting=true --results-directory $resultsDirectory -- --minimum-expected-tests 1 --report-trx --report-gh
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }

- name: Upload test results
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: test-results
path: artifacts/test-results
if-no-files-found: error

- name: Pack and install hidi locally
shell: pwsh
run: |
Expand Down
21 changes: 15 additions & 6 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,25 @@ jobs:
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
CollectCoverage: true
CoverletOutputFormat: 'opencover' # https://github.com/microsoft/vstest/issues/4014#issuecomment-1307913682
shell: pwsh
run: |
dotnet tool run dotnet-sonarscanner begin /k:"microsoft_OpenAPI.NET.OData" /o:"microsoft" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths="test/**/coverage.net8.0.opencover.xml,artifacts/hidi/coverage/*opencover*.xml" /d:sonar.coverageReportPaths="artifacts/hidi/powershell-coverage/sonar-coverage.xml"
dotnet tool run dotnet-sonarscanner begin /k:"microsoft_OpenAPI.NET.OData" /o:"microsoft" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths="artifacts/test-results/*opencover*.xml" /d:sonar.coverageReportPaths="artifacts/hidi/powershell-coverage/sonar-coverage.xml"
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
dotnet workload restore
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
dotnet build
dotnet test test\Microsoft.OpenAPI.OData.Reader.Tests\Microsoft.OpenAPI.OData.Reader.Tests.csproj --no-build --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
dotnet run --project test\Microsoft.OpenApi.Hidi.Tests\Microsoft.OpenApi.Hidi.Tests.csproj --no-build -- --minimum-expected-tests 1 --coverlet --coverlet-output-format opencover --coverlet-include "[Microsoft.OpenApi.Hidi]*" --results-directory artifacts\hidi\coverage
dotnet test --solution Microsoft.OpenApi.OData.sln --no-build --results-directory artifacts\test-results -- --minimum-expected-tests 1 --report-trx --report-gh --coverlet --coverlet-output-format opencover --coverlet-include "[Microsoft.OpenApi.OData.Reader]*" --coverlet-include "[Microsoft.OpenApi.Hidi]*"
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
if (-not (Get-ChildItem artifacts\hidi\coverage -Filter '*opencover*.xml')) { throw "Hidi OpenCover report was not generated." }
$reports = @(Get-ChildItem artifacts\test-results -Filter '*opencover*.xml')
if ($reports.Count -ne 2) { throw "Expected an OpenCover report from each test project." }
dotnet tool run dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }

- name: Upload test and coverage results
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: sonar-test-results
path: artifacts/test-results
if-no-files-found: error
31 changes: 21 additions & 10 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,21 @@
"group": "test",
"args": [
"test",
"--solution",
"${workspaceFolder}/Microsoft.OpenApi.OData.sln",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary",
"--collect:\"XPlat Code Coverage\""
"-p:EnableWindowsTargeting=true",
"--results-directory",
"${workspaceFolder}/artifacts/test-results",
"--",
"--minimum-expected-tests",
"1",
"--coverlet",
"--coverlet-output-format",
"cobertura",
"--coverlet-include",
"[Microsoft.OpenApi.OData.Reader]*",
"--coverlet-include",
"[Microsoft.OpenApi.Hidi]*"
],
"problemMatcher": "$msCompile"
},
Expand All @@ -35,15 +46,15 @@
"linux": {
"command": "rm",
"args": [
"-r",
"${workspaceFolder}/test/Microsoft.OpenAPI.OData.Reader.Tests/TestResults"
"-rf",
"${workspaceFolder}/artifacts/test-results"
]
},
"windows": {
"command": "powershell",
"args": [
"-command",
"Remove-Item -Recurse -Include TestResults -Path ${workspaceFolder}/tests"
"if (Test-Path -LiteralPath '${workspaceFolder}/artifacts/test-results') { Remove-Item -Recurse -LiteralPath '${workspaceFolder}/artifacts/test-results' }"
]
}
},
Expand All @@ -54,14 +65,14 @@
"linux":{
"command": "reportgenerator",
"args": [
"-reports:${workspaceFolder}/tests/**/coverage.cobertura.xml",
"-reports:${workspaceFolder}/artifacts/test-results/*cobertura*.xml",
"-targetdir:${workspaceFolder}/reports/coverage"
],
},
"windows": {
"command": "reportgenerator",
"args": [
"-reports:${workspaceFolder}\\test\\**\\coverage.cobertura.xml",
"-reports:${workspaceFolder}\\artifacts\\test-results\\*cobertura*.xml",
"-targetdir:${workspaceFolder}\\reports\\coverage"
]
},
Expand All @@ -72,7 +83,7 @@
"dependsOrder": "sequence"
},
{
"label": "coverage:launch",
"label": "coverage:open",
"type": "shell",
"linux": {
"command": "xdg-open",
Expand Down Expand Up @@ -100,7 +111,7 @@
"dependsOrder": "sequence",
"dependsOn": [
"coverage:unit",
"coverage:launch"
"coverage:open"
]
},
{
Expand Down
22 changes: 18 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,29 @@ OpenAPI.net.OData is a mono-repo containing source code for the following packag

[Microsoft.OpenApi.Hidi](src/Microsoft.OpenApi.Hidi/readme.md) is a .NET tool,
not an OData library package. Install the .NET 10 SDK and .NET 8 runtime to build
and test both projects. Do not change the solution-wide test runner: OData uses
VSTest and hidi uses Microsoft.Testing.Platform.
and test both projects. Both test projects use xUnit v3 and
Microsoft.Testing.Platform, selected by `global.json`. Reader tests still target
.NET 8; Hidi tests target .NET 10.

```powershell
dotnet build Microsoft.OpenApi.OData.sln -c Release
dotnet test test\Microsoft.OpenAPI.OData.Reader.Tests\Microsoft.OpenAPI.OData.Reader.Tests.csproj -c Release
dotnet run --project test\Microsoft.OpenApi.Hidi.Tests\Microsoft.OpenApi.Hidi.Tests.csproj -c Release -- --minimum-expected-tests 1
dotnet test --solution Microsoft.OpenApi.OData.sln -c Release --no-build -- --minimum-expected-tests 1
```

On non-Windows hosts, pass `-p:EnableWindowsTargeting=true` to both commands
because the solution also contains the Windows-only GUI project.
Use `--project <path>` instead of `--solution <path>` for a single test project.
MTP options replace VSTest's `--logger`, `--collect`, and MSBuild coverage options:

```powershell
dotnet test --solution Microsoft.OpenApi.OData.sln -c Release --no-build --results-directory artifacts\test-results -- --minimum-expected-tests 1 --report-trx --coverlet --coverlet-output-format cobertura --coverlet-include "[Microsoft.OpenApi.OData.Reader]*" --coverlet-include "[Microsoft.OpenApi.Hidi]*"
```

This produces separate TRX and coverage reports for each test assembly.
CI uses `--report-gh` for GitHub Actions and `--report-azdo` with TRX publication
for Azure DevOps. SonarCloud collects OpenCover reports for both projects in
`artifacts/test-results`, alongside the separately measured Pester helper coverage.

Hidi uses published OpenAPI core/YAML packages and the local OData project. Its
public-only signing key preserves assembly identity and friend-assembly access;
never add the source repository's private strong-name key. Production signing
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ The command remains `hidi`.

The `support/v2` branch maintains hidi 2.x separately from the OData library
version. Hidi requires .NET 8 to run; building the repository and running hidi
tests requires the .NET 10 SDK. Existing OData tests still use .NET 8 and VSTest.
tests requires the .NET 10 SDK. Both test projects use xUnit v3 and
Microsoft.Testing.Platform; OData tests still target .NET 8. Run them together
with `dotnet test --solution Microsoft.OpenApi.OData.sln -c Release -- --minimum-expected-tests 1`
(add `-p:EnableWindowsTargeting=true` on non-Windows hosts). See
[contributing](CONTRIBUTING.md#hidi) for coverage and reporting commands.

Hidi's filtered history was imported with a merge, not squashed. **Merge this
migration PR using a merge commit, not squash or rebase**, so the canonical
Expand Down
15 changes: 6 additions & 9 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ ForEach ($ver in $SNVersions)
}

# Other variables
$ProductProj = $ENLISTMENT_ROOT + "\src\Microsoft.OpenAPI.OData.Reader\Microsoft.OpenApi.OData.Reader.csproj"
$TESTProj = $ENLISTMENT_ROOT + "\test\Microsoft.OpenAPI.OData.Reader.Tests\Microsoft.OpenApi.OData.Reader.Tests.csproj"
$Solution = $ENLISTMENT_ROOT + "\Microsoft.OpenApi.OData.sln"

$TESTDIR = $ENLISTMENT_ROOT + "\bin\$Configuration\Test\net472"
$PRODUCTDIR = $ENLISTMENT_ROOT + "\bin\$Configuration\net472"
Expand Down Expand Up @@ -186,13 +185,10 @@ Function BuildProcess

$script:BUILD_START_TIME = Get-Date

Write-Host "Build Product ..."
Write-Host "Build Solution ..."

& dotnet.exe build $ProductProj -c $Configuration

Write-Host "Build Test ..."

& dotnet.exe build $TESTProj -c $Configuration
& dotnet.exe build $Solution -c $Configuration
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }

Write-Host "Build Done" -ForegroundColor $Success
$script:BUILD_END_TIME = Get-Date
Expand All @@ -204,7 +200,8 @@ Function TestProcess

$script:TEST_START_TIME = Get-Date

& dotnet test $TESTProj -c $Configuration
& dotnet test --solution $Solution -c $Configuration --no-build -- --minimum-expected-tests 1
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }

Write-Host "Test Done" -ForegroundColor $Success
$script:TEST_END_TIME = Get-Date
Expand Down
3 changes: 3 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
"version": "10.0.100",
"rollForward": "latestFeature",
"allowPrerelease": false
},
"test": {
"runner": "Microsoft.Testing.Platform"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
using System.Collections.Generic;
using System.Text;
using Microsoft.OData.Edm.Validation;
using Xunit.Abstractions;

namespace Microsoft.OpenApi.OData.Tests
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
// ------------------------------------------------------------

using Xunit.Abstractions;
using Xunit;

namespace Microsoft.OpenApi.OData.Tests
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using System.Threading.Tasks;
using Microsoft.OData.Edm;
using Xunit;
using Xunit.Abstractions;

namespace Microsoft.OpenApi.OData.Tests;
public class EdmModelOpenApiExtensionsTest(ITestOutputHelper output)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
using Microsoft.OpenApi.OData.Edm;
using Microsoft.OpenApi.OData.Generator;
using Xunit;
using Xunit.Abstractions;

namespace Microsoft.OpenApi.OData.Tests
{
Expand Down Expand Up @@ -61,7 +60,7 @@
// Act
var schema = context.CreateEdmTypeSchema(collectionType, new());
Assert.NotNull(schema);
var json = JsonNode.Parse(await schema.SerializeAsJsonAsync(context.Settings.OpenApiSpecVersion));

Check warning on line 63 in test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiEdmTypeSchemaGeneratorTest.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Calls to methods which accept CancellationToken should use TestContext.Current.CancellationToken to allow test cancellation to be more responsive.

See more on https://sonarcloud.io/project/issues?id=microsoft_OpenAPI.NET.OData&issues=AaE8PvGleu8GDtkkAHkq&open=AaE8PvGleu8GDtkkAHkq&pullRequest=915

// & Assert
if (specVersion == OpenApiSpecVersion.OpenApi2_0)
Expand Down Expand Up @@ -97,7 +96,7 @@
// Act
var schema = context.CreateEdmTypeSchema(collectionType, new());
Assert.NotNull(schema);
var json = JsonNode.Parse(await schema.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi3_0));

Check warning on line 99 in test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiEdmTypeSchemaGeneratorTest.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Calls to methods which accept CancellationToken should use TestContext.Current.CancellationToken to allow test cancellation to be more responsive.

See more on https://sonarcloud.io/project/issues?id=microsoft_OpenAPI.NET.OData&issues=AaE8PvGleu8GDtkkAHkr&open=AaE8PvGleu8GDtkkAHkr&pullRequest=915

// & Assert
Assert.True(JsonNode.DeepEquals(JsonNode.Parse(@"{
Expand All @@ -120,7 +119,7 @@
// Act
var schema = context.CreateEdmTypeSchema(collectionType, new());
Assert.NotNull(schema);
var json = JsonNode.Parse(await schema.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi3_0));

Check warning on line 122 in test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiEdmTypeSchemaGeneratorTest.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Calls to methods which accept CancellationToken should use TestContext.Current.CancellationToken to allow test cancellation to be more responsive.

See more on https://sonarcloud.io/project/issues?id=microsoft_OpenAPI.NET.OData&issues=AaE8PvGleu8GDtkkAHks&open=AaE8PvGleu8GDtkkAHks&pullRequest=915

// & Assert
Assert.True(JsonNode.DeepEquals(JsonNode.Parse(@"{
Expand All @@ -143,7 +142,7 @@
// Act
var schema = context.CreateEdmTypeSchema(collectionType, new());
Assert.NotNull(schema);
var json = JsonNode.Parse(await schema.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi3_0));

Check warning on line 145 in test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiEdmTypeSchemaGeneratorTest.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Calls to methods which accept CancellationToken should use TestContext.Current.CancellationToken to allow test cancellation to be more responsive.

See more on https://sonarcloud.io/project/issues?id=microsoft_OpenAPI.NET.OData&issues=AaE8PvGleu8GDtkkAHkt&open=AaE8PvGleu8GDtkkAHkt&pullRequest=915

// & Assert
Assert.True(JsonNode.DeepEquals(JsonNode.Parse(@"{
Expand Down Expand Up @@ -320,7 +319,7 @@
// Act
var schema = context.CreateEdmTypeSchema(edmTypeReference, new());
Assert.NotNull(schema); // guard
var json = JsonNode.Parse(await schema.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi3_0));

Check warning on line 322 in test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiEdmTypeSchemaGeneratorTest.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Calls to methods which accept CancellationToken should use TestContext.Current.CancellationToken to allow test cancellation to be more responsive.

See more on https://sonarcloud.io/project/issues?id=microsoft_OpenAPI.NET.OData&issues=AaE8PvGleu8GDtkkAHku&open=AaE8PvGleu8GDtkkAHku&pullRequest=915

// & Assert
if (isNullable)
Expand Down Expand Up @@ -351,7 +350,7 @@
// Act
var schema = context.CreateEdmTypeSchema(edmTypeReference, new());
Assert.NotNull(schema); // guard
var json = JsonNode.Parse(await schema.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi3_0));

Check warning on line 353 in test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiEdmTypeSchemaGeneratorTest.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Calls to methods which accept CancellationToken should use TestContext.Current.CancellationToken to allow test cancellation to be more responsive.

See more on https://sonarcloud.io/project/issues?id=microsoft_OpenAPI.NET.OData&issues=AaE8PvGleu8GDtkkAHkv&open=AaE8PvGleu8GDtkkAHkv&pullRequest=915

// & Assert
if (isNullable)
Expand Down Expand Up @@ -466,7 +465,7 @@
// Act
var schema = context.CreateEdmTypeSchema(edmTypeReference, new());
Assert.NotNull(schema); // guard
var json = JsonNode.Parse(await schema.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi3_0));

Check warning on line 468 in test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiEdmTypeSchemaGeneratorTest.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Calls to methods which accept CancellationToken should use TestContext.Current.CancellationToken to allow test cancellation to be more responsive.

See more on https://sonarcloud.io/project/issues?id=microsoft_OpenAPI.NET.OData&issues=AaE8PvGleu8GDtkkAHkw&open=AaE8PvGleu8GDtkkAHkw&pullRequest=915

// & Assert
if (isNullable)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
using Microsoft.OpenApi.OData.Edm;
using Microsoft.OpenApi.OData.Generator;
using Xunit;
using Xunit.Abstractions;

namespace Microsoft.OpenApi.OData.Tests
{
Expand Down Expand Up @@ -192,7 +191,7 @@
// Act
var schema = context.CreateStructuredTypeSchema(entity, new());
var derivedSchema = context.CreateStructuredTypeSchema(derivedEntity, new());
var rawJson = await schema.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi3_0);

Check warning on line 194 in test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiSchemaGeneratorTests.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Calls to methods which accept CancellationToken should use TestContext.Current.CancellationToken to allow test cancellation to be more responsive.

See more on https://sonarcloud.io/project/issues?id=microsoft_OpenAPI.NET.OData&issues=AaE8PvDAeu8GDtkkAHkZ&open=AaE8PvDAeu8GDtkkAHkZ&pullRequest=915
var json = JsonNode.Parse(rawJson);

// Assert
Expand Down Expand Up @@ -285,7 +284,7 @@

// Act
var schema = context.CreateStructuredTypeSchema(complex, new());
string json = await schema.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi3_0);

Check warning on line 287 in test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiSchemaGeneratorTests.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Calls to methods which accept CancellationToken should use TestContext.Current.CancellationToken to allow test cancellation to be more responsive.

See more on https://sonarcloud.io/project/issues?id=microsoft_OpenAPI.NET.OData&issues=AaE8PvDAeu8GDtkkAHkb&open=AaE8PvDAeu8GDtkkAHkb&pullRequest=915

// Assert
Assert.NotNull(json);
Expand Down Expand Up @@ -364,7 +363,7 @@

// Act
OpenApiSchema schema = context.CreateStructuredTypeSchema(entity, new());
string json = await schema.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi3_0);

Check warning on line 366 in test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiSchemaGeneratorTests.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Calls to methods which accept CancellationToken should use TestContext.Current.CancellationToken to allow test cancellation to be more responsive.

See more on https://sonarcloud.io/project/issues?id=microsoft_OpenAPI.NET.OData&issues=AaE8PvDAeu8GDtkkAHka&open=AaE8PvDAeu8GDtkkAHka&pullRequest=915

// Assert
Assert.NotNull(json);
Expand Down Expand Up @@ -478,7 +477,7 @@
Assert.Equal("Address", schema.Title);

// Act
string json = await schema.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi3_0);

Check warning on line 480 in test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiSchemaGeneratorTests.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Calls to methods which accept CancellationToken should use TestContext.Current.CancellationToken to allow test cancellation to be more responsive.

See more on https://sonarcloud.io/project/issues?id=microsoft_OpenAPI.NET.OData&issues=AaE8PvDAeu8GDtkkAHkc&open=AaE8PvDAeu8GDtkkAHkc&pullRequest=915

// Assert
Assert.NotNull(json);
Expand Down Expand Up @@ -552,7 +551,7 @@
Assert.Equal("Tree", declaredSchema.Title);

// Act
string json = await schema.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi3_0);

Check warning on line 554 in test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiSchemaGeneratorTests.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Calls to methods which accept CancellationToken should use TestContext.Current.CancellationToken to allow test cancellation to be more responsive.

See more on https://sonarcloud.io/project/issues?id=microsoft_OpenAPI.NET.OData&issues=AaE8PvDAeu8GDtkkAHkd&open=AaE8PvDAeu8GDtkkAHkd&pullRequest=915

// Assert
Assert.NotNull(json);
Expand Down Expand Up @@ -618,7 +617,7 @@
Assert.Equal("Zoo", schema.Title);

// Act
string json = await schema.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi3_0);

Check warning on line 620 in test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiSchemaGeneratorTests.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Calls to methods which accept CancellationToken should use TestContext.Current.CancellationToken to allow test cancellation to be more responsive.

See more on https://sonarcloud.io/project/issues?id=microsoft_OpenAPI.NET.OData&issues=AaE8PvDAeu8GDtkkAHke&open=AaE8PvDAeu8GDtkkAHke&pullRequest=915

// Assert
Assert.NotNull(json);
Expand Down Expand Up @@ -699,7 +698,7 @@
Assert.Equal("Human", declaredSchema.Title);

// Act
string json = await schema.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi3_0);

Check warning on line 701 in test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiSchemaGeneratorTests.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Calls to methods which accept CancellationToken should use TestContext.Current.CancellationToken to allow test cancellation to be more responsive.

See more on https://sonarcloud.io/project/issues?id=microsoft_OpenAPI.NET.OData&issues=AaE8PvDAeu8GDtkkAHkf&open=AaE8PvDAeu8GDtkkAHkf&pullRequest=915
_output.WriteLine(json);
// Assert
Assert.NotNull(json);
Expand Down Expand Up @@ -791,7 +790,7 @@

// Act
var schema = context.CreateStructuredTypeSchema(entityType, new());
string json = await schema.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi3_0);

Check warning on line 793 in test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiSchemaGeneratorTests.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Calls to methods which accept CancellationToken should use TestContext.Current.CancellationToken to allow test cancellation to be more responsive.

See more on https://sonarcloud.io/project/issues?id=microsoft_OpenAPI.NET.OData&issues=AaE8PvDAeu8GDtkkAHkg&open=AaE8PvDAeu8GDtkkAHkg&pullRequest=915

// Assert
Assert.NotNull(json);
Expand Down Expand Up @@ -844,7 +843,7 @@
Assert.Equal([ "Blue", "White" ], schema.Enum.Select(e => e.ToString()));

// Act
string json = await schema.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi3_0);

Check warning on line 846 in test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiSchemaGeneratorTests.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Calls to methods which accept CancellationToken should use TestContext.Current.CancellationToken to allow test cancellation to be more responsive.

See more on https://sonarcloud.io/project/issues?id=microsoft_OpenAPI.NET.OData&issues=AaE8PvDAeu8GDtkkAHkh&open=AaE8PvDAeu8GDtkkAHkh&pullRequest=915

// Assert
Assert.NotNull(json);
Expand Down Expand Up @@ -879,7 +878,7 @@
// Act
var schema = context.CreatePropertySchema(property, new());
Assert.NotNull(schema);
string json = await schema.SerializeAsJsonAsync(specVersion);

Check warning on line 881 in test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiSchemaGeneratorTests.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Calls to methods which accept CancellationToken should use TestContext.Current.CancellationToken to allow test cancellation to be more responsive.

See more on https://sonarcloud.io/project/issues?id=microsoft_OpenAPI.NET.OData&issues=AaE8PvDAeu8GDtkkAHki&open=AaE8PvDAeu8GDtkkAHki&pullRequest=915

// Assert

Expand Down Expand Up @@ -916,7 +915,7 @@
// Act
var schema = context.CreatePropertySchema(property, new());
Assert.NotNull(schema);
string json = await schema.SerializeAsJsonAsync(specVersion);

Check warning on line 918 in test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiSchemaGeneratorTests.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Calls to methods which accept CancellationToken should use TestContext.Current.CancellationToken to allow test cancellation to be more responsive.

See more on https://sonarcloud.io/project/issues?id=microsoft_OpenAPI.NET.OData&issues=AaE8PvDAeu8GDtkkAHkj&open=AaE8PvDAeu8GDtkkAHkj&pullRequest=915
_output.WriteLine(json);

var expected = JsonNode.Parse(specVersion switch
Expand Down Expand Up @@ -981,7 +980,7 @@
// Act
var schema = context.CreatePropertySchema(property, new());
Assert.NotNull(schema);
var json = JsonNode.Parse(await schema.SerializeAsJsonAsync(specVersion));

Check warning on line 983 in test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiSchemaGeneratorTests.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Calls to methods which accept CancellationToken should use TestContext.Current.CancellationToken to allow test cancellation to be more responsive.

See more on https://sonarcloud.io/project/issues?id=microsoft_OpenAPI.NET.OData&issues=AaE8PvDAeu8GDtkkAHkk&open=AaE8PvDAeu8GDtkkAHkk&pullRequest=915

// Assert
if (specVersion == OpenApiSpecVersion.OpenApi2_0)
Expand Down Expand Up @@ -1061,7 +1060,7 @@
Assert.NotNull(schema);
Assert.Equal(JsonSchemaType.Boolean, schema.Type);

string json = await schema.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi3_0);

Check warning on line 1063 in test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiSchemaGeneratorTests.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Calls to methods which accept CancellationToken should use TestContext.Current.CancellationToken to allow test cancellation to be more responsive.

See more on https://sonarcloud.io/project/issues?id=microsoft_OpenAPI.NET.OData&issues=AaE8PvDAeu8GDtkkAHkl&open=AaE8PvDAeu8GDtkkAHkl&pullRequest=915
Assert.True(JsonNode.DeepEquals(JsonNode.Parse(@"{
""type"": ""boolean"",
""default"": false
Expand All @@ -1086,7 +1085,7 @@
Assert.NotNull(schema);
Assert.Equal(JsonSchemaType.String, schema.Type);

string json = await schema.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi3_0);

Check warning on line 1088 in test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiSchemaGeneratorTests.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Calls to methods which accept CancellationToken should use TestContext.Current.CancellationToken to allow test cancellation to be more responsive.

See more on https://sonarcloud.io/project/issues?id=microsoft_OpenAPI.NET.OData&issues=AaE8PvDAeu8GDtkkAHkm&open=AaE8PvDAeu8GDtkkAHkm&pullRequest=915
Assert.True(JsonNode.DeepEquals(JsonNode.Parse(@"{
""maxLength"": 44,
""type"": ""string"",
Expand All @@ -1111,7 +1110,7 @@
Assert.NotNull(schema);
Assert.Equal(JsonSchemaType.Number, schema.Type);

string json = await schema.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi3_0);

Check warning on line 1113 in test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiSchemaGeneratorTests.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Calls to methods which accept CancellationToken should use TestContext.Current.CancellationToken to allow test cancellation to be more responsive.

See more on https://sonarcloud.io/project/issues?id=microsoft_OpenAPI.NET.OData&issues=AaE8PvDAeu8GDtkkAHkn&open=AaE8PvDAeu8GDtkkAHkn&pullRequest=915
Assert.True(JsonNode.DeepEquals(JsonNode.Parse(@"{
""maximum"": 2147483647,
""minimum"": -2147483648,
Expand All @@ -1137,7 +1136,7 @@
Assert.NotNull(schema);
Assert.Null(schema.Type);

string json = await schema.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi3_0);

Check warning on line 1139 in test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiSchemaGeneratorTests.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Calls to methods which accept CancellationToken should use TestContext.Current.CancellationToken to allow test cancellation to be more responsive.

See more on https://sonarcloud.io/project/issues?id=microsoft_OpenAPI.NET.OData&issues=AaE8PvDAeu8GDtkkAHko&open=AaE8PvDAeu8GDtkkAHko&pullRequest=915

Assert.True(JsonNode.DeepEquals(JsonNode.Parse(@"{
""oneOf"": [
Expand Down Expand Up @@ -1179,7 +1178,7 @@
Assert.NotNull(schema);
Assert.Null(schema.Type);

string json = await schema.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi3_0);

Check warning on line 1181 in test/Microsoft.OpenAPI.OData.Reader.Tests/Generator/OpenApiSchemaGeneratorTests.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Calls to methods which accept CancellationToken should use TestContext.Current.CancellationToken to allow test cancellation to be more responsive.

See more on https://sonarcloud.io/project/issues?id=microsoft_OpenAPI.NET.OData&issues=AaE8PvDAeu8GDtkkAHkp&open=AaE8PvDAeu8GDtkkAHkp&pullRequest=915

Assert.Equal("{ }", json);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
<AssemblyName>Microsoft.OpenApi.OData.Reader.Tests</AssemblyName>
<RootNamespace>Microsoft.OpenApi.OData.Reader.Tests</RootNamespace>
<TargetFrameworks>net8.0</TargetFrameworks>
<OutputType>Exe</OutputType>
<IsTestProject>true</IsTestProject>
<IsPackable>false</IsPackable>
<UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner>
<LangVersion>latest</LangVersion>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\tool\Microsoft.OpenApi.OData.snk</AssemblyOriginatorKeyFile>
Expand Down Expand Up @@ -80,21 +84,12 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.4">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.msbuild" Version="6.0.4">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.MTP" Version="10.0.1" PrivateAssets="all" />
<PackageReference Include="Microsoft.Testing.Extensions.AzureDevOpsReport" Version="2.4.0" />
<PackageReference Include="Microsoft.Testing.Extensions.GitHubActionsReport" Version="2.4.0" />
<PackageReference Include="Microsoft.Testing.Extensions.TrxReport" Version="2.4.0" />
<PackageReference Include="moq" Version="4.20.72" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit.v3" Version="4.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading
Loading