Skip to content

Commit

Permalink
All warnings gone. All tests passed
Browse files Browse the repository at this point in the history
  • Loading branch information
seesharper committed Oct 27, 2024
1 parent 2f42bb7 commit e0f425a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 26 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"Newobj",
"Stelem",
"Stloc",
"Unkeyed",
"Xunit"
],
"dotnet-test-explorer.testArguments": "-c release -f netcoreapp2.0"
Expand Down
2 changes: 1 addition & 1 deletion src/LightInject.Tests/KeyedMicrosoftTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ internal class Service : IService

public Service([ServiceKey] string id) => _id = id;

public override string? ToString() => _id;
public override string ToString() => _id;
}

internal class OtherService
Expand Down
12 changes: 6 additions & 6 deletions src/LightInject.Tests/MicrosoftTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ public void ConstrainedOpenGenericServicesCanBeResolved()
Assert.Equal(2, allServices.Count);
Assert.Same(poco, allServices[0].Value);
Assert.Same(poco, allServices[1].Value);
Assert.Equal(1, constrainedServices.Count);
Assert.Single(constrainedServices);
Assert.Same(singletonService, constrainedServices[0].Value);
}

Expand All @@ -630,7 +630,7 @@ public void ConstrainedOpenGenericServicesReturnsEmptyWithNoMatches()
// Act
var constrainedServices = rootScope.GetAllInstances<IFakeOpenGenericService<IFakeSingletonService>>().ToList();
// Assert
Assert.Equal(0, constrainedServices.Count);
Assert.Empty(constrainedServices);
}

[Fact]
Expand All @@ -655,7 +655,7 @@ public void InterfaceConstrainedOpenGenericServicesCanBeResolved()
Assert.Equal(2, allServices.Count);
Assert.Same(enumerableVal, allServices[0].Value);
Assert.Same(enumerableVal, allServices[1].Value);
Assert.Equal(1, constrainedServices.Count);
Assert.Single(constrainedServices);
Assert.Same(singletonService, constrainedServices[0].Value);
}

Expand Down Expand Up @@ -684,7 +684,7 @@ public void AbstractClassConstrainedOpenGenericServicesCanBeResolved()
Assert.Equal(2, allServices.Count);
Assert.Same(classInheritingClassInheritingAbstractClass, allServices[0].Value);
Assert.Same(classInheritingClassInheritingAbstractClass, allServices[1].Value);
Assert.Equal(1, constrainedServices.Count);
Assert.Single(constrainedServices);
Assert.Same(poco, constrainedServices[0].Value);
}

Expand Down Expand Up @@ -729,8 +729,8 @@ public void ResolvingEnumerableContainingOpenGenericServiceUsesCorrectSlot()
// Assert
Assert.IsType<FakeService>(service);
Assert.Equal(2, services.Length);
Assert.True(services.Any(s => s.GetType() == typeof(FakeService)));
Assert.True(services.Any(s => s.GetType() == typeof(FakeOpenGenericService<PocoClass>)));
Assert.Contains(services, s => s.GetType() == typeof(FakeService));
Assert.Contains(services, s => s.GetType() == typeof(FakeOpenGenericService<PocoClass>));
}


Expand Down
20 changes: 1 addition & 19 deletions src/LightInject/LightInject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3340,24 +3340,6 @@ public IServiceRegistry RegisterOrdered(
return this;
}

/// <inheritdoc/>
public IServiceRegistry RegisterOrdered(Type serviceType, ServiceRegistration[] serviceRegistrations)
{
List<Action<IEmitter>> emitters = new List<Action<IEmitter>>();
foreach (var registration in serviceRegistrations)
{
var emitMethod = ResolveEmitMethod(registration);
emitters.Add(emitMethod);
}

Action<IEmitter> emitAction = (emitter) => EmitEnumerable(emitters.ToArray(), serviceType, emitter);

Type enumerableType = typeof(IEnumerable<>).MakeGenericType(serviceType);
registrationOrder++;
RegisterEmitMethod(enumerableType, string.Empty, registrationOrder, emitAction);
return this;
}

/// <inheritdoc/>
public void Compile(Func<ServiceRegistration, bool> predicate)
{
Expand Down Expand Up @@ -7074,7 +7056,7 @@ public Scope(ServiceContainer serviceFactory)
/// <summary>
/// Registers the <paramref name="disposable"/> so that it is disposed when the scope is completed.
/// </summary>
/// <param name="disposable">The <see cref="IDisposable"/> or <see cref="IAsyncDisposable"/> object to register.</param>
/// <param name="disposable">The <see cref="IDisposable"/> to register.</param>
public void TrackInstance(object disposable)
{
if (disposable is Scope)
Expand Down

0 comments on commit e0f425a

Please sign in to comment.