Skip to content

Commit 7b4cb60

Browse files
Replace registered IProblemDetailsWriter in-place at the same index. Fixes #1135
1 parent 2271993 commit 7b4cb60

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/AspNetCore/WebApi/src/Asp.Versioning.Http/DependencyInjection/IServiceCollectionExtensions.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ LinkGenerator NewFactory( IServiceProvider serviceProvider )
214214
}
215215
}
216216

217-
// TODO: Remove in .NET 9.0 or .NET 8.0 patch
217+
// TODO: Fixed and released; remove in .NET 10.0
218218
// BUG: https://github.com/dotnet/aspnetcore/issues/52577
219219
private static void TryAddProblemDetailsRfc7231Compliance( IServiceCollection services )
220220
{
@@ -225,11 +225,12 @@ private static void TryAddProblemDetailsRfc7231Compliance( IServiceCollection se
225225
return;
226226
}
227227

228+
var index = services.IndexOf( descriptor );
228229
var decoratedType = descriptor.ImplementationType!;
229230
var lifetime = descriptor.Lifetime;
230231

232+
services[index] = Describe( typeof( IProblemDetailsWriter ), sp => NewProblemDetailsWriter( sp, decoratedType ), lifetime );
231233
services.Add( Describe( decoratedType, decoratedType, lifetime ) );
232-
services.Replace( Describe( typeof( IProblemDetailsWriter ), sp => NewProblemDetailsWriter( sp, decoratedType ), lifetime ) );
233234

234235
static bool IsDefaultProblemDetailsWriter( ServiceDescriptor serviceDescriptor ) =>
235236
serviceDescriptor.ServiceType == typeof( IProblemDetailsWriter ) &&

0 commit comments

Comments
 (0)