Repository navigation
[aspnetcore] Add .NET 10 support for aspnetcore #25124
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
Changes from all commits
68cd05b
d91861a
acabe40
a973931
f8d9aad
3639b30
6206646
f400b48
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| name: Samples C# .Net 10 Server | ||
|
|
||
| on: | ||
| push: | ||
| paths: | ||
| - samples/server/petstore/aspnetcore-10.0/** | ||
| - samples/server/petstore/aspnetcore-10.0-*/** | ||
| pull_request: | ||
| paths: | ||
| - samples/server/petstore/aspnetcore-10.0/** | ||
| - samples/server/petstore/aspnetcore-10.0-*/** | ||
| jobs: | ||
| build: | ||
| name: Build .Net 10 servers | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| sample: | ||
| - samples/server/petstore/aspnetcore-10.0 | ||
| - samples/server/petstore/aspnetcore-10.0-NewtonsoftFalse | ||
| - samples/server/petstore/aspnetcore-10.0-nullableReferenceTypes | ||
| - samples/server/petstore/aspnetcore-10.0-pocoModels | ||
| - samples/server/petstore/aspnetcore-10.0-project4Models | ||
| - samples/server/petstore/aspnetcore-10.0-useSwashBuckle | ||
| - samples/server/petstore/aspnetcore-10.0-use-centralized-package-version-management | ||
| steps: | ||
| - uses: actions/checkout@v7 | ||
| - uses: actions/setup-dotnet@v6.0.0 | ||
| with: | ||
| dotnet-version: '10.x' | ||
| - name: Build | ||
| working-directory: ${{ matrix.sample }} | ||
| run: dotnet build Org.OpenAPITools.sln | ||
| - name: Test | ||
| working-directory: ${{ matrix.sample }} | ||
| run: dotnet test Org.OpenAPITools.sln | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| generatorName: aspnetcore | ||
| outputDir: samples/server/petstore/aspnetcore-10.0-NewtonsoftFalse | ||
| inputSpec: modules/openapi-generator/src/test/resources/3_0/aspnetcore/petstore.yaml | ||
| templateDir: modules/openapi-generator/src/main/resources/aspnetcore/3.0 | ||
| additionalProperties: | ||
| packageGuid: '{3C799344-F285-4669-8FD5-7ED9B795D5C5}' | ||
| aspnetCoreVersion: "10.0" | ||
| userSecretsGuid: 'cb87e868-8646-48ef-9bb6-344b537d0d37' | ||
| useNewtonsoft: false |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| generatorName: aspnetcore | ||
| outputDir: samples/server/petstore/aspnetcore-10.0-abstract-class | ||
| inputSpec: modules/openapi-generator/src/test/resources/3_0/aspnetcore/petstore.yaml | ||
| templateDir: modules/openapi-generator/src/main/resources/aspnetcore/3.0 | ||
| additionalProperties: | ||
| packageGuid: '{3C799344-F285-4669-8FD5-7ED9B795D5C5}' | ||
| aspnetCoreVersion: "10.0" | ||
| userSecretsGuid: 'cb87e868-8646-48ef-9bb6-344b537d0d37' | ||
| classModifier: abstract |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| generatorName: aspnetcore | ||
| outputDir: samples/server/petstore/aspnetcore-10.0-nullableReferenceTypes | ||
| inputSpec: modules/openapi-generator/src/test/resources/3_0/aspnetcore/petstore.yaml | ||
| templateDir: modules/openapi-generator/src/main/resources/aspnetcore/3.0 | ||
| additionalProperties: | ||
| packageGuid: '{3C799344-F285-4669-8FD5-7ED9B795D5C5}' | ||
| aspnetCoreVersion: "10.0" | ||
| userSecretsGuid: 'cb87e868-8646-48ef-9bb6-344b537d0d37' | ||
| nullableReferenceTypes: true |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| generatorName: aspnetcore | ||
| outputDir: samples/server/petstore/aspnetcore-10.0-pocoModels | ||
| inputSpec: modules/openapi-generator/src/test/resources/3_0/aspnetcore/petstore.yaml | ||
| templateDir: modules/openapi-generator/src/main/resources/aspnetcore/3.0 | ||
| additionalProperties: | ||
| packageGuid: '{3C799344-F285-4669-8FD5-7ED9B795D5C5}' | ||
| aspnetCoreVersion: "10.0" | ||
| userSecretsGuid: 'cb87e868-8646-48ef-9bb6-344b537d0d37' | ||
| pocoModels: true |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| generatorName: aspnetcore | ||
| outputDir: samples/server/petstore/aspnetcore-10.0-project4Models | ||
| inputSpec: modules/openapi-generator/src/test/resources/3_0/aspnetcore/petstore.yaml | ||
| templateDir: modules/openapi-generator/src/main/resources/aspnetcore/3.0 | ||
| additionalProperties: | ||
| packageGuid: '{3C799344-F285-4669-8FD5-7ED9B795D5C5}' | ||
| aspnetCoreVersion: "10.0" | ||
| userSecretsGuid: 'cb87e868-8646-48ef-9bb6-344b537d0d37' | ||
| useSeparateModelProject: true |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| generatorName: aspnetcore | ||
| outputDir: samples/server/petstore/aspnetcore-10.0-use-centralized-package-version-management | ||
| inputSpec: modules/openapi-generator/src/test/resources/3_0/aspnetcore/petstore.yaml | ||
| templateDir: modules/openapi-generator/src/main/resources/aspnetcore/3.0 | ||
| additionalProperties: | ||
| packageGuid: '{3C799344-F285-4669-8FD5-7ED9B795D5C5}' | ||
| aspnetCoreVersion: "10.0" | ||
| userSecretsGuid: 'cb87e868-8646-48ef-9bb6-344b537d0d37' | ||
| centralizedPackageVersionManagement: "enable" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| generatorName: aspnetcore | ||
| outputDir: samples/server/petstore/aspnetcore-10.0-useSwashBuckle | ||
| inputSpec: modules/openapi-generator/src/test/resources/3_0/aspnetcore/petstore.yaml | ||
| templateDir: modules/openapi-generator/src/main/resources/aspnetcore/3.0 | ||
| additionalProperties: | ||
| packageGuid: '{3C799344-F285-4669-8FD5-7ED9B795D5C5}' | ||
| aspnetCoreVersion: "10.0" | ||
| userSecretsGuid: 'cb87e868-8646-48ef-9bb6-344b537d0d37' | ||
| useSwashBuckle: false | ||
| buildTarget: library | ||
| isLibrary: true |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| generatorName: aspnetcore | ||
| outputDir: samples/server/petstore/aspnetcore-10.0 | ||
| inputSpec: modules/openapi-generator/src/test/resources/3_0/aspnetcore/petstore.yaml | ||
| templateDir: modules/openapi-generator/src/main/resources/aspnetcore/3.0 | ||
| additionalProperties: | ||
| packageGuid: '{3C799344-F285-4669-8FD5-7ED9B795D5C5}' | ||
| aspnetCoreVersion: "10.0" | ||
| userSecretsGuid: 'cb87e868-8646-48ef-9bb6-344b537d0d37' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,6 +58,7 @@ public class AspNetServerCodegen extends AbstractCSharpCodegen { | |
| public static final String MODEL_CLASS_MODIFIER = "modelClassModifier"; | ||
| public static final String TARGET_FRAMEWORK = "targetFramework"; | ||
| public static final String NET_60_OR_LATER = "net60OrLater"; | ||
| public static final String NET_10_OR_LATER = "net10OrLater"; | ||
|
|
||
| public static final String PROJECT_SDK = "projectSdk"; | ||
| public static final String SDK_WEB = "Microsoft.NET.Sdk.Web"; | ||
|
|
@@ -86,7 +87,7 @@ public class AspNetServerCodegen extends AbstractCSharpCodegen { | |
| protected int serverPort = 8080; | ||
| protected String serverHost = "0.0.0.0"; | ||
| protected CliOption swashbuckleVersion = new CliOption(SWASHBUCKLE_VERSION, "Swashbuckle version: 3.0.0 (deprecated), 4.0.0 (deprecated), 5.0.0 (deprecated), 6.4.0"); | ||
| protected CliOption aspnetCoreVersion = new CliOption(ASPNET_CORE_VERSION, "ASP.NET Core version: 6.0, 5.0, 3.1, 3.0, 2.2, 2.1, 2.0 (deprecated)"); | ||
| protected CliOption aspnetCoreVersion = new CliOption(ASPNET_CORE_VERSION, "ASP.NET Core version: 10.0, 8.0, 7.0, 6.0, 5.0, 3.1, 3.0, 2.2, 2.1, 2.0 (deprecated)"); | ||
| private CliOption classModifier = new CliOption(CLASS_MODIFIER, "Class Modifier for controller classes: Empty string or abstract."); | ||
| private CliOption operationModifier = new CliOption(OPERATION_MODIFIER, "Operation Modifier can be virtual or abstract"); | ||
| private CliOption modelClassModifier = new CliOption(MODEL_CLASS_MODIFIER, "Model Class Modifier can be nothing or partial"); | ||
|
|
@@ -199,7 +200,8 @@ public AspNetServerCodegen() { | |
| aspnetCoreVersion.addEnum("6.0", "ASP.NET Core 6.0"); | ||
| aspnetCoreVersion.addEnum("7.0", "ASP.NET Core 7.0"); | ||
| aspnetCoreVersion.addEnum("8.0", "ASP.NET Core 8.0"); | ||
| aspnetCoreVersion.setDefault("8.0"); | ||
| aspnetCoreVersion.addEnum("10.0", "ASP.NET Core 10.0"); | ||
| aspnetCoreVersion.setDefault("10.0"); | ||
|
cubic-dev-ai[bot] marked this conversation as resolved.
Resolved
|
||
| aspnetCoreVersion.setOptValue(aspnetCoreVersion.getDefault()); | ||
| cliOptions.add(aspnetCoreVersion); | ||
|
|
||
|
|
@@ -488,6 +490,9 @@ public void processOpts() { | |
|
|
||
|
|
||
| setCentralizedPackageManagementOption(); | ||
| if ("true".equals(additionalProperties.get(CENTRALIZED_PACKAGE_VERSION_MANAGEMENT))) { | ||
| supportingFiles.add(new SupportingFile("Directory.Packages.props.mustache", packageFolder, "Directory.Packages.props")); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: With Prompt for AI agents |
||
| } | ||
| } | ||
|
|
||
| private void setCentralizedPackageManagementOption() { | ||
|
|
@@ -739,6 +744,7 @@ private void setAspnetCoreVersion(String packageFolder) { | |
|
|
||
| private String determineTemplateVersion(String frameworkVersion) { | ||
| switch (frameworkVersion) { | ||
| case "10.0": | ||
| case "8.0": | ||
| case "7.0": | ||
| case "6.0": | ||
|
|
@@ -834,6 +840,13 @@ private void setIsFramework() { | |
| useFrameworkReference = true; | ||
| additionalProperties.put(USE_FRAMEWORK_REFERENCE, useFrameworkReference); | ||
| additionalProperties.put(TARGET_FRAMEWORK, "net8.0"); | ||
| } else if (aspnetCoreVersion.getOptValue().startsWith("10.")) { | ||
| LOGGER.warn( | ||
| "ASP.NET core version is {} so changing to use frameworkReference instead of packageReference ", | ||
| aspnetCoreVersion.getOptValue()); | ||
| useFrameworkReference = true; | ||
| additionalProperties.put(USE_FRAMEWORK_REFERENCE, useFrameworkReference); | ||
| additionalProperties.put(TARGET_FRAMEWORK, "net10.0"); | ||
| } else { | ||
| if (additionalProperties.containsKey(USE_FRAMEWORK_REFERENCE)) { | ||
| useFrameworkReference = convertPropertyToBooleanAndWriteBack(USE_FRAMEWORK_REFERENCE); | ||
|
|
@@ -850,9 +863,13 @@ private void setAdditionalPropertyForFramework() { | |
| String targetFramework = ((String) additionalProperties.get(TARGET_FRAMEWORK)); | ||
| if (targetFramework.startsWith("net6.0") || | ||
| targetFramework.startsWith("net7.0") || | ||
| targetFramework.startsWith("net8.0")) { | ||
| targetFramework.startsWith("net8.0") || | ||
| targetFramework.startsWith("net10.0")) { | ||
| additionalProperties.put(NET_60_OR_LATER, true); | ||
| } | ||
| if (targetFramework.startsWith("net10.0")) { | ||
| additionalProperties.put(NET_10_OR_LATER, true); | ||
| } | ||
| } | ||
|
|
||
| private void setUseNewtonsoft() { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <!-- Packages should be ordered alphabetically --> | ||
| <Project> | ||
| <ItemGroup> | ||
| <PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="9.0.1" /> | ||
| <PackageVersion Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" /> | ||
| <PackageVersion Include="Swashbuckle.AspNetCore.Newtonsoft" Version="7.2.0" /> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: The central package list omits versions for Prompt for AI agents |
||
| <PackageVersion Include="Swashbuckle.AspNetCore.SwaggerUI" Version="7.2.0" /> | ||
| <PackageVersion Include="Swashbuckle.AspNetCore.Annotations" Version="7.2.0" /> | ||
| <PackageVersion Include="JsonSubTypes" Version="2.0.1" /> | ||
| </ItemGroup> | ||
| </Project> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # OpenAPI Generator Ignore | ||
| # Generated by openapi-generator https://github.com/openapitools/openapi-generator | ||
|
|
||
| # Use this file to prevent files from being overwritten by the generator. | ||
| # The patterns follow closely to .gitignore or .dockerignore. | ||
|
|
||
| # As an example, the C# client generator defines ApiClient.cs. | ||
| # You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: | ||
| #ApiClient.cs | ||
|
|
||
| # You can match any string of characters against a directory, file or extension with a single asterisk (*): | ||
| #foo/*/qux | ||
| # The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux | ||
|
|
||
| # You can recursively match patterns against a directory, file or extension with a double asterisk (**): | ||
| #foo/**/qux | ||
| # This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux | ||
|
|
||
| # You can also negate patterns with an exclamation (!). | ||
| # For example, you can ignore all files in a docs folder with the file extension .md: | ||
| #docs/*.md | ||
| # Then explicitly reverse the ignore rule for a single file: | ||
| #!docs/README.md |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| Org.OpenAPITools.sln | ||
| README.md | ||
| build.bat | ||
| build.sh | ||
| src/Org.OpenAPITools/.gitignore | ||
| src/Org.OpenAPITools/Attributes/ValidateModelStateAttribute.cs | ||
| src/Org.OpenAPITools/Authentication/ApiAuthentication.cs | ||
| src/Org.OpenAPITools/Controllers/DefaultApi.cs | ||
| src/Org.OpenAPITools/Controllers/FakeApi.cs | ||
| src/Org.OpenAPITools/Controllers/PetApi.cs | ||
| src/Org.OpenAPITools/Controllers/StoreApi.cs | ||
| src/Org.OpenAPITools/Controllers/UserApi.cs | ||
| src/Org.OpenAPITools/Converters/CustomEnumConverter.cs | ||
| src/Org.OpenAPITools/Dockerfile | ||
| src/Org.OpenAPITools/Filters/BasePathFilter.cs | ||
| src/Org.OpenAPITools/Filters/GeneratePathParamsValidationFilter.cs | ||
| src/Org.OpenAPITools/Formatters/InputFormatterStream.cs | ||
| src/Org.OpenAPITools/Models/Animal.cs | ||
| src/Org.OpenAPITools/Models/ApiResponse.cs | ||
| src/Org.OpenAPITools/Models/Cat.cs | ||
| src/Org.OpenAPITools/Models/Category.cs | ||
| src/Org.OpenAPITools/Models/Dog.cs | ||
| src/Org.OpenAPITools/Models/Order.cs | ||
| src/Org.OpenAPITools/Models/Pet.cs | ||
| src/Org.OpenAPITools/Models/Tag.cs | ||
| src/Org.OpenAPITools/Models/TestEnum.cs | ||
| src/Org.OpenAPITools/Models/TestNullable.cs | ||
| src/Org.OpenAPITools/Models/User.cs | ||
| src/Org.OpenAPITools/OpenApi/TypeExtensions.cs | ||
| src/Org.OpenAPITools/Org.OpenAPITools.csproj | ||
| src/Org.OpenAPITools/Program.cs | ||
| src/Org.OpenAPITools/Properties/launchSettings.json | ||
| src/Org.OpenAPITools/Startup.cs | ||
| src/Org.OpenAPITools/appsettings.Development.json | ||
| src/Org.OpenAPITools/appsettings.json | ||
| src/Org.OpenAPITools/wwwroot/index.html | ||
| src/Org.OpenAPITools/wwwroot/openapi-original.json |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 7.26.0-SNAPSHOT |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| | ||
| Microsoft Visual Studio Solution File, Format Version 12.00 | ||
| # Visual Studio 15 | ||
| VisualStudioVersion = 15.0.27428.2043 | ||
| MinimumVisualStudioVersion = 10.0.40219.1 | ||
| Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Org.OpenAPITools", "src\Org.OpenAPITools\Org.OpenAPITools.csproj", "{3C799344-F285-4669-8FD5-7ED9B795D5C5}" | ||
| EndProject | ||
| Global | ||
| GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
| Debug|Any CPU = Debug|Any CPU | ||
| Release|Any CPU = Release|Any CPU | ||
| EndGlobalSection | ||
| GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
| {3C799344-F285-4669-8FD5-7ED9B795D5C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
| {3C799344-F285-4669-8FD5-7ED9B795D5C5}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
| {3C799344-F285-4669-8FD5-7ED9B795D5C5}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
| {3C799344-F285-4669-8FD5-7ED9B795D5C5}.Release|Any CPU.Build.0 = Release|Any CPU | ||
| EndGlobalSection | ||
| GlobalSection(SolutionProperties) = preSolution | ||
| HideSolutionNode = FALSE | ||
| EndGlobalSection | ||
| EndGlobal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: The matrix omits the generated
aspnetcore-10.0-abstract-classsample, so changes to it trigger this workflow without building or testing it. Add that sample to the matrix.Prompt for AI agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@McMlok the feedback looks valid. can you please take a look?