Skip to content

Commit

Permalink
Merge pull request #191 from atc-net/feature/minimal-api
Browse files Browse the repository at this point in the history
Support for MinimalApi
  • Loading branch information
perkops authored Jun 27, 2024
2 parents 3b6f041 + 66efa2a commit 941ffa6
Show file tree
Hide file tree
Showing 2,462 changed files with 75,985 additions and 34,293 deletions.
83 changes: 76 additions & 7 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.9
# Updated: 01-02-2022
# ATC coding rules - https://github.com/atc-net/atc-coding-rules
# Version: 1.0.1
# Updated: 03-06-2024
# Location: Root
# Distribution: DotNet6
# Distribution: DotNet8
# Inspired by: https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/code-style-rule-options

##########################################
Expand Down Expand Up @@ -87,6 +87,7 @@ dotnet_separate_import_directive_groups = false
# .NET Code Style Settings
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#net-code-style-settings
[*.{cs,csx,cake}]

# "this." and "Me." qualifiers
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#this-and-me
dotnet_style_qualification_for_field = false
Expand Down Expand Up @@ -146,12 +147,17 @@ dotnet_style_operator_placement_when_wrapping = end_of_line
# C# Code Style Settings
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#c-code-style-settings
[*.{cs,csx,cake}]

# Implicit and explicit types
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#implicit-and-explicit-types
csharp_style_var_for_built_in_types = true # IDE0007 and IDE0008
csharp_style_var_when_type_is_apparent = true # IDE0007 and IDE0008
csharp_style_var_elsewhere = true # IDE0007 and IDE0008

# Namespace declaration preferences
# https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0160-ide0161?view=vs-2022
csharp_style_namespace_declarations = file_scoped # IDE0160 and IDE0161

# Expression-bodied members
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#expression-bodied-members
csharp_style_expression_bodied_constructors = when_on_single_line # IDE0021
Expand Down Expand Up @@ -195,8 +201,8 @@ csharp_style_unused_value_assignment_preference = discard_variable

# Index and range preferences
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#index-and-range-preferences
csharp_style_prefer_index_operator = true # IDE0056
csharp_style_prefer_range_operator = true # IDE0057
csharp_style_prefer_index_operator = true:suggestion # IDE0056
csharp_style_prefer_range_operator = true:suggestion # IDE0057

# Miscellaneous preferences
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#miscellaneous-preferences
Expand Down Expand Up @@ -259,6 +265,7 @@ csharp_space_between_square_brackets = false
# https://docs.microsoft.com/visualstudio/ide/editorconfig-formatting-conventions#wrap-options
csharp_preserve_single_line_statements = false
csharp_preserve_single_line_blocks = true
csharp_style_namespace_declarations = file_scoped:suggestion

##########################################
# .NET Naming Conventions
Expand Down Expand Up @@ -443,19 +450,60 @@ dotnet_naming_rule.parameters_rule.severity = warning
dotnet_diagnostic.MA0003.severity = suggestion # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/Meziantou/MA0003.md
dotnet_diagnostic.MA0004.severity = suggestion # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/Meziantou/MA0004.md
dotnet_diagnostic.MA0006.severity = none # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/Meziantou/MA0006.md
dotnet_diagnostic.MA0011.severity = none # Duplicate of CA1305
dotnet_diagnostic.MA0016.severity = error # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/Meziantou/MA0016.md
dotnet_diagnostic.MA0025.severity = suggestion # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/Meziantou/MA0025.md
dotnet_diagnostic.MA0026.severity = suggestion # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/Meziantou/MA0026.md
dotnet_diagnostic.MA0028.severity = none # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/Meziantou/MA0028.md
dotnet_diagnostic.MA0038.severity = none # Duplicate of CA1822
dotnet_diagnostic.MA0048.severity = error # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/Meziantou/MA0048.md


# Microsoft - Code Analysis
# https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/
dotnet_diagnostic.CA1014.severity = none # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/CA1014.md
dotnet_diagnostic.CA1068.severity = error # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/CA1068.md
dotnet_diagnostic.CA1305.severity = error
dotnet_diagnostic.CA1510.severity = suggestion # Use ArgumentNullException throw helper
dotnet_diagnostic.CA1511.severity = suggestion # Use ArgumentException throw helper
dotnet_diagnostic.CA1512.severity = suggestion # Use ArgumentOutOfRangeException throw helper
dotnet_diagnostic.CA1513.severity = suggestion # Use ObjectDisposedException throw helper
dotnet_diagnostic.CA1514.severity = error # Avoid redundant length argument
dotnet_diagnostic.CA1707.severity = error # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/CA1707.md
dotnet_diagnostic.CA1812.severity = none
dotnet_diagnostic.CA1822.severity = suggestion
dotnet_diagnostic.CA1849.severity = error # Call async methods when in an async method
dotnet_diagnostic.CA1854.severity = suggestion # Prefer the 'IDictionary.TryGetValue(TKey, out TValue)' method
dotnet_diagnostic.CA1855.severity = suggestion # Prefer 'Clear' over 'Fill'
dotnet_diagnostic.CA1856.severity = error # Incorrect usage of ConstantExpected attribute
dotnet_diagnostic.CA1857.severity = suggestion # A constant is expected for the parameter
dotnet_diagnostic.CA1858.severity = suggestion # Use 'StartsWith' instead of 'IndexOf'
dotnet_diagnostic.CA1859.severity = suggestion # Use concrete types when possible for improved performance
dotnet_diagnostic.CA1860.severity = suggestion # Avoid using 'Enumerable.Any()' extension method
dotnet_diagnostic.CA1861.severity = suggestion # Avoid constant arrays as arguments
dotnet_diagnostic.CA1862.severity = error # Use the 'StringComparison' method overloads to perform case-insensitive string comparisons
dotnet_diagnostic.CA1863.severity = suggestion # Use 'CompositeFormat'
dotnet_diagnostic.CA1864.severity = suggestion # Prefer the 'IDictionary.TryAdd(TKey, TValue)' method
dotnet_diagnostic.CA1865.severity = suggestion # Use char overload
dotnet_diagnostic.CA1866.severity = suggestion # Use char overload
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.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
dotnet_diagnostic.CA2019.severity = error # ThreadStatic fields should not use inline initialization
dotnet_diagnostic.CA2021.severity = error # Don't call Enumerable.Cast<T> or Enumerable.OfType<T> with incompatible types
dotnet_diagnostic.CA2250.severity = suggestion # Use ThrowIfCancellationRequested
dotnet_diagnostic.CA2252.severity = suggestion # Opt-in to preview features should be used with caution
dotnet_diagnostic.CA2253.severity = error # Named placeholders should not be numeric values
dotnet_diagnostic.CA2254.severity = suggestion # Template should be a static expression
dotnet_diagnostic.CA2255.severity = suggestion # The ModuleInitializer attribute should not be used in libraries
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.IDE0005.severity = warning # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/IDE0005.md
dotnet_diagnostic.IDE0058.severity = none # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/IDE0058.md


Expand All @@ -480,6 +528,7 @@ dotnet_diagnostic.SA1202.severity = none # https://github.com/atc-net
dotnet_diagnostic.SA1204.severity = none # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/StyleCop/SA1204.md
dotnet_diagnostic.SA1413.severity = error # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/StyleCop/SA1413.md
dotnet_diagnostic.SA1600.severity = none # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/StyleCop/SA1600.md
dotnet_diagnostic.SA1601.severity = none
dotnet_diagnostic.SA1602.severity = none # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/StyleCop/SA1602.md
dotnet_diagnostic.SA1604.severity = none # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/StyleCop/SA1604.md
dotnet_diagnostic.SA1623.severity = none # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/StyleCop/SA1623.md
Expand All @@ -491,6 +540,10 @@ dotnet_diagnostic.SA1649.severity = error # https://github.com/atc-net
# SonarAnalyzer.CSharp
# https://rules.sonarsource.com/csharp
dotnet_diagnostic.S1135.severity = suggestion # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/SonarAnalyzerCSharp/S1135.md
dotnet_diagnostic.S2629.severity = none # Don't use string interpolation in logging message templates.
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"


##########################################
Expand All @@ -514,7 +567,23 @@ dotnet_diagnostic.CA1848.severity = suggestion # Use the LoggerMessage delegate
dotnet_diagnostic.CA2254.severity = suggestion # Template should be a static expression - https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca2254

dotnet_diagnostic.S1172.severity = none # False positive
dotnet_diagnostic.S2629.Severity = none
dotnet_diagnostic.S3267.severity = none # Loop should be simplified by calling Select(x => x.Value)) - We dont like this rule because of readability/maintainability
dotnet_diagnostic.S3878.Severity = none
dotnet_diagnostic.S6605.Severity = none
dotnet_diagnostic.S6608.Severity = none # Indexing at Count-1 should be used instead of the "Enumerable" extension method "Last"
dotnet_diagnostic.S6667.Severity = none

dotnet_diagnostic.SA1010.severity = none # Opening square brackets should not be preceded by a space
dotnet_diagnostic.SA1118.Severity = none # Parameter spans multiple lines
dotnet_diagnostic.SA1414.Severity = none # Tuple types in signatures should have element names
dotnet_diagnostic.SA1414.Severity = none # Tuple types in signatures should have element names

dotnet_diagnostic.CS1591.Severity = none
dotnet_diagnostic.CA1822.Severity = none
dotnet_diagnostic.CA1859.Severity = none
dotnet_diagnostic.CA1860.Severity = none
dotnet_diagnostic.CA1861.Severity = none
dotnet_diagnostic.S125.Severity = none
dotnet_diagnostic.S1481.Severity = none
dotnet_diagnostic.SA1512.Severity = none
dotnet_diagnostic.SA1513.Severity = none
14 changes: 7 additions & 7 deletions .github/workflows/post-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 🛒 Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.PAT_WORKFLOWS }}
Expand All @@ -30,10 +30,10 @@ jobs:
with:
setAllVars: true

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

- name: ⚙️ Set up JDK 17
uses: actions/setup-java@v3
Expand All @@ -51,7 +51,7 @@ jobs:
run: dotnet build -c Release --no-restore /p:UseSourceLink=true

- name: 🧪 Run unit tests
run: dotnet test -c Release --no-build
run: dotnet test -c Release --no-build --filter "Category!=Integration"

- name: 🌩️ SonarCloud install scanner
run: dotnet tool install --global dotnet-sonarscanner
Expand All @@ -62,9 +62,9 @@ jobs:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
shell: pwsh
run: |
dotnet sonarscanner begin /k:"atc-rest-api-generator" /o:"atc-net" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
dotnet sonarscanner begin /k:"atc-rest-api-generator" /o:"atc-net" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
dotnet build -c Release /p:UseSourceLink=true --no-restore
dotnet sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
dotnet sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
- name: ⏩ Merge to stable-branch
run: |
Expand Down
28 changes: 14 additions & 14 deletions .github/workflows/pre-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: 🛒 Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

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

- name: 📐 Ensure nuget.org added as package source on Windows
if: matrix.os == 'windows-latest'
Expand All @@ -42,14 +42,14 @@ jobs:
- dotnet-build
steps:
- name: 🛒 Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

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

- name: 🔁 Restore packages
run: dotnet restore
Expand All @@ -58,7 +58,7 @@ jobs:
run: dotnet build -c Release --no-restore /p:UseSourceLink=true

- name: 🧪 Run unit tests
run: dotnet test -c Release --no-build
run: dotnet test -c Release --no-build --filter "Category!=Integration"

smoke-tests:
strategy:
Expand All @@ -70,14 +70,14 @@ jobs:
- dotnet-test
steps:
- name: 🛒 Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

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

- name: 📐 Ensure nuget.org added as package source on Windows
if: matrix.os == 'windows-latest'
Expand All @@ -94,7 +94,7 @@ jobs:
run: curl -O https://petstore3.swagger.io/api/v3/openapi.yaml

- name: ⚙️ Generate Code
run: dotnet run -- generate server all -p "Swagger Petstore" -s ../../openapi.yaml --outputSlnPath ../../petstore3/ --outputSrcPath ../../petstore3/src --outputTestPath ../../petstore3/test --optionsPath ../../sample/Demo.ApiDesign/ApiGeneratorOptions.json --disableCodingRules -v
run: dotnet run -- generate server all -p "Swagger Petstore" -s ../../openapi.yaml --outputSlnPath ../../petstore3/ --outputSrcPath ../../petstore3/src --outputTestPath ../../petstore3/test --optionsPath ../../ApiGeneratorOptions.json --disableCodingRules --verbose
working-directory: src/Atc.Rest.ApiGenerator.CLI

- name: 🛠️ Build Generated Code
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 🛒 Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.PAT_WORKFLOWS }}
Expand All @@ -27,10 +27,10 @@ jobs:
with:
setAllVars: true

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

- name: 🧹 Clean
run: dotnet clean -c Release && dotnet nuget locals all --clear
Expand Down
20 changes: 20 additions & 0 deletions ApiGeneratorOptions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"generator": {
"aspNetOutputType": "Mvc",
"swaggerThemeMode": "None",
"useRestExtended": true,
"includeDeprecated": false,
"request": {},
"response": {
"useProblemDetailsAsDefaultBody": false
}
},
"validation": {
"strictMode": false,
"operationIdValidation": false,
"operationIdCasingStyle": "CamelCase",
"modelNameCasingStyle": "PascalCase",
"modelPropertyNameCasingStyle": "CamelCase"
},
"includeDeprecated": false
}
Loading

0 comments on commit 941ffa6

Please sign in to comment.