Skip to content

Commit

Permalink
Merge pull request #195 from atc-net/feature/maintenance
Browse files Browse the repository at this point in the history
Feature/maintenance
  • Loading branch information
davidkallesen authored Jul 14, 2024
2 parents c00fc53 + dd1ca97 commit 414e20d
Show file tree
Hide file tree
Showing 38 changed files with 125 additions and 137 deletions.
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -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.159" PrivateAssets="All" />
<PackageReference Include="Meziantou.Analyzer" Version="2.0.160" 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.28.0.94264" PrivateAssets="All" />
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.29.0.95321" PrivateAssets="All" />
</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.490" />
<PackageReference Include="Atc.CodeDocumentation" Version="2.0.490" />
<PackageReference Include="Atc" Version="2.0.495" />
<PackageReference Include="Atc.CodeDocumentation" Version="2.0.495" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.10.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,49 @@ public static IList<AttributeParameters> Create(
result.Add(new AttributeParameters("MaxLength", maxLengthAttribute.Length.ToString()));
break;
case RangeAttribute rangeAttribute:
result.Add(new AttributeParameters("Range", $"{rangeAttribute.Minimum}, {rangeAttribute.Maximum}"));
var minimum = rangeAttribute.Minimum;
var maximum = rangeAttribute.Maximum;

if (rangeAttribute.OperandType == typeof(double))
{
if (double.MinValue.Equals((double)rangeAttribute.Minimum) ||
rangeAttribute.Minimum is double.NegativeInfinity)
{
minimum = "double.MinValue";
}

if (double.MaxValue.Equals((double)rangeAttribute.Maximum) ||
rangeAttribute.Maximum is double.PositiveInfinity)
{
maximum = "double.MaxValue";
}
}
else if (rangeAttribute.OperandType == typeof(int))
{
if (int.MinValue.Equals((int)rangeAttribute.Minimum))
{
minimum = "int.MinValue";
}

if (int.MaxValue.Equals((int)rangeAttribute.Maximum))
{
maximum = "int.MaxValue";
}
}
else if (rangeAttribute.OperandType == typeof(long))
{
if (long.MinValue.Equals((long)rangeAttribute.Minimum))
{
minimum = "long.MinValue";
}

if (long.MaxValue.Equals((long)rangeAttribute.Maximum))
{
maximum = "long.MaxValue";
}
}

result.Add(new AttributeParameters("Range", $"{minimum}, {maximum}"));
break;
case RegularExpressionAttribute regularExpressionAttribute:
result.Add(new AttributeParameters("RegularExpression", regularExpressionAttribute.GetEscapedPattern()));
Expand Down
9 changes: 3 additions & 6 deletions src/Atc.Rest.ApiGenerator.CLI/ApiOptionsHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,7 @@ private static void ApplyGeneratorOverrides(
apiOptions.Generator.ProjectName = serverCommandSettings.ProjectPrefixName;
}

if (!serverCommandSettings.RemoveNamespaceGroupSeparatorInGlobalUsings ||
apiOptions.Generator.RemoveNamespaceGroupSeparatorInGlobalUsings)
if (serverCommandSettings.RemoveNamespaceGroupSeparatorInGlobalUsings)
{
apiOptions.Generator.RemoveNamespaceGroupSeparatorInGlobalUsings = serverCommandSettings.RemoveNamespaceGroupSeparatorInGlobalUsings;
}
Expand All @@ -175,8 +174,7 @@ private static void ApplyGeneratorOverrides(
apiOptions.Generator.ProjectName = clientApiCommandSettings.ProjectPrefixName;
}

if (!clientApiCommandSettings.RemoveNamespaceGroupSeparatorInGlobalUsings ||
apiOptions.Generator.RemoveNamespaceGroupSeparatorInGlobalUsings)
if (clientApiCommandSettings.RemoveNamespaceGroupSeparatorInGlobalUsings)
{
apiOptions.Generator.RemoveNamespaceGroupSeparatorInGlobalUsings = clientApiCommandSettings.RemoveNamespaceGroupSeparatorInGlobalUsings;
}
Expand Down Expand Up @@ -205,8 +203,7 @@ private static void ApplyGeneratorOverrides(
apiOptions.Generator.Client.HttpClientName = $"{baseGenerateCommandSettings.ProjectPrefixName}-ApiClient";
}

apiOptions.Generator.Client.ExcludeEndpointGeneration =
clientApiCommandSettings.ExcludeEndpointGeneration;
apiOptions.Generator.Client.ExcludeEndpointGeneration = clientApiCommandSettings.ExcludeEndpointGeneration;

break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Atc" Version="2.0.490" />
<PackageReference Include="Atc.Console.Spectre" Version="2.0.490" />
<PackageReference Include="Atc" Version="2.0.495" />
<PackageReference Include="Atc.Console.Spectre" Version="2.0.495" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,6 @@ private async Task<int> ExecuteInternalAsync(
var shouldScaffoldCodingRules = CodingRulesHelper.ShouldScaffoldCodingRules(outputSlnPath, settings.DisableCodingRules);
var isUsingCodingRules = CodingRulesHelper.IsUsingCodingRules(outputSlnPath, settings.DisableCodingRules);

if (settings.AspNetOutputType.IsSet)
{
apiOptions.Generator.AspNetOutputType = settings.AspNetOutputType.Value;
}

if (settings.SwaggerThemeMode.IsSet)
{
apiOptions.Generator.SwaggerThemeMode = settings.SwaggerThemeMode.Value;
}

if (shouldScaffoldCodingRules &&
!NetworkInformationHelper.HasHttpConnection())
{
Expand All @@ -100,8 +90,7 @@ private async Task<int> ExecuteInternalAsync(
outputTestPath,
apiDocumentContainer,
apiOptions,
isUsingCodingRules,
settings.RemoveNamespaceGroupSeparatorInGlobalUsings))
isUsingCodingRules))
{
return ConsoleExitStatusCodes.Failure;
}
Expand All @@ -116,7 +105,6 @@ private async Task<int> ExecuteInternalAsync(
apiDocumentContainer,
apiOptions,
isUsingCodingRules,
settings.RemoveNamespaceGroupSeparatorInGlobalUsings,
outputSrcPath))
{
return ConsoleExitStatusCodes.Failure;
Expand All @@ -132,7 +120,6 @@ private async Task<int> ExecuteInternalAsync(
apiDocumentContainer,
apiOptions,
isUsingCodingRules,
settings.RemoveNamespaceGroupSeparatorInGlobalUsings,
outputSrcPath,
outputSrcPath))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,6 @@ private async Task<int> ExecuteInternalAsync(
var shouldScaffoldCodingRules = CodingRulesHelper.ShouldScaffoldCodingRules(settings.OutputPath, settings.DisableCodingRules);
var isUsingCodingRules = CodingRulesHelper.IsUsingCodingRules(settings.OutputPath, settings.DisableCodingRules);

if (settings.AspNetOutputType.IsSet)
{
apiOptions.Generator.AspNetOutputType = settings.AspNetOutputType.Value;
}

if (shouldScaffoldCodingRules &&
!NetworkInformationHelper.HasHttpConnection())
{
Expand All @@ -88,8 +83,7 @@ private async Task<int> ExecuteInternalAsync(
outputTestPath,
apiDocumentContainer,
apiOptions,
isUsingCodingRules,
settings.RemoveNamespaceGroupSeparatorInGlobalUsings))
isUsingCodingRules))
{
return ConsoleExitStatusCodes.Failure;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,6 @@ private async Task<int> ExecuteInternalAsync(
var shouldScaffoldCodingRules = CodingRulesHelper.ShouldScaffoldCodingRules(settings.OutputPath, settings.DisableCodingRules);
var isUsingCodingRules = CodingRulesHelper.IsUsingCodingRules(settings.OutputPath, settings.DisableCodingRules);

if (settings.AspNetOutputType.IsSet)
{
apiOptions.Generator.AspNetOutputType = settings.AspNetOutputType.Value;
}

if (shouldScaffoldCodingRules &&
!NetworkInformationHelper.HasHttpConnection())
{
Expand Down Expand Up @@ -89,7 +84,6 @@ private async Task<int> ExecuteInternalAsync(
apiDocumentContainer,
apiOptions,
isUsingCodingRules,
settings.RemoveNamespaceGroupSeparatorInGlobalUsings,
new DirectoryInfo(settings.ApiPath)))
{
return ConsoleExitStatusCodes.Failure;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,6 @@ private async Task<int> ExecuteInternalAsync(
var shouldScaffoldCodingRules = CodingRulesHelper.ShouldScaffoldCodingRules(settings.OutputPath, settings.DisableCodingRules);
var isUsingCodingRules = CodingRulesHelper.IsUsingCodingRules(settings.OutputPath, settings.DisableCodingRules);

if (settings.AspNetOutputType.IsSet)
{
apiOptions.Generator.AspNetOutputType = settings.AspNetOutputType.Value;
}

if (settings.SwaggerThemeMode.IsSet)
{
apiOptions.Generator.SwaggerThemeMode = settings.SwaggerThemeMode.Value;
}

if (shouldScaffoldCodingRules &&
!NetworkInformationHelper.HasHttpConnection())
{
Expand Down Expand Up @@ -94,7 +84,6 @@ private async Task<int> ExecuteInternalAsync(
apiDocumentContainer,
apiOptions,
isUsingCodingRules,
settings.RemoveNamespaceGroupSeparatorInGlobalUsings,
new DirectoryInfo(settings.ApiPath),
new DirectoryInfo(settings.DomainPath)))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Atc" Version="2.0.490" />
<PackageReference Include="Atc" Version="2.0.495" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
</ItemGroup>

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.490" />
<PackageReference Include="Atc.CodeDocumentation" Version="2.0.490" />
<PackageReference Include="Atc" Version="2.0.495" />
<PackageReference Include="Atc.CodeDocumentation" Version="2.0.495" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public static class ApiOperationResponseModelExtensions
return dataType;
}

if (responseModel.Namespace.EndsWith(responseModel.DataType, StringComparison.Ordinal))
if (responseModel.Namespace.EndsWith($".{responseModel.DataType}", StringComparison.Ordinal) ||
responseModel.Namespace.Contains($"{responseModel.DataType}.", StringComparison.Ordinal))
{
return $"{responseModel.Namespace}.{dataType}";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Atc" Version="2.0.490" />
<PackageReference Include="Atc" Version="2.0.495" />
</ItemGroup>

<ItemGroup>
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.490" />
<PackageReference Include="Atc.Rest" Version="2.0.490" />
<PackageReference Include="Atc" Version="2.0.495" />
<PackageReference Include="Atc.Rest" Version="2.0.495" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Atc" Version="2.0.490" />
<PackageReference Include="Atc.DotNet" Version="2.0.490" />
<PackageReference Include="Atc.OpenApi" Version="2.0.490" />
<PackageReference Include="Atc" Version="2.0.495" />
<PackageReference Include="Atc.DotNet" Version="2.0.495" />
<PackageReference Include="Atc.OpenApi" Version="2.0.495" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
</ItemGroup>

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

<ItemGroup>
<PackageReference Include="Atc" Version="2.0.490" />
<PackageReference Include="Atc" Version="2.0.495" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
</ItemGroup>

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.490" />
<PackageReference Include="Atc.CodeDocumentation" Version="2.0.490" />
<PackageReference Include="Atc.OpenApi" Version="2.0.490" />
<PackageReference Include="Atc" Version="2.0.495" />
<PackageReference Include="Atc.CodeDocumentation" Version="2.0.495" />
<PackageReference Include="Atc.OpenApi" Version="2.0.495" />
<PackageReference Include="Microsoft.OpenApi" Version="1.6.15" />
<PackageReference Include="Microsoft.OpenApi.Readers" Version="1.6.15" />
</ItemGroup>
Expand Down
12 changes: 6 additions & 6 deletions src/Atc.Rest.ApiGenerator/Atc.Rest.ApiGenerator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Atc" Version="2.0.490" />
<PackageReference Include="Atc.CodeAnalysis.CSharp" Version="2.0.490" />
<PackageReference Include="Atc.Console.Spectre" Version="2.0.490" />
<PackageReference Include="Atc.DotNet" Version="2.0.490" />
<PackageReference Include="Atc.OpenApi" Version="2.0.490" />
<PackageReference Include="Atc.Rest.Client" Version="1.0.74" />
<PackageReference Include="Atc" Version="2.0.495" />
<PackageReference Include="Atc.CodeAnalysis.CSharp" Version="2.0.495" />
<PackageReference Include="Atc.Console.Spectre" Version="2.0.495" />
<PackageReference Include="Atc.DotNet" Version="2.0.495" />
<PackageReference Include="Atc.OpenApi" Version="2.0.495" />
<PackageReference Include="Atc.Rest.Client" Version="1.0.79" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.10.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.OpenApi.Readers" Version="1.6.15" />
Expand Down
4 changes: 2 additions & 2 deletions src/Atc.Rest.ApiGenerator/Generators/ServerApiGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public async Task<bool> Generate()

serverApiGeneratorMvc.MaintainApiSpecification(projectOptions.DocumentFile);
serverApiGeneratorMvc.MaintainGlobalUsings(
projectOptions.RemoveNamespaceGroupSeparatorInGlobalUsings);
projectOptions.ApiOptions.Generator.RemoveNamespaceGroupSeparatorInGlobalUsings);
}
else
{
Expand All @@ -95,7 +95,7 @@ public async Task<bool> Generate()

serverApiGeneratorMinimalApi.MaintainApiSpecification(projectOptions.DocumentFile);
serverApiGeneratorMinimalApi.MaintainGlobalUsings(
projectOptions.RemoveNamespaceGroupSeparatorInGlobalUsings);
projectOptions.ApiOptions.Generator.RemoveNamespaceGroupSeparatorInGlobalUsings);
}

return true;
Expand Down
6 changes: 3 additions & 3 deletions src/Atc.Rest.ApiGenerator/Generators/ServerDomainGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public async Task<bool> Generate()
serverDomainGeneratorMvc.GenerateAssemblyMarker();

serverDomainGeneratorMvc.MaintainGlobalUsings(
projectOptions.RemoveNamespaceGroupSeparatorInGlobalUsings);
projectOptions.ApiOptions.Generator.RemoveNamespaceGroupSeparatorInGlobalUsings);
}
else
{
Expand All @@ -98,7 +98,7 @@ public async Task<bool> Generate()
serverDomainGeneratorMinimalApi.GenerateServiceCollectionExtensions();

serverDomainGeneratorMinimalApi.MaintainGlobalUsings(
projectOptions.RemoveNamespaceGroupSeparatorInGlobalUsings);
projectOptions.ApiOptions.Generator.RemoveNamespaceGroupSeparatorInGlobalUsings);
}

if (serverDomainTestGenerator is not null &&
Expand All @@ -112,7 +112,7 @@ public async Task<bool> Generate()

serverDomainTestGenerator.MaintainGlobalUsings(
projectOptions.UsingCodingRules,
projectOptions.RemoveNamespaceGroupSeparatorInGlobalUsings);
projectOptions.ApiOptions.Generator.RemoveNamespaceGroupSeparatorInGlobalUsings);
}

return true;
Expand Down
Loading

0 comments on commit 414e20d

Please sign in to comment.