Skip to content

Update to .NET 10 preview 4 and Microsoft.OpenApi 2.0.0-preview.17 #3386

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: dotnet-vnext
Choose a base branch
from

Conversation

martincostello
Copy link
Collaborator

Update Microsoft.OpenApi to version 2.0.0-preview.17 using the latest daily build of ASP.NET Core 10 preview 4.

This PR is mainly to get a head-start on adapting to the breaking changes between 2.0.0-preview.11 and 2.0.0-preview.17 of Microsoft.OpenApi.

@martincostello martincostello added dependencies Pull requests that update a dependency file .NET Pull requests that update .NET code labels Apr 28, 2025
@codecov-commenter
Copy link

codecov-commenter commented Apr 28, 2025

❌ 12 Tests Failed:

Tests completed Failed Passed Skipped
2787 12 2775 0
View the top 3 failed test(s) by shortest run time
TestFirst.IntegrationTests.CreateProductTests CreateProduct_Returns201_IfContentIsValid
Stack Traces | 0.001s run time
at Microsoft.OpenApi.Reader.OpenApiModelFactory.InternalLoad(MemoryStream input, String format, OpenApiReaderSettings settings)
   at Microsoft.OpenApi.Reader.OpenApiModelFactory.Load(MemoryStream stream, String format, OpenApiReaderSettings settings)
   at Microsoft.OpenApi.Models.OpenApiDocument.Load(MemoryStream stream, String format, OpenApiReaderSettings settings)
   at Swashbuckle.AspNetCore.ApiTesting.ApiTestRunnerOptionsExtensions.AddOpenApiFile(ApiTestRunnerOptions options, String documentName, String filePath) in ....../_/src/Swashbuckle.AspNetCore.ApiTesting/ApiTestRunnerOptionsExtensions.cs:line 15
   at TestFirst.IntegrationTests.ApiTestRunner.<>c.<.ctor>b__0_0(ApiTestRunnerOptions c) in .../test/WebSites/TestFirst.IntegrationTests/ApiTestsSetup.cs:line 18
   at Swashbuckle.AspNetCore.ApiTesting.ApiTestRunnerBase.Configure(Action`1 setupAction) in ....../_/src/Swashbuckle.AspNetCore.ApiTesting/ApiTestRunnerBase.cs:line 21
   at TestFirst.IntegrationTests.ApiTestRunner..ctor() in .../test/WebSites/TestFirst.IntegrationTests/ApiTestsSetup.cs:line 11
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
TestFirst.IntegrationTests.GetProductsTests GetProducsts_Returns200_IfRequiredParametersProvided
Stack Traces | 0.001s run time
at Microsoft.OpenApi.Reader.OpenApiModelFactory.InternalLoad(MemoryStream input, String format, OpenApiReaderSettings settings)
   at Microsoft.OpenApi.Reader.OpenApiModelFactory.Load(MemoryStream stream, String format, OpenApiReaderSettings settings)
   at Microsoft.OpenApi.Models.OpenApiDocument.Load(MemoryStream stream, String format, OpenApiReaderSettings settings)
   at Swashbuckle.AspNetCore.ApiTesting.ApiTestRunnerOptionsExtensions.AddOpenApiFile(ApiTestRunnerOptions options, String documentName, String filePath) in ....../_/src/Swashbuckle.AspNetCore.ApiTesting/ApiTestRunnerOptionsExtensions.cs:line 15
   at TestFirst.IntegrationTests.ApiTestRunner.<>c.<.ctor>b__0_0(ApiTestRunnerOptions c) in .../test/WebSites/TestFirst.IntegrationTests/ApiTestsSetup.cs:line 18
   at Swashbuckle.AspNetCore.ApiTesting.ApiTestRunnerBase.Configure(Action`1 setupAction) in ....../_/src/Swashbuckle.AspNetCore.ApiTesting/ApiTestRunnerBase.cs:line 21
   at TestFirst.IntegrationTests.ApiTestRunner..ctor() in .../test/WebSites/TestFirst.IntegrationTests/ApiTestsSetup.cs:line 11
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
TestFirst.IntegrationTests.GetProductsTests GetProducts_Returns400_IfRequiredParametersMissing
Stack Traces | 0.001s run time
at Microsoft.OpenApi.Reader.OpenApiModelFactory.InternalLoad(MemoryStream input, String format, OpenApiReaderSettings settings)
   at Microsoft.OpenApi.Reader.OpenApiModelFactory.Load(MemoryStream stream, String format, OpenApiReaderSettings settings)
   at Microsoft.OpenApi.Models.OpenApiDocument.Load(MemoryStream stream, String format, OpenApiReaderSettings settings)
   at Swashbuckle.AspNetCore.ApiTesting.ApiTestRunnerOptionsExtensions.AddOpenApiFile(ApiTestRunnerOptions options, String documentName, String filePath) in ....../_/src/Swashbuckle.AspNetCore.ApiTesting/ApiTestRunnerOptionsExtensions.cs:line 15
   at TestFirst.IntegrationTests.ApiTestRunner.<>c.<.ctor>b__0_0(ApiTestRunnerOptions c) in .../test/WebSites/TestFirst.IntegrationTests/ApiTestsSetup.cs:line 18
   at Swashbuckle.AspNetCore.ApiTesting.ApiTestRunnerBase.Configure(Action`1 setupAction) in ....../_/src/Swashbuckle.AspNetCore.ApiTesting/ApiTestRunnerBase.cs:line 21
   at TestFirst.IntegrationTests.ApiTestRunner..ctor() in .../test/WebSites/TestFirst.IntegrationTests/ApiTestsSetup.cs:line 11
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@bkoelman
Copy link
Contributor

It's a pain that we lost all sorting. Related conversation: microsoft/OpenAPI.NET#1314 (comment).

@martincostello
Copy link
Collaborator Author

Yeah - I was going to look tomorrow at having the code sort the lists before returning the document to the caller. It's not ideal, but it's a partial solution until/unless they revert the changes to use specific concrete types.

Subclassing List<T> might also be an option - either way is more code for us to maintain...

@bkoelman
Copy link
Contributor

I wonder why they changed all signatures from IList<> to List<>, etc. If the reason is because of CA1859, subclassing is going to undo those benefits. And recursively sorting afterwards also results in a magnitude worse performance.

I quickly hacked together something here to unblock me and see what else breaks. But to do the sorting properly, it needs to be done recursively, such as here. Hope that helps.

@martincostello
Copy link
Collaborator Author

Yeah, a recursive approach was what I was going to do. I have benchmarks in a consuming repository, so I can see the effect (albeit very localised on a small API surface) after the changes to see how bad it is.

martincostello added a commit that referenced this pull request Apr 29, 2025
Cherry-pick changes from #3386 to prepare for ASP.NET Core 10 preview 4 and Microsoft.OpenApi 2.0.0-preview.17.
martincostello added a commit that referenced this pull request Apr 29, 2025
Cherry-pick changes from #3386 to prepare for ASP.NET Core 10 preview 4 and Microsoft.OpenApi 2.0.0-preview.17.
Update Microsoft.OpenApi to version 2.0.0-preview.17 using the latest daily build of ASP.NET Core 10 preview 4.
Update API baselines for change from `OperationType` to `HttpMethod `.
.NET 8 and 9 TestFirst integration tests are failing, so skip for now.
@martincostello
Copy link
Collaborator Author

Not sure why the build is failing, but (disregarding the fact it's using a daily build) this should be "done" for supporting Microsoft.OpenApi 2.0.0-preview.17.

Use the new `SerializeAs()` method to resolve TODOs.
Use the right writer.
@bkoelman
Copy link
Contributor

bkoelman commented May 1, 2025

I suspect that 04b52e9#r156107432 got lost in the conversation. The actual issue has been resolved, but the concern about copying remains.

@martincostello do you have an opinion here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file .NET Pull requests that update .NET code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants