diff --git a/src/Scrutor/ServiceTypeSelector.cs b/src/Scrutor/ServiceTypeSelector.cs index 0637d6e7..c8251b92 100644 --- a/src/Scrutor/ServiceTypeSelector.cs +++ b/src/Scrutor/ServiceTypeSelector.cs @@ -20,13 +20,13 @@ public ServiceTypeSelector(IImplementationTypeSelector inner, ISet types) private ISet Types { get; } - private List Selectors { get; } = new(); + private List Selectors { get; } = []; private RegistrationStrategy? RegistrationStrategy { get; set; } public ILifetimeSelector AsSelf() { - return As(t => new[] { t }); + return As(t => [t]); } public ILifetimeSelector As() @@ -45,7 +45,7 @@ public ILifetimeSelector As(IEnumerable types) { Preconditions.NotNull(types, nameof(types)); - return AddSelector(Types.Select(t => new TypeMap(t, types)), Enumerable.Empty()); + return AddSelector(Types.Select(t => new TypeMap(t, types)), []); } public ILifetimeSelector AsImplementedInterfaces() @@ -70,7 +70,7 @@ public ILifetimeSelector AsSelfWithInterfaces(Func predicate) Preconditions.NotNull(predicate, nameof(predicate)); return AddSelector( - Types.Select(t => new TypeMap(t, new[] { t })), + Types.Select(t => new TypeMap(t, [t])), Types.Select(t => new TypeFactoryMap(t, x => x.GetRequiredService(t), Selector(t, predicate)))); static IEnumerable Selector(Type type, Func predicate) @@ -79,7 +79,7 @@ static IEnumerable Selector(Type type, Func predicate) { // This prevents trying to register open generic types // with an ImplementationFactory, which is unsupported. - return Enumerable.Empty(); + return []; } return GetInterfaces(type).Where(predicate); @@ -100,7 +100,7 @@ public ILifetimeSelector As(Func> selector) { Preconditions.NotNull(selector, nameof(selector)); - return AddSelector(Types.Select(t => new TypeMap(t, selector(t))), Enumerable.Empty()); + return AddSelector(Types.Select(t => new TypeMap(t, selector(t))), []); } public IImplementationTypeSelector UsingAttributes() diff --git a/src/Scrutor/TypeSourceSelector.cs b/src/Scrutor/TypeSourceSelector.cs index df5b9b07..82b7b432 100644 --- a/src/Scrutor/TypeSourceSelector.cs +++ b/src/Scrutor/TypeSourceSelector.cs @@ -12,12 +12,12 @@ public class TypeSourceSelector : ITypeSourceSelector, ISelector private static Assembly EntryAssembly => Assembly.GetEntryAssembly() ?? throw new InvalidOperationException("Could not get entry assembly."); - private List Selectors { get; } = new(); + private List Selectors { get; } = []; /// public IImplementationTypeSelector FromAssemblyOf() { - return InternalFromAssembliesOf(new[] { typeof(T) }); + return InternalFromAssembliesOf([typeof(T)]); } /// diff --git a/test/Scrutor.Tests/ScanningTests.cs b/test/Scrutor.Tests/ScanningTests.cs index 57b623f3..23ce5a3a 100644 --- a/test/Scrutor.Tests/ScanningTests.cs +++ b/test/Scrutor.Tests/ScanningTests.cs @@ -307,7 +307,7 @@ public void CanCreateDefault() var remainingSetOfTypes = Collection .Select(descriptor => descriptor.ServiceType) - .Except(types.Concat(new[] { typeof(DefaultAttributes) })) + .Except(types.Concat([typeof(DefaultAttributes)])) .ToList(); Assert.Equal(5, Collection.Count);