khellang / Middleware

Various ASP.NET Core middleware
MIT License
806 stars 110 forks source link

Changes in ASP.NET Core v7 #191

Open lonix1 opened 1 year ago

lonix1 commented 1 year ago

ASP.NET Core v7 has some changes that deal with problem details.

Does anyone know how that impacts the middleware in this library, if at all?

(Is there any overlap now? If you've already upgraded to v7, would you mind advising me whether any changes were necessary, and whether you still use this library, etc.?)

lonix1 commented 1 year ago

I've found at least one problem so far, this used to work:

services.AddProblemDetails().AddProblemDetailsConventions();

But now that gives:

The call is ambiguous between the following methods or properties: 'Microsoft.Extensions.DependencyInjection.ProblemDetailsServiceCollectionExtensions.AddProblemDetails(Microsoft.Extensions.DependencyInjection.IServiceCollection)' and 'Hellang.Middleware.ProblemDetails.ProblemDetailsExtensions.AddProblemDetails(Microsoft.Extensions.DependencyInjection.IServiceCollection)' [MyProject]csharp(CS0121)

Workaround:

Hellang.Middleware.ProblemDetails.ProblemDetailsExtensions
  .AddProblemDetails(services)  
  .AddProblemDetailsConventions();
VictorioBerra commented 1 year ago

I am seeing the same problem. @khellang can you comment on if we need both? Or yours calls the new one? Or yours overrides the new one?

TomBruns commented 1 year ago

As mentioned elsewhere you can do this to resolve the issue: using ProblemDetailsOptions = Hellang.Middleware.ProblemDetails.ProblemDetailsOptions;

This lets the normal syntax work: builder.Services.AddProblemDetails(options =>