Skip to content

Fix dictionaries as parameters and handler using #217

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

Merged
merged 12 commits into from
Mar 3, 2025
Merged
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
12 changes: 9 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# ATC coding rules - https://github.com/atc-net/atc-coding-rules
# Version: 1.0.1
# Updated: 03-06-2024
# Version: 1.0.0
# Updated: 01-03-2025
# Location: Root
# Distribution: DotNet8
# Distribution: DotNet9
# Inspired by: https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/code-style-rule-options

##########################################
Expand Down Expand Up @@ -492,6 +492,8 @@ dotnet_diagnostic.CA1867.severity = suggestion # Use char overload
dotnet_diagnostic.CA1868.severity = suggestion # Unnecessary call to 'Contains(item)'
dotnet_diagnostic.CA1869.severity = suggestion # Cache and reuse 'JsonSerializerOptions' instances
dotnet_diagnostic.CA1870.severity = suggestion # Use a cached 'SearchValues' instance
dotnet_diagnostic.CA1871.severity = suggestion # Do not pass a nullable struct to 'ArgumentNullException.ThrowIfNull'
dotnet_diagnostic.CA1872.severity = suggestion # Prefer 'Convert.ToHexString' and 'Convert.ToHexStringLower' over call chains based on 'BitConverter.ToString'
dotnet_diagnostic.CA2007.severity = suggestion # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/CA2007.md
dotnet_diagnostic.CA2017.severity = error # Parameter count mismatch
dotnet_diagnostic.CA2018.severity = error # The count argument to Buffer.BlockCopy should specify the number of bytes to copy
Expand All @@ -505,6 +507,9 @@ dotnet_diagnostic.CA2255.severity = suggestion # The ModuleInitializer attr
dotnet_diagnostic.CA2259.severity = error # Ensure ThreadStatic is only used with static fields
dotnet_diagnostic.CA2260.severity = error # Implement generic math interfaces correctly
dotnet_diagnostic.CA2261.severity = error # Do not use ConfigureAwaitOptions.SuppressThrowing with Task<TResult>
dotnet_diagnostic.CA2262.severity = suggestion # Set 'MaxResponseHeadersLength' properly
dotnet_diagnostic.CA2263.severity = suggestion # Prefer generic overload when type is known
dotnet_diagnostic.CA2264.severity = error # Do not pass a non-nullable value to 'ArgumentNullException.ThrowIfNull'
dotnet_diagnostic.IDE0005.severity = warning # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/IDE0005.md
dotnet_diagnostic.IDE0010.severity = suggestion # Populate switch
dotnet_diagnostic.IDE0028.severity = suggestion # Collection initialization can be simplified
Expand Down Expand Up @@ -556,6 +561,7 @@ dotnet_diagnostic.S3358.severity = none # Extract this nested ternary
dotnet_diagnostic.S6602.severity = none # "Find" method should be used instead of the "FirstOrDefault"
dotnet_diagnostic.S6603.severity = none # The collection-specific "TrueForAll" method should be used instead of the "All"
dotnet_diagnostic.S6605.severity = none # Collection-specific "Exists" method should be used instead of the "Any"
dotnet_diagnostic.S6964.severity = none # Value type property used as input in a controller action should be nullable, required or annotated with the JsonRequiredAttribute to avoid under-posting.


##########################################
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/post-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ on:
push:
branches:
- main
- '!stable'
- '!release'
- "!stable"
- "!release"

env:
ATC_EMAIL: '[email protected]'
ATC_NAME: 'Atc-Net'
NUGET_REPO_URL: 'https://nuget.pkg.github.com/atc-net/index.json'
ATC_EMAIL: "[email protected]"
ATC_NAME: "Atc-Net"
NUGET_REPO_URL: "https://nuget.pkg.github.com/atc-net/index.json"

jobs:
merge-to-stable:
Expand All @@ -30,16 +30,16 @@ jobs:
with:
setAllVars: true

- name: ⚙️ Setup dotnet 8.0.x
- name: ⚙️ Setup dotnet 9.0.x
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
dotnet-version: "9.0.x"

- name: ⚙️ Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'zulu'
distribution: "zulu"

- name: 🧹 Clean
run: dotnet clean -c Release && dotnet nuget locals all --clear
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/pre-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ jobs:
with:
fetch-depth: 0

- name: ⚙️ Setup dotnet 8.0.x
- name: ⚙️ Setup dotnet 9.0.x
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
dotnet-version: "9.0.x"

- name: 📐 Ensure nuget.org added as package source on Windows
if: matrix.os == 'windows-latest'
Expand All @@ -46,10 +46,10 @@ jobs:
with:
fetch-depth: 0

- name: ⚙️ Setup dotnet 8.0.x
- name: ⚙️ Setup dotnet 9.0.x
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
dotnet-version: "9.0.x"

- name: 🔁 Restore packages
run: dotnet restore
Expand All @@ -74,10 +74,10 @@ jobs:
with:
fetch-depth: 0

- name: ⚙️ Setup dotnet 8.0.x
- name: ⚙️ Setup dotnet 9.0.x
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
dotnet-version: "9.0.x"

- name: 📐 Ensure nuget.org added as package source on Windows
if: matrix.os == 'windows-latest'
Expand All @@ -99,4 +99,4 @@ jobs:

- name: 🛠️ Build Generated Code
run: dotnet build
working-directory: petstore3
working-directory: petstore3
12 changes: 6 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ on:
workflow_dispatch:

env:
ATC_EMAIL: '[email protected]'
ATC_NAME: 'Atc-Net'
NUGET_REPO_URL: 'https://api.nuget.org/v3/index.json'
ATC_EMAIL: "[email protected]"
ATC_NAME: "Atc-Net"
NUGET_REPO_URL: "https://api.nuget.org/v3/index.json"

jobs:
release:
Expand All @@ -27,10 +27,10 @@ jobs:
with:
setAllVars: true

- name: ⚙️ Setup dotnet 8.0.x
- name: ⚙️ Setup dotnet 9.0.x
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
dotnet-version: "9.0.x"

- name: 🧹 Clean
run: dotnet clean -c Release && dotnet nuget locals all --clear
Expand Down Expand Up @@ -61,4 +61,4 @@ jobs:
uses: satak/webrequest-action@master
with:
url: https://atc-api.azurewebsites.net/nuget-search/package?packageId=atc-rest-api-generator&invalidateCache=true
method: GET
method: GET
6 changes: 3 additions & 3 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<Nullable>enable</Nullable>
<LangVersion>12.0</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>1573,1591,1712</NoWarn>

Expand All @@ -43,10 +43,10 @@
<ItemGroup Label="Code Analyzers">
<PackageReference Include="AsyncFixer" Version="1.6.0" PrivateAssets="All" />
<PackageReference Include="Asyncify" Version="0.9.7" PrivateAssets="All" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.179" PrivateAssets="All" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.188" PrivateAssets="All" />
<PackageReference Include="SecurityCodeScan.VS2019" Version="5.6.7" PrivateAssets="All" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.435" PrivateAssets="All" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.32.0.97167" PrivateAssets="All" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="10.7.0.110445" PrivateAssets="All" />
</ItemGroup>

</Project>
34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,17 @@

|Project|Target Framework|Description|Nuget Download Link|
|---|---|---|---|
|[Atc.Rest.ApiGenerator](src/Atc.Rest.ApiGenerator) | net8.0 | Atc.Rest.ApiGenerator is a WebApi C# code generator using a OpenApi 3.0.x specification YAML file. | [![Nuget](https://img.shields.io/nuget/dt/Atc.Rest.ApiGenerator?logo=nuget&style=flat-square)](https://www.nuget.org/packages/Atc.Rest.ApiGenerator) |
|[Atc.Rest.ApiGenerator.CLI](src/Atc.Rest.ApiGenerator.CLI) |net8.0 | A CLI tool that use Atc.Rest.ApiGenerator to create/update a project specified by a OpenApi 3.0.x specification YAML file. | [![Nuget](https://img.shields.io/nuget/dt/atc-rest-api-generator?logo=nuget&style=flat-square)](https://www.nuget.org/packages/atc-rest-api-generator) |
|[Atc.Rest.ApiGenerator.CodingRules](src/Atc.Rest.ApiGenerator.CodingRules) | net8.0| Create/update atc coding rules for the generated code | |
|[Atc.Rest.ApiGenerator.Contracts](src/Atc.Rest.ApiGenerator.Contracts) | net8.0| Shared contracts and interfaces for the generated code. | |
|[Atc.Rest.ApiGenerator.Framework.Mvc](src/Atc.Rest.ApiGenerator.Framework.Mvc) | net8.0| Provides support for generating ASP.NET MVC / Controller based REST API server implementations. | |
|[Atc.Rest.ApiGenerator.Framework.Minimal](src/Atc.Rest.ApiGenerator.Framework.Minimal) | net8.0| Provides support for generating MinimalAPI based REST server implementations. | |
|[Atc.Rest.ApiGenerator.Client.CSharp](src/Atc.Rest.ApiGenerator.Client.CSharp) | net8.0| Generates C# client code for interacting with the generated REST APIs. | |
|[Atc.Rest.ApiGenerator.Framework](src/Atc.Rest.ApiGenerator.Framework) | net8.0| Shared framework components and utilities for the API generator projects. | |
|[Atc.Rest.ApiGenerator.OpenApi](src/Atc.Rest.ApiGenerator.OpenApi) | net8.0| Handles OpenAPI specification parsing and manipulation for the API generator. | |
|[Atc.Rest.ApiGenerator.Nuget](src/Atc.Rest.ApiGenerator.Nuget) | net8.0| Manages NuGet packages required by the generated code and frameworks. | |
|[Atc.CodeGeneration.CSharp](src/Atc.CodeGeneration.CSharp) | net8.0| Provides utilities and functionalities for generating C# code. | |
|[Atc.Rest.ApiGenerator](src/Atc.Rest.ApiGenerator) | net9.0 | Atc.Rest.ApiGenerator is a WebApi C# code generator using a OpenApi 3.0.x specification YAML file. | [![Nuget](https://img.shields.io/nuget/dt/Atc.Rest.ApiGenerator?logo=nuget&style=flat-square)](https://www.nuget.org/packages/Atc.Rest.ApiGenerator) |
|[Atc.Rest.ApiGenerator.CLI](src/Atc.Rest.ApiGenerator.CLI) |net9.0 | A CLI tool that use Atc.Rest.ApiGenerator to create/update a project specified by a OpenApi 3.0.x specification YAML file. | [![Nuget](https://img.shields.io/nuget/dt/atc-rest-api-generator?logo=nuget&style=flat-square)](https://www.nuget.org/packages/atc-rest-api-generator) |
|[Atc.Rest.ApiGenerator.CodingRules](src/Atc.Rest.ApiGenerator.CodingRules) | net9.0| Create/update atc coding rules for the generated code | |
|[Atc.Rest.ApiGenerator.Contracts](src/Atc.Rest.ApiGenerator.Contracts) | net9.0| Shared contracts and interfaces for the generated code. | |
|[Atc.Rest.ApiGenerator.Framework.Mvc](src/Atc.Rest.ApiGenerator.Framework.Mvc) | net9.0| Provides support for generating ASP.NET MVC / Controller based REST API server implementations. | |
|[Atc.Rest.ApiGenerator.Framework.Minimal](src/Atc.Rest.ApiGenerator.Framework.Minimal) | net9.0| Provides support for generating MinimalAPI based REST server implementations. | |
|[Atc.Rest.ApiGenerator.Client.CSharp](src/Atc.Rest.ApiGenerator.Client.CSharp) | net9.0| Generates C# client code for interacting with the generated REST APIs. | |
|[Atc.Rest.ApiGenerator.Framework](src/Atc.Rest.ApiGenerator.Framework) | net9.0| Shared framework components and utilities for the API generator projects. | |
|[Atc.Rest.ApiGenerator.OpenApi](src/Atc.Rest.ApiGenerator.OpenApi) | net9.0| Handles OpenAPI specification parsing and manipulation for the API generator. | |
|[Atc.Rest.ApiGenerator.Nuget](src/Atc.Rest.ApiGenerator.Nuget) | net9.0| Manages NuGet packages required by the generated code and frameworks. | |
|[Atc.CodeGeneration.CSharp](src/Atc.CodeGeneration.CSharp) | net9.0| Provides utilities and functionalities for generating C# code. | |

## Project dependency graph

Expand Down Expand Up @@ -512,23 +512,23 @@ Running the above command produces the following output:
🟢 root: atc-coding-rules-updater.json created
🟢 root: atc-coding-rules-updater.ps1 created
🐭 Working on EditorConfig files
Download from: [GitHub] /atc-net/atc-coding-rules/main/distribution/dotnet8/.editorconfig
Download from: [GitHub] /atc-net/atc-coding-rules/main/distribution/dotnet9/.editorconfig
Download time: 27.947 ms
🟢 root: .editorconfig created
Download from: [GitHub] /atc-net/atc-coding-rules/main/distribution/dotnet8/src/.editorconfig
Download from: [GitHub] /atc-net/atc-coding-rules/main/distribution/dotnet9/src/.editorconfig
Download time: 22.987 ms
🟢 src: .editorconfig created
Download from: [GitHub] /atc-net/atc-coding-rules/main/distribution/dotnet8/test/.editorconfig
Download from: [GitHub] /atc-net/atc-coding-rules/main/distribution/dotnet9/test/.editorconfig
Download time: 24.465 ms
🟢 test: .editorconfig created
🔨 Working on Directory.Build.props files
Download from: [GitHub] /atc-net/atc-coding-rules/main/distribution/dotnet8/Directory.Build.props
Download from: [GitHub] /atc-net/atc-coding-rules/main/distribution/dotnet9/Directory.Build.props
Download time: 20.880 ms
🟢 root: Directory.Build.props created
Download from: [GitHub] /atc-net/atc-coding-rules/main/distribution/dotnet8/src/Directory.Build.props
Download from: [GitHub] /atc-net/atc-coding-rules/main/distribution/dotnet9/src/Directory.Build.props
Download time: 48.340 ms
🟢 src: Directory.Build.props created
Download from: [GitHub] /atc-net/atc-coding-rules/main/distribution/dotnet8/test/Directory.Build.props
Download from: [GitHub] /atc-net/atc-coding-rules/main/distribution/dotnet9/test/Directory.Build.props
Download time: 29.480 ms
🟢 test: Directory.Build.props created
✅ Done
Expand Down
2 changes: 1 addition & 1 deletion atc-coding-rules-updater.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"projectTarget": "DotNet8",
"projectTarget": "Dotnet9",
"useLatestMinorNugetVersion": true,
"useTemporarySuppressions": false,
"temporarySuppressionAsExcel": false,
Expand Down
4 changes: 2 additions & 2 deletions src/.editorconfig
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# ATC coding rules - https://github.com/atc-net/atc-coding-rules
# Version: 1.0.0
# Updated: 25-09-2023
# Updated: 03-06-2024
# Location: src
# Distribution: DotNet8
# Distribution: DotNet9
# Inspired by: https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/code-style-rule-options

##########################################
Expand Down
12 changes: 8 additions & 4 deletions src/Atc.CodeGeneration.CSharp/Atc.CodeGeneration.CSharp.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Atc" Version="2.0.525" />
<PackageReference Include="Atc.CodeDocumentation" Version="2.0.525" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.11.0" />
<PackageReference Include="Atc" Version="2.0.552" />
<PackageReference Include="Atc.CodeDocumentation" Version="2.0.552" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.13.0" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="SonarAnalyzer.CSharp" Version="10.7.0.110445" />
</ItemGroup>

</Project>
3 changes: 3 additions & 0 deletions src/Atc.CodeGeneration.CSharp/Content/DeclarationModifiers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ public enum DeclarationModifiers
[Description("private async")]
PrivateAsync,

[Description("private static async")]
PrivateStaticAsync,

[Description("protected")]
Protected,

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<PackageId>atc-rest-api-generator</PackageId>
<PackageTags>rest;api;netstandard;generator</PackageTags>
<Description>A .NET Core Web API C# code generator using a OpenApi 3.0.x specification YAML file.</Description>
Expand All @@ -13,9 +13,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Atc" Version="2.0.525" />
<PackageReference Include="Atc.Console.Spectre" Version="2.0.525" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0" />
<PackageReference Include="Atc" Version="2.0.552" />
<PackageReference Include="Atc.Console.Spectre" Version="2.0.552" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.2" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Atc.Rest.ApiGenerator.CLI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private static string[] SetHelpArgumentIfNeeded(
{
if (args.Length == 0)
{
return new[] { CommandConstants.ArgumentShortHelp };
return [CommandConstants.ArgumentShortHelp];
}

// TODO: Add multiple validations
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.0" />
<PackageReference Include="Microsoft.OpenApi" Version="1.6.22" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.2" />
<PackageReference Include="Microsoft.OpenApi" Version="1.6.23" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ public string Generate()
case HttpStatusCode.Continue:
case HttpStatusCode.SwitchingProtocols:
case HttpStatusCode.Processing:
case HttpStatusCode.EarlyHints:
case HttpStatusCode.Created:
case HttpStatusCode.Accepted:
case HttpStatusCode.EarlyHints:
case HttpStatusCode.NonAuthoritativeInformation:
case HttpStatusCode.NoContent:
case HttpStatusCode.ResetContent:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,14 +250,12 @@ private void AppendContentWithProblemDetails(
sb.AppendLine(12, "? result");
sb.AppendLine(12, $": throw new InvalidOperationException(\"Content is not the expected type - please use the Is{responseModel.StatusCode.ToNormalizedString()} property first.\");");
break;
case HttpStatusCode.EarlyHints:
// Skip.
break;
case HttpStatusCode.Continue:
case HttpStatusCode.SwitchingProtocols:
case HttpStatusCode.Processing:
case HttpStatusCode.Created:
case HttpStatusCode.Accepted:
case HttpStatusCode.EarlyHints:
case HttpStatusCode.NonAuthoritativeInformation:
case HttpStatusCode.NoContent:
case HttpStatusCode.ResetContent:
Expand Down Expand Up @@ -341,14 +339,12 @@ private void AppendContentWithoutProblemDetails(
sb.AppendLine();
AppendMethodContentStatusCodeOk(sb, responseModel);
break;
case HttpStatusCode.EarlyHints:
// Skip.
break;
case HttpStatusCode.Continue:
case HttpStatusCode.SwitchingProtocols:
case HttpStatusCode.Processing:
case HttpStatusCode.Created:
case HttpStatusCode.Accepted:
case HttpStatusCode.EarlyHints:
case HttpStatusCode.NonAuthoritativeInformation:
case HttpStatusCode.NoContent:
case HttpStatusCode.ResetContent:
Expand Down
Loading
Loading