diff --git a/src/Arcturus.Extensions.ResultObjects.AspNetCore/ActionResults/ProblemDetailsActionResult.cs b/src/Arcturus.Extensions.ResultObjects.AspNetCore/ActionResults/ProblemDetailsActionResult.cs index a32786f..0cdb5c2 100644 --- a/src/Arcturus.Extensions.ResultObjects.AspNetCore/ActionResults/ProblemDetailsActionResult.cs +++ b/src/Arcturus.Extensions.ResultObjects.AspNetCore/ActionResults/ProblemDetailsActionResult.cs @@ -17,15 +17,12 @@ public Task ExecuteResultAsync(ActionContext context) { HttpStatusCode defaultStatusCode = _result.HttpStatusCode ?? HttpStatusCode.BadRequest; - //var cts = new ProblemDetailsContext() - //{ - // HttpContext = context.HttpContext - //}; var factory = context.HttpContext.RequestServices.GetService(); var problemDetails = factory!.CreateProblemDetails(context.HttpContext, (int)defaultStatusCode); problemDetails.Type ??= "https://schemas/2022/fault/#" + defaultStatusCode.ToString().ToLower(); problemDetails.Title ??= _result.Fault?.Code; problemDetails.Detail = _result.Fault?.Message; + problemDetails.Instance = $"{context.HttpContext.Request.Method} {context.HttpContext.Request.Path}"; //if (_properties?.Length > 0) //{ // prbml.Extensions.Add("fields", _properties.ToKeyValueList(_ => _.Code, _ => _.Message)); diff --git a/src/Arcturus.Extensions.ResultObjects.AspNetCore/Arcturus.Extensions.ResultObjects.AspNetCore.csproj b/src/Arcturus.Extensions.ResultObjects.AspNetCore/Arcturus.Extensions.ResultObjects.AspNetCore.csproj index 0aa89bb..85ea6f0 100644 --- a/src/Arcturus.Extensions.ResultObjects.AspNetCore/Arcturus.Extensions.ResultObjects.AspNetCore.csproj +++ b/src/Arcturus.Extensions.ResultObjects.AspNetCore/Arcturus.Extensions.ResultObjects.AspNetCore.csproj @@ -4,6 +4,12 @@ Arcturus.Extensions.ResultObjects.AspNetCore MIT result,resultobject,aspnetcore,arcturus + true + $(NoWarn);1591 + + + + bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml diff --git a/src/Arcturus.Extensions.ResultObjects.AspNetCore/Internals/JsonSerializerExtensions.cs b/src/Arcturus.Extensions.ResultObjects.AspNetCore/Internals/JsonSerializerExtensions.cs index 5e7cf78..cc1e869 100644 --- a/src/Arcturus.Extensions.ResultObjects.AspNetCore/Internals/JsonSerializerExtensions.cs +++ b/src/Arcturus.Extensions.ResultObjects.AspNetCore/Internals/JsonSerializerExtensions.cs @@ -7,18 +7,18 @@ namespace Arcturus.Extensions.ResultObjects.AspNetCore.Internals; internal static class JsonSerializerExtensions { - public static bool HasKnownPolymorphism(this JsonTypeInfo jsonTypeInfo) + internal static bool HasKnownPolymorphism(this JsonTypeInfo jsonTypeInfo) => jsonTypeInfo.Type.IsSealed || jsonTypeInfo.Type.IsValueType || jsonTypeInfo.PolymorphismOptions is not null; - public static bool ShouldUseWith(this JsonTypeInfo jsonTypeInfo, [NotNullWhen(false)] Type? runtimeType) + internal static bool ShouldUseWith(this JsonTypeInfo jsonTypeInfo, [NotNullWhen(false)] Type? runtimeType) => runtimeType is null || jsonTypeInfo.Type == runtimeType || jsonTypeInfo.HasKnownPolymorphism(); - public static JsonTypeInfo GetReadOnlyTypeInfo(this JsonSerializerOptions options, Type type) + internal static JsonTypeInfo GetReadOnlyTypeInfo(this JsonSerializerOptions options, Type type) { options.MakeReadOnly(); return options.GetTypeInfo(type); } - public static JsonTypeInfo GetRequiredTypeInfo(this JsonSerializerContext context, Type type) + internal static JsonTypeInfo GetRequiredTypeInfo(this JsonSerializerContext context, Type type) => context.GetTypeInfo(type) ?? throw new InvalidOperationException($"Unable to obtain the JsonTypeInfo for type '{type.FullName}' from the context '{context.GetType().FullName}'."); } diff --git a/src/Arcturus.Extensions.ResultObjects.AspNetCore/ResultExtensions.cs b/src/Arcturus.Extensions.ResultObjects.AspNetCore/ResultExtensions.cs index f413fe5..316f98f 100644 --- a/src/Arcturus.Extensions.ResultObjects.AspNetCore/ResultExtensions.cs +++ b/src/Arcturus.Extensions.ResultObjects.AspNetCore/ResultExtensions.cs @@ -31,10 +31,10 @@ public static IActionResult ToActionResult(this Result result) result.WithHttpStatusCode(_defaultStatusCode)); } /// - /// + /// Converts a object to an object. /// - /// - /// + /// The object to convert. + /// An object representing the result. public static IActionResult ToActionResult(this Result result) { if (result.IsSuccess && result.HttpStatusCode is null) @@ -52,10 +52,10 @@ public static IActionResult ToActionResult(this Result result) } /// - /// + /// Converts a Task of object to an object. /// - /// - /// + /// The object to convert. + /// An object representing the result. public async static Task ToActionResult(this Task result) => (await result).ToActionResult(); /// diff --git a/src/Arcturus.Extensions.ResultObjects.AspNetCore/Results/ProblemDetailsResult.cs b/src/Arcturus.Extensions.ResultObjects.AspNetCore/Results/ProblemDetailsResult.cs index fed3fae..c0313fb 100644 --- a/src/Arcturus.Extensions.ResultObjects.AspNetCore/Results/ProblemDetailsResult.cs +++ b/src/Arcturus.Extensions.ResultObjects.AspNetCore/Results/ProblemDetailsResult.cs @@ -17,14 +17,13 @@ public Task ExecuteAsync(HttpContext httpContext) { HttpStatusCode defaultStatusCode = _result.HttpStatusCode ?? HttpStatusCode.BadRequest; - //var factory1 = httpContext.RequestServices.GetService(); var factory = httpContext.RequestServices.GetService(); var problemDetails = factory!.CreateProblemDetails(httpContext, (int)defaultStatusCode); problemDetails.Title ??= _result.Fault?.Code; problemDetails.Detail = _result.Fault?.Message; problemDetails.Type ??= "https://schemas/2022/fault/#" + defaultStatusCode.ToString().ToLower(); - + problemDetails.Instance = $"{httpContext.Request.Method} {httpContext.Request.Path}"; //var cts = new ProblemDetailsContext() //{ // HttpContext = httpContext diff --git a/src/Arcturus.ResultObjects/Arcturus.ResultObjects.csproj b/src/Arcturus.ResultObjects/Arcturus.ResultObjects.csproj index 2dbba2c..157f96e 100644 --- a/src/Arcturus.ResultObjects/Arcturus.ResultObjects.csproj +++ b/src/Arcturus.ResultObjects/Arcturus.ResultObjects.csproj @@ -3,6 +3,7 @@ Arcturus.ResultObjects result,resultobject,arcturus + MIT true $(NoWarn);1591 diff --git a/src/Arcturus.ResultObjects/ResultExtensions.cs b/src/Arcturus.ResultObjects/ResultExtensions.cs index 4ba8c41..eb5527d 100644 --- a/src/Arcturus.ResultObjects/ResultExtensions.cs +++ b/src/Arcturus.ResultObjects/ResultExtensions.cs @@ -73,7 +73,6 @@ public static Result WithHelpLink(this Result result, string uri) /// /// Assigns a helplink to the result. /// - /// Type of result object. /// Required. /// Url of the help link. ///