diff --git a/.github/workflows/pipelines.yml b/.github/workflows/pipelines.yml index 65e65e34e..5199acc44 100644 --- a/.github/workflows/pipelines.yml +++ b/.github/workflows/pipelines.yml @@ -121,6 +121,7 @@ jobs: "src/**/Cuemon.Extensions.Reflection.csproj" "src/**/Cuemon.Extensions.Runtime.Caching.csproj" "src/**/Cuemon.Extensions.Text.csproj" + "src/**/Cuemon.Extensions.Text.Json.csproj" "src/**/Cuemon.Extensions.Threading.csproj" "src/**/Cuemon.Extensions.Xml.csproj" "src/**/Cuemon.IO.csproj" @@ -197,13 +198,6 @@ jobs: with: includePreview: true - - name: Download cuemon.snk file - uses: codebeltnet/gcp-download-file@v1 - with: - serviceAccountKey: ${{ secrets.GCP_TOKEN }} - bucketName: ${{ secrets.GCP_BUCKETNAME }} - objectName: cuemon.snk - - name: Install .NET Tool - Report Generator uses: codebeltnet/dotnet-tool-install-reportgenerator@v1 @@ -223,7 +217,8 @@ jobs: projects: ${{ matrix.project }} configuration: ${{ matrix.configuration }} restoreCacheKey: ${{ runner.os == 'Linux' && needs.prepare_linux.outputs.restoreCacheKey || needs.prepare_windows.outputs.restoreCacheKey }} - level: normal + buildSwitches: -p:SkipSignAssembly=true + testArguments: -- RunConfiguration.DisableAppDomain=true env: CONNECTIONSTRINGS__ADVENTUREWORKS: ${{ secrets.DB_ADVENTUREWORKS }} @@ -247,13 +242,6 @@ jobs: with: includePreview: true - - name: Download cuemon.snk file - uses: codebeltnet/gcp-download-file@v1 - with: - serviceAccountKey: ${{ secrets.GCP_TOKEN }} - bucketName: ${{ secrets.GCP_BUCKETNAME }} - objectName: cuemon.snk - - name: Install .NET Tool - Sonar Scanner uses: codebeltnet/dotnet-tool-install-sonarscanner@v1 @@ -275,6 +263,7 @@ jobs: uses: codebeltnet/dotnet-build@v2 with: uploadBuildArtifact: false + buildSwitches: -p:SkipSignAssembly=true - name: Finalize SonarCloud Analysis uses: codebeltnet/sonarcloud-scan-finalize@v1 @@ -310,13 +299,6 @@ jobs: with: includePreview: true - - name: Download cuemon.snk file - uses: codebeltnet/gcp-download-file@v1 - with: - serviceAccountKey: ${{ secrets.GCP_TOKEN }} - bucketName: ${{ secrets.GCP_BUCKETNAME }} - objectName: cuemon.snk - - name: Restore Dependencies uses: codebeltnet/dotnet-restore@v2 with: @@ -330,6 +312,7 @@ jobs: uses: codebeltnet/dotnet-build@v2 with: uploadBuildArtifact: false + buildSwitches: -p:SkipSignAssembly=true - name: Finalize CodeQL SAST Analysis uses: codebeltnet/codeql-scan-finalize@v1 diff --git a/.nuget/Cuemon.Extensions.AspNetCore.Text.Json/PackageReleaseNotes.txt b/.nuget/Cuemon.Extensions.AspNetCore.Text.Json/PackageReleaseNotes.txt index b369647aa..c202c0557 100644 --- a/.nuget/Cuemon.Extensions.AspNetCore.Text.Json/PackageReleaseNotes.txt +++ b/.nuget/Cuemon.Extensions.AspNetCore.Text.Json/PackageReleaseNotes.txt @@ -6,7 +6,7 @@ Availability: .NET 9 and .NET 8 - REMOVED Support for TFM .NET 6 (LTS)   # Improvements -- EXTENDED JsonConverterCollectionExtensions class in the Cuemon.Extensions.AspNetCore.Text.Json.Converters namespace to include one new extension method: AddProblemDetailsConverter +- EXTENDED JsonConverterCollectionExtensions class in the Cuemon.Extensions.AspNetCore.Text.Json.Converters namespace to include two new extension methods: AddProblemDetailsConverter and AddHeaderDictionaryConverter   Version 8.3.2 Availability: .NET 8 and .NET 6 diff --git a/.nuget/Cuemon.Extensions.Text.Json/PackageReleaseNotes.txt b/.nuget/Cuemon.Extensions.Text.Json/PackageReleaseNotes.txt index 1124d3d9b..c506fbdf8 100644 --- a/.nuget/Cuemon.Extensions.Text.Json/PackageReleaseNotes.txt +++ b/.nuget/Cuemon.Extensions.Text.Json/PackageReleaseNotes.txt @@ -1,15 +1,20 @@ Version 9.0.0 -Availability: .NET 9 and .NET 8 +Availability: .NET 9, .NET 8 and .NET Standard 2.0   # ALM - CHANGED Dependencies to latest and greatest with respect to TFMs - REMOVED Support for TFM .NET 6 (LTS) +- ADDED Support for TFM .NET Standard 2.0   # New Features - ADDED FailureConverter class in the Cuemon.Extensions.Text.Json.Converters namespace to convert FailureConverter to JSON   # Improvements -- EXTENDED JsonConverterCollectionExtensions class in the Cuemon.Extensions.Text.Json.Converters namespace to include one new extension method: AddFailureConverter +- EXTENDED JsonConverterCollectionExtensions class in the Cuemon.Extensions.Text.Json.Converters namespace to include three new extension methods: AddFailureConverter, RemoveAllOf and RemoveAllOf{T} +- EXTENDED JsonSerializerOptionsExtensions class in the Cuemon.Extensions.Text.Json namespace to include one new extension method: Clone +  +# Bug Fixes +- FIXED ExceptionConverter class in the Cuemon.Extensions.Text.Json.Converters namespace to use JsonSerializerOptions when converting JSON to Exception   Version 8.3.2 Availability: .NET 8 and .NET 6 diff --git a/CHANGELOG.md b/CHANGELOG.md index dcd5c7bb0..7a447d1d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,9 @@ For more details, please refer to `PackageReleaseNotes.txt` on a per assembly ba ## [9.0.0] - TBD (sometime in November 2024) This major release is first and foremost focused on ironing out any wrinkles that have been introduced with .NET 9 preview releases so the final release is production ready together with the official launch from Microsoft. + Next focus point will be ensuring a consistent developer experience while ironing out some of the more stale legacy code in the project. + Expect breaking changes with this major release. New features: @@ -37,6 +39,11 @@ Removed features: - TestOutputHelperAccessor class in the Cuemon.Extensions.Xunit namespace that provides a default implementation of the ITestOutputHelper interface - ServiceProviderExtensions class in the Cuemon.Extensions.Xunit.Hosting namespace that consist of one extension method for the IServiceProvider interface: GetRequiredScopedService - ServiceCollectionExtensions class in the Cuemon.Extensions.Xunit.Hosting namespace was extended with three new extension methods for the IServiceCollection interface: AddXunitTestOutputHelperAccessor, AddXunitTestOutputHelperAccessor{T} and an overload of AddXunitTestOutputHelperAccessor +- JsonConverterCollectionExtensions class in the Cuemon.Extensions.AspNetCore.Text.Json.Converters namespace to include two new extension methods: AddProblemDetailsConverter and AddHeaderDictionaryConverter +- XmlConverterExtensions class in the Cuemon.Extensions.AspNetCore.Xml.Converters namespace was extended to include one new extension method: AddProblemDetailsConverter +- XmlConverterExtensions class in the Cuemon.Extensions.Xml.Serialization.Converters namespace was extended to include one new extension method: AddFailureConverter +- JsonConverterCollectionExtensions class in the Cuemon.Extensions.Text.Json.Converters namespace was extended to include three new extension methods: AddFailureConverter, RemoveAllOf and RemoveAllOf{T} +- JsonSerializerOptionsExtensions class in the Cuemon.Extensions.Text.Json namespace was extended to include one new extension method: Clone ### Changed @@ -81,11 +88,7 @@ Removed features: - FaultDescriptorFilter class in the Cuemon.AspNetCore.Mvc.Filters.Diagnostics namespace to support preferred fault descriptor (e.g., FaultDetails or ProblemDetails) - FaultDescriptorOptions class in the Cuemon.AspNetCore.Diagnostics namespace to include a property named FaultDescriptor (PreferredFaultDescriptor); default is PreferredFaultDescriptor.FaultDetails - HttpExceptionDescriptor class in the Cuemon.AspNetCore.Diagnostics namespace to include two new properties; Instance (Uri) and TraceId (string) -- JsonConverterCollectionExtensions class in the Cuemon.Extensions.AspNetCore.Text.Json.Converters namespace was extended to include one new extension method: AddProblemDetailsConverter -- XmlConverterExtensions class in the Cuemon.Extensions.AspNetCore.Xml.Converters namespace was extended to include one new extension method: AddProblemDetailsConverter - ApplicationBuilderExtensions class in the Cuemon.Extensions.AspNetCore.Diagnostics namespace to support preferred fault descriptor (e.g., FaultDetails or ProblemDetails) in the UseFaultDescriptorExceptionHandler extension method -- JsonConverterCollectionExtensions class in the Cuemon.Extensions.Text.Json.Converters namespace was extended to include one new extension method: AddFailureConverter -- XmlConverterExtensions class in the Cuemon.Extensions.Xml.Serialization.Converters namespace was extended to include one new extension method: AddFailureConverter - XmlConverter{T} class in the Cuemon.Xml.Serialization.Converters namespace to use generic type T with two new abstract methods: WriteXml and ReadXml - CultureInfoExtensions class in the Cuemon.Extensions.Globalization namespace to use Codebelt.Extensions.YamlDotNet assembly instead of previously built-in YAML support from Codebelt.Extensions.YamlDotNet assembly diff --git a/Directory.Build.props b/Directory.Build.props index 1b5e3e2ce..c4e067fb7 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -76,8 +76,8 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -93,6 +93,7 @@ - + + diff --git a/Directory.Build.targets b/Directory.Build.targets index b719a7fd7..511f34d28 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -14,8 +14,8 @@ - 00000 - $(MinVerMajor).$(MinVerMinor).$(MinVerPatch).$(BUILD_BUILDNUMBER) + 0 + $(MinVerMajor).$(MinVerMinor).$(MinVerPatch).$(GITHUB_RUN_NUMBER) diff --git a/src/Cuemon.AspNetCore.Authentication/Basic/BasicAuthenticationHandler.cs b/src/Cuemon.AspNetCore.Authentication/Basic/BasicAuthenticationHandler.cs index c4f357909..263ebd63c 100644 --- a/src/Cuemon.AspNetCore.Authentication/Basic/BasicAuthenticationHandler.cs +++ b/src/Cuemon.AspNetCore.Authentication/Basic/BasicAuthenticationHandler.cs @@ -17,18 +17,6 @@ namespace Cuemon.AspNetCore.Authentication.Basic /// public class BasicAuthenticationHandler : AuthenticationHandler { -#if NET6_0 - /// - /// Initializes a new instance of the class. - /// - /// The monitor for the options instance. - /// The . - /// The . - /// The . - public BasicAuthenticationHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock) - { - } -#else /// /// Initializes a new instance of the class. /// @@ -38,7 +26,6 @@ public BasicAuthenticationHandler(IOptionsMonitor op public BasicAuthenticationHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder) : base(options, logger, encoder) { } -#endif /// /// Handle authenticate as an asynchronous operation. diff --git a/src/Cuemon.AspNetCore.Authentication/Digest/DigestAuthenticationHandler.cs b/src/Cuemon.AspNetCore.Authentication/Digest/DigestAuthenticationHandler.cs index 596771a58..7fb424da4 100644 --- a/src/Cuemon.AspNetCore.Authentication/Digest/DigestAuthenticationHandler.cs +++ b/src/Cuemon.AspNetCore.Authentication/Digest/DigestAuthenticationHandler.cs @@ -20,20 +20,6 @@ public class DigestAuthenticationHandler : AuthenticationHandler - /// Initializes a new instance of the class. - /// - /// The monitor for the options instance. - /// The . - /// The . - /// The . - /// The dependency injected implementation of an . - public DigestAuthenticationHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock, INonceTracker nonceTracker = null) : base(options, logger, encoder, clock) - { - _nonceTracker = nonceTracker; - } -#else /// /// Initializes a new instance of the class. /// @@ -45,7 +31,6 @@ public DigestAuthenticationHandler(IOptionsMonitor { _nonceTracker = nonceTracker; } -#endif /// /// Handle authenticate as an asynchronous operation. diff --git a/src/Cuemon.AspNetCore.Authentication/Hmac/HmacAuthenticationHandler.cs b/src/Cuemon.AspNetCore.Authentication/Hmac/HmacAuthenticationHandler.cs index 0d5a1f762..05592869a 100644 --- a/src/Cuemon.AspNetCore.Authentication/Hmac/HmacAuthenticationHandler.cs +++ b/src/Cuemon.AspNetCore.Authentication/Hmac/HmacAuthenticationHandler.cs @@ -16,18 +16,6 @@ namespace Cuemon.AspNetCore.Authentication.Hmac /// public class HmacAuthenticationHandler : AuthenticationHandler { -#if NET6_0 - /// - /// Initializes a new instance of the class. - /// - /// The monitor for the options instance. - /// The . - /// The . - /// The . - public HmacAuthenticationHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock) - { - } -#else /// /// Initializes a new instance of the class. /// @@ -37,7 +25,6 @@ public HmacAuthenticationHandler(IOptionsMonitor opti public HmacAuthenticationHandler(IOptionsMonitor options, ILoggerFactory logger, UrlEncoder encoder) : base(options, logger, encoder) { } -#endif /// /// Handle authenticate as an asynchronous operation. diff --git a/src/Cuemon.Core.App/Cuemon.Core.App.csproj b/src/Cuemon.Core.App/Cuemon.Core.App.csproj index 01ab011bf..5cb8e1a9e 100644 --- a/src/Cuemon.Core.App/Cuemon.Core.App.csproj +++ b/src/Cuemon.Core.App/Cuemon.Core.App.csproj @@ -1,7 +1,6 @@  - net9.0;net8.0 230bdf91-e7c7-4cb4-a39d-e1a5374c5602 @@ -41,7 +40,6 @@ - diff --git a/src/Cuemon.Core/StringFactory.cs b/src/Cuemon.Core/StringFactory.cs index 4f9444f65..73725b840 100644 --- a/src/Cuemon.Core/StringFactory.cs +++ b/src/Cuemon.Core/StringFactory.cs @@ -24,7 +24,7 @@ public static class StringFactory public static string CreateHexadecimal(byte[] value) { Validator.ThrowIfNull(value); -#if NET6_0_OR_GREATER +#if NET8_0_OR_GREATER return Convert.ToHexString(value).Replace("-", "").ToLowerInvariant(); #else return BitConverter.ToString(value).Replace("-", "").ToLowerInvariant(); diff --git a/src/Cuemon.Extensions.AspNetCore.Text.Json/Bootstrapper.cs b/src/Cuemon.Extensions.AspNetCore.Text.Json/Bootstrapper.cs index 50f33939b..66d43d904 100644 --- a/src/Cuemon.Extensions.AspNetCore.Text.Json/Bootstrapper.cs +++ b/src/Cuemon.Extensions.AspNetCore.Text.Json/Bootstrapper.cs @@ -21,6 +21,7 @@ internal static void Initialize() { list.AddStringValuesConverter(); list.AddProblemDetailsConverter(); + list.AddHeaderDictionaryConverter(); }; } } diff --git a/src/Cuemon.Extensions.AspNetCore.Text.Json/Converters/JsonConverterCollectionExtensions.cs b/src/Cuemon.Extensions.AspNetCore.Text.Json/Converters/JsonConverterCollectionExtensions.cs index d15eb0015..bb6246273 100644 --- a/src/Cuemon.Extensions.AspNetCore.Text.Json/Converters/JsonConverterCollectionExtensions.cs +++ b/src/Cuemon.Extensions.AspNetCore.Text.Json/Converters/JsonConverterCollectionExtensions.cs @@ -7,6 +7,7 @@ using Cuemon.Diagnostics; using Cuemon.Extensions.Text.Json; using Cuemon.Extensions.Text.Json.Converters; +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Primitives; @@ -18,10 +19,48 @@ namespace Cuemon.Extensions.AspNetCore.Text.Json.Converters public static class JsonConverterCollectionExtensions { /// - /// Adds a JSON converter to the list. + /// Adds an JSON converter to the collection. /// - /// The to extend. - /// A reference to after the operation has completed. + /// The collection of to extend. + /// A reference to so that additional calls can be chained. + public static ICollection AddHeaderDictionaryConverter(this ICollection converters) + { + converters.Add(DynamicJsonConverter.Create((writer, value, options) => + { + writer.WriteStartObject(); + foreach (var kvp in value) + { + writer.WritePropertyName(options.SetPropertyName(kvp.Key)); + writer.WriteStringValue(kvp.Value); + } + writer.WriteEndObject(); + }, (ref Utf8JsonReader reader, Type _, JsonSerializerOptions _) => + { + var dictionary = new HeaderDictionary(); + while (reader.Read()) + { + if (reader.TokenType == JsonTokenType.EndObject) + { + break; + } + if (reader.TokenType == JsonTokenType.PropertyName) + { + var key = reader.GetString()!; + reader.Read(); + var value = reader.GetString(); + dictionary.Add(key, value); + } + } + return dictionary; + })); + return converters; + } + + /// + /// Adds a JSON converter to the collection. + /// + /// The collection of to extend. + /// A reference to so that additional calls can be chained. public static ICollection AddProblemDetailsConverter(this ICollection converters) { converters.Add(DynamicJsonConverter.Create(WriteProblemDetails)); @@ -48,11 +87,11 @@ private static void WriteProblemDetails(Utf8JsonWriter writer, ProblemDetails pd } /// - /// Adds an JSON converter to the list. + /// Adds an JSON converter to the collection. /// - /// The to extend. + /// The collection of to extend. /// The which may be configured. - /// A reference to after the operation has completed. + /// A reference to so that additional calls can be chained. public static ICollection AddHttpExceptionDescriptorConverter(this ICollection converters, Action setup = null) { converters.AddExceptionDescriptorConverterOf(setup, (writer, descriptor, options) => @@ -78,10 +117,10 @@ public static ICollection AddHttpExceptionDescriptorConverter(thi } /// - /// Adds an JSON converter to the list. + /// Adds an JSON converter to the collection. /// - /// The to extend. - /// A reference to after the operation has completed. + /// The collection of to extend. + /// A reference to so that additional calls can be chained. public static ICollection AddStringValuesConverter(this ICollection converters) { converters.Add(DynamicJsonConverter.Create((writer, values, _) => diff --git a/src/Cuemon.Extensions.DependencyInjection/Cuemon.Extensions.DependencyInjection.csproj b/src/Cuemon.Extensions.DependencyInjection/Cuemon.Extensions.DependencyInjection.csproj index d8ad566e2..d9a293599 100644 --- a/src/Cuemon.Extensions.DependencyInjection/Cuemon.Extensions.DependencyInjection.csproj +++ b/src/Cuemon.Extensions.DependencyInjection/Cuemon.Extensions.DependencyInjection.csproj @@ -19,11 +19,6 @@ - - - - - diff --git a/src/Cuemon.Extensions.Globalization/Cuemon.Extensions.Globalization.csproj b/src/Cuemon.Extensions.Globalization/Cuemon.Extensions.Globalization.csproj index b41f716b2..8f4c3bf71 100644 --- a/src/Cuemon.Extensions.Globalization/Cuemon.Extensions.Globalization.csproj +++ b/src/Cuemon.Extensions.Globalization/Cuemon.Extensions.Globalization.csproj @@ -1200,11 +1200,7 @@ - - - - - + diff --git a/src/Cuemon.Extensions.Hosting/Cuemon.Extensions.Hosting.csproj b/src/Cuemon.Extensions.Hosting/Cuemon.Extensions.Hosting.csproj index 6a2cbd0ef..884330859 100644 --- a/src/Cuemon.Extensions.Hosting/Cuemon.Extensions.Hosting.csproj +++ b/src/Cuemon.Extensions.Hosting/Cuemon.Extensions.Hosting.csproj @@ -17,10 +17,6 @@ - - - - diff --git a/src/Cuemon.Extensions.Hosting/HostBuilderExtensions.cs b/src/Cuemon.Extensions.Hosting/HostBuilderExtensions.cs index 47055c9d8..4f0fa3282 100644 --- a/src/Cuemon.Extensions.Hosting/HostBuilderExtensions.cs +++ b/src/Cuemon.Extensions.Hosting/HostBuilderExtensions.cs @@ -1,4 +1,4 @@ -#if NET6_0_OR_GREATER +#if NET8_0_OR_GREATER using System; using System.Collections.Generic; using Cuemon.Extensions.Collections.Generic; diff --git a/src/Cuemon.Extensions.Hosting/HostEnvironmentExtensions.cs b/src/Cuemon.Extensions.Hosting/HostEnvironmentExtensions.cs index 51bf82724..f3e2b4fb1 100644 --- a/src/Cuemon.Extensions.Hosting/HostEnvironmentExtensions.cs +++ b/src/Cuemon.Extensions.Hosting/HostEnvironmentExtensions.cs @@ -1,4 +1,4 @@ -#if NET6_0_OR_GREATER +#if NET8_0_OR_GREATER using Microsoft.Extensions.Hosting; namespace Cuemon.Extensions.Hosting diff --git a/src/Cuemon.Extensions.IO/StreamExtensions.cs b/src/Cuemon.Extensions.IO/StreamExtensions.cs index c5d5a25c3..f219e65de 100644 --- a/src/Cuemon.Extensions.IO/StreamExtensions.cs +++ b/src/Cuemon.Extensions.IO/StreamExtensions.cs @@ -197,7 +197,7 @@ public static Task ToEncodedStringAsync(this Stream value, Action /// Compresses the using the BROTLI algorithm. @@ -312,7 +312,7 @@ public static Task CompressGZipAsync(this Stream value, Action /// Decompresses the using the BROTLI data format specification. diff --git a/src/Cuemon.Extensions.Net/Cuemon.Extensions.Net.csproj b/src/Cuemon.Extensions.Net/Cuemon.Extensions.Net.csproj index 460d7e81d..20b7be272 100644 --- a/src/Cuemon.Extensions.Net/Cuemon.Extensions.Net.csproj +++ b/src/Cuemon.Extensions.Net/Cuemon.Extensions.Net.csproj @@ -17,10 +17,6 @@ - - - - diff --git a/src/Cuemon.Extensions.Net/Http/SlimHttpClientFactory.cs b/src/Cuemon.Extensions.Net/Http/SlimHttpClientFactory.cs index 66f6b44cb..35156ebec 100644 --- a/src/Cuemon.Extensions.Net/Http/SlimHttpClientFactory.cs +++ b/src/Cuemon.Extensions.Net/Http/SlimHttpClientFactory.cs @@ -7,7 +7,7 @@ namespace Cuemon.Extensions.Net.Http { -#if NET6_0_OR_GREATER +#if NET8_0_OR_GREATER /// /// Provides a simple and lightweight implementation of the interface. /// @@ -22,7 +22,7 @@ namespace Cuemon.Extensions.Net.Http /// Inspiration taken from https://github.com/dotnet/runtime/blob/master/src/libraries/Microsoft.Extensions.Http/src/DefaultHttpClientFactory.cs #endif public class SlimHttpClientFactory : IHttpClientFactory -#if NET6_0_OR_GREATER +#if NET8_0_OR_GREATER , IHttpMessageHandlerFactory #endif { diff --git a/src/Cuemon.Extensions.Text.Json/Converters/ExceptionConverter.cs b/src/Cuemon.Extensions.Text.Json/Converters/ExceptionConverter.cs index b69799c3b..04292ecd0 100644 --- a/src/Cuemon.Extensions.Text.Json/Converters/ExceptionConverter.cs +++ b/src/Cuemon.Extensions.Text.Json/Converters/ExceptionConverter.cs @@ -58,11 +58,11 @@ public override bool CanConvert(Type typeToConvert) /// The value that was converted. public override Exception Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - var stack = ParseJsonReader(ref reader, typeToConvert); + var stack = ParseJsonReader(ref reader, typeToConvert, options); return Decorator.Enclose(stack).CreateException(); } - private static Stack> ParseJsonReader(ref Utf8JsonReader reader, Type typeToConvert) + private static Stack> ParseJsonReader(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { var stack = new Stack>(); var properties = new List(); @@ -93,7 +93,7 @@ private static Stack> ParseJsonReader(ref Utf8JsonReader r } else { - var propertyValue = JsonSerializer.Deserialize(ref reader, property.PropertyType); + var propertyValue = JsonSerializer.Deserialize(ref reader, property.PropertyType, options); if (propertyValue is JsonElement element) { propertyValue = element.GetRawText(); diff --git a/src/Cuemon.Extensions.Text.Json/Converters/JsonConverterCollectionExtensions.cs b/src/Cuemon.Extensions.Text.Json/Converters/JsonConverterCollectionExtensions.cs index 8cc919545..4a9206b8a 100644 --- a/src/Cuemon.Extensions.Text.Json/Converters/JsonConverterCollectionExtensions.cs +++ b/src/Cuemon.Extensions.Text.Json/Converters/JsonConverterCollectionExtensions.cs @@ -15,6 +15,41 @@ namespace Cuemon.Extensions.Text.Json.Converters /// public static class JsonConverterCollectionExtensions { + /// + /// Removes one or more implementations where evaluates true in the collection of . + /// + /// The type of object or value handled by the . + /// The collection of to extend. + /// A reference to so that additional calls can be chained. + /// + /// cannot be null. + /// + public static ICollection RemoveAllOf(this ICollection converters) + { + return RemoveAllOf(converters, typeof(T)); + } + + /// + /// Removes one or more implementations where evaluates true in the collection of . + /// + /// The collection of to extend. + /// The type of objects or values handled by a sequence of . + /// A reference to so that additional calls can be chained. + /// + /// cannot be null. + /// + public static ICollection RemoveAllOf(this ICollection converters, params Type[] types) + { + Validator.ThrowIfNull(converters); + Validator.ThrowIfNull(types); + var rejects = types.SelectMany(type => converters.Where(jc => jc.CanConvert(type))).ToList(); + foreach (var reject in rejects) + { + converters.Remove(reject); + } + return converters; + } + /// /// Adds a JSON converter to the list. /// diff --git a/src/Cuemon.Extensions.Text.Json/Converters/StringEnumConverter.cs b/src/Cuemon.Extensions.Text.Json/Converters/StringEnumConverter.cs index 831d546da..8b3041847 100644 --- a/src/Cuemon.Extensions.Text.Json/Converters/StringEnumConverter.cs +++ b/src/Cuemon.Extensions.Text.Json/Converters/StringEnumConverter.cs @@ -20,7 +20,7 @@ public StringEnumConverter() /// /// Determines whether the type can be converted. /// - /// The type is checked as to whether it can be converted. + /// The type is checked whether it can be converted. /// true if the type can be converted, false otherwise. public override bool CanConvert(Type typeToConvert) { @@ -43,11 +43,19 @@ public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializer var enumConverterFactory = typeof(JsonConverterFactory).Assembly.GetType("System.Text.Json.Serialization.Converters.EnumConverterFactory"); if (enumConverterOptions != null && enumConverterFactory != null) { +#if NET8_0_OR_GREATER var createMethod = enumConverterFactory.GetMethod("Create", MemberReflection.Everything, new[] { typeof(Type), enumConverterOptions, typeof(JsonNamingPolicy), typeof(JsonSerializerOptions) }); if (createMethod != null) { return (JsonConverter)createMethod.Invoke(null, new object[] { typeToConvert, 1, options.PropertyNamingPolicy, options }); } +#else + var createMethod = enumConverterFactory.GetMethod("Create", MemberReflection.Everything, null, new[] { typeof(Type), enumConverterOptions, typeof(JsonNamingPolicy), typeof(JsonSerializerOptions) }, null); + if (createMethod != null) + { + return (JsonConverter)createMethod.Invoke(null, new object[] { typeToConvert, 1, options.PropertyNamingPolicy, options }); + } +#endif } throw new NotSupportedException("Unable to locate internal members required by this method."); } diff --git a/src/Cuemon.Extensions.Text.Json/Cuemon.Extensions.Text.Json.csproj b/src/Cuemon.Extensions.Text.Json/Cuemon.Extensions.Text.Json.csproj index e766c06ab..c67b19fba 100644 --- a/src/Cuemon.Extensions.Text.Json/Cuemon.Extensions.Text.Json.csproj +++ b/src/Cuemon.Extensions.Text.Json/Cuemon.Extensions.Text.Json.csproj @@ -1,7 +1,6 @@  - net9.0;net8.0 a80adf91-e7c7-4cb4-a39d-e1a5374c5602 @@ -20,12 +19,8 @@ - + - - - - diff --git a/src/Cuemon.Extensions.Text.Json/Formatters/JsonFormatter.cs b/src/Cuemon.Extensions.Text.Json/Formatters/JsonFormatter.cs index 27aa3de61..75bc0f3de 100644 --- a/src/Cuemon.Extensions.Text.Json/Formatters/JsonFormatter.cs +++ b/src/Cuemon.Extensions.Text.Json/Formatters/JsonFormatter.cs @@ -2,6 +2,7 @@ using System.IO; using System.Text.Json; using System.Text.Json.Serialization; +using System.Xml; using Cuemon.IO; using Cuemon.Runtime.Serialization.Formatters; @@ -49,8 +50,10 @@ public override Stream Serialize(object source, Type objectType) Validator.ThrowIfNull(source); Validator.ThrowIfNull(objectType); +#if NET8_0_OR_GREATER return StreamFactory.Create(writer => { + using (var jsonWriter = new Utf8JsonWriter(writer, new JsonWriterOptions() { Indented = Options.Settings.WriteIndented, @@ -60,6 +63,21 @@ public override Stream Serialize(object source, Type objectType) JsonSerializer.Serialize(jsonWriter, source, objectType, Options.Settings); } }); +#else + return Patterns.SafeInvoke(() => new MemoryStream(), ms => + { + using (var jsonWriter = new Utf8JsonWriter(ms, new JsonWriterOptions() + { + Indented = Options.Settings.WriteIndented, + Encoder = Options.Settings.Encoder + })) + { + JsonSerializer.Serialize(jsonWriter, source, objectType, Options.Settings); + } + ms.Position = 0; + return ms; + }); +#endif } /// diff --git a/src/Cuemon.Extensions.Text.Json/JsonSerializerOptionsExtensions.cs b/src/Cuemon.Extensions.Text.Json/JsonSerializerOptionsExtensions.cs index 5a67f405b..d06069375 100644 --- a/src/Cuemon.Extensions.Text.Json/JsonSerializerOptionsExtensions.cs +++ b/src/Cuemon.Extensions.Text.Json/JsonSerializerOptionsExtensions.cs @@ -1,4 +1,5 @@ -using System.Text.Json; +using System; +using System.Text.Json; namespace Cuemon.Extensions.Text.Json { @@ -7,6 +8,23 @@ namespace Cuemon.Extensions.Text.Json /// public static class JsonSerializerOptionsExtensions { + /// + /// Copies the options from a instance to a new instance. + /// + /// The to extend. + /// The which may be configured. + /// A new cloned instance of with optional altering as specified by the delegate. + /// + /// cannot be null. + /// + public static JsonSerializerOptions Clone(this JsonSerializerOptions options, Action setup = null) + { + Validator.ThrowIfNull(options); + options = new JsonSerializerOptions(options); + setup?.Invoke(options); + return options; + } + /// /// Returns the specified adhering to the underlying . /// diff --git a/src/Cuemon.Extensions.Threading/Cuemon.Extensions.Threading.csproj b/src/Cuemon.Extensions.Threading/Cuemon.Extensions.Threading.csproj index 8af85ddb8..07dc074cf 100644 --- a/src/Cuemon.Extensions.Threading/Cuemon.Extensions.Threading.csproj +++ b/src/Cuemon.Extensions.Threading/Cuemon.Extensions.Threading.csproj @@ -14,7 +14,7 @@ - + diff --git a/src/Cuemon.IO/BufferWriterOptions.cs b/src/Cuemon.IO/BufferWriterOptions.cs index fa2a8144c..3f21fa7d5 100644 --- a/src/Cuemon.IO/BufferWriterOptions.cs +++ b/src/Cuemon.IO/BufferWriterOptions.cs @@ -1,4 +1,4 @@ -#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER +#if NETSTANDARD2_1_OR_GREATER || NET8_0_OR_GREATER using System.Buffers; using Cuemon.Text; diff --git a/src/Cuemon.IO/Extensions/StreamDecoratorExtensions.cs b/src/Cuemon.IO/Extensions/StreamDecoratorExtensions.cs index d588a6337..cfe2aa658 100644 --- a/src/Cuemon.IO/Extensions/StreamDecoratorExtensions.cs +++ b/src/Cuemon.IO/Extensions/StreamDecoratorExtensions.cs @@ -203,7 +203,7 @@ private static async Task ToEncodedStringAsyncCore(this IDecorator /// Compress the enclosed of the specified using the Brotli algorithm. @@ -460,7 +460,7 @@ private static Task CompressAsync(IDecorator decorator, Async { return Patterns.SafeInvokeAsync(() => new MemoryStream(), async (target, ct) => { -#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER +#if NETSTANDARD2_1_OR_GREATER || NET8_0_OR_GREATER await using (var compressed = decompressor(target, options.Level, true)) { await Decorator.Enclose(decorator.Inner).CopyStreamAsync(compressed, options.BufferSize, ct: ct).ConfigureAwait(false); @@ -496,7 +496,7 @@ private static Task DecompressAsync(IDecorator decorator, Asy { return Patterns.SafeInvokeAsync(() => new MemoryStream(), async (target, ct) => { -#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER +#if NETSTANDARD2_1_OR_GREATER || NET8_0_OR_GREATER await using (var uncompressed = compressor(decorator.Inner, CompressionMode.Decompress, true)) { await Decorator.Enclose(uncompressed).CopyStreamAsync(target, options.BufferSize, ct: ct).ConfigureAwait(false); diff --git a/src/Cuemon.IO/StreamFactory.cs b/src/Cuemon.IO/StreamFactory.cs index ad51bdbb7..1554eb91b 100644 --- a/src/Cuemon.IO/StreamFactory.cs +++ b/src/Cuemon.IO/StreamFactory.cs @@ -1,5 +1,5 @@ using System; -#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER +#if NETSTANDARD2_1_OR_GREATER || NET8_0_OR_GREATER using System.Buffers; #endif using System.Collections.Generic; @@ -115,7 +115,7 @@ public static Stream Create(Action /// Creates and returns a by the specified delegate . diff --git a/test/Cuemon.AspNetCore.Authentication.Tests/Cuemon.AspNetCore.Authentication.Tests.csproj b/test/Cuemon.AspNetCore.Authentication.Tests/Cuemon.AspNetCore.Authentication.Tests.csproj index c8d06b81d..92862df87 100644 --- a/test/Cuemon.AspNetCore.Authentication.Tests/Cuemon.AspNetCore.Authentication.Tests.csproj +++ b/test/Cuemon.AspNetCore.Authentication.Tests/Cuemon.AspNetCore.Authentication.Tests.csproj @@ -14,7 +14,7 @@ - + diff --git a/test/Cuemon.AspNetCore.FunctionalTests/Cuemon.AspNetCore.FunctionalTests.csproj b/test/Cuemon.AspNetCore.FunctionalTests/Cuemon.AspNetCore.FunctionalTests.csproj index 48edbd10e..b808adde8 100644 --- a/test/Cuemon.AspNetCore.FunctionalTests/Cuemon.AspNetCore.FunctionalTests.csproj +++ b/test/Cuemon.AspNetCore.FunctionalTests/Cuemon.AspNetCore.FunctionalTests.csproj @@ -6,9 +6,8 @@ - - + diff --git a/test/Cuemon.AspNetCore.FunctionalTests/Diagnostics/ApplicationBuilderExtensionsTest.cs b/test/Cuemon.AspNetCore.FunctionalTests/Diagnostics/ApplicationBuilderExtensionsTest.cs index 0015f2760..8e214c7d0 100644 --- a/test/Cuemon.AspNetCore.FunctionalTests/Diagnostics/ApplicationBuilderExtensionsTest.cs +++ b/test/Cuemon.AspNetCore.FunctionalTests/Diagnostics/ApplicationBuilderExtensionsTest.cs @@ -4,7 +4,6 @@ using Cuemon.AspNetCore.Http; using Cuemon.Diagnostics; using Cuemon.Extensions.AspNetCore.Diagnostics; -using Codebelt.Extensions.AspNetCore.Newtonsoft.Json.Formatters; using Cuemon.Extensions.AspNetCore.Text.Json.Formatters; using Cuemon.Extensions.AspNetCore.Xml.Formatters; using Cuemon.Extensions.DependencyInjection; @@ -563,193 +562,6 @@ public async Task UseFaultDescriptorExceptionHandler_ShouldCaptureException_Rend } } - [Fact] - public async Task UseFaultDescriptorExceptionHandler_ShouldCaptureException_RenderAsExceptionDescriptor_UsingNewtonsoftJson_WithSensitivityAll() - { - using var response = await WebHostTestFactory.RunAsync( - services => - { - services.AddFaultDescriptorOptions(o => o.FaultDescriptor = PreferredFaultDescriptor.FaultDetails); - services.AddNewtonsoftJsonExceptionResponseFormatter(); - services.PostConfigureAllOf(o => o.SensitivityDetails = FaultSensitivityDetails.All); - }, - app => - { - app.UseFaultDescriptorExceptionHandler(); - app.Use(async (context, next) => - { - try - { - throw new ArgumentException("This is an inner exception message ...", nameof(app)) - { - Data = - { - { "1st", "data value" } - }, - HelpLink = "https://www.savvyio.net/" - }; - } - catch (Exception e) - { - throw new NotFoundException("Main exception - look out for inner!", e); - } - - await next(context); - }); - }, - responseFactory: client => - { - client.DefaultRequestHeaders.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/json")); - return client.GetAsync("/"); - }); - - var body = await response.Content.ReadAsStringAsync(); - - TestOutput.WriteLine(body); - - Assert.True(Match(""" - { - "error": { - "instance": "http://localhost/", - "status": 404, - "code": "NotFound", - "message": "Main exception - look out for inner!", - "failure": { - "type": "Cuemon.AspNetCore.Http.NotFoundException", - "source": "Cuemon.AspNetCore.FunctionalTests", - "message": "Main exception - look out for inner!", - "stack": [ - "at Cuemon.AspNetCore.Diagnostics.ApplicationBuilderExtensionsTest.<>c.<*", - "--- End of stack trace from previous location ---", - "at Microsoft.AspNetCore.Diagnostics.ExceptionHandler*" - ], - "headers": {}, - "statusCode": 404, - "reasonPhrase": "Not Found", - "inner": { - "type": "System.ArgumentException", - "source": "Cuemon.AspNetCore.FunctionalTests", - "message": "This is an inner exception message ... (Parameter 'app')", - "stack": [ - "at Cuemon.AspNetCore.Diagnostics.ApplicationBuilderExtensionsTest.<>c.<*" - ], - "data": { - "1st": "data value" - }, - "paramName": "app" - } - } - }, - "evidence": { - "request": { - "location": "http://localhost/", - "method": "GET", - "headers": { - "accept": "application/json", - "host": "localhost" - }, - "query": [], - "cookies": [], - "body": "" - } - }, - "traceId": "*" - } - """.ReplaceLineEndings(), body.ReplaceLineEndings(), o => o.ThrowOnNoMatch = true)); - } - - [Fact] - public async Task UseFaultDescriptorExceptionHandler_ShouldCaptureException_RenderAsProblemDetails_UsingNewtonsoftJson_WithSensitivityAll() - { - using var response = await WebHostTestFactory.RunAsync( - services => - { - services.AddFaultDescriptorOptions(o => o.FaultDescriptor = PreferredFaultDescriptor.ProblemDetails); - services.AddNewtonsoftJsonExceptionResponseFormatter(); - services.PostConfigureAllOf(o => o.SensitivityDetails = FaultSensitivityDetails.All); - }, - app => - { - app.UseFaultDescriptorExceptionHandler(); - app.Use(async (context, next) => - { - try - { - throw new ArgumentException("This is an inner exception message ...", nameof(app)) - { - Data = - { - { "1st", "data value" } - }, - HelpLink = "https://www.savvyio.net/" - }; - } - catch (Exception e) - { - throw new NotFoundException("Main exception - look out for inner!", e); - } - - await next(context); - }); - }, - responseFactory: client => - { - client.DefaultRequestHeaders.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/json")); - return client.GetAsync("/"); - }); - - var body = await response.Content.ReadAsStringAsync(); - - TestOutput.WriteLine(body); - - Assert.True(Match(""" - { - "type": "about:blank", - "title": "NotFound", - "status": 404, - "detail": "Main exception - look out for inner!", - "instance": "http://localhost/", - "traceId": "*", - "failure": { - "type": "Cuemon.AspNetCore.Http.NotFoundException", - "source": "Cuemon.AspNetCore.FunctionalTests", - "message": "Main exception - look out for inner!", - "stack": [ - "at Cuemon.AspNetCore.Diagnostics.ApplicationBuilderExtensionsTest.<>c.<*", - "--- End of stack trace from previous location ---", - "at Microsoft.AspNetCore.Diagnostics.ExceptionHandler*" - ], - "headers": {}, - "statusCode": 404, - "reasonPhrase": "Not Found", - "inner": { - "type": "System.ArgumentException", - "source": "Cuemon.AspNetCore.FunctionalTests", - "message": "This is an inner exception message ... (Parameter 'app')", - "stack": [ - "at Cuemon.AspNetCore.Diagnostics.ApplicationBuilderExtensionsTest.<>c.<*" - ], - "data": { - "key": "data value" - }, - "paramName": "app" - } - }, - "request": { - "location": "http://localhost/", - "method": "GET", - "headers": { - "accept": "application/json", - "host": "localhost" - }, - "query": [], - "cookies": [], - "body": "" - } - } - """.ReplaceLineEndings(), body.ReplaceLineEndings(), o => o.ThrowOnNoMatch = true)); - } - [Fact] public async Task UseFaultDescriptorExceptionHandler_ShouldCaptureException_RenderAsExceptionDescriptor_UsingXml_WithSensitivityAll() { @@ -807,7 +619,7 @@ public async Task UseFaultDescriptorExceptionHandler_ShouldCaptureException_Rend Cuemon.AspNetCore.FunctionalTests Main exception - look out for inner! - at Cuemon.AspNetCore.Diagnostics.ApplicationBuilderExtensionsTest.<>c.<<UseFaultDescriptorExceptionHandler_ShouldCaptureException_RenderAsExceptionDescriptor_UsingXml_WithSensitivityAll>b__5_7>* + at Cuemon.AspNetCore.Diagnostics.ApplicationBuilderExtensionsTest* --- End of stack trace from previous location --- at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware* @@ -897,7 +709,7 @@ public async Task UseFaultDescriptorExceptionHandler_ShouldCaptureException_Rend Cuemon.AspNetCore.FunctionalTests Main exception - look out for inner! - at Cuemon.AspNetCore.Diagnostics.ApplicationBuilderExtensionsTest.<>c.<<UseFaultDescriptorExceptionHandler_ShouldCaptureException_RenderAsProblemDetails_UsingXml_WithSensitivityAll>* + at Cuemon.AspNetCore.Diagnostics.ApplicationBuilderExtensionsTest* --- End of stack trace from previous location --- at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware* @@ -907,7 +719,7 @@ public async Task UseFaultDescriptorExceptionHandler_ShouldCaptureException_Rend Cuemon.AspNetCore.FunctionalTests This is an inner exception message ... (Parameter 'app') - at Cuemon.AspNetCore.Diagnostics.ApplicationBuilderExtensionsTest.<>c.<<UseFaultDescriptorExceptionHandler_ShouldCaptureException_RenderAsProblemDetails_UsingXml_WithSensitivityAll>b__6_7>* + at Cuemon.AspNetCore.Diagnostics.ApplicationBuilderExtensionsTest* data value diff --git a/test/Cuemon.AspNetCore.Mvc.FunctionalTests/Cuemon.AspNetCore.Mvc.FunctionalTests.csproj b/test/Cuemon.AspNetCore.Mvc.FunctionalTests/Cuemon.AspNetCore.Mvc.FunctionalTests.csproj index eea39c04c..5091af1ec 100644 --- a/test/Cuemon.AspNetCore.Mvc.FunctionalTests/Cuemon.AspNetCore.Mvc.FunctionalTests.csproj +++ b/test/Cuemon.AspNetCore.Mvc.FunctionalTests/Cuemon.AspNetCore.Mvc.FunctionalTests.csproj @@ -6,9 +6,8 @@ - - + diff --git a/test/Cuemon.AspNetCore.Mvc.FunctionalTests/Filters/Diagnostics/FaultDescriptorFilterTest.cs b/test/Cuemon.AspNetCore.Mvc.FunctionalTests/Filters/Diagnostics/FaultDescriptorFilterTest.cs index bf5d91951..068481cac 100644 --- a/test/Cuemon.AspNetCore.Mvc.FunctionalTests/Filters/Diagnostics/FaultDescriptorFilterTest.cs +++ b/test/Cuemon.AspNetCore.Mvc.FunctionalTests/Filters/Diagnostics/FaultDescriptorFilterTest.cs @@ -4,7 +4,6 @@ using Cuemon.AspNetCore.Mvc.Assets; using Cuemon.Diagnostics; using Cuemon.Extensions.AspNetCore.Mvc.Filters; -using Codebelt.Extensions.AspNetCore.Mvc.Formatters.Newtonsoft.Json; using Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json; using Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml; using Cuemon.Extensions.DependencyInjection; @@ -554,536 +553,7 @@ public async Task OnException_ShouldCaptureException_RenderAsDefault_UsingJson(F } } - [Theory] - [InlineData(FaultSensitivityDetails.All)] - [InlineData(FaultSensitivityDetails.Evidence)] - [InlineData(FaultSensitivityDetails.FailureWithStackTraceAndData)] - [InlineData(FaultSensitivityDetails.FailureWithData)] - [InlineData(FaultSensitivityDetails.FailureWithStackTrace)] - [InlineData(FaultSensitivityDetails.Failure)] - [InlineData(FaultSensitivityDetails.None)] - public async Task OnException_ShouldCaptureException_RenderAsProblemDetails_UsingNewtonsoftJson(FaultSensitivityDetails sensitivity) - { - using var response = await WebHostTestFactory.RunAsync( - services => - { - services - .AddControllers(o => o.Filters.AddFaultDescriptor()) - .AddApplicationPart(typeof(StatusCodesController).Assembly) - .AddNewtonsoftJsonFormatters() - .AddFaultDescriptorOptions(o => o.FaultDescriptor = PreferredFaultDescriptor.ProblemDetails); - services.PostConfigureAllOf(o => o.SensitivityDetails = sensitivity); - }, - app => - { - app.UseRouting(); - app.UseEndpoints(routes => { routes.MapControllers(); }); - }, - responseFactory: client => - { - client.DefaultRequestHeaders.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/json")); - return client.GetAsync("/statuscodes/XXX/serverError"); - }); - - var body = await response.Content.ReadAsStringAsync(); - TestOutput.WriteLine(body); - - switch (sensitivity) - { - case FaultSensitivityDetails.All: - Assert.True(Match(""" - { - "type": "about:blank", - "title": "InternalServerError", - "status": 500, - "detail": "An unhandled exception was raised by *", - "instance": "http://localhost/statuscodes/XXX/serverError", - "traceId": "*", - "failure": { - "type": "System.NotSupportedException", - "source": "Cuemon.AspNetCore.Mvc.FunctionalTests", - "message": "Main exception - look out for inner!", - "stack": [ - "at Cuemon.AspNetCore.Mvc.Assets.StatusCodesController.Get_XXX(String app) *", - "at *", - "at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncActionResultExecutor.Execute*", - "at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()", - "at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)", - "at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()", - "--- End of stack trace from previous location ---", - "at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)", - "at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)", - "at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()", - "--- End of stack trace from previous location ---", - "at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.*" - ], - "inner": { - "type": "System.ArgumentException", - "source": "Cuemon.AspNetCore.Mvc.FunctionalTests", - "message": "This is an inner exception message ... (Parameter 'app')", - "stack": [ - "at Cuemon.AspNetCore.Mvc.Assets.StatusCodesController.Get_XXX(String app)*" - ], - "data": { - "key": "serverError" - }, - "paramName": "app" - } - }, - "request": { - "location": "http://localhost/statuscodes/XXX/serverError", - "method": "GET", - "headers": { - "accept": "application/json", - "host": "localhost" - }, - "query": [], - "cookies": [], - "body": "" - } - } - """.ReplaceLineEndings(), body.ReplaceLineEndings(), o => o.ThrowOnNoMatch = true)); - break; - case FaultSensitivityDetails.Evidence: - Assert.True(Match(""" - { - "type": "about:blank", - "title": "InternalServerError", - "status": 500, - "detail": "An unhandled exception was raised by *", - "instance": "http://localhost/statuscodes/XXX/serverError", - "traceId": "*", - "request": { - "location": "http://localhost/statuscodes/XXX/serverError", - "method": "GET", - "headers": { - "accept": "application/json", - "host": "localhost" - }, - "query": [], - "cookies": [], - "body": "" - } - } - """.ReplaceLineEndings(), body.ReplaceLineEndings(), o => o.ThrowOnNoMatch = true)); - break; - case FaultSensitivityDetails.FailureWithStackTraceAndData: - Assert.True(Match(""" - { - "type": "about:blank", - "title": "InternalServerError", - "status": 500, - "detail": "An unhandled exception was raised by *", - "instance": "http://localhost/statuscodes/XXX/serverError", - "traceId": "*", - "failure": { - "type": "System.NotSupportedException", - "source": "Cuemon.AspNetCore.Mvc.FunctionalTests", - "message": "Main exception - look out for inner!", - "stack": [ - "at Cuemon.AspNetCore.Mvc.Assets.StatusCodesController.Get_XXX(String app) *", - "at *", - "at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncActionResultExecutor.Execute*", - "at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()", - "at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)", - "at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()", - "--- End of stack trace from previous location ---", - "at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)", - "at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)", - "at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()", - "--- End of stack trace from previous location ---", - "at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.*" - ], - "inner": { - "type": "System.ArgumentException", - "source": "Cuemon.AspNetCore.Mvc.FunctionalTests", - "message": "This is an inner exception message ... (Parameter 'app')", - "stack": [ - "at Cuemon.AspNetCore.Mvc.Assets.StatusCodesController.Get_XXX(String app)*" - ], - "data": { - "key": "serverError" - }, - "paramName": "app" - } - } - } - """.ReplaceLineEndings(), body.ReplaceLineEndings(), o => o.ThrowOnNoMatch = true)); - break; - case FaultSensitivityDetails.FailureWithData: - Assert.True(Match(""" - { - "type": "about:blank", - "title": "InternalServerError", - "status": 500, - "detail": "An unhandled exception was raised by *", - "instance": "http://localhost/statuscodes/XXX/serverError", - "traceId": "*", - "failure": { - "type": "System.NotSupportedException", - "source": "Cuemon.AspNetCore.Mvc.FunctionalTests", - "message": "Main exception - look out for inner!", - "inner": { - "type": "System.ArgumentException", - "source": "Cuemon.AspNetCore.Mvc.FunctionalTests", - "message": "This is an inner exception message ... (Parameter 'app')", - "data": { - "key": "serverError" - }, - "paramName": "app" - } - } - } - """.ReplaceLineEndings(), body.ReplaceLineEndings(), o => o.ThrowOnNoMatch = true)); - break; - case FaultSensitivityDetails.FailureWithStackTrace: - Assert.True(Match(""" - { - "type": "about:blank", - "title": "InternalServerError", - "status": 500, - "detail": "An unhandled exception was raised by *", - "instance": "http://localhost/statuscodes/XXX/serverError", - "traceId": "*", - "failure": { - "type": "System.NotSupportedException", - "source": "Cuemon.AspNetCore.Mvc.FunctionalTests", - "message": "Main exception - look out for inner!", - "stack": [ - "at Cuemon.AspNetCore.Mvc.Assets.StatusCodesController.Get_XXX(String app) *", - "at *", - "at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncActionResultExecutor.Execute*", - "at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()", - "at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)", - "at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()", - "--- End of stack trace from previous location ---", - "at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)", - "at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)", - "at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()", - "--- End of stack trace from previous location ---", - "at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.*" - ], - "inner": { - "type": "System.ArgumentException", - "source": "Cuemon.AspNetCore.Mvc.FunctionalTests", - "message": "This is an inner exception message ... (Parameter 'app')", - "stack": [ - "at Cuemon.AspNetCore.Mvc.Assets.StatusCodesController.Get_XXX(String app)*" - ], - "paramName": "app" - } - } - } - """.ReplaceLineEndings(), body.ReplaceLineEndings(), o => o.ThrowOnNoMatch = true)); - break; - case FaultSensitivityDetails.Failure: - Assert.True(Match(""" - { - "type": "about:blank", - "title": "InternalServerError", - "status": 500, - "detail": "An unhandled exception was raised by *", - "instance": "http://localhost/statuscodes/XXX/serverError", - "traceId": "*", - "failure": { - "type": "System.NotSupportedException", - "source": "Cuemon.AspNetCore.Mvc.FunctionalTests", - "message": "Main exception - look out for inner!", - "inner": { - "type": "System.ArgumentException", - "source": "Cuemon.AspNetCore.Mvc.FunctionalTests", - "message": "This is an inner exception message ... (Parameter 'app')", - "paramName": "app" - } - } - } - """.ReplaceLineEndings(), body.ReplaceLineEndings(), o => o.ThrowOnNoMatch = true)); - break; - case FaultSensitivityDetails.None: - Assert.True(Match(""" - { - "type": "about:blank", - "title": "InternalServerError", - "status": 500, - "detail": "An unhandled exception was raised by *", - "instance": "http://localhost/statuscodes/XXX/serverError", - "traceId": "*" - } - """.ReplaceLineEndings(), body.ReplaceLineEndings(), o => o.ThrowOnNoMatch = true)); - break; - } - } - - [Theory] - [InlineData(FaultSensitivityDetails.All)] - [InlineData(FaultSensitivityDetails.Evidence)] - [InlineData(FaultSensitivityDetails.FailureWithStackTraceAndData)] - [InlineData(FaultSensitivityDetails.FailureWithData)] - [InlineData(FaultSensitivityDetails.FailureWithStackTrace)] - [InlineData(FaultSensitivityDetails.Failure)] - [InlineData(FaultSensitivityDetails.None)] - public async Task OnException_ShouldCaptureException_RenderAsDefault_UsingNewtonsoftJson(FaultSensitivityDetails sensitivity) - { - using var response = await WebHostTestFactory.RunAsync( - services => - { - services - .AddControllers(o => o.Filters.AddFaultDescriptor()) - .AddApplicationPart(typeof(StatusCodesController).Assembly) - .AddNewtonsoftJsonFormatters() - .AddFaultDescriptorOptions(o => o.FaultDescriptor = PreferredFaultDescriptor.FaultDetails); - services.PostConfigureAllOf(o => o.SensitivityDetails = sensitivity); - }, - app => - { - app.UseRouting(); - app.UseEndpoints(routes => { routes.MapControllers(); }); - }, - responseFactory: client => - { - client.DefaultRequestHeaders.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/json")); - return client.GetAsync("/statuscodes/XXX/serverError"); - }); - - var body = await response.Content.ReadAsStringAsync(); - TestOutput.WriteLine(body); - - switch (sensitivity) - { - case FaultSensitivityDetails.All: - Assert.True(Match(""" - { - "error": { - "instance": "http://localhost/statuscodes/XXX/serverError", - "status": 500, - "code": "InternalServerError", - "message": "An unhandled exception was raised by *.", - "failure": { - "type": "System.NotSupportedException", - "source": "Cuemon.AspNetCore.Mvc.FunctionalTests", - "message": "Main exception - look out for inner!", - "stack": [ - "at Cuemon.AspNetCore.Mvc.Assets.StatusCodesController.Get_XXX(String app) *", - "at *", - "at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncActionResultExecutor.Execute*", - "at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()", - "at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)", - "at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()", - "--- End of stack trace from previous location ---", - "at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)", - "at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)", - "at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()", - "--- End of stack trace from previous location ---", - "at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.*" - ], - "inner": { - "type": "System.ArgumentException", - "source": "Cuemon.AspNetCore.Mvc.FunctionalTests", - "message": "This is an inner exception message ... (Parameter 'app')", - "stack": [ - "at Cuemon.AspNetCore.Mvc.Assets.StatusCodesController.Get_XXX(String app)*" - ], - "data": { - "app": "serverError" - }, - "paramName": "app" - } - } - }, - "evidence": { - "request": { - "location": "http://localhost/statuscodes/XXX/serverError", - "method": "GET", - "headers": { - "accept": "application/json", - "host": "localhost" - }, - "query": [], - "cookies": [], - "body": "" - } - }, - "traceId": "*" - } - """.ReplaceLineEndings(), body.ReplaceLineEndings(), o => o.ThrowOnNoMatch = true)); - break; - case FaultSensitivityDetails.Evidence: - Assert.True(Match(""" - { - "error": { - "instance": "http://localhost/statuscodes/XXX/serverError", - "status": 500, - "code": "InternalServerError", - "message": "An unhandled exception was raised by *." - }, - "evidence": { - "request": { - "location": "http://localhost/statuscodes/XXX/serverError", - "method": "GET", - "headers": { - "accept": "application/json", - "host": "localhost" - }, - "query": [], - "cookies": [], - "body": "" - } - }, - "traceId": "*" - } - """.ReplaceLineEndings(), body.ReplaceLineEndings(), o => o.ThrowOnNoMatch = true)); - break; - case FaultSensitivityDetails.FailureWithStackTraceAndData: - Assert.True(Match(""" - { - "error": { - "instance": "http://localhost/statuscodes/XXX/serverError", - "status": 500, - "code": "InternalServerError", - "message": "An unhandled exception was raised by *.", - "failure": { - "type": "System.NotSupportedException", - "source": "Cuemon.AspNetCore.Mvc.FunctionalTests", - "message": "Main exception - look out for inner!", - "stack": [ - "at Cuemon.AspNetCore.Mvc.Assets.StatusCodesController.Get_XXX(String app) *", - "at *", - "at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncActionResultExecutor.Execute*", - "at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()", - "at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)", - "at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()", - "--- End of stack trace from previous location ---", - "at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)", - "at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)", - "at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()", - "--- End of stack trace from previous location ---", - "at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.*" - ], - "inner": { - "type": "System.ArgumentException", - "source": "Cuemon.AspNetCore.Mvc.FunctionalTests", - "message": "This is an inner exception message ... (Parameter 'app')", - "stack": [ - "at Cuemon.AspNetCore.Mvc.Assets.StatusCodesController.Get_XXX(String app)*" - ], - "data": { - "app": "serverError" - }, - "paramName": "app" - } - } - }, - "traceId": "*" - } - """.ReplaceLineEndings(), body.ReplaceLineEndings(), o => o.ThrowOnNoMatch = true)); - break; - case FaultSensitivityDetails.FailureWithData: - Assert.True(Match(""" - { - "error": { - "instance": "http://localhost/statuscodes/XXX/serverError", - "status": 500, - "code": "InternalServerError", - "message": "An unhandled exception was raised by *.", - "failure": { - "type": "System.NotSupportedException", - "source": "Cuemon.AspNetCore.Mvc.FunctionalTests", - "message": "Main exception - look out for inner!", - "inner": { - "type": "System.ArgumentException", - "source": "Cuemon.AspNetCore.Mvc.FunctionalTests", - "message": "This is an inner exception message ... (Parameter 'app')", - "data": { - "app": "serverError" - }, - "paramName": "app" - } - } - }, - "traceId": "*" - } - """.ReplaceLineEndings(), body.ReplaceLineEndings(), o => o.ThrowOnNoMatch = true)); - break; - case FaultSensitivityDetails.FailureWithStackTrace: - Assert.True(Match(""" - { - "error": { - "instance": "http://localhost/statuscodes/XXX/serverError", - "status": 500, - "code": "InternalServerError", - "message": "An unhandled exception was raised by *.", - "failure": { - "type": "System.NotSupportedException", - "source": "Cuemon.AspNetCore.Mvc.FunctionalTests", - "message": "Main exception - look out for inner!", - "stack": [ - "at Cuemon.AspNetCore.Mvc.Assets.StatusCodesController.Get_XXX(String app) *", - "at *", - "at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncActionResultExecutor.Execute*", - "at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()", - "at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)", - "at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()", - "--- End of stack trace from previous location ---", - "at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)", - "at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)", - "at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()", - "--- End of stack trace from previous location ---", - "at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.*" - ], - "inner": { - "type": "System.ArgumentException", - "source": "Cuemon.AspNetCore.Mvc.FunctionalTests", - "message": "This is an inner exception message ... (Parameter 'app')", - "stack": [ - "at Cuemon.AspNetCore.Mvc.Assets.StatusCodesController.Get_XXX(String app)*" - ], - "paramName": "app" - } - } - }, - "traceId": "*" - } - """.ReplaceLineEndings(), body.ReplaceLineEndings(), o => o.ThrowOnNoMatch = true)); - break; - case FaultSensitivityDetails.Failure: - Assert.True(Match(""" - { - "error": { - "instance": "http://localhost/statuscodes/XXX/serverError", - "status": 500, - "code": "InternalServerError", - "message": "An unhandled exception was raised by *.", - "failure": { - "type": "System.NotSupportedException", - "source": "Cuemon.AspNetCore.Mvc.FunctionalTests", - "message": "Main exception - look out for inner!", - "inner": { - "type": "System.ArgumentException", - "source": "Cuemon.AspNetCore.Mvc.FunctionalTests", - "message": "This is an inner exception message ... (Parameter 'app')", - "paramName": "app" - } - } - }, - "traceId": "*" - } - """.ReplaceLineEndings(), body.ReplaceLineEndings(), o => o.ThrowOnNoMatch = true)); - break; - case FaultSensitivityDetails.None: - Assert.True(Match(""" - { - "error": { - "instance": "http://localhost/statuscodes/XXX/serverError", - "status": 500, - "code": "InternalServerError", - "message": "An unhandled exception was raised by *." - }, - "traceId": "*" - } - """.ReplaceLineEndings(), body.ReplaceLineEndings(), o => o.ThrowOnNoMatch = true)); - break; - } - } + [Theory] [InlineData(FaultSensitivityDetails.All)] diff --git a/test/Cuemon.AspNetCore.Mvc.Tests/Cuemon.AspNetCore.Mvc.Tests.csproj b/test/Cuemon.AspNetCore.Mvc.Tests/Cuemon.AspNetCore.Mvc.Tests.csproj index b5153f73d..fdaceeee0 100644 --- a/test/Cuemon.AspNetCore.Mvc.Tests/Cuemon.AspNetCore.Mvc.Tests.csproj +++ b/test/Cuemon.AspNetCore.Mvc.Tests/Cuemon.AspNetCore.Mvc.Tests.csproj @@ -7,6 +7,7 @@ + @@ -15,8 +16,7 @@ - - + diff --git a/test/Cuemon.AspNetCore.Mvc.Tests/Filters/Diagnostics/FaultDescriptorFilterTest.cs b/test/Cuemon.AspNetCore.Mvc.Tests/Filters/Diagnostics/FaultDescriptorFilterTest.cs index 7814c7385..198b161eb 100644 --- a/test/Cuemon.AspNetCore.Mvc.Tests/Filters/Diagnostics/FaultDescriptorFilterTest.cs +++ b/test/Cuemon.AspNetCore.Mvc.Tests/Filters/Diagnostics/FaultDescriptorFilterTest.cs @@ -6,9 +6,9 @@ using Cuemon.Extensions.AspNetCore.Diagnostics; using Cuemon.Extensions.AspNetCore.Http.Throttling; using Cuemon.Extensions.AspNetCore.Mvc.Filters; -using Codebelt.Extensions.AspNetCore.Mvc.Formatters.Newtonsoft.Json; using Codebelt.Extensions.Xunit; using Codebelt.Extensions.Xunit.Hosting.AspNetCore; +using Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.TestHost; @@ -34,8 +34,7 @@ public async Task OnException_ShouldIncludeFailure_DifferentiateOnUseBaseExcepti services .AddControllers(o => { o.Filters.AddFaultDescriptor(); }) .AddApplicationPart(typeof(FakeController).Assembly) - .AddNewtonsoftJson() - .AddNewtonsoftJsonFormatters() + .AddJsonFormatters() .AddFaultDescriptorOptions(o => o.UseBaseException = useBaseException); services.PostConfigureAllExceptionDescriptorOptions(o => o.SensitivityDetails = FaultSensitivityDetails.Failure); }, (context, app) => @@ -104,8 +103,7 @@ public async Task OnException_ShouldCaptureUserAgentException_BadRequestMessage( o.Filters.AddUserAgentSentinel(); }) .AddApplicationPart(typeof(FakeController).Assembly) - .AddNewtonsoftJson() - .AddNewtonsoftJsonFormatters() + .AddJsonFormatters() .AddUserAgentSentinelOptions(o => o.RequireUserAgentHeader = true); }, (context, app) => { @@ -143,8 +141,7 @@ public async Task OnException_ShouldCaptureThrottlingException_TooManyRequests() o.Filters.AddFaultDescriptor(); o.Filters.AddThrottlingSentinel(); }).AddApplicationPart(typeof(FakeController).Assembly) - .AddNewtonsoftJson() - .AddNewtonsoftJsonFormatters() + .AddJsonFormatters() .AddThrottlingSentinelOptions(o => { o.ContextResolver = _ => "dummy"; @@ -183,8 +180,7 @@ public async Task OnException_ShouldCaptureBadRequest() using (var filter = WebHostTestFactory.CreateWithHostBuilderContext((context, services) => { services.AddControllers(o => { o.Filters.AddFaultDescriptor(); }).AddApplicationPart(typeof(FakeController).Assembly) - .AddNewtonsoftJson() - .AddNewtonsoftJsonFormatters(); + .AddJsonFormatters(); }, (context, app) => { app.UseRouting(); @@ -217,8 +213,7 @@ public async Task OnException_ShouldCaptureConflict() using (var filter = WebHostTestFactory.CreateWithHostBuilderContext((context, services) => { services.AddControllers(o => { o.Filters.AddFaultDescriptor(); }).AddApplicationPart(typeof(FakeController).Assembly) - .AddNewtonsoftJson() - .AddNewtonsoftJsonFormatters(); + .AddJsonFormatters(); }, (context, app) => { app.UseRouting(); @@ -251,8 +246,7 @@ public async Task OnException_ShouldCaptureForbidden() using (var filter = WebHostTestFactory.CreateWithHostBuilderContext((context, services) => { services.AddControllers(o => { o.Filters.AddFaultDescriptor(); }).AddApplicationPart(typeof(FakeController).Assembly) - .AddNewtonsoftJson() - .AddNewtonsoftJsonFormatters(); + .AddJsonFormatters(); }, (context, app) => { app.UseRouting(); @@ -285,8 +279,7 @@ public async Task OnException_ShouldCaptureGone() using (var filter = WebHostTestFactory.CreateWithHostBuilderContext((context, services) => { services.AddControllers(o => { o.Filters.AddFaultDescriptor(); }).AddApplicationPart(typeof(FakeController).Assembly) - .AddNewtonsoftJson() - .AddNewtonsoftJsonFormatters(); + .AddJsonFormatters(); }, (context, app) => { app.UseRouting(); @@ -319,8 +312,7 @@ public async Task OnException_ShouldCaptureNotFound() using (var filter = WebHostTestFactory.CreateWithHostBuilderContext((context, services) => { services.AddControllers(o => { o.Filters.AddFaultDescriptor(); }).AddApplicationPart(typeof(FakeController).Assembly) - .AddNewtonsoftJson() - .AddNewtonsoftJsonFormatters(); + .AddJsonFormatters(); }, (context, app) => { app.UseRouting(); @@ -353,8 +345,7 @@ public async Task OnException_ShouldCapturePayloadTooLarge() using (var filter = WebHostTestFactory.CreateWithHostBuilderContext((context, services) => { services.AddControllers(o => { o.Filters.AddFaultDescriptor(); }).AddApplicationPart(typeof(FakeController).Assembly) - .AddNewtonsoftJson() - .AddNewtonsoftJsonFormatters(); + .AddJsonFormatters(); }, (context, app) => { app.UseRouting(); @@ -387,8 +378,7 @@ public async Task OnException_ShouldCapturePreconditionFailed() using (var filter = WebHostTestFactory.CreateWithHostBuilderContext((context, services) => { services.AddControllers(o => { o.Filters.AddFaultDescriptor(); }).AddApplicationPart(typeof(FakeController).Assembly) - .AddNewtonsoftJson() - .AddNewtonsoftJsonFormatters(); + .AddJsonFormatters(); }, (context, app) => { app.UseRouting(); @@ -421,8 +411,7 @@ public async Task OnException_ShouldCapturePreconditionRequired() using (var filter = WebHostTestFactory.CreateWithHostBuilderContext((context, services) => { services.AddControllers(o => { o.Filters.AddFaultDescriptor(); }).AddApplicationPart(typeof(FakeController).Assembly) - .AddNewtonsoftJson() - .AddNewtonsoftJsonFormatters(); + .AddJsonFormatters(); }, (context, app) => { app.UseRouting(); @@ -455,8 +444,7 @@ public async Task OnException_ShouldCaptureTooManyRequests() using (var filter = WebHostTestFactory.CreateWithHostBuilderContext((context, services) => { services.AddControllers(o => { o.Filters.AddFaultDescriptor(); }).AddApplicationPart(typeof(FakeController).Assembly) - .AddNewtonsoftJson() - .AddNewtonsoftJsonFormatters(); + .AddJsonFormatters(); }, (context, app) => { app.UseRouting(); @@ -489,8 +477,7 @@ public async Task OnException_ShouldCaptureUnauthorized() using (var filter = WebHostTestFactory.CreateWithHostBuilderContext((context, services) => { services.AddControllers(o => { o.Filters.AddFaultDescriptor(); }).AddApplicationPart(typeof(FakeController).Assembly) - .AddNewtonsoftJson() - .AddNewtonsoftJsonFormatters(); + .AddJsonFormatters(); }, (context, app) => { app.UseRouting(); @@ -523,8 +510,7 @@ public async Task OnException_ShouldCaptureMethodNotAllowed() using (var filter = WebHostTestFactory.CreateWithHostBuilderContext((context, services) => { services.AddControllers(o => { o.Filters.AddFaultDescriptor(); }).AddApplicationPart(typeof(FakeController).Assembly) - .AddNewtonsoftJson() - .AddNewtonsoftJsonFormatters(); + .AddJsonFormatters(); }, (context, app) => { app.UseRouting(); @@ -557,8 +543,7 @@ public async Task OnException_ShouldCaptureNotAcceptable() using (var filter = WebHostTestFactory.CreateWithHostBuilderContext((context, services) => { services.AddControllers(o => { o.Filters.AddFaultDescriptor(); }).AddApplicationPart(typeof(FakeController).Assembly) - .AddNewtonsoftJson() - .AddNewtonsoftJsonFormatters(); + .AddJsonFormatters(); }, (context, app) => { app.UseRouting(); @@ -591,8 +576,7 @@ public async Task OnException_ShouldCaptureGeneric() using (var filter = WebHostTestFactory.CreateWithHostBuilderContext((context, services) => { services.AddControllers(o => { o.Filters.AddFaultDescriptor(); }).AddApplicationPart(typeof(FakeController).Assembly) - .AddNewtonsoftJson() - .AddNewtonsoftJsonFormatters(); + .AddJsonFormatters(); }, (context, app) => { app.UseRouting(); @@ -622,8 +606,7 @@ public async Task OnException_ShouldCaptureUnsupportedMediaType() using (var filter = WebHostTestFactory.CreateWithHostBuilderContext((context, services) => { services.AddControllers(o => { o.Filters.AddFaultDescriptor(); }).AddApplicationPart(typeof(FakeController).Assembly) - .AddNewtonsoftJson() - .AddNewtonsoftJsonFormatters(); + .AddJsonFormatters(); }, (context, app) => { app.UseRouting(); diff --git a/test/Cuemon.AspNetCore.Mvc.Tests/Filters/Headers/ApiKeySentinelFilterTest.cs b/test/Cuemon.AspNetCore.Mvc.Tests/Filters/Headers/ApiKeySentinelFilterTest.cs index 7aed9975c..707634232 100644 --- a/test/Cuemon.AspNetCore.Mvc.Tests/Filters/Headers/ApiKeySentinelFilterTest.cs +++ b/test/Cuemon.AspNetCore.Mvc.Tests/Filters/Headers/ApiKeySentinelFilterTest.cs @@ -5,9 +5,9 @@ using Cuemon.AspNetCore.Mvc.Assets; using Cuemon.Extensions.AspNetCore.Http.Headers; using Cuemon.Extensions.AspNetCore.Mvc.Filters; -using Codebelt.Extensions.AspNetCore.Mvc.Formatters.Newtonsoft.Json; using Codebelt.Extensions.Xunit; using Codebelt.Extensions.Xunit.Hosting.AspNetCore; +using Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.TestHost; @@ -33,8 +33,7 @@ public async Task OnAuthorizationAsync_ShouldProvideForbiddenResult_WithBadReque { o.Filters.AddApiKeySentinel(); }).AddApplicationPart(typeof(FakeController).Assembly) - .AddNewtonsoftJson() - .AddNewtonsoftJsonFormatters(); + .AddJsonFormatters(); }, app => { app.UseRouting(); @@ -60,8 +59,7 @@ public async Task OnAuthorizationAsync_ShouldProvideForbiddenResult_WithForbidde { o.Filters.AddApiKeySentinel(); }).AddApplicationPart(typeof(FakeController).Assembly) - .AddNewtonsoftJson() - .AddNewtonsoftJsonFormatters() + .AddJsonFormatters() .AddApiKeySentinelOptions(o => { o.AllowedKeys.Add("Cuemon-Key"); diff --git a/test/Cuemon.AspNetCore.Mvc.Tests/Filters/Headers/UserAgentSentinelFilterTest.cs b/test/Cuemon.AspNetCore.Mvc.Tests/Filters/Headers/UserAgentSentinelFilterTest.cs index 29ace5989..462b4ae29 100644 --- a/test/Cuemon.AspNetCore.Mvc.Tests/Filters/Headers/UserAgentSentinelFilterTest.cs +++ b/test/Cuemon.AspNetCore.Mvc.Tests/Filters/Headers/UserAgentSentinelFilterTest.cs @@ -3,9 +3,9 @@ using Cuemon.AspNetCore.Http.Headers; using Cuemon.AspNetCore.Mvc.Assets; using Cuemon.Extensions.AspNetCore.Mvc.Filters; -using Codebelt.Extensions.AspNetCore.Mvc.Formatters.Newtonsoft.Json; using Codebelt.Extensions.Xunit; using Codebelt.Extensions.Xunit.Hosting.AspNetCore; +using Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.TestHost; @@ -35,8 +35,7 @@ public async Task OnActionExecutionAsync_ShouldCaptureUserAgentException_BadRequ o.Filters.AddUserAgentSentinel(); }) .AddApplicationPart(typeof(FakeController).Assembly) - .AddNewtonsoftJson() - .AddNewtonsoftJsonFormatters() + .AddJsonFormatters() .AddUserAgentSentinelOptions(o => o.RequireUserAgentHeader = true); }, app => { @@ -68,8 +67,7 @@ public async Task OnActionExecutionAsync_ShouldCaptureUserAgentException_Forbidd o.Filters.AddUserAgentSentinel(); }) .AddApplicationPart(typeof(FakeController).Assembly) - .AddNewtonsoftJson() - .AddNewtonsoftJsonFormatters() + .AddJsonFormatters() .AddUserAgentSentinelOptions(o => { o.RequireUserAgentHeader = true; diff --git a/test/Cuemon.AspNetCore.Mvc.Tests/Filters/Throttling/ThrottlingSentinelFilterTest.cs b/test/Cuemon.AspNetCore.Mvc.Tests/Filters/Throttling/ThrottlingSentinelFilterTest.cs index c1391a452..455179428 100644 --- a/test/Cuemon.AspNetCore.Mvc.Tests/Filters/Throttling/ThrottlingSentinelFilterTest.cs +++ b/test/Cuemon.AspNetCore.Mvc.Tests/Filters/Throttling/ThrottlingSentinelFilterTest.cs @@ -7,9 +7,9 @@ using Cuemon.Extensions; using Cuemon.Extensions.AspNetCore.Http.Throttling; using Cuemon.Extensions.AspNetCore.Mvc.Filters; -using Codebelt.Extensions.AspNetCore.Mvc.Formatters.Newtonsoft.Json; using Codebelt.Extensions.Xunit; using Codebelt.Extensions.Xunit.Hosting.AspNetCore; +using Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.TestHost; @@ -37,8 +37,7 @@ public async Task OnActionExecutionAsync_ShouldCaptureThrottlingException() o.Filters.Add(); o.Filters.AddThrottlingSentinel(); }).AddApplicationPart(typeof(FakeController).Assembly) - .AddNewtonsoftJson() - .AddNewtonsoftJsonFormatters() + .AddJsonFormatters() .AddThrottlingSentinelOptions(o => { o.ContextResolver = context => nameof(OnActionExecutionAsync_ShouldCaptureThrottlingException); @@ -89,8 +88,7 @@ public async Task OnActionExecutionAsync_ShouldThrowThrottlingException() { o.Filters.AddThrottlingSentinel(); }).AddApplicationPart(typeof(FakeController).Assembly) - .AddNewtonsoftJson() - .AddNewtonsoftJsonFormatters() + .AddJsonFormatters() .AddThrottlingSentinelOptions(o => { o.ContextResolver = context => nameof(OnActionExecutionAsync_ShouldCaptureThrottlingException); diff --git a/test/Cuemon.AspNetCore.Razor.TagHelpers.Tests/Cuemon.AspNetCore.Razor.TagHelpers.Tests.csproj b/test/Cuemon.AspNetCore.Razor.TagHelpers.Tests/Cuemon.AspNetCore.Razor.TagHelpers.Tests.csproj index d0435670f..0339b469a 100644 --- a/test/Cuemon.AspNetCore.Razor.TagHelpers.Tests/Cuemon.AspNetCore.Razor.TagHelpers.Tests.csproj +++ b/test/Cuemon.AspNetCore.Razor.TagHelpers.Tests/Cuemon.AspNetCore.Razor.TagHelpers.Tests.csproj @@ -12,7 +12,7 @@ - + diff --git a/test/Cuemon.AspNetCore.Tests/Bootstrapper.cs b/test/Cuemon.AspNetCore.Tests/Bootstrapper.cs new file mode 100644 index 000000000..ff4a23638 --- /dev/null +++ b/test/Cuemon.AspNetCore.Tests/Bootstrapper.cs @@ -0,0 +1,20 @@ +using System.Runtime.CompilerServices; +using Cuemon.Extensions.AspNetCore.Text.Json.Converters; +using Cuemon.Extensions.Text.Json.Converters; +using Cuemon.Extensions.Text.Json.Formatters; + +namespace Cuemon.AspNetCore +{ + static class Bootstrapper + { + [ModuleInitializer] + internal static void Initialize() + { + JsonFormatterOptions.DefaultConverters += o => + { + o.AddHeaderDictionaryConverter(); + o.AddDateTimeConverter(); + }; + } + } +} diff --git a/test/Cuemon.AspNetCore.Tests/Cuemon.AspNetCore.Tests.csproj b/test/Cuemon.AspNetCore.Tests/Cuemon.AspNetCore.Tests.csproj index 18653a020..c3855b397 100644 --- a/test/Cuemon.AspNetCore.Tests/Cuemon.AspNetCore.Tests.csproj +++ b/test/Cuemon.AspNetCore.Tests/Cuemon.AspNetCore.Tests.csproj @@ -7,14 +7,15 @@ + + - - + diff --git a/test/Cuemon.AspNetCore.Tests/Http/BadRequestExceptionTest.cs b/test/Cuemon.AspNetCore.Tests/Http/BadRequestExceptionTest.cs index 399d81e73..a0b9fa097 100644 --- a/test/Cuemon.AspNetCore.Tests/Http/BadRequestExceptionTest.cs +++ b/test/Cuemon.AspNetCore.Tests/Http/BadRequestExceptionTest.cs @@ -1,6 +1,6 @@ using Cuemon.Extensions.IO; -using Codebelt.Extensions.Newtonsoft.Json.Formatters; using Codebelt.Extensions.Xunit; +using Cuemon.Extensions.Text.Json.Formatters; using Cuemon.Xml.Serialization.Formatters; using Microsoft.AspNetCore.Http; using Xunit; @@ -18,7 +18,7 @@ public BadRequestExceptionTest(ITestOutputHelper output) : base(output) public void Ctor_ShouldBeSerializableAndHaveCorrectStatusCodeOf400_Json() { var sut1 = new BadRequestException(); - var sut2 = new NewtonsoftJsonFormatter(); + var sut2 = new JsonFormatter(); var sut3 = sut2.Serialize(sut1); var sut4 = sut3.ToEncodedString(o => o.LeaveOpen = true); diff --git a/test/Cuemon.AspNetCore.Tests/Http/ForbiddenExceptionTest.cs b/test/Cuemon.AspNetCore.Tests/Http/ForbiddenExceptionTest.cs index ee5fed765..120148e88 100644 --- a/test/Cuemon.AspNetCore.Tests/Http/ForbiddenExceptionTest.cs +++ b/test/Cuemon.AspNetCore.Tests/Http/ForbiddenExceptionTest.cs @@ -1,6 +1,6 @@ using Cuemon.Extensions.IO; -using Codebelt.Extensions.Newtonsoft.Json.Formatters; using Codebelt.Extensions.Xunit; +using Cuemon.Extensions.Text.Json.Formatters; using Cuemon.Xml.Serialization.Formatters; using Microsoft.AspNetCore.Http; using Xunit; @@ -18,7 +18,7 @@ public ForbiddenExceptionTest(ITestOutputHelper output) : base(output) public void Ctor_ShouldBeSerializableAndHaveCorrectStatusCodeOf403_Json() { var sut1 = new ForbiddenException(); - var sut2 = new NewtonsoftJsonFormatter(); + var sut2 = new JsonFormatter(); var sut3 = sut2.Serialize(sut1); var sut4 = sut3.ToEncodedString(o => o.LeaveOpen = true); diff --git a/test/Cuemon.AspNetCore.Tests/Http/GoneExceptionTest.cs b/test/Cuemon.AspNetCore.Tests/Http/GoneExceptionTest.cs index ed5ca491f..4e306385e 100644 --- a/test/Cuemon.AspNetCore.Tests/Http/GoneExceptionTest.cs +++ b/test/Cuemon.AspNetCore.Tests/Http/GoneExceptionTest.cs @@ -1,6 +1,6 @@ using Cuemon.Extensions.IO; -using Codebelt.Extensions.Newtonsoft.Json.Formatters; using Codebelt.Extensions.Xunit; +using Cuemon.Extensions.Text.Json.Formatters; using Cuemon.Xml.Serialization.Formatters; using Microsoft.AspNetCore.Http; using Xunit; @@ -18,7 +18,7 @@ public GoneExceptionTest(ITestOutputHelper output) : base(output) public void Ctor_ShouldBeSerializableAndHaveCorrectStatusCodeOf410_Json() { var sut1 = new GoneException(); - var sut2 = new NewtonsoftJsonFormatter(); + var sut2 = new JsonFormatter(); var sut3 = sut2.Serialize(sut1); var sut4 = sut3.ToEncodedString(o => o.LeaveOpen = true); diff --git a/test/Cuemon.AspNetCore.Tests/Http/Headers/ApiKeyExceptionTest.cs b/test/Cuemon.AspNetCore.Tests/Http/Headers/ApiKeyExceptionTest.cs index 033dff8ea..dc388ee36 100644 --- a/test/Cuemon.AspNetCore.Tests/Http/Headers/ApiKeyExceptionTest.cs +++ b/test/Cuemon.AspNetCore.Tests/Http/Headers/ApiKeyExceptionTest.cs @@ -1,6 +1,6 @@ using Cuemon.Extensions.IO; -using Codebelt.Extensions.Newtonsoft.Json.Formatters; using Codebelt.Extensions.Xunit; +using Cuemon.Extensions.Text.Json.Formatters; using Cuemon.Xml.Serialization.Formatters; using Microsoft.AspNetCore.Http; using Xunit; @@ -18,7 +18,7 @@ public ApiKeyExceptionTest(ITestOutputHelper output) : base(output) public void ApiKeyException_ShouldBeSerializable_Json() { var sut1 = new ApiKeyException(400, "Bad Request."); - var sut2 = new NewtonsoftJsonFormatter(); + var sut2 = new JsonFormatter(); var sut3 = sut2.Serialize(sut1); var sut4 = sut3.ToEncodedString(o => o.LeaveOpen = true); diff --git a/test/Cuemon.AspNetCore.Tests/Http/Headers/UserAgentExceptionTest.cs b/test/Cuemon.AspNetCore.Tests/Http/Headers/UserAgentExceptionTest.cs index 24962782d..cf3f8728d 100644 --- a/test/Cuemon.AspNetCore.Tests/Http/Headers/UserAgentExceptionTest.cs +++ b/test/Cuemon.AspNetCore.Tests/Http/Headers/UserAgentExceptionTest.cs @@ -1,6 +1,6 @@ using Cuemon.Extensions.IO; -using Codebelt.Extensions.Newtonsoft.Json.Formatters; using Codebelt.Extensions.Xunit; +using Cuemon.Extensions.Text.Json.Formatters; using Cuemon.Xml.Serialization.Formatters; using Microsoft.AspNetCore.Http; using Xunit; @@ -18,7 +18,7 @@ public UserAgentExceptionTest(ITestOutputHelper output) : base(output) public void UserAgentException_ShouldBeSerializable_Json() { var sut1 = new UserAgentException(400, "Bad Request."); - var sut2 = new NewtonsoftJsonFormatter(); + var sut2 = new JsonFormatter(); var sut3 = sut2.Serialize(sut1); var sut4 = sut3.ToEncodedString(o => o.LeaveOpen = true); diff --git a/test/Cuemon.AspNetCore.Tests/Http/MethodNotAllowedExceptionTest.cs b/test/Cuemon.AspNetCore.Tests/Http/MethodNotAllowedExceptionTest.cs index 2586f3a04..3f8b65861 100644 --- a/test/Cuemon.AspNetCore.Tests/Http/MethodNotAllowedExceptionTest.cs +++ b/test/Cuemon.AspNetCore.Tests/Http/MethodNotAllowedExceptionTest.cs @@ -1,6 +1,6 @@ using Cuemon.Extensions.IO; -using Codebelt.Extensions.Newtonsoft.Json.Formatters; using Codebelt.Extensions.Xunit; +using Cuemon.Extensions.Text.Json.Formatters; using Cuemon.Xml.Serialization.Formatters; using Microsoft.AspNetCore.Http; using Xunit; @@ -18,7 +18,7 @@ public MethodNotAllowedExceptionTest(ITestOutputHelper output) : base(output) public void Ctor_ShouldBeSerializableAndHaveCorrectStatusCodeOf405_Json() { var sut1 = new MethodNotAllowedException(); - var sut2 = new NewtonsoftJsonFormatter(); + var sut2 = new JsonFormatter(); var sut3 = sut2.Serialize(sut1); var sut4 = sut3.ToEncodedString(o => o.LeaveOpen = true); diff --git a/test/Cuemon.AspNetCore.Tests/Http/NotAcceptableExceptionTest.cs b/test/Cuemon.AspNetCore.Tests/Http/NotAcceptableExceptionTest.cs index a4b39800b..56f6ea842 100644 --- a/test/Cuemon.AspNetCore.Tests/Http/NotAcceptableExceptionTest.cs +++ b/test/Cuemon.AspNetCore.Tests/Http/NotAcceptableExceptionTest.cs @@ -1,6 +1,6 @@ using Cuemon.Extensions.IO; -using Codebelt.Extensions.Newtonsoft.Json.Formatters; using Codebelt.Extensions.Xunit; +using Cuemon.Extensions.Text.Json.Formatters; using Cuemon.Xml.Serialization.Formatters; using Microsoft.AspNetCore.Http; using Xunit; @@ -18,7 +18,7 @@ public NotAcceptableExceptionTest(ITestOutputHelper output) : base(output) public void Ctor_ShouldBeSerializableAndHaveCorrectStatusCodeOf406_Json() { var sut1 = new NotAcceptableException(); - var sut2 = new NewtonsoftJsonFormatter(); + var sut2 = new JsonFormatter(); var sut3 = sut2.Serialize(sut1); var sut4 = sut3.ToEncodedString(o => o.LeaveOpen = true); diff --git a/test/Cuemon.AspNetCore.Tests/Http/NotFoundExceptionTest.cs b/test/Cuemon.AspNetCore.Tests/Http/NotFoundExceptionTest.cs index 17fe53f86..a38a9d76a 100644 --- a/test/Cuemon.AspNetCore.Tests/Http/NotFoundExceptionTest.cs +++ b/test/Cuemon.AspNetCore.Tests/Http/NotFoundExceptionTest.cs @@ -1,6 +1,6 @@ using Cuemon.Extensions.IO; -using Codebelt.Extensions.Newtonsoft.Json.Formatters; using Codebelt.Extensions.Xunit; +using Cuemon.Extensions.Text.Json.Formatters; using Cuemon.Xml.Serialization.Formatters; using Microsoft.AspNetCore.Http; using Xunit; @@ -18,7 +18,7 @@ public NotFoundExceptionTest(ITestOutputHelper output) : base(output) public void Ctor_ShouldBeSerializableAndHaveCorrectStatusCodeOf404_Json() { var sut1 = new NotFoundException(); - var sut2 = new NewtonsoftJsonFormatter(); + var sut2 = new JsonFormatter(); var sut3 = sut2.Serialize(sut1); var sut4 = sut3.ToEncodedString(o => o.LeaveOpen = true); diff --git a/test/Cuemon.AspNetCore.Tests/Http/PayloadTooLargeExceptionTest.cs b/test/Cuemon.AspNetCore.Tests/Http/PayloadTooLargeExceptionTest.cs index 557150b56..d036fc1a6 100644 --- a/test/Cuemon.AspNetCore.Tests/Http/PayloadTooLargeExceptionTest.cs +++ b/test/Cuemon.AspNetCore.Tests/Http/PayloadTooLargeExceptionTest.cs @@ -1,6 +1,6 @@ using Cuemon.Extensions.IO; -using Codebelt.Extensions.Newtonsoft.Json.Formatters; using Codebelt.Extensions.Xunit; +using Cuemon.Extensions.Text.Json.Formatters; using Cuemon.Xml.Serialization.Formatters; using Microsoft.AspNetCore.Http; using Xunit; @@ -18,7 +18,7 @@ public PayloadTooLargeExceptionTest(ITestOutputHelper output) : base(output) public void Ctor_ShouldBeSerializableAndHaveCorrectStatusCodeOf413_Json() { var sut1 = new PayloadTooLargeException(); - var sut2 = new NewtonsoftJsonFormatter(); + var sut2 = new JsonFormatter(); var sut3 = sut2.Serialize(sut1); var sut4 = sut3.ToEncodedString(o => o.LeaveOpen = true); diff --git a/test/Cuemon.AspNetCore.Tests/Http/PreconditionFailedExceptionTest.cs b/test/Cuemon.AspNetCore.Tests/Http/PreconditionFailedExceptionTest.cs index 2b5eb0ead..b5f4e55bc 100644 --- a/test/Cuemon.AspNetCore.Tests/Http/PreconditionFailedExceptionTest.cs +++ b/test/Cuemon.AspNetCore.Tests/Http/PreconditionFailedExceptionTest.cs @@ -1,6 +1,6 @@ using Cuemon.Extensions.IO; -using Codebelt.Extensions.Newtonsoft.Json.Formatters; using Codebelt.Extensions.Xunit; +using Cuemon.Extensions.Text.Json.Formatters; using Cuemon.Xml.Serialization.Formatters; using Microsoft.AspNetCore.Http; using Xunit; @@ -18,7 +18,7 @@ public PreconditionFailedExceptionTest(ITestOutputHelper output) : base(output) public void Ctor_ShouldBeSerializableAndHaveCorrectStatusCodeOf412_Json() { var sut1 = new PreconditionFailedException(); - var sut2 = new NewtonsoftJsonFormatter(); + var sut2 = new JsonFormatter(); var sut3 = sut2.Serialize(sut1); var sut4 = sut3.ToEncodedString(o => o.LeaveOpen = true); diff --git a/test/Cuemon.AspNetCore.Tests/Http/PreconditionRequiredExceptionTest.cs b/test/Cuemon.AspNetCore.Tests/Http/PreconditionRequiredExceptionTest.cs index 5e1b663a7..aaf8afe1f 100644 --- a/test/Cuemon.AspNetCore.Tests/Http/PreconditionRequiredExceptionTest.cs +++ b/test/Cuemon.AspNetCore.Tests/Http/PreconditionRequiredExceptionTest.cs @@ -1,6 +1,6 @@ using Cuemon.Extensions.IO; -using Codebelt.Extensions.Newtonsoft.Json.Formatters; using Codebelt.Extensions.Xunit; +using Cuemon.Extensions.Text.Json.Formatters; using Cuemon.Xml.Serialization.Formatters; using Microsoft.AspNetCore.Http; using Xunit; @@ -18,7 +18,7 @@ public PreconditionRequiredExceptionTest(ITestOutputHelper output) : base(output public void Ctor_ShouldBeSerializableAndHaveCorrectStatusCodeOf428_Json() { var sut1 = new PreconditionRequiredException(); - var sut2 = new NewtonsoftJsonFormatter(); + var sut2 = new JsonFormatter(); var sut3 = sut2.Serialize(sut1); var sut4 = sut3.ToEncodedString(o => o.LeaveOpen = true); diff --git a/test/Cuemon.AspNetCore.Tests/Http/Throttling/ThrottlingExceptionTest.cs b/test/Cuemon.AspNetCore.Tests/Http/Throttling/ThrottlingExceptionTest.cs index 155a52da0..c14f4387c 100644 --- a/test/Cuemon.AspNetCore.Tests/Http/Throttling/ThrottlingExceptionTest.cs +++ b/test/Cuemon.AspNetCore.Tests/Http/Throttling/ThrottlingExceptionTest.cs @@ -1,7 +1,7 @@ using System; using Cuemon.Extensions.IO; -using Codebelt.Extensions.Newtonsoft.Json.Formatters; using Codebelt.Extensions.Xunit; +using Cuemon.Extensions.Text.Json.Formatters; using Cuemon.Xml.Serialization.Formatters; using Microsoft.AspNetCore.Http; using Xunit; @@ -20,7 +20,7 @@ public void ThrottlingException_ShouldBeSerializable_Json() { var reset = DateTime.Today.AddDays(1); var sut1 = new ThrottlingException("Throttling rate limit quota violation. Quota limit exceeded.", 100, TimeSpan.FromHours(1), reset); - var sut2 = new NewtonsoftJsonFormatter(); + var sut2 = new JsonFormatter(); var sut3 = sut2.Serialize(sut1); var sut4 = sut3.ToEncodedString(o => o.LeaveOpen = true); diff --git a/test/Cuemon.AspNetCore.Tests/Http/TooManyRequestsExceptionTest.cs b/test/Cuemon.AspNetCore.Tests/Http/TooManyRequestsExceptionTest.cs index 628374172..eb1649d01 100644 --- a/test/Cuemon.AspNetCore.Tests/Http/TooManyRequestsExceptionTest.cs +++ b/test/Cuemon.AspNetCore.Tests/Http/TooManyRequestsExceptionTest.cs @@ -1,6 +1,6 @@ using Cuemon.Extensions.IO; -using Codebelt.Extensions.Newtonsoft.Json.Formatters; using Codebelt.Extensions.Xunit; +using Cuemon.Extensions.Text.Json.Formatters; using Cuemon.Xml.Serialization.Formatters; using Microsoft.AspNetCore.Http; using Xunit; @@ -18,7 +18,7 @@ public TooManyRequestsExceptionTest(ITestOutputHelper output) : base(output) public void Ctor_ShouldBeSerializableAndHaveCorrectStatusCodeOf429_Json() { var sut1 = new TooManyRequestsException(); - var sut2 = new NewtonsoftJsonFormatter(); + var sut2 = new JsonFormatter(); var sut3 = sut2.Serialize(sut1); var sut4 = sut3.ToEncodedString(o => o.LeaveOpen = true); diff --git a/test/Cuemon.AspNetCore.Tests/Http/UnauthorizedExceptionTest.cs b/test/Cuemon.AspNetCore.Tests/Http/UnauthorizedExceptionTest.cs index cf952ab48..77eae1934 100644 --- a/test/Cuemon.AspNetCore.Tests/Http/UnauthorizedExceptionTest.cs +++ b/test/Cuemon.AspNetCore.Tests/Http/UnauthorizedExceptionTest.cs @@ -1,6 +1,6 @@ using Cuemon.Extensions.IO; -using Codebelt.Extensions.Newtonsoft.Json.Formatters; using Codebelt.Extensions.Xunit; +using Cuemon.Extensions.Text.Json.Formatters; using Cuemon.Xml.Serialization.Formatters; using Microsoft.AspNetCore.Http; using Xunit; @@ -18,7 +18,7 @@ public UnauthorizedExceptionTest(ITestOutputHelper output) : base(output) public void Ctor_ShouldBeSerializableAndHaveCorrectStatusCodeOf401_Json() { var sut1 = new UnauthorizedException(); - var sut2 = new NewtonsoftJsonFormatter(); + var sut2 = new JsonFormatter(); var sut3 = sut2.Serialize(sut1); var sut4 = sut3.ToEncodedString(o => o.LeaveOpen = true); diff --git a/test/Cuemon.AspNetCore.Tests/Http/UnsupportedMediaTypeTest.cs b/test/Cuemon.AspNetCore.Tests/Http/UnsupportedMediaTypeTest.cs index fdba91a20..5633cc660 100644 --- a/test/Cuemon.AspNetCore.Tests/Http/UnsupportedMediaTypeTest.cs +++ b/test/Cuemon.AspNetCore.Tests/Http/UnsupportedMediaTypeTest.cs @@ -1,6 +1,6 @@ using Cuemon.Extensions.IO; -using Codebelt.Extensions.Newtonsoft.Json.Formatters; using Codebelt.Extensions.Xunit; +using Cuemon.Extensions.Text.Json.Formatters; using Cuemon.Xml.Serialization.Formatters; using Microsoft.AspNetCore.Http; using Xunit; @@ -18,7 +18,7 @@ public UnsupportedMediaTypeTest(ITestOutputHelper output) : base(output) public void Ctor_ShouldBeSerializableAndHaveCorrectStatusCodeOf415_Json() { var sut1 = new UnsupportedMediaTypeException(); - var sut2 = new NewtonsoftJsonFormatter(); + var sut2 = new JsonFormatter(); var sut3 = sut2.Serialize(sut1); var sut4 = sut3.ToEncodedString(o => o.LeaveOpen = true); diff --git a/test/Cuemon.Core.Tests/Assets/ClampOptions.cs b/test/Cuemon.Core.Tests/Assets/ClampOptions.cs index 38df041a3..c1f325c8b 100644 --- a/test/Cuemon.Core.Tests/Assets/ClampOptions.cs +++ b/test/Cuemon.Core.Tests/Assets/ClampOptions.cs @@ -16,7 +16,7 @@ public int MaxConcurrentJobs get => _maxConcurrentJobs; set { -#if NET6_0_OR_GREATER +#if NET8_0_OR_GREATER _maxConcurrentJobs = Math.Clamp(value, 1, byte.MaxValue); #else _maxConcurrentJobs = Clamp(value, 1, byte.MaxValue); diff --git a/test/Cuemon.Core.Tests/Assets/UnmanagedDisposable.cs b/test/Cuemon.Core.Tests/Assets/UnmanagedDisposable.cs index 269a6f987..4b7f727f1 100644 --- a/test/Cuemon.Core.Tests/Assets/UnmanagedDisposable.cs +++ b/test/Cuemon.Core.Tests/Assets/UnmanagedDisposable.cs @@ -28,7 +28,7 @@ public delegate IntPtr CreateFileDelegate(string lpFileName, public UnmanagedDisposable() { -#if NET6_0_OR_GREATER +#if NET8_0_OR_GREATER if (Environment.OSVersion.Platform == PlatformID.Win32NT) { if (NativeLibrary.TryLoad("kernel32.dll", GetType().Assembly, DllImportSearchPath.System32, out _libHandle)) @@ -84,7 +84,7 @@ protected override void OnDisposeManagedResources() protected override void OnDisposeUnmanagedResources() { -#if NET6_0_OR_GREATER +#if NET8_0_OR_GREATER if (Environment.OSVersion.Platform == PlatformID.Win32NT) { if (_handle != IntPtr.Zero) diff --git a/test/Cuemon.Core.Tests/Cuemon.Core.Tests.csproj b/test/Cuemon.Core.Tests/Cuemon.Core.Tests.csproj index f65c46a11..779467eae 100644 --- a/test/Cuemon.Core.Tests/Cuemon.Core.Tests.csproj +++ b/test/Cuemon.Core.Tests/Cuemon.Core.Tests.csproj @@ -17,7 +17,6 @@ - @@ -29,6 +28,7 @@ + diff --git a/test/Cuemon.Core.Tests/DisposableTest.cs b/test/Cuemon.Core.Tests/DisposableTest.cs index 2cd2c8d53..ab93a3e44 100644 --- a/test/Cuemon.Core.Tests/DisposableTest.cs +++ b/test/Cuemon.Core.Tests/DisposableTest.cs @@ -173,8 +173,6 @@ public void UnmanagedDisposable_VerifyThatAssetIsBeingDisposedOnFinalize() GC.WaitForPendingFinalizers(); } - Thread.Sleep(TimeSpan.FromSeconds(30)); // await GC - if (unmanaged.TryGetTarget(out var ud2)) { Assert.True(ud2.Disposed); diff --git a/test/Cuemon.Core.Tests/Reflection/AssemblyDecoratorExtensionsTest.cs b/test/Cuemon.Core.Tests/Reflection/AssemblyDecoratorExtensionsTest.cs index b41e28f05..cff1e548b 100644 --- a/test/Cuemon.Core.Tests/Reflection/AssemblyDecoratorExtensionsTest.cs +++ b/test/Cuemon.Core.Tests/Reflection/AssemblyDecoratorExtensionsTest.cs @@ -4,6 +4,7 @@ using System.Reflection; using Cuemon.Assets; using Codebelt.Extensions.Xunit; +using Cuemon.Extensions; using Xunit; using Xunit.Abstractions; @@ -38,7 +39,7 @@ public void GetTypes_ShouldReturnAllTypesFromCuemonCore() var disposableTypesCount = Decorator.Enclose(disposableTypes).Inner.Count(); var configurationTypesCount = Decorator.Enclose(configurationTypes).Inner.Count(); - TestOutput.WriteLines(disposableTypes); + TestOutput.WriteLine(disposableTypes.ToDelimitedString()); Assert.InRange(allTypesCount, 475, 575); // range because of tooling on CI adding dynamic types and high range of refactoring Assert.Equal(5, disposableTypesCount); diff --git a/test/Cuemon.Core.Tests/Runtime/FileDependencyTest.cs b/test/Cuemon.Core.Tests/Runtime/FileDependencyTest.cs index bc5c50a85..9bdd8b9af 100644 --- a/test/Cuemon.Core.Tests/Runtime/FileDependencyTest.cs +++ b/test/Cuemon.Core.Tests/Runtime/FileDependencyTest.cs @@ -4,6 +4,7 @@ using System.Threading; using System.Threading.Tasks; using Codebelt.Extensions.Xunit; +using Cuemon.Extensions; using Xunit; using Xunit.Abstractions; @@ -60,7 +61,7 @@ public async Task StartAsync_ShouldReceiveTwoSignalsFromFileWatcher() var signaled = ce.Wait(TimeSpan.FromSeconds(15)); - TestOutput.WriteLines(sut5); + TestOutput.WriteLine(sut5.ToDelimitedString()); sut3.DependencyChanged -= sut6; @@ -103,7 +104,7 @@ public async Task StartAsync_ShouldReceiveOnlyOneSignalFromFileWatcher() var signaled = are.WaitOne(TimeSpan.FromSeconds(15)); - TestOutput.WriteLines(sut5); + TestOutput.WriteLine(sut5.ToDelimitedString()); sut3.DependencyChanged -= sut6; diff --git a/test/Cuemon.Core.Tests/Text/ParserFactoryTest.cs b/test/Cuemon.Core.Tests/Text/ParserFactoryTest.cs index dfb48fb67..2d26445ad 100644 --- a/test/Cuemon.Core.Tests/Text/ParserFactoryTest.cs +++ b/test/Cuemon.Core.Tests/Text/ParserFactoryTest.cs @@ -82,7 +82,7 @@ public void ParserFactory_ShouldConvertString_ToTypeConverterImplementation() var sg = Guid.NewGuid(); Assert.Equal(sg, ParserFactory.FromObject().Parse(sg.ToString())); -#if NET6_0_OR_GREATER +#if NET8_0_OR_GREATER var v = new Version(); Assert.Equal(v, ParserFactory.FromObject().Parse(v.ToString(), typeof(Version))); #endif diff --git a/test/Cuemon.Core.Tests/TypeArgumentExceptionTest.cs b/test/Cuemon.Core.Tests/TypeArgumentExceptionTest.cs index 1796afa80..917e23425 100644 --- a/test/Cuemon.Core.Tests/TypeArgumentExceptionTest.cs +++ b/test/Cuemon.Core.Tests/TypeArgumentExceptionTest.cs @@ -2,8 +2,8 @@ using System.Threading; using Cuemon.Extensions; using Cuemon.Extensions.IO; -using Codebelt.Extensions.Newtonsoft.Json.Formatters; using Codebelt.Extensions.Xunit; +using Cuemon.Extensions.Text.Json.Formatters; using Cuemon.Xml.Serialization.Formatters; using Xunit; using Xunit.Abstractions; @@ -20,7 +20,7 @@ public TypeArgumentExceptionTest(ITestOutputHelper output) : base(output) public void ArgumentException_ShouldBeSerializable_Json() { var sut1 = new ArgumentException("My fancy message.", "myArg"); - var sut2 = new NewtonsoftJsonFormatter(); + var sut2 = new JsonFormatter(); var sut3 = sut2.Serialize(sut1); var sut4 = sut3.ToEncodedString(o => o.LeaveOpen = true); @@ -58,7 +58,7 @@ public void TypeArgumentException_ShouldBeSerializable_Json() { var random = Generate.RandomString(10); var sut1 = new TypeArgumentException(random); - var sut2 = new NewtonsoftJsonFormatter(); + var sut2 = new JsonFormatter(); var sut3 = sut2.Serialize(sut1); var sut4 = sut3.ToEncodedString(o => o.LeaveOpen = true); @@ -95,7 +95,7 @@ public void TypeArgumentException_ShouldBeSerializable_Json() public void TypeArgumentException_WithInnerException_ShouldBeSerializable_Json() { var sut1 = new TypeArgumentException("Should have IE.", new ArgumentReservedKeywordException("Test", new AbandonedMutexException(20, null))); - var sut2 = new NewtonsoftJsonFormatter(); + var sut2 = new JsonFormatter(); var sut3 = sut2.Serialize(sut1); var sut4 = sut3.ToEncodedString(o => o.LeaveOpen = true); diff --git a/test/Cuemon.Core.Tests/TypeArgumentOutOfRangeExceptionTest.cs b/test/Cuemon.Core.Tests/TypeArgumentOutOfRangeExceptionTest.cs index bdd5f09c7..3d618fbe9 100644 --- a/test/Cuemon.Core.Tests/TypeArgumentOutOfRangeExceptionTest.cs +++ b/test/Cuemon.Core.Tests/TypeArgumentOutOfRangeExceptionTest.cs @@ -1,8 +1,8 @@ using System.Runtime.InteropServices; using Cuemon.Extensions; using Cuemon.Extensions.IO; -using Codebelt.Extensions.Newtonsoft.Json.Formatters; using Codebelt.Extensions.Xunit; +using Cuemon.Extensions.Text.Json.Formatters; using Cuemon.Xml.Serialization.Formatters; using Xunit; using Xunit.Abstractions; @@ -22,7 +22,7 @@ public void TypeArgumentOutOfRangeException_ShouldBeSerializable_Json() var actualValue = 42; var randomMessage = Generate.RandomString(50); var sut1 = new TypeArgumentOutOfRangeException(randomParamName, 42, randomMessage); - var sut2 = new NewtonsoftJsonFormatter(); + var sut2 = new JsonFormatter(); var sut3 = sut2.Serialize(sut1); var sut4 = sut3.ToEncodedString(o => o.LeaveOpen = true); diff --git a/test/Cuemon.Data.SqlClient.Tests/Cuemon.Data.SqlClient.Tests.csproj b/test/Cuemon.Data.SqlClient.Tests/Cuemon.Data.SqlClient.Tests.csproj index ae2f7746a..48d1ffb39 100644 --- a/test/Cuemon.Data.SqlClient.Tests/Cuemon.Data.SqlClient.Tests.csproj +++ b/test/Cuemon.Data.SqlClient.Tests/Cuemon.Data.SqlClient.Tests.csproj @@ -13,7 +13,7 @@ - + diff --git a/test/Cuemon.Data.Tests/Cuemon.Data.Tests.csproj b/test/Cuemon.Data.Tests/Cuemon.Data.Tests.csproj index 3ebfe912a..1564a0fc0 100644 --- a/test/Cuemon.Data.Tests/Cuemon.Data.Tests.csproj +++ b/test/Cuemon.Data.Tests/Cuemon.Data.Tests.csproj @@ -33,7 +33,7 @@ - + @@ -51,13 +51,13 @@ + - - + diff --git a/test/Cuemon.Data.Tests/UniqueIndexViolationExceptionTest.cs b/test/Cuemon.Data.Tests/UniqueIndexViolationExceptionTest.cs index d63e71560..8091993e8 100644 --- a/test/Cuemon.Data.Tests/UniqueIndexViolationExceptionTest.cs +++ b/test/Cuemon.Data.Tests/UniqueIndexViolationExceptionTest.cs @@ -1,7 +1,6 @@ -using Cuemon.Extensions; -using Cuemon.Extensions.IO; -using Codebelt.Extensions.Newtonsoft.Json.Formatters; +using Cuemon.Extensions.IO; using Codebelt.Extensions.Xunit; +using Cuemon.Extensions.Text.Json.Formatters; using Xunit; using Xunit.Abstractions; @@ -18,7 +17,7 @@ public void UniqueIndexViolationException_ShouldBeSerializable_Json() { var random = Generate.RandomString(10); var sut1 = new UniqueIndexViolationException(random); - var sut2 = new NewtonsoftJsonFormatter(); + var sut2 = new JsonFormatter(); var sut3 = sut2.Serialize(sut1); var sut4 = sut3.ToEncodedString(o => o.LeaveOpen = true); diff --git a/test/Cuemon.Extensions.AspNetCore.Authentication.AwsSignature4.Tests/Cuemon.Extensions.AspNetCore.Authentication.AwsSignature4.Tests.csproj b/test/Cuemon.Extensions.AspNetCore.Authentication.AwsSignature4.Tests/Cuemon.Extensions.AspNetCore.Authentication.AwsSignature4.Tests.csproj index 5ac61a999..a9d10a62c 100644 --- a/test/Cuemon.Extensions.AspNetCore.Authentication.AwsSignature4.Tests/Cuemon.Extensions.AspNetCore.Authentication.AwsSignature4.Tests.csproj +++ b/test/Cuemon.Extensions.AspNetCore.Authentication.AwsSignature4.Tests/Cuemon.Extensions.AspNetCore.Authentication.AwsSignature4.Tests.csproj @@ -10,7 +10,7 @@ - + diff --git a/test/Cuemon.Extensions.AspNetCore.Authentication.Tests/AuthorizationResponseHandlerTest.cs b/test/Cuemon.Extensions.AspNetCore.Authentication.Tests/AuthorizationResponseHandlerTest.cs index 5085e7880..2e6b812dd 100644 --- a/test/Cuemon.Extensions.AspNetCore.Authentication.Tests/AuthorizationResponseHandlerTest.cs +++ b/test/Cuemon.Extensions.AspNetCore.Authentication.Tests/AuthorizationResponseHandlerTest.cs @@ -10,7 +10,6 @@ using Cuemon.Collections.Generic; using Cuemon.Diagnostics; using Cuemon.Extensions.AspNetCore.Diagnostics; -using Codebelt.Extensions.AspNetCore.Newtonsoft.Json.Formatters; using Cuemon.Extensions.AspNetCore.Text.Json.Formatters; using Cuemon.Extensions.AspNetCore.Xml.Formatters; using Codebelt.Extensions.Xunit; @@ -441,95 +440,6 @@ public async void AuthorizationResponseHandler_BasicScheme_ShouldRenderResponseI } } - [Theory] - [InlineData(FaultSensitivityDetails.All)] - [InlineData(FaultSensitivityDetails.None)] - public async void AuthorizationResponseHandler_BasicScheme_ShouldRenderResponseInJsonByNewtonsoft_UsingAspNetBootstrapping(FaultSensitivityDetails sensitivityDetails) - { - using (var startup = WebHostTestFactory.Create(services => - { - services.AddNewtonsoftJsonExceptionResponseFormatter(); - services.AddAuthorizationResponseHandler(); - services.AddAuthentication(BasicAuthorizationHeader.Scheme) - .AddBasic(o => - { - o.RequireSecureConnection = false; - o.Authenticator = (username, password) => null; - }); - services.AddAuthorization(o => - { - o.FallbackPolicy = new AuthorizationPolicyBuilder() - .AddAuthenticationSchemes(BasicAuthorizationHeader.Scheme) - .RequireAuthenticatedUser() - .Build(); - - }); - services.AddRouting(); - services.PostConfigureAllExceptionDescriptorOptions(o => o.SensitivityDetails = sensitivityDetails); - }, app => - { - app.UseRouting(); - app.UseAuthentication(); - app.UseAuthorization(); - app.UseEndpoints(endpoints => - { - endpoints.MapGet("/", context => context.Response.WriteAsync($"Hello {context.User.Identity!.Name}")); - }); - })) - { - var client = startup.Host.GetTestClient(); - var bb = new BasicAuthorizationHeaderBuilder() - .AddUserName("Agent") - .AddPassword("Test"); - - client.DefaultRequestHeaders.Add(HeaderNames.Authorization, bb.Build().ToString()); - client.DefaultRequestHeaders.Add(HeaderNames.Accept, "application/json"); - - var result = await client.GetAsync("/"); - var content = await result.Content.ReadAsStringAsync(); - - TestOutput.WriteLine(content); - - Assert.Equal(HttpStatusCode.Unauthorized, result.StatusCode); - Assert.Equal("Basic realm=\"AuthenticationServer\"", result.Headers.WwwAuthenticate.ToString()); - if (sensitivityDetails == FaultSensitivityDetails.All) - { - Assert.Equal(""" - { - "error": { - "status": 401, - "code": "Unauthorized", - "message": "The request has not been applied because it lacks valid authentication credentials for the target resource.", - "failure": { - "type": "Cuemon.AspNetCore.Http.UnauthorizedException", - "message": "The request has not been applied because it lacks valid authentication credentials for the target resource.", - "headers": {}, - "statusCode": 401, - "reasonPhrase": "Unauthorized", - "inner": { - "type": "System.Security.SecurityException", - "message": "Unable to authenticate Agent." - } - } - } - } - """.ReplaceLineEndings(), content.ReplaceLineEndings()); - } - else - { - Assert.Equal(""" - { - "error": { - "status": 401, - "code": "Unauthorized", - "message": "The request has not been applied because it lacks valid authentication credentials for the target resource." - } - } - """.ReplaceLineEndings(), content.ReplaceLineEndings()); - } - } - } - [Fact] public async void AuthorizationResponseHandler_BasicScheme_ShouldAuthorizeWithTestAgent_UsingAspNetBootstrapping() { diff --git a/test/Cuemon.Extensions.AspNetCore.Authentication.Tests/Cuemon.Extensions.AspNetCore.Authentication.Tests.csproj b/test/Cuemon.Extensions.AspNetCore.Authentication.Tests/Cuemon.Extensions.AspNetCore.Authentication.Tests.csproj index ddd24dcb3..a01a3b64e 100644 --- a/test/Cuemon.Extensions.AspNetCore.Authentication.Tests/Cuemon.Extensions.AspNetCore.Authentication.Tests.csproj +++ b/test/Cuemon.Extensions.AspNetCore.Authentication.Tests/Cuemon.Extensions.AspNetCore.Authentication.Tests.csproj @@ -13,8 +13,7 @@ - - + diff --git a/test/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json.Tests/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json.Tests.csproj b/test/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json.Tests/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json.Tests.csproj index 492a265dd..0c38f8efa 100644 --- a/test/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json.Tests/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json.Tests.csproj +++ b/test/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json.Tests/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Text.Json.Tests.csproj @@ -11,7 +11,7 @@ - + diff --git a/test/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml.Tests/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml.Tests.csproj b/test/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml.Tests/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml.Tests.csproj index 43352190f..76cedbe7a 100644 --- a/test/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml.Tests/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml.Tests.csproj +++ b/test/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml.Tests/Cuemon.Extensions.AspNetCore.Mvc.Formatters.Xml.Tests.csproj @@ -11,7 +11,7 @@ - + diff --git a/test/Cuemon.Extensions.AspNetCore.Mvc.RazorPages.Tests/Cuemon.Extensions.AspNetCore.Mvc.RazorPages.Tests.csproj b/test/Cuemon.Extensions.AspNetCore.Mvc.RazorPages.Tests/Cuemon.Extensions.AspNetCore.Mvc.RazorPages.Tests.csproj index 77d2a4f8d..24527a0cc 100644 --- a/test/Cuemon.Extensions.AspNetCore.Mvc.RazorPages.Tests/Cuemon.Extensions.AspNetCore.Mvc.RazorPages.Tests.csproj +++ b/test/Cuemon.Extensions.AspNetCore.Mvc.RazorPages.Tests/Cuemon.Extensions.AspNetCore.Mvc.RazorPages.Tests.csproj @@ -11,7 +11,7 @@ - + diff --git a/test/Cuemon.Extensions.AspNetCore.Mvc.Tests/Cuemon.Extensions.AspNetCore.Mvc.Tests.csproj b/test/Cuemon.Extensions.AspNetCore.Mvc.Tests/Cuemon.Extensions.AspNetCore.Mvc.Tests.csproj index 0b77d2539..2140b16f2 100644 --- a/test/Cuemon.Extensions.AspNetCore.Mvc.Tests/Cuemon.Extensions.AspNetCore.Mvc.Tests.csproj +++ b/test/Cuemon.Extensions.AspNetCore.Mvc.Tests/Cuemon.Extensions.AspNetCore.Mvc.Tests.csproj @@ -13,7 +13,7 @@ - + diff --git a/test/Cuemon.Extensions.AspNetCore.Tests/Cuemon.Extensions.AspNetCore.Tests.csproj b/test/Cuemon.Extensions.AspNetCore.Tests/Cuemon.Extensions.AspNetCore.Tests.csproj index 6008b9e88..37a6b3bd0 100644 --- a/test/Cuemon.Extensions.AspNetCore.Tests/Cuemon.Extensions.AspNetCore.Tests.csproj +++ b/test/Cuemon.Extensions.AspNetCore.Tests/Cuemon.Extensions.AspNetCore.Tests.csproj @@ -17,8 +17,7 @@ - - + diff --git a/test/Cuemon.Extensions.AspNetCore.Tests/Diagnostics/ServiceProviderExtensionsTest.cs b/test/Cuemon.Extensions.AspNetCore.Tests/Diagnostics/ServiceProviderExtensionsTest.cs index 38627f699..6fa9b2fa1 100644 --- a/test/Cuemon.Extensions.AspNetCore.Tests/Diagnostics/ServiceProviderExtensionsTest.cs +++ b/test/Cuemon.Extensions.AspNetCore.Tests/Diagnostics/ServiceProviderExtensionsTest.cs @@ -1,6 +1,5 @@ using System; using System.Linq; -using Codebelt.Extensions.AspNetCore.Newtonsoft.Json.Formatters; using Cuemon.Extensions.AspNetCore.Text.Json.Formatters; using Cuemon.Extensions.AspNetCore.Xml.Formatters; using Codebelt.Extensions.Xunit; @@ -24,7 +23,6 @@ public void GetExceptionResponseFormatters_ShouldGetAllRegisteredServicesOf_IExc services.AddOptions(); services.AddXmlExceptionResponseFormatter(); services.AddJsonExceptionResponseFormatter(); - services.AddNewtonsoftJsonExceptionResponseFormatter(); var serviceProvider = services.BuildServiceProvider(); @@ -34,7 +32,7 @@ public void GetExceptionResponseFormatters_ShouldGetAllRegisteredServicesOf_IExc TestOutput.WriteLine(formattersAndResponseHandlers.ToDelimitedString(o => o.Delimiter = Environment.NewLine)); - Assert.Equal(9, formattersAndResponseHandlers.Count); + Assert.Equal(6, formattersAndResponseHandlers.Count); Assert.Equal(""" XmlFormatterOptions -> application/xml XmlFormatterOptions -> text/xml @@ -42,9 +40,6 @@ public void GetExceptionResponseFormatters_ShouldGetAllRegisteredServicesOf_IExc JsonFormatterOptions -> application/json JsonFormatterOptions -> text/json JsonFormatterOptions -> application/problem+json - NewtonsoftJsonFormatterOptions -> application/json - NewtonsoftJsonFormatterOptions -> text/json - NewtonsoftJsonFormatterOptions -> application/problem+json """.ReplaceLineEndings(), formattersAndResponseHandlers.ToDelimitedString(o => o.Delimiter = Environment.NewLine)); } } diff --git a/test/Cuemon.Extensions.DependencyInjection.Tests/Cuemon.Extensions.DependencyInjection.Tests.csproj b/test/Cuemon.Extensions.DependencyInjection.Tests/Cuemon.Extensions.DependencyInjection.Tests.csproj index cd50fab42..608a6836e 100644 --- a/test/Cuemon.Extensions.DependencyInjection.Tests/Cuemon.Extensions.DependencyInjection.Tests.csproj +++ b/test/Cuemon.Extensions.DependencyInjection.Tests/Cuemon.Extensions.DependencyInjection.Tests.csproj @@ -16,8 +16,4 @@ - - - - diff --git a/test/Cuemon.Extensions.DependencyInjection.Tests/ServiceCollectionExtensionsTest.cs b/test/Cuemon.Extensions.DependencyInjection.Tests/ServiceCollectionExtensionsTest.cs index 1ffe54185..4738dd980 100644 --- a/test/Cuemon.Extensions.DependencyInjection.Tests/ServiceCollectionExtensionsTest.cs +++ b/test/Cuemon.Extensions.DependencyInjection.Tests/ServiceCollectionExtensionsTest.cs @@ -3,7 +3,6 @@ #if NET8_0_OR_GREATER using Cuemon.AspNetCore.Diagnostics; using Cuemon.AspNetCore.Mvc.Filters.Diagnostics; -using Codebelt.Extensions.Newtonsoft.Json.Formatters; using Cuemon.Extensions.Text.Json.Formatters; using Cuemon.Xml.Serialization.Formatters; #endif @@ -387,7 +386,7 @@ public void TryAdd_ShouldAddServiceToServiceCollectionUsingFactoryWithSpecifiedL Assert.Null(sut9); } -#if NET6_0_OR_GREATER +#if NET8_0_OR_GREATER [Fact] public void TryConfigure_ShouldAddConfigureOptions() @@ -462,11 +461,6 @@ public void SynchronizeOptions_ShouldNotChangeAnything_ValuesAreAsConfigured() o.Settings.DefaultBufferSize = 4096; o.SensitivityDetails = FaultSensitivityDetails.Failure; }) - .Configure(o => - { - o.Settings.MaxDepth = 16; - o.SensitivityDetails = FaultSensitivityDetails.All; - }) .Configure(o => { o.Settings.Writer.Async = true; @@ -489,7 +483,6 @@ public void SynchronizeOptions_ShouldNotChangeAnything_ValuesAreAsConfigured() var serviceProvider = services.BuildServiceProvider(); var jsonFormatterOptions = serviceProvider.GetRequiredService>().Value; - var newtonsoftJsonFormatterOptions = serviceProvider.GetRequiredService>().Value; var xmlFormatterOptions = serviceProvider.GetRequiredService>().Value; var faultDescriptorOptions = serviceProvider.GetRequiredService>().Value; var mvcFaultDescriptorOptions = serviceProvider.GetRequiredService>().Value; @@ -498,9 +491,6 @@ public void SynchronizeOptions_ShouldNotChangeAnything_ValuesAreAsConfigured() Assert.Equal(FaultSensitivityDetails.Failure, jsonFormatterOptions.SensitivityDetails); Assert.Equal(4096, jsonFormatterOptions.Settings.DefaultBufferSize); - Assert.Equal(FaultSensitivityDetails.All, newtonsoftJsonFormatterOptions.SensitivityDetails); - Assert.Equal(16, newtonsoftJsonFormatterOptions.Settings.MaxDepth); - Assert.Equal(FaultSensitivityDetails.Evidence, xmlFormatterOptions.SensitivityDetails); Assert.True(xmlFormatterOptions.Settings.Writer.Async); @@ -525,11 +515,6 @@ public void SynchronizeOptions_ShouldChangeAllWithAServiceTypeHavingIExceptionDe o.Settings.DefaultBufferSize = 4096; o.SensitivityDetails = FaultSensitivityDetails.Failure; }) - .Configure(o => - { - o.Settings.MaxDepth = 16; - o.SensitivityDetails = FaultSensitivityDetails.All; - }) .Configure(o => { o.Settings.Writer.Async = true; @@ -556,7 +541,6 @@ public void SynchronizeOptions_ShouldChangeAllWithAServiceTypeHavingIExceptionDe var serviceProvider = services.BuildServiceProvider(); var jsonFormatterOptions = serviceProvider.GetRequiredService>().Value; - var newtonsoftJsonFormatterOptions = serviceProvider.GetRequiredService>().Value; var xmlFormatterOptions = serviceProvider.GetRequiredService>().Value; var faultDescriptorOptions = serviceProvider.GetRequiredService>().Value; var mvcFaultDescriptorOptions = serviceProvider.GetRequiredService>().Value; @@ -565,9 +549,6 @@ public void SynchronizeOptions_ShouldChangeAllWithAServiceTypeHavingIExceptionDe Assert.Equal(FaultSensitivityDetails.None, jsonFormatterOptions.SensitivityDetails); Assert.Equal(4096, jsonFormatterOptions.Settings.DefaultBufferSize); - Assert.Equal(FaultSensitivityDetails.None, newtonsoftJsonFormatterOptions.SensitivityDetails); - Assert.Equal(16, newtonsoftJsonFormatterOptions.Settings.MaxDepth); - Assert.Equal(FaultSensitivityDetails.None, xmlFormatterOptions.SensitivityDetails); Assert.True(xmlFormatterOptions.Settings.Writer.Async); @@ -579,7 +560,7 @@ public void SynchronizeOptions_ShouldChangeAllWithAServiceTypeHavingIExceptionDe Assert.Equal(FaultSensitivityDetails.None, exceptionDescriptorOptions.SensitivityDetails); - Assert.Equal(6, invocationCount); + Assert.Equal(5, invocationCount); } [Fact] @@ -592,11 +573,6 @@ public void SynchronizeOptions_ShouldChangeAllWithAServiceTypeHavingFaultDescrip o.Settings.DefaultBufferSize = 4096; o.SensitivityDetails = FaultSensitivityDetails.Failure; }) - .Configure(o => - { - o.Settings.MaxDepth = 16; - o.SensitivityDetails = FaultSensitivityDetails.All; - }) .Configure(o => { o.Settings.Writer.Async = true; @@ -624,7 +600,6 @@ public void SynchronizeOptions_ShouldChangeAllWithAServiceTypeHavingFaultDescrip var serviceProvider = services.BuildServiceProvider(); var jsonFormatterOptions = serviceProvider.GetRequiredService>().Value; - var newtonsoftJsonFormatterOptions = serviceProvider.GetRequiredService>().Value; var xmlFormatterOptions = serviceProvider.GetRequiredService>().Value; var faultDescriptorOptions = serviceProvider.GetRequiredService>().Value; var mvcFaultDescriptorOptions = serviceProvider.GetRequiredService>().Value; @@ -633,9 +608,6 @@ public void SynchronizeOptions_ShouldChangeAllWithAServiceTypeHavingFaultDescrip Assert.Equal(FaultSensitivityDetails.Failure, jsonFormatterOptions.SensitivityDetails); Assert.Equal(4096, jsonFormatterOptions.Settings.DefaultBufferSize); - Assert.Equal(FaultSensitivityDetails.All, newtonsoftJsonFormatterOptions.SensitivityDetails); - Assert.Equal(16, newtonsoftJsonFormatterOptions.Settings.MaxDepth); - Assert.Equal(FaultSensitivityDetails.Evidence, xmlFormatterOptions.SensitivityDetails); Assert.True(xmlFormatterOptions.Settings.Writer.Async); diff --git a/test/Cuemon.Extensions.Hosting.Tests/Cuemon.Extensions.Hosting.Tests.csproj b/test/Cuemon.Extensions.Hosting.Tests/Cuemon.Extensions.Hosting.Tests.csproj index 3594a20ef..0e28ed459 100644 --- a/test/Cuemon.Extensions.Hosting.Tests/Cuemon.Extensions.Hosting.Tests.csproj +++ b/test/Cuemon.Extensions.Hosting.Tests/Cuemon.Extensions.Hosting.Tests.csproj @@ -9,7 +9,7 @@ - + diff --git a/test/Cuemon.Extensions.Hosting.Tests/HostEnvironmentExtensionsTest.cs b/test/Cuemon.Extensions.Hosting.Tests/HostEnvironmentExtensionsTest.cs index d53f4683d..43a7dc543 100644 --- a/test/Cuemon.Extensions.Hosting.Tests/HostEnvironmentExtensionsTest.cs +++ b/test/Cuemon.Extensions.Hosting.Tests/HostEnvironmentExtensionsTest.cs @@ -24,7 +24,7 @@ public override void ConfigureServices(IServiceCollection services) [Fact] public void IsLocalDevelopment_VerifyEnvironmentEqualsLocalDevelopment() { -#if NET6_0_OR_GREATER +#if NET8_0_OR_GREATER Assert.True(HostingEnvironment.IsLocalDevelopment()); Assert.False(HostingEnvironment.IsProduction()); Assert.False(HostingEnvironment.IsStaging()); @@ -41,7 +41,7 @@ public void IsLocalDevelopment_VerifyEnvironmentEqualsLocalDevelopment() [Fact] public void IsLocalDevelopment_VerifyEnvironmentIsNonProduction() { -#if NET6_0_OR_GREATER +#if NET8_0_OR_GREATER Assert.True(HostingEnvironment.IsNonProduction()); Assert.False(HostingEnvironment.IsProduction()); #else diff --git a/test/Cuemon.Extensions.IO.Tests/StreamExtensionsTest.cs b/test/Cuemon.Extensions.IO.Tests/StreamExtensionsTest.cs index e137e3833..541ca3b89 100644 --- a/test/Cuemon.Extensions.IO.Tests/StreamExtensionsTest.cs +++ b/test/Cuemon.Extensions.IO.Tests/StreamExtensionsTest.cs @@ -219,7 +219,7 @@ public async Task ToEncodedStringAsync_ShouldConvertStreamToUnicodeEncodedString Assert.Equal(636, sut6.Length); } -#if NET6_0_OR_GREATER +#if NET8_0_OR_GREATER [Fact] public void CompressBrotli_ShouldCompressAndDecompress() diff --git a/test/Cuemon.Extensions.IO.Tests/TextReaderExtensionsTest.cs b/test/Cuemon.Extensions.IO.Tests/TextReaderExtensionsTest.cs index b43bfd569..703c655e5 100644 --- a/test/Cuemon.Extensions.IO.Tests/TextReaderExtensionsTest.cs +++ b/test/Cuemon.Extensions.IO.Tests/TextReaderExtensionsTest.cs @@ -26,7 +26,7 @@ public async Task CopyToAsync_ShouldCopyContentOfReaderToWriter() sut2.Dispose(); -#if NET6_0_OR_GREATER +#if NET8_0_OR_GREATER await sut3.DisposeAsync(); await sut4.DisposeAsync(); #else diff --git a/test/Cuemon.Extensions.Runtime.Caching.Tests/Cuemon.Extensions.Runtime.Caching.Tests.csproj b/test/Cuemon.Extensions.Runtime.Caching.Tests/Cuemon.Extensions.Runtime.Caching.Tests.csproj index 38f070a6a..de31ed191 100644 --- a/test/Cuemon.Extensions.Runtime.Caching.Tests/Cuemon.Extensions.Runtime.Caching.Tests.csproj +++ b/test/Cuemon.Extensions.Runtime.Caching.Tests/Cuemon.Extensions.Runtime.Caching.Tests.csproj @@ -9,7 +9,7 @@ - + \ No newline at end of file diff --git a/test/Cuemon.IO.Tests/StreamDecoratorExtensionsTest.cs b/test/Cuemon.IO.Tests/StreamDecoratorExtensionsTest.cs index 125e343fe..2213bca6b 100644 --- a/test/Cuemon.IO.Tests/StreamDecoratorExtensionsTest.cs +++ b/test/Cuemon.IO.Tests/StreamDecoratorExtensionsTest.cs @@ -16,7 +16,7 @@ public StreamDecoratorExtensionsTest(ITestOutputHelper output) : base(output) { } -#if NET6_0_OR_GREATER +#if NET8_0_OR_GREATER [Fact] public void CompressBrotli_ShouldCompressAndDecompress() diff --git a/test/Cuemon.Resilience.Tests/Cuemon.Resilience.Tests.csproj b/test/Cuemon.Resilience.Tests/Cuemon.Resilience.Tests.csproj index 7669a150e..b58a58d0e 100644 --- a/test/Cuemon.Resilience.Tests/Cuemon.Resilience.Tests.csproj +++ b/test/Cuemon.Resilience.Tests/Cuemon.Resilience.Tests.csproj @@ -12,11 +12,8 @@ + - - - - diff --git a/test/Cuemon.Resilience.Tests/LatencyExceptionExceptionTest.cs b/test/Cuemon.Resilience.Tests/LatencyExceptionExceptionTest.cs index 5d91ac519..042950ba7 100644 --- a/test/Cuemon.Resilience.Tests/LatencyExceptionExceptionTest.cs +++ b/test/Cuemon.Resilience.Tests/LatencyExceptionExceptionTest.cs @@ -1,7 +1,6 @@ -using Cuemon.Extensions; -using Cuemon.Extensions.IO; -using Codebelt.Extensions.Newtonsoft.Json.Formatters; +using Cuemon.Extensions.IO; using Codebelt.Extensions.Xunit; +using Cuemon.Extensions.Text.Json.Formatters; using Xunit; using Xunit.Abstractions; @@ -18,7 +17,7 @@ public void LatencyExceptionException_ShouldBeSerializable_Json() { var random = Generate.RandomString(10); var sut1 = new LatencyException(random); - var sut2 = new NewtonsoftJsonFormatter(); + var sut2 = new JsonFormatter(); var sut3 = sut2.Serialize(sut1); var sut4 = sut3.ToEncodedString(o => o.LeaveOpen = true); diff --git a/test/Cuemon.Resilience.Tests/TransientFaultExceptionTest.cs b/test/Cuemon.Resilience.Tests/TransientFaultExceptionTest.cs index fed985c98..bf52d167c 100644 --- a/test/Cuemon.Resilience.Tests/TransientFaultExceptionTest.cs +++ b/test/Cuemon.Resilience.Tests/TransientFaultExceptionTest.cs @@ -1,10 +1,9 @@ using System; using System.Collections.Generic; using System.Reflection; -using Cuemon.Extensions; using Cuemon.Extensions.IO; -using Codebelt.Extensions.Newtonsoft.Json.Formatters; using Codebelt.Extensions.Xunit; +using Cuemon.Extensions.Text.Json.Formatters; using Cuemon.Reflection; using Xunit; using Xunit.Abstractions; @@ -22,7 +21,7 @@ public TransientFaultExceptionTest(ITestOutputHelper output) : base(output) public void TransientFaultException_ShouldBeSerializable_Json(string random) { var sut1 = new TransientFaultException(random, new TransientFaultEvidence(10, TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(2), MethodDescriptor.Create(MethodBase.GetCurrentMethod()).AppendRuntimeArguments(random))); - var sut2 = new NewtonsoftJsonFormatter(); + var sut2 = new JsonFormatter(); var sut3 = sut2.Serialize(sut1); var sut4 = sut3.ToEncodedString(o => o.LeaveOpen = true); @@ -63,7 +62,7 @@ public void TransientFaultException_ShouldBeSerializable_Json(string random) public void TransientFaultException_WithInnerException_ShouldBeSerializable_Json() { var sut1 = new TransientFaultException("The transient operation has failed.", new ArithmeticException(), new TransientFaultEvidence(10, TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(2), MethodDescriptor.Create(MethodBase.GetCurrentMethod()))); - var sut2 = new NewtonsoftJsonFormatter(); + var sut2 = new JsonFormatter(); var sut3 = sut2.Serialize(sut1); var sut4 = sut3.ToEncodedString(o => o.LeaveOpen = true); diff --git a/test/Cuemon.Runtime.Caching.Tests/Cuemon.Runtime.Caching.Tests.csproj b/test/Cuemon.Runtime.Caching.Tests/Cuemon.Runtime.Caching.Tests.csproj index 29f02bb16..6a3ffb647 100644 --- a/test/Cuemon.Runtime.Caching.Tests/Cuemon.Runtime.Caching.Tests.csproj +++ b/test/Cuemon.Runtime.Caching.Tests/Cuemon.Runtime.Caching.Tests.csproj @@ -15,7 +15,7 @@ - + \ No newline at end of file diff --git a/test/Cuemon.Security.Cryptography.Tests/UnkeyedHashFactoryTest.cs b/test/Cuemon.Security.Cryptography.Tests/UnkeyedHashFactoryTest.cs index 2009ddbd2..8b0646ad3 100644 --- a/test/Cuemon.Security.Cryptography.Tests/UnkeyedHashFactoryTest.cs +++ b/test/Cuemon.Security.Cryptography.Tests/UnkeyedHashFactoryTest.cs @@ -36,7 +36,7 @@ public void CreateCryptoSha256_ShouldBeValidHashResult() Assert.Equal("db4bfcbd4da0cd85a60c3c37d3fbd8805c77f15fc6b1fdfe614ee0a7c8fdb4c0", h.ComputeHash(Alphanumeric.LettersAndNumbers).ToHexadecimalString()); Assert.Equal("db4bfcbd4da0cd85a60c3c37d3fbd8805c77f15fc6b1fdfe614ee0a7c8fdb4c0", h.ComputeHash(Decorator.Enclose(Alphanumeric.LettersAndNumbers).ToStream()).ToHexadecimalString()); Assert.Equal("84d89877f0d4041efb6bf91a16f0248f2fd573e6af05c19f96bedb9f882f7882", h.ComputeHash(Alphanumeric.Numbers).ToHexadecimalString()); -#if NET6_0_OR_GREATER +#if NET8_0_OR_GREATER Assert.Equal("53ab3a50f51855beeae9721ab68656312c7f105b9b34bbfa97875dbfda72dbc6", h.ComputeHash(DateTime.UnixEpoch).ToHexadecimalString()); #endif Assert.Equal("1f1a24c833be74a0f4f99007aa70a51e2456e41f745a5628721ea2b8e1c07641", h.ComputeHash(213, "fdfsfsf", 9999).ToHexadecimalString()); diff --git a/tooling/gse/gse.csproj b/tooling/gse/gse.csproj index fe25f93ef..0f5630575 100644 --- a/tooling/gse/gse.csproj +++ b/tooling/gse/gse.csproj @@ -19,7 +19,7 @@ - +