Skip to content

Commit

Permalink
Fix ASP0016 warning
Browse files Browse the repository at this point in the history
  • Loading branch information
arenekosreal committed May 15, 2024
1 parent ad21559 commit 281b484
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions E5Renewer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,23 @@
).ConfigureApiBehaviorOptions(
(options) =>
{
options.InvalidModelStateResponseFactory = (actionContext) => GenerateDummyResult(actionContext.HttpContext).Result;
options.InvalidModelStateResponseFactory = (actionContext) =>
{
InvokeResult result = GenerateDummyResult(actionContext.HttpContext).Result;
return new JsonResult(result);
};
}
);
WebApplication app = builder.Build();
app.UseExceptionHandler((exceptionHandlerApp) => exceptionHandlerApp.Run(GenerateDummyResult));
app.UseExceptionHandler(
(exceptionHandlerApp) => exceptionHandlerApp.Run(
async (context) =>
{
InvokeResult result = await GenerateDummyResult(context);
await context.Response.WriteAsJsonAsync(result);
}
)
);
app.UseRouting();
string[] allowedMethods = ["GET", "POST"];
app.Logger.LogDebug("Setting allowed method to {0}", string.Join(", ", allowedMethods));
Expand Down Expand Up @@ -306,7 +318,7 @@ bool IsPortUsed(uint port)
return false;
}

async Task<IActionResult> GenerateDummyResult(HttpContext context)
async Task<InvokeResult> GenerateDummyResult(HttpContext context)
{
IUnixTimestampGenerator unixTimestampGenerator = context.RequestServices.GetRequiredService<IUnixTimestampGenerator>();
Dictionary<string, object?> queries;
Expand Down Expand Up @@ -338,11 +350,10 @@ async Task<IActionResult> GenerateDummyResult(HttpContext context)
firstOfQuote > lastOfSlash ?
fullPath.Substring(lastOfSlash + 1, firstOfQuote - lastOfSlash) :
fullPath.Substring(lastOfSlash + 1);
return new JsonResult(new InvokeResult(
return new InvokeResult(
methodName,
queries,
null,
unixTimestampGenerator.GetUnixTimestamp()
)
);
);
}

0 comments on commit 281b484

Please sign in to comment.