Skip to content

Commit

Permalink
Merge pull request #210 from atc-net/hotfix/parameter-name-casings
Browse files Browse the repository at this point in the history
Fix parameter name casings for FromRoute in Mvc mode
  • Loading branch information
davidkallesen authored Nov 18, 2024
2 parents 858b460 + 778d1fa commit e36b618
Show file tree
Hide file tree
Showing 72 changed files with 162 additions and 153 deletions.
24 changes: 23 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -464,11 +464,13 @@ dotnet_diagnostic.MA0048.severity = error # https://github.com/atc-net
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.CA1308.severity = suggestion # Normalize strings to uppercase
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.CA1515.severity = suggestion # Because an application's API isn't typically referenced from outside the assembly, types can be made internal (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1515)
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
Expand Down Expand Up @@ -504,7 +506,16 @@ dotnet_diagnostic.CA2259.severity = error # Ensure ThreadStatic is onl
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.IDE0010.severity = suggestion # Populate switch
dotnet_diagnostic.IDE0028.severity = suggestion # Collection initialization can be simplified
dotnet_diagnostic.IDE0021.severity = suggestion # Use expression body for constructor
dotnet_diagnostic.IDE0055.severity = none # Fix formatting
dotnet_diagnostic.IDE0058.severity = none # https://github.com/atc-net/atc-coding-rules/blob/main/documentation/CodeAnalyzersRules/MicrosoftCodeAnalysis/IDE0058.md
dotnet_diagnostic.IDE0061.severity = suggestion # Use expression body for local function
dotnet_diagnostic.IDE0130.severity = suggestion # Namespace does not match folder structure
dotnet_diagnostic.IDE0290.severity = none # Use primary constructor
dotnet_diagnostic.IDE0301.severity = suggestion # Use collection expression for empty
dotnet_diagnostic.IDE0305.severity = suggestion # Collection initialization can be simplified


# Microsoft - Compiler Errors
Expand Down Expand Up @@ -541,6 +552,7 @@ dotnet_diagnostic.SA1649.severity = error # https://github.com/atc-net
# 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.S3358.severity = none # Extract this nested ternary operation into an independent statement.
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 Down Expand Up @@ -584,9 +596,19 @@ 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

dotnet_diagnostic.AsyncFixer02.Severity = none # ToListAsync should be used instead of xxx
dotnet_diagnostic.AsyncFixer02.Severity = none # ToListAsync should be used instead of xxx

dotnet_diagnostic.IDE0022.Severity = none # Use expression body for method
dotnet_diagnostic.IDE0045.Severity = none # 'if' statement can be simplified
dotnet_diagnostic.IDE0046.Severity = none # 'if' statement can be simplified
dotnet_diagnostic.IDE0052.Severity = none # Private member
dotnet_diagnostic.IDE0059.Severity = none # Unnecessary assignment of a value
dotnet_diagnostic.IDE0060.Severity = none # Remove unused parameter
dotnet_diagnostic.IDE0270.Severity = none # Null check can be simplified
dotnet_diagnostic.IDE0300.Severity = none # Collection initialization can be simplified
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<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.163" PrivateAssets="All" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.179" 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" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
</PropertyGroup>

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

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Atc" Version="2.0.513" />
<PackageReference Include="Atc.Console.Spectre" Version="2.0.513" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<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" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public override string Description
{
get
{
var values = Enum.GetNames(typeof(AspNetOutputType))
var values = Enum.GetNames<AspNetOutputType>()
.Select(enumValue => enumValue.Equals(Default.ToString(), StringComparison.Ordinal)
? $"{enumValue} (default)"
: enumValue)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public override string Description
{
get
{
var values = Enum.GetNames(typeof(SwaggerThemeMode))
var values = Enum.GetNames<SwaggerThemeMode>()
.Select(enumValue => enumValue.Equals(Default.ToString(), StringComparison.Ordinal)
? $"{enumValue} (default)"
: enumValue)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
</PropertyGroup>

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

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public async Task ScaffoldProjectFile()
],
[
new("DocumentationFile", Attributes: null, @$"bin\Debug\net8.0\{projectName}.xml"),
new("NoWarn", Attributes: null, "1573;1591;1701;1702;1712;8618;"),
new("NoWarn", Attributes: null, "$(NoWarn);1573;1591;1701;1702;1712;8618;"),
],
],
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Atc" Version="2.0.513" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
<PackageReference Include="Atc" Version="2.0.525" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Atc" Version="2.0.513" />
<PackageReference Include="Atc.CodeDocumentation" Version="2.0.513" />
<PackageReference Include="Atc" Version="2.0.525" />
<PackageReference Include="Atc.CodeDocumentation" Version="2.0.525" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Atc" Version="2.0.513" />
<PackageReference Include="Atc" Version="2.0.525" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ public static ContentGeneratorServerResultParameters Create(
var okResponseModel = responseModels.Find(x => x.StatusCode == HttpStatusCode.OK) ??
responseModels.Find(x => x.StatusCode == HttpStatusCode.Created);

if (ShouldAppendImplicitOperatorContent(httpStatusCodes, okResponseModel?.DataType, openApiOperation.Responses.IsSchemaUsingBinaryFormatForOkResponse()))
if (ShouldAppendImplicitOperatorContent(
httpStatusCodes,
okResponseModel?.DataType,
openApiOperation.Responses.IsSchemaUsingBinaryFormatForOkResponse()))
{
var collectionDataType = okResponseModel?.CollectionDataType;
var dataType = okResponseModel?.DataType;
Expand Down Expand Up @@ -76,8 +79,8 @@ private static bool ShouldAppendImplicitOperatorContent(
httpStatusCode = HttpStatusCode.Created;
}

if (string.IsNullOrEmpty(modelName) &&
httpStatusCode == HttpStatusCode.Created)
if (httpStatusCode == HttpStatusCode.Created &&
string.IsNullOrEmpty(modelName))
{
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public async Task ScaffoldProjectFile()
],
[
new("DocumentationFile", Attributes: null, @$"bin\Debug\net8.0\{projectName}.xml"),
new("NoWarn", Attributes: null, "1573;1591;1701;1702;1712;8618;"),
new("NoWarn", Attributes: null, "$(NoWarn);1573;1591;1701;1702;1712;8618;"),
],
],
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public async Task ScaffoldProjectFile()
],
[
new("DocumentationFile", Attributes: null, @$"bin\Debug\net8.0\{projectName}.xml"),
new("NoWarn", Attributes: null, "1573;1591;1701;1702;1712;8618;"),
new("NoWarn", Attributes: null, "$(NoWarn);1573;1591;1701;1702;1712;8618;"),
],
],
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public async Task ScaffoldProjectFile()
],
[
new("DocumentationFile", Attributes: null, @$"bin\Debug\net8.0\{projectName}.xml"),
new("NoWarn", Attributes: null, "1573;1591;1701;1702;1712;8618;"),
new("NoWarn", Attributes: null, "$(NoWarn);1573;1591;1701;1702;1712;8618;"),
],
],
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public async Task ScaffoldProjectFile()
],
[
new("DocumentationFile", Attributes: null, @$"bin\Debug\net8.0\{projectName}.xml"),
new("NoWarn", Attributes: null, "1573;1591;1701;1702;1712;8618;"),
new("NoWarn", Attributes: null, "$(NoWarn);1573;1591;1701;1702;1712;8618;"),
],
],
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Atc" Version="2.0.513" />
<PackageReference Include="Atc.Rest" Version="2.0.513" />
<PackageReference Include="Atc" Version="2.0.525" />
<PackageReference Include="Atc.Rest" Version="2.0.525" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,21 @@ private static void AppendPropertyAttributes(
{
switch (item.ParameterLocationType)
{
case ParameterLocationType.Query:
case ParameterLocationType.Header:
case ParameterLocationType.Route:
case ParameterLocationType.Header:
case ParameterLocationType.Cookie:
if (string.IsNullOrEmpty(item.Name))
{
sb.AppendLine(4, $"[From{item.ParameterLocationType}]");
}
else
{
sb.AppendLine(4, $"[From{item.ParameterLocationType}(Name = \"{item.Name}\")]");
}

break;

case ParameterLocationType.Query:
if (string.IsNullOrEmpty(item.Name) ||
item.Name.Equals(item.ParameterName, StringComparison.OrdinalIgnoreCase))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public async Task ScaffoldProjectFile()
],
[
new("DocumentationFile", Attributes: null, @$"bin\Debug\net8.0\{projectName}.xml"),
new("NoWarn", Attributes: null, "1573;1591;1701;1702;1712;8618;"),
new("NoWarn", Attributes: null, "$(NoWarn);1573;1591;1701;1702;1712;8618;"),
],
],
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public async Task ScaffoldProjectFile()
],
[
new("DocumentationFile", Attributes: null, @$"bin\Debug\net8.0\{projectName}.xml"),
new("NoWarn", Attributes: null, "1573;1591;1701;1702;1712;8618;"),
new("NoWarn", Attributes: null, "$(NoWarn);1573;1591;1701;1702;1712;8618;"),
],
],
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public async Task ScaffoldProjectFile()
],
[
new("DocumentationFile", Attributes: null, @$"bin\Debug\net8.0\{projectName}.xml"),
new("NoWarn", Attributes: null, "1573;1591;1701;1702;1712;8618;"),
new("NoWarn", Attributes: null, "$(NoWarn);1573;1591;1701;1702;1712;8618;"),
],
],
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public async Task ScaffoldProjectFile()
],
[
new("DocumentationFile", Attributes: null, @$"bin\Debug\net8.0\{projectName}.xml"),
new("NoWarn", Attributes: null, "1573;1591;1701;1702;1712;8618;"),
new("NoWarn", Attributes: null, "$(NoWarn);1573;1591;1701;1702;1712;8618;"),
],
],
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Atc" Version="2.0.513" />
<PackageReference Include="Atc.DotNet" Version="2.0.513" />
<PackageReference Include="Atc.OpenApi" Version="2.0.513" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
<PackageReference Include="Atc" Version="2.0.525" />
<PackageReference Include="Atc.DotNet" Version="2.0.525" />
<PackageReference Include="Atc.OpenApi" Version="2.0.525" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ public class NugetPackageReferenceProvider(
private Dictionary<string, string> PackageDefaultVersions { get; } = new(StringComparer.Ordinal)
{
{ "Asp.Versioning.Http", "8.1.0" },
{ "Atc", "2.0.472" },
{ "Atc", "2.0.525" },
{ "Atc.Azure.Options", "3.0.31" },
{ "Atc.Rest", "2.0.472" },
{ "Atc.Rest", "2.0.525" },
{ "Atc.Rest.Client", "1.0.36" },
{ "Atc.Rest.Extended", "2.0.472" },
{ "Atc.Rest.FluentAssertions", "2.0.472" },
{ "Atc.Rest.MinimalApi", "1.0.81" },
{ "Atc.XUnit", "2.0.472" },
{ "Atc.Rest.Extended", "2.0.525" },
{ "Atc.Rest.FluentAssertions", "2.0.525" },
{ "Atc.Rest.MinimalApi", "1.0.87" },
{ "Atc.XUnit", "2.0.525" },
{ "AutoFixture", "4.18.1" },
{ "AutoFixture.AutoNSubstitute", "4.18.1" },
{ "AutoFixture.Xunit2", "4.18.1" },
Expand All @@ -28,7 +28,7 @@ public class NugetPackageReferenceProvider(
{ "Microsoft.NETCore.Platforms", "7.0.4" },
{ "Microsoft.NET.Test.Sdk", "17.10.0" },
{ "NSubstitute", "5.1.0" },
{ "Swashbuckle.AspNetCore", "6.7.0" },
{ "Swashbuckle.AspNetCore", "7.0.0" },
{ "xunit", "2.8.1" },
{ "xunit.runner.visualstudio", "2.8.1" },
};
Expand Down Expand Up @@ -84,6 +84,7 @@ public async Task<Version> GetAtcApiGeneratorVersion()
{
new("Asp.Versioning.Http", PackageDefaultVersions["Asp.Versioning.Http"]),
new("Atc", atcVersion),
new("Atc.Rest.Extended", atcVersion),
new("Atc.Rest.MinimalApi", PackageDefaultVersions["Atc.Rest.MinimalApi"]),
new("Microsoft.NETCore.Platforms", PackageDefaultVersions["Microsoft.NETCore.Platforms"]),
new("Swashbuckle.AspNetCore", PackageDefaultVersions["Swashbuckle.AspNetCore"]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Atc" Version="2.0.513" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
<PackageReference Include="Atc" Version="2.0.525" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Atc" Version="2.0.513" />
<PackageReference Include="Atc.CodeDocumentation" Version="2.0.513" />
<PackageReference Include="Atc.OpenApi" Version="2.0.513" />
<PackageReference Include="Microsoft.OpenApi" Version="1.6.17" />
<PackageReference Include="Microsoft.OpenApi.Readers" Version="1.6.17" />
<PackageReference Include="Atc" Version="2.0.525" />
<PackageReference Include="Atc.CodeDocumentation" Version="2.0.525" />
<PackageReference Include="Atc.OpenApi" Version="2.0.525" />
<PackageReference Include="Microsoft.OpenApi" Version="1.6.22" />
<PackageReference Include="Microsoft.OpenApi.Readers" Version="1.6.22" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit e36b618

Please sign in to comment.