Skip to content

Commit 2300123

Browse files
authored
Make ObjectFactory<T> covariant (dotnet#102553)
1 parent 2f81513 commit 2300123

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/libraries/Microsoft.Extensions.DependencyInjection.Abstractions/ref/Microsoft.Extensions.DependencyInjection.Abstractions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public static partial class KeyedService
7373
public static object AnyKey { get { throw null; } }
7474
}
7575
public delegate object ObjectFactory(System.IServiceProvider serviceProvider, object?[]? arguments);
76-
public delegate T ObjectFactory<T>(System.IServiceProvider serviceProvider, object?[]? arguments);
76+
public delegate T ObjectFactory<out T>(System.IServiceProvider serviceProvider, object?[]? arguments);
7777
public partial class ServiceCollection : Microsoft.Extensions.DependencyInjection.IServiceCollection, System.Collections.Generic.ICollection<Microsoft.Extensions.DependencyInjection.ServiceDescriptor>, System.Collections.Generic.IEnumerable<Microsoft.Extensions.DependencyInjection.ServiceDescriptor>, System.Collections.Generic.IList<Microsoft.Extensions.DependencyInjection.ServiceDescriptor>, System.Collections.IEnumerable
7878
{
7979
public ServiceCollection() { }

src/libraries/Microsoft.Extensions.DependencyInjection.Abstractions/src/ObjectFactoryT.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ namespace Microsoft.Extensions.DependencyInjection
1212
/// <param name="serviceProvider">The <see cref="IServiceProvider"/> to get service arguments from.</param>
1313
/// <param name="arguments">Additional constructor arguments.</param>
1414
/// <returns>An instance of type <typeparamref name="T" />.</returns>
15-
public delegate T ObjectFactory<T>(IServiceProvider serviceProvider, object?[]? arguments);
15+
public delegate T ObjectFactory<out T>(IServiceProvider serviceProvider, object?[]? arguments);
1616
}

0 commit comments

Comments
 (0)