Skip to content

Commit

Permalink
Merge pull request #313 from atc-net/feature/upgrade-deprecated-ms-pa…
Browse files Browse the repository at this point in the history
…ckages

Feature/upgrade deprecated ms packages
  • Loading branch information
davidkallesen authored Apr 6, 2024
2 parents 9cf1811 + 7e0b3db commit 406862f
Show file tree
Hide file tree
Showing 33 changed files with 91 additions and 115 deletions.
4 changes: 2 additions & 2 deletions docs/CodeDoc/Atc.DotNet/Atc.DotNet.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@
| 16384 | UwpLibrary | Uwp Library | |
| 32768 | WpfLibrary | Wpf Library | |
| 61440 | Libraries | Libraries | |
| 65536 | Modules | Azure Iot Edge Module | |
| 65536 | AzureIotEdgeModule | Azure Iot Edge Module | |
| 65536 | AzureIotEdgeModule | Modules | |
| 65536 | Modules | Modules | |
| 131072 | VisualStudioExtension | Visual Studio Extension | |
| 262144 | WebApi | Web Api | |
| 524288 | WorkerService | Worker Service | |
Expand Down
15 changes: 0 additions & 15 deletions docs/CodeDoc/Atc.Rest.Extended/Atc.Rest.Extended.Versioning.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,4 @@
>```csharp
>string ApiVersionQueryParameterShort
>```
<br />
## VersionErrorResponseProvider
>```csharp
>public class VersionErrorResponseProvider : IErrorResponseProvider
>```
### Methods
#### CreateResponse
>```csharp
>IActionResult CreateResponse(ErrorResponseContext context)
>```
<hr /><div style='text-align: right'><i>Generated by MarkdownCodeDoc version 1.2</i></div>
1 change: 0 additions & 1 deletion docs/CodeDoc/Atc.Rest.Extended/Index.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
## [Atc.Rest.Extended.Versioning](Atc.Rest.Extended.Versioning.md)

- [ApiVersionConstants](Atc.Rest.Extended.Versioning.md#apiversionconstants)
- [VersionErrorResponseProvider](Atc.Rest.Extended.Versioning.md#versionerrorresponseprovider)

## [Microsoft.AspNetCore.Builder](Microsoft.AspNetCore.Builder.md)

Expand Down
3 changes: 0 additions & 3 deletions docs/CodeDoc/Atc.Rest.Extended/IndexExtended.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@
- string ApiVersionMediaTypeParameter
- string ApiVersionQueryParameter
- string ApiVersionQueryParameterShort
- [VersionErrorResponseProvider](Atc.Rest.Extended.Versioning.md#versionerrorresponseprovider)
- Methods
- CreateResponse(ErrorResponseContext context)

## [Microsoft.AspNetCore.Builder](Microsoft.AspNetCore.Builder.md)

Expand Down
4 changes: 2 additions & 2 deletions docs/CodeDoc/Atc.Rest/Atc.Rest.Extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
<br />
## EndpointRouteBuilderExtensions
## EndpointRouteBuilderExExtensions
>```csharp
>public static class EndpointRouteBuilderExtensions
>public static class EndpointRouteBuilderExExtensions
>```
### Static Methods
Expand Down
6 changes: 3 additions & 3 deletions docs/CodeDoc/Atc.Rest/Index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
## [Atc.Rest.Extensions](Atc.Rest.Extensions.md)

- [AllowAnonymousAccessForDevelopmentHandler](Atc.Rest.Extensions.md#allowanonymousaccessfordevelopmenthandler)
- [EndpointRouteBuilderExtensions](Atc.Rest.Extensions.md#endpointroutebuilderextensions)
- [EndpointRouteBuilderExExtensions](Atc.Rest.Extensions.md#endpointroutebuilderexextensions)

## [Atc.Rest.Helpers](Atc.Rest.Helpers.md)

Expand Down Expand Up @@ -61,8 +61,8 @@
- [AnonymousAccessExtensions](Microsoft.AspNetCore.Http.md#anonymousaccessextensions)
- [FormFileExtensions](Microsoft.AspNetCore.Http.md#formfileextensions)
- [HeaderDictionaryExtensions](Microsoft.AspNetCore.Http.md#headerdictionaryextensions)
- [HttpContextExtensions](Microsoft.AspNetCore.Http.md#httpcontextextensions)
- [HttpRequestExtensions](Microsoft.AspNetCore.Http.md#httprequestextensions)
- [HttpContextExExtensions](Microsoft.AspNetCore.Http.md#httpcontextexextensions)
- [HttpRequestExExtensions](Microsoft.AspNetCore.Http.md#httprequestexextensions)
- [WellKnownHttpHeaders](Microsoft.AspNetCore.Http.md#wellknownhttpheaders)

## [Microsoft.AspNetCore.Mvc.Filters](Microsoft.AspNetCore.Mvc.Filters.md)
Expand Down
6 changes: 3 additions & 3 deletions docs/CodeDoc/Atc.Rest/IndexExtended.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
- [AllowAnonymousAccessForDevelopmentHandler](Atc.Rest.Extensions.md#allowanonymousaccessfordevelopmenthandler)
- Methods
- HandleAsync(AuthorizationHandlerContext context)
- [EndpointRouteBuilderExtensions](Atc.Rest.Extensions.md#endpointroutebuilderextensions)
- [EndpointRouteBuilderExExtensions](Atc.Rest.Extensions.md#endpointroutebuilderexextensions)
- Static Methods
- MapApiAssemblyInformations(this IEndpointRouteBuilder endpoints, string pattern)
- MapApiManagementAssemblyInformations(this IEndpointRouteBuilder endpoints)
Expand Down Expand Up @@ -208,11 +208,11 @@
- GetCallingOnBehalfOfIdentity(this IHeaderDictionary headers)
- GetOrAddCorrelationId(this IHeaderDictionary headers)
- GetOrAddRequestId(this IHeaderDictionary headers)
- [HttpContextExtensions](Microsoft.AspNetCore.Http.md#httpcontextextensions)
- [HttpContextExExtensions](Microsoft.AspNetCore.Http.md#httpcontextexextensions)
- Static Methods
- GetCorrelationId(this HttpContext context)
- GetRequestId(this HttpContext context)
- [HttpRequestExtensions](Microsoft.AspNetCore.Http.md#httprequestextensions)
- [HttpRequestExExtensions](Microsoft.AspNetCore.Http.md#httprequestexextensions)
- Static Methods
- GetRawBodyBytesAsync(this HttpRequest request)
- GetRawBodyStringAsync(this HttpRequest request, Encoding encoding = null)
Expand Down
8 changes: 4 additions & 4 deletions docs/CodeDoc/Atc.Rest/Microsoft.AspNetCore.Http.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@
<br />
## HttpContextExtensions
## HttpContextExExtensions
>```csharp
>public static class HttpContextExtensions
>public static class HttpContextExExtensions
>```
### Static Methods
Expand All @@ -89,10 +89,10 @@
<br />
## HttpRequestExtensions
## HttpRequestExExtensions
>```csharp
>public static class HttpRequestExtensions
>public static class HttpRequestExExtensions
>```
### Static Methods
Expand Down
1 change: 0 additions & 1 deletion src/Atc.CodeAnalysis.CSharp/Atc.CodeAnalysis.CSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.9.2" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Atc.DotNet/DotnetNugetHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static List<DotnetNugetPackageMetadataBase> GetAllPackageReferences(strin

if (!fileContent.StartsWith('<'))
{
throw new UnsupportedContentTypeException("Expect xml content");
throw new DataException("Expect xml content");
}

var data = new List<DotnetNugetPackageMetadataBase>();
Expand Down
2 changes: 1 addition & 1 deletion src/Atc.DotNet/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
global using System.Collections.ObjectModel;
global using System.Data;
global using System.Diagnostics;
global using System.Diagnostics.CodeAnalysis;
global using System.Globalization;
Expand All @@ -11,6 +12,5 @@
global using Atc.DotNet.Models;
global using Atc.Helpers;

global using Microsoft.AspNetCore.Mvc.ModelBinding;
global using Microsoft.Extensions.Logging;
global using Microsoft.Extensions.Logging.Abstractions;
2 changes: 1 addition & 1 deletion src/Atc.OpenApi/Extensions/OpenApiResponsesExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public static bool IsSchemaTypePaginationForStatusCode(this OpenApiResponses res

public static bool IsSchemaTypeProblemDetailsForStatusCode(this OpenApiResponses responses, HttpStatusCode httpStatusCode)
{
return string.Equals(responses.GetSchemaForStatusCode(httpStatusCode)?.Reference?.Id, nameof(ProblemDetails), StringComparison.Ordinal);
return string.Equals(responses.GetSchemaForStatusCode(httpStatusCode)?.Reference?.Id, "ProblemDetails", StringComparison.Ordinal);
}

public static bool IsSchemaUsingBinaryFormatForOkResponse(this OpenApiResponses responses)
Expand Down
4 changes: 1 addition & 3 deletions src/Atc.OpenApi/GlobalUsings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@
global using System.Globalization;
global using System.Net;
global using System.Net.Mime;
global using System.Text.RegularExpressions;

global using Microsoft.AspNetCore.Mvc;
global using System.Text.RegularExpressions;
3 changes: 1 addition & 2 deletions src/Atc.Rest.Extended/Atc.Rest.Extended.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Asp.Versioning.Mvc.ApiExplorer" Version="8.1.0" />
<PackageReference Include="FluentValidation.AspNetCore" Version="11.3.0" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.22.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.3" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="5.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer" Version="5.1.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,17 @@ public static IServiceCollection AddRestApi<TStartup>(
if (restApiOptions.UseApiVersioning)
{
services.ConfigureOptions<ConfigureApiVersioningOptions>();
services.AddApiVersioning();
services.AddVersionedApiExplorer(o => o.GroupNameFormat = "'v'VV");
services.AddApiVersioning(options =>
{
options.DefaultApiVersion = new ApiVersion(1, 0);
options.AssumeDefaultVersionWhenUnspecified = true;
options.ReportApiVersions = true;
})
.AddApiExplorer(options =>
{
options.GroupNameFormat = "'v'VV";
options.SubstituteApiVersionInUrl = true;
});
}

if (restApiOptions.UseOpenApiSpec)
Expand Down
4 changes: 2 additions & 2 deletions src/Atc.Rest.Extended/GlobalUsings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
global using System.Net.Mime;
global using System.Reflection;
global using System.Text;
global using System.Text.Json;

global using Asp.Versioning;
global using Asp.Versioning.ApiExplorer;
global using Atc.Rest.Extended.Extensions;
global using Atc.Rest.Extended.Filters;
global using Atc.Rest.Extended.Options;
Expand All @@ -24,7 +25,6 @@
global using Microsoft.AspNetCore.Mvc.ApiExplorer;
global using Microsoft.AspNetCore.Mvc.Controllers;
global using Microsoft.AspNetCore.Mvc.ModelBinding;
global using Microsoft.AspNetCore.Mvc.Versioning;
global using Microsoft.Extensions.Configuration;
global using Microsoft.Extensions.DependencyInjection;
global using Microsoft.Extensions.Hosting;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,5 @@ public void Configure(ApiVersioningOptions options)
new QueryStringApiVersionReader(ApiVersionConstants.ApiVersionQueryParameter),
new QueryStringApiVersionReader(ApiVersionConstants.ApiVersionQueryParameterShort),
new UrlSegmentApiVersionReader());

options.ErrorResponses = new VersionErrorResponseProvider(telemetry);
}
}
33 changes: 0 additions & 33 deletions src/Atc.Rest.Extended/Versioning/VersionErrorResponseProvider.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Atc.Rest.Extensions;

public static class EndpointRouteBuilderExtensions
public static class EndpointRouteBuilderExExtensions
{
private static readonly Dictionary<string, string> YamlCache = new(StringComparer.Ordinal);

Expand All @@ -25,9 +25,9 @@ public static void MapApiSpecificationEndpoint(
endpoints.Map(yamlEndpoint, async context =>
{
string yaml;
if (YamlCache.ContainsKey(yamlEndpoint))
if (YamlCache.TryGetValue(yamlEndpoint, out var value))
{
yaml = YamlCache[yamlEndpoint];
yaml = value;
}
else
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ReSharper disable once CheckNamespace
namespace Microsoft.AspNetCore.Http;

public static class HttpContextExtensions
public static class HttpContextExExtensions
{
public static string? GetCorrelationId(this HttpContext context)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ReSharper disable CheckNamespace
namespace Microsoft.AspNetCore.Http;

public static class HttpRequestExtensions
public static class HttpRequestExExtensions
{
/// <summary>
/// Retrieve the raw body as a string from the Request.Body stream
Expand Down
4 changes: 3 additions & 1 deletion src/Atc.XUnit/Internal/AssemblyAnalyzerHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ private static Type[] CollectFilteredAssemblyTypes(Assembly assembly, List<Type>
var firstParameterType = method.GetParameters()[0].ParameterType;
var firstParameterNameSimplified = GetSimpleTypeName(firstParameterType);
if (classNamePrefixSimplified.Equals(firstParameterNameSimplified, StringComparison.Ordinal) ||
("I" + classNamePrefixSimplified).Equals(firstParameterNameSimplified, StringComparison.Ordinal))
("I" + classNamePrefixSimplified).Equals(firstParameterNameSimplified, StringComparison.Ordinal) ||
classNamePrefixSimplified.Equals(firstParameterNameSimplified + "Ex", StringComparison.Ordinal) ||
("I" + classNamePrefixSimplified).Equals(firstParameterNameSimplified + "Ex", StringComparison.Ordinal))
{
// Ok
return null;
Expand Down
2 changes: 1 addition & 1 deletion src/Atc/Atc.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.DataAnnotations" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageReference Include="System.Text.Json" Version="8.0.3" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,16 @@ public static bool TryIsValid(
return true;
}

errorMessage = attribute.ErrorMessage
.Replace("field {0}", "value", StringComparison.Ordinal)
.Replace("{0} field", "value", StringComparison.Ordinal);
if (attribute.ErrorMessage is null)
{
errorMessage = "The value is not a valid IPAddress.";
}
else
{
errorMessage = attribute.ErrorMessage
.Replace("field {0}", "value", StringComparison.Ordinal)
.Replace("{0} field", "value", StringComparison.Ordinal);
}

return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,16 @@ public static bool TryIsValid(
return true;
}

errorMessage = attribute.ErrorMessage
.Replace("field {0}", "value", StringComparison.Ordinal)
.Replace("{0} field", "value", StringComparison.Ordinal);
if (attribute.ErrorMessage is null)
{
errorMessage = "The value is not a valid KeyString.";
}
else
{
errorMessage = attribute.ErrorMessage
.Replace("field {0}", "value", StringComparison.Ordinal)
.Replace("{0} field", "value", StringComparison.Ordinal);
}

return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,16 @@ public static bool TryIsValid(
return true;
}

errorMessage = attribute.ErrorMessage
.Replace("field {0}", "value", StringComparison.Ordinal)
.Replace("{0} field", "value", StringComparison.Ordinal);
if (attribute.ErrorMessage is null)
{
errorMessage = "The value is invalid.";
}
else
{
errorMessage = attribute.ErrorMessage
.Replace("field {0}", "value", StringComparison.Ordinal)
.Replace("{0} field", "value", StringComparison.Ordinal);
}

return false;
}
Expand Down
Loading

0 comments on commit 406862f

Please sign in to comment.