- add jetbrains.annotations

- fix more resharper issues
pull/32/head
Simon Gockner 7 years ago
parent 46f0fd4443
commit 49e836f872
  1. 2
      LightweightIocContainer/IocContainer.cs
  2. 1
      LightweightIocContainer/LightweightIocContainer.csproj
  3. 11
      Test.LightweightIocContainer/IocContainerTest.cs
  4. 1
      Test.LightweightIocContainer/Test.LightweightIocContainer.csproj

@ -6,6 +6,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using JetBrains.Annotations;
using LightweightIocContainer.Exceptions; using LightweightIocContainer.Exceptions;
using LightweightIocContainer.Interfaces; using LightweightIocContainer.Interfaces;
using LightweightIocContainer.Interfaces.Registrations; using LightweightIocContainer.Interfaces.Registrations;
@ -201,6 +202,7 @@ namespace LightweightIocContainer
/// <param name="type">The type that will be created</param> /// <param name="type">The type that will be created</param>
/// <param name="arguments">The existing arguments</param> /// <param name="arguments">The existing arguments</param>
/// <returns>An array of all needed constructor arguments to create <param name="type"></param></returns> /// <returns>An array of all needed constructor arguments to create <param name="type"></param></returns>
[CanBeNull]
private object[] ResolveConstructorArguments(Type type, object[] arguments) private object[] ResolveConstructorArguments(Type type, object[] arguments)
{ {
//find best ctor //find best ctor

@ -17,6 +17,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2019.1.1" />
<PackageReference Include="System.Reflection.Emit" Version="4.3.0" /> <PackageReference Include="System.Reflection.Emit" Version="4.3.0" />
</ItemGroup> </ItemGroup>

@ -1,3 +1,4 @@
using JetBrains.Annotations;
using LightweightIocContainer; using LightweightIocContainer;
using LightweightIocContainer.Exceptions; using LightweightIocContainer.Exceptions;
using LightweightIocContainer.Interfaces; using LightweightIocContainer.Interfaces;
@ -18,6 +19,7 @@ namespace Test.LightweightIocContainer
} }
[UsedImplicitly]
public interface ITestFactory public interface ITestFactory
{ {
ITest Create(); ITest Create();
@ -35,6 +37,7 @@ namespace Test.LightweightIocContainer
} }
[UsedImplicitly]
private class TestConstructor : ITest private class TestConstructor : ITest
{ {
public TestConstructor(string name, Test test) public TestConstructor(string name, Test test)
@ -87,7 +90,7 @@ namespace Test.LightweightIocContainer
IIocContainer iocContainer = new IocContainer(); IIocContainer iocContainer = new IocContainer();
iocContainer.Register(RegistrationFactory.Register<ITest, Test>()); iocContainer.Register(RegistrationFactory.Register<ITest, Test>());
var exception = Assert.Throws<MultipleRegistrationException>(() => iocContainer.Register(RegistrationFactory.Register<ITest, TestConstructor>())); MultipleRegistrationException exception = Assert.Throws<MultipleRegistrationException>(() => iocContainer.Register(RegistrationFactory.Register<ITest, TestConstructor>()));
Assert.AreEqual(typeof(ITest), exception.Type); Assert.AreEqual(typeof(ITest), exception.Type);
} }
@ -104,7 +107,7 @@ namespace Test.LightweightIocContainer
{ {
IIocContainer iocContainer = new IocContainer(); IIocContainer iocContainer = new IocContainer();
var exception = Assert.Throws<TypeNotRegisteredException>(() => iocContainer.Resolve<ITest>()); TypeNotRegisteredException exception = Assert.Throws<TypeNotRegisteredException>(() => iocContainer.Resolve<ITest>());
Assert.AreEqual(typeof(ITest), exception.Type); Assert.AreEqual(typeof(ITest), exception.Type);
} }
@ -189,7 +192,7 @@ namespace Test.LightweightIocContainer
IIocContainer iocContainer = new IocContainer(); IIocContainer iocContainer = new IocContainer();
iocContainer.Register(RegistrationFactory.Register<ITest, Test, MultitonScope>()); iocContainer.Register(RegistrationFactory.Register<ITest, Test, MultitonScope>());
var exception = Assert.Throws<MultitonResolveException>(() => iocContainer.Resolve<ITest>()); MultitonResolveException exception = Assert.Throws<MultitonResolveException>(() => iocContainer.Resolve<ITest>());
Assert.AreEqual(typeof(ITest), exception.Type); Assert.AreEqual(typeof(ITest), exception.Type);
} }
@ -199,7 +202,7 @@ namespace Test.LightweightIocContainer
IIocContainer iocContainer = new IocContainer(); IIocContainer iocContainer = new IocContainer();
iocContainer.Register(RegistrationFactory.Register<ITest, Test, MultitonScope>()); iocContainer.Register(RegistrationFactory.Register<ITest, Test, MultitonScope>());
var exception = Assert.Throws<MultitonResolveException>(() => iocContainer.Resolve<ITest>(new object())); MultitonResolveException exception = Assert.Throws<MultitonResolveException>(() => iocContainer.Resolve<ITest>(new object()));
Assert.AreEqual(typeof(ITest), exception.Type); Assert.AreEqual(typeof(ITest), exception.Type);
} }

@ -7,6 +7,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2019.1.1" />
<PackageReference Include="Moq" Version="4.11.0" /> <PackageReference Include="Moq" Version="4.11.0" />
<PackageReference Include="nunit" Version="3.12.0" /> <PackageReference Include="nunit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.13.0" /> <PackageReference Include="NUnit3TestAdapter" Version="3.13.0" />

Loading…
Cancel
Save