diff --git a/LightweightIocContainer/Validation/IocValidator.cs b/LightweightIocContainer.Validation/IocValidator.cs similarity index 100% rename from LightweightIocContainer/Validation/IocValidator.cs rename to LightweightIocContainer.Validation/IocValidator.cs diff --git a/LightweightIocContainer.Validation/LightweightIocContainer.Validation.csproj b/LightweightIocContainer.Validation/LightweightIocContainer.Validation.csproj new file mode 100644 index 0000000..4b1e4c2 --- /dev/null +++ b/LightweightIocContainer.Validation/LightweightIocContainer.Validation.csproj @@ -0,0 +1,46 @@ + + + + net6.0 + SimonG + Copyright(c) 2022 SimonG. All Rights Reserved. + A lightweight IOC Container Validator. + https://github.com/SimonG96/LightweightIocContainer + default + enable + enable + LightweightIocContainer.Validation.xml + 4.0.0 + beta5 + + + + true + https://github.com/SimonG96/LightweightIocContainer + MIT + README.md + true + snupkg + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + + + + + + + + + diff --git a/LightweightIocContainer.Validation/LightweightIocContainer.Validation.xml b/LightweightIocContainer.Validation/LightweightIocContainer.Validation.xml new file mode 100644 index 0000000..5bedfa5 --- /dev/null +++ b/LightweightIocContainer.Validation/LightweightIocContainer.Validation.xml @@ -0,0 +1,33 @@ + + + + LightweightIocContainer.Validation + + + + + Validator for your to check if everything can be resolved with your current setup + + + + + Validator for your to check if everything can be resolved with your current setup + + The + + + + Add parameters that can't be default for your type to be created successfully + + The new value of the parameter + The of your registered interface + The of your + + + + Validates your given and checks if everything can be resolved with the current setup + Collection of all exceptions that are thrown during validation + + + + diff --git a/LightweightIocContainer.Validation/Properties/AssemblyInfo.cs b/LightweightIocContainer.Validation/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/LightweightIocContainer.Validation/Properties/AssemblyInfo.cs @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/LightweightIocContainer.Validation/README.md b/LightweightIocContainer.Validation/README.md new file mode 100644 index 0000000..cae2447 --- /dev/null +++ b/LightweightIocContainer.Validation/README.md @@ -0,0 +1,54 @@ +# Lightweight IOC Container + +A lightweight IOC Container that is powerful enough to do all the things you need it to do. + +[![GitHub Actions](https://github.com/SimonG96/LightweightIocContainer/workflows/CI/badge.svg)](https://github.com/SimonG96/LightweightIocContainer/actions) + +[![Nuget](https://img.shields.io/nuget/dt/LightweightIocContainer.svg?label=NuGet%20Downloads&logo=NuGet)](https://www.nuget.org/packages/LightweightIocContainer/) +[![Nuget](https://img.shields.io/nuget/v/LightweightIocContainer.svg?label=NuGet%20Version&logo=NuGet)](https://www.nuget.org/packages/LightweightIocContainer/) +[![Nuget (with prereleases)](https://img.shields.io/nuget/vpre/LightweightIocContainer.svg?label=NuGet%20Pre-Release&logo=NuGet)](https://www.nuget.org/packages/LightweightIocContainer/) + +## Get started with the Lightweight IOC Container Validator + +### How to install + +The easiest way to [install](https://github.com/SimonG96/LightweightIocContainer/wiki/Install-Lightweight-IOC-Container) the Lightweight IOC Container is by using [NuGet](https://www.nuget.org/packages/LightweightIocContainer/). +You can either use the [`PackageManager`](https://github.com/SimonG96/LightweightIocContainer/wiki/Install-Lightweight-IOC-Container#packagemanager) in VisualStudio: + +```PM +PM> Install-Package LightweightIocContainer.Validator -Version 4.0.0-beta4 +``` + +or you can use the [`.NET CLI`](https://github.com/SimonG96/LightweightIocContainer/wiki/Install-Lightweight-IOC-Container#net-cli): + +```.net +> dotnet add package LightweightIocContainer.Validator --version 4.0.0-beta4 +``` + +### Validation + +You can validate your `IocContainer` setup by using the `IocValidator` in a unit test: + +```c# +[TestFixture] +public class IocValidationTest +{ + [Test] + public void ValidateIocContainerSetup() + { + IocContainer container = new(); + container.Install(new Installer()); + + IocValidator validator = new(container); + validator.Validate(); + } +} +``` + +If this test is successful, everything is correctly installed and can be resolved by the `IocContainer`. By going through the thrown exceptions in case of a failed test you will see what is not working correctly with your current setup. + +### Demo Project + +There is a [demo project][demoProjectLink] available where you can check out how different functions of the Lightweight IOC Container can be used. + +[demoProjectLink]: https://github.com/SimonG96/LightweightIocContainer_Example diff --git a/LightweightIocContainer.sln b/LightweightIocContainer.sln index 814541d..e4fa8ab 100644 --- a/LightweightIocContainer.sln +++ b/LightweightIocContainer.sln @@ -7,6 +7,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LightweightIocContainer", " EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test.LightweightIocContainer", "Test.LightweightIocContainer\Test.LightweightIocContainer.csproj", "{F9A8A01E-D080-4998-9135-D342B2C4B4CD}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LightweightIocContainer.Validation", "LightweightIocContainer.Validation\LightweightIocContainer.Validation.csproj", "{B3212FDE-BAC1-40AD-ABEE-DBB12A93D275}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test.LightweightIocContainer.Validation", "Test.LightweightIocContainer.Validation\Test.LightweightIocContainer.Validation.csproj", "{82818CE7-6219-4A2E-A506-3AE09A00578C}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -21,6 +25,14 @@ Global {F9A8A01E-D080-4998-9135-D342B2C4B4CD}.Debug|Any CPU.Build.0 = Debug|Any CPU {F9A8A01E-D080-4998-9135-D342B2C4B4CD}.Release|Any CPU.ActiveCfg = Release|Any CPU {F9A8A01E-D080-4998-9135-D342B2C4B4CD}.Release|Any CPU.Build.0 = Release|Any CPU + {B3212FDE-BAC1-40AD-ABEE-DBB12A93D275}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B3212FDE-BAC1-40AD-ABEE-DBB12A93D275}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B3212FDE-BAC1-40AD-ABEE-DBB12A93D275}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B3212FDE-BAC1-40AD-ABEE-DBB12A93D275}.Release|Any CPU.Build.0 = Release|Any CPU + {82818CE7-6219-4A2E-A506-3AE09A00578C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {82818CE7-6219-4A2E-A506-3AE09A00578C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {82818CE7-6219-4A2E-A506-3AE09A00578C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {82818CE7-6219-4A2E-A506-3AE09A00578C}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/LightweightIocContainer/LightweightIocContainer.csproj b/LightweightIocContainer/LightweightIocContainer.csproj index 98c38c8..09a27a2 100644 --- a/LightweightIocContainer/LightweightIocContainer.csproj +++ b/LightweightIocContainer/LightweightIocContainer.csproj @@ -11,7 +11,7 @@ enable LightweightIocContainer.xml 4.0.0 - beta4 + beta5 @@ -28,7 +28,6 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - diff --git a/LightweightIocContainer/LightweightIocContainer.xml b/LightweightIocContainer/LightweightIocContainer.xml index 750e800..b5eb336 100644 --- a/LightweightIocContainer/LightweightIocContainer.xml +++ b/LightweightIocContainer/LightweightIocContainer.xml @@ -1875,30 +1875,5 @@ The given The default value for the given - - - Validator for your to check if everything can be resolved with your current setup - - - - - Validator for your to check if everything can be resolved with your current setup - - The - - - - Add parameters that can't be default for your type to be created successfully - - The new value of the parameter - The of your registered interface - The of your - - - - Validates your given and checks if everything can be resolved with the current setup - Collection of all exceptions that are thrown during validation - - diff --git a/LightweightIocContainer/Properties/AssemblyInfo.cs b/LightweightIocContainer/Properties/AssemblyInfo.cs index 18bea16..79de6d3 100644 --- a/LightweightIocContainer/Properties/AssemblyInfo.cs +++ b/LightweightIocContainer/Properties/AssemblyInfo.cs @@ -4,4 +4,7 @@ using System.Runtime.CompilerServices; -[assembly:InternalsVisibleTo("Test.LightweightIocContainer")] \ No newline at end of file +[assembly:InternalsVisibleTo("LightweightIocContainer.Validation")] + +[assembly:InternalsVisibleTo("Test.LightweightIocContainer")] +[assembly:InternalsVisibleTo("Test.LightweightIocContainer.Validation")] diff --git a/README.md b/README.md index 0422abc..c48d17c 100644 --- a/README.md +++ b/README.md @@ -57,28 +57,6 @@ or you can use the [`.NET CLI`](https://github.com/SimonG96/LightweightIocContai container.Dispose(); ``` -### Validation - -You can validate your `IocContainer` setup by using the `IocValidator` in a unit test: - -```c# -[TestFixture] -public class IocValidationTest -{ - [Test] - public void ValidateIocContainerSetup() - { - IocContainer container = new(); - container.Install(new Installer()); - - IocValidator validator = new(container); - validator.Validate(); - } -} -``` - -If this test is successful, everything is correctly installed and can be resolved by the `IocContainer`. By going through the thrown exceptions in case of a failed test you will see what is not working correctly with your current setup. - ### Demo Project There is a [demo project][demoProjectLink] available where you can check out how different functions of the Lightweight IOC Container can be used. diff --git a/Test.LightweightIocContainer/IocValidatorTest.cs b/Test.LightweightIocContainer.Validation/IocValidatorTest.cs similarity index 91% rename from Test.LightweightIocContainer/IocValidatorTest.cs rename to Test.LightweightIocContainer.Validation/IocValidatorTest.cs index aa89013..fbeff71 100644 --- a/Test.LightweightIocContainer/IocValidatorTest.cs +++ b/Test.LightweightIocContainer.Validation/IocValidatorTest.cs @@ -36,6 +36,14 @@ public class IocValidatorTest { public Test(IParameter parameter) => parameter.Method(); } + + private class Test2 : ITest2 + { + public Test2(ITest dependency) + { + + } + } @@ -52,14 +60,7 @@ public class IocValidatorTest ITest2 Create(ITest test); } - - private class Test2 : ITest2 - { - public Test2(ITest parameter) - { - - } - } + [UsedImplicitly] public interface IInvalidFactory @@ -149,13 +150,13 @@ public class IocValidatorTest if (aggregateException?.InnerExceptions[0] is not NoMatchingConstructorFoundException noMatchingConstructorFoundException) { - Assert.Fail(); + Assert.Fail($"First element of {nameof(aggregateException.InnerExceptions)} is not of type {nameof(NoMatchingConstructorFoundException)}."); return; } if (noMatchingConstructorFoundException.InnerExceptions[0] is not ConstructorNotMatchingException iTest2CtorNotMatchingException) { - Assert.Fail(); + Assert.Fail($"First element of {nameof(noMatchingConstructorFoundException.InnerExceptions)} is not of type {nameof(ConstructorNotMatchingException)}."); return; } @@ -181,6 +182,6 @@ public class IocValidatorTest if (exception is NoMatchingConstructorFoundException noMatchingConstructorFoundException) Assert.AreEqual(typeof(T), noMatchingConstructorFoundException.Type); else - Assert.Fail($"Exception is no NoMatchingConstructorFoundException, actual type: {exception?.GetType()}"); + Assert.Fail($"Exception is no {nameof(NoMatchingConstructorFoundException)}, actual type: {exception?.GetType()}"); } -} \ No newline at end of file +} diff --git a/Test.LightweightIocContainer.Validation/Test.LightweightIocContainer.Validation.csproj b/Test.LightweightIocContainer.Validation/Test.LightweightIocContainer.Validation.csproj new file mode 100644 index 0000000..558913c --- /dev/null +++ b/Test.LightweightIocContainer.Validation/Test.LightweightIocContainer.Validation.csproj @@ -0,0 +1,26 @@ + + + + net6.0 + false + SimonG + default + enable + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + +