Merge pull request #59 from theKBro/splitValidationProject

Split package into multiple packages
ImplementExpressionTrees
Simon G 3 years ago committed by GitHub
commit 908f3d65c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 0
      LightweightIocContainer.Validation/IocValidator.cs
  2. 46
      LightweightIocContainer.Validation/LightweightIocContainer.Validation.csproj
  3. 33
      LightweightIocContainer.Validation/LightweightIocContainer.Validation.xml
  4. 1
      LightweightIocContainer.Validation/Properties/AssemblyInfo.cs
  5. 54
      LightweightIocContainer.Validation/README.md
  6. 12
      LightweightIocContainer.sln
  7. 3
      LightweightIocContainer/LightweightIocContainer.csproj
  8. 25
      LightweightIocContainer/LightweightIocContainer.xml
  9. 5
      LightweightIocContainer/Properties/AssemblyInfo.cs
  10. 22
      README.md
  11. 25
      Test.LightweightIocContainer.Validation/IocValidatorTest.cs
  12. 26
      Test.LightweightIocContainer.Validation/Test.LightweightIocContainer.Validation.csproj

@ -0,0 +1,46 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Authors>SimonG</Authors>
<Copyright>Copyright(c) 2022 SimonG. All Rights Reserved.</Copyright>
<Description>A lightweight IOC Container Validator.</Description>
<RepositoryUrl>https://github.com/SimonG96/LightweightIocContainer</RepositoryUrl>
<LangVersion>default</LangVersion>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<DocumentationFile>LightweightIocContainer.Validation.xml</DocumentationFile>
<VersionPrefix>4.0.0</VersionPrefix>
<VersionSuffix>beta5</VersionSuffix>
</PropertyGroup>
<PropertyGroup>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageProjectUrl>https://github.com/SimonG96/LightweightIocContainer</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageReadmeFile>README.md</PackageReadmeFile>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Moq" Version="4.18.2" />
<PackageReference Include="System.Reflection.Emit" Version="4.7.0" />
</ItemGroup>
<ItemGroup>
<Content Include="README.md" Pack="true" PackagePath="" />
</ItemGroup>
<ItemGroup Condition="Exists('..\LightweightIocContainer\LightweightIocContainer.csproj')">
<ProjectReference Include="..\LightweightIocContainer\LightweightIocContainer.csproj" />
</ItemGroup>
<ItemGroup Condition="!Exists('..\LightweightIocContainer\LightweightIocContainer.csproj')">
<PackageReference Include="LightweightIocContainer" Version="$(Version)" />
</ItemGroup>
</Project>

@ -0,0 +1,33 @@
<?xml version="1.0"?>
<doc>
<assembly>
<name>LightweightIocContainer.Validation</name>
</assembly>
<members>
<member name="T:LightweightIocContainer.Validation.IocValidator">
<summary>
Validator for your <see cref="T:LightweightIocContainer.IocContainer"/> to check if everything can be resolved with your current setup
</summary>
</member>
<member name="M:LightweightIocContainer.Validation.IocValidator.#ctor(LightweightIocContainer.IocContainer)">
<summary>
Validator for your <see cref="T:LightweightIocContainer.IocContainer"/> to check if everything can be resolved with your current setup
</summary>
<param name="iocContainer">The <see cref="T:LightweightIocContainer.IocContainer"/></param>
</member>
<member name="M:LightweightIocContainer.Validation.IocValidator.AddParameter``2(``1)">
<summary>
Add parameters that can't be default for your type to be created successfully
</summary>
<param name="parameter">The new value of the parameter</param>
<typeparam name="TInterface">The <see cref="T:System.Type"/> of your registered interface</typeparam>
<typeparam name="TParameter">The <see cref="T:System.Type"/> of your <paramref name="parameter"></paramref></typeparam>
</member>
<member name="M:LightweightIocContainer.Validation.IocValidator.Validate">
<summary>
Validates your given <see cref="T:LightweightIocContainer.IocContainer"/> and checks if everything can be resolved with the current setup
<exception cref="T:System.AggregateException">Collection of all exceptions that are thrown during validation</exception>
</summary>
</member>
</members>
</doc>

@ -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

@ -7,6 +7,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LightweightIocContainer", "
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test.LightweightIocContainer", "Test.LightweightIocContainer\Test.LightweightIocContainer.csproj", "{F9A8A01E-D080-4998-9135-D342B2C4B4CD}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test.LightweightIocContainer", "Test.LightweightIocContainer\Test.LightweightIocContainer.csproj", "{F9A8A01E-D080-4998-9135-D342B2C4B4CD}"
EndProject 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 Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU 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}.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.ActiveCfg = Release|Any CPU
{F9A8A01E-D080-4998-9135-D342B2C4B4CD}.Release|Any CPU.Build.0 = 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 EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

@ -11,7 +11,7 @@
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<DocumentationFile>LightweightIocContainer.xml</DocumentationFile> <DocumentationFile>LightweightIocContainer.xml</DocumentationFile>
<VersionPrefix>4.0.0</VersionPrefix> <VersionPrefix>4.0.0</VersionPrefix>
<VersionSuffix>beta4</VersionSuffix> <VersionSuffix>beta5</VersionSuffix>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
@ -28,7 +28,6 @@
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Moq" Version="4.18.2" />
<PackageReference Include="System.Reflection.Emit" Version="4.7.0" /> <PackageReference Include="System.Reflection.Emit" Version="4.7.0" />
</ItemGroup> </ItemGroup>

@ -1875,30 +1875,5 @@
<param name="type">The given <see cref="T:System.Type"/></param> <param name="type">The given <see cref="T:System.Type"/></param>
<returns>The default value for the given <see cref="T:System.Type"/></returns> <returns>The default value for the given <see cref="T:System.Type"/></returns>
</member> </member>
<member name="T:LightweightIocContainer.Validation.IocValidator">
<summary>
Validator for your <see cref="T:LightweightIocContainer.IocContainer"/> to check if everything can be resolved with your current setup
</summary>
</member>
<member name="M:LightweightIocContainer.Validation.IocValidator.#ctor(LightweightIocContainer.IocContainer)">
<summary>
Validator for your <see cref="T:LightweightIocContainer.IocContainer"/> to check if everything can be resolved with your current setup
</summary>
<param name="iocContainer">The <see cref="T:LightweightIocContainer.IocContainer"/></param>
</member>
<member name="M:LightweightIocContainer.Validation.IocValidator.AddParameter``2(``1)">
<summary>
Add parameters that can't be default for your type to be created successfully
</summary>
<param name="parameter">The new value of the parameter</param>
<typeparam name="TInterface">The <see cref="T:System.Type"/> of your registered interface</typeparam>
<typeparam name="TParameter">The <see cref="T:System.Type"/> of your <paramref name="parameter"></paramref></typeparam>
</member>
<member name="M:LightweightIocContainer.Validation.IocValidator.Validate">
<summary>
Validates your given <see cref="T:LightweightIocContainer.IocContainer"/> and checks if everything can be resolved with the current setup
<exception cref="T:System.AggregateException">Collection of all exceptions that are thrown during validation</exception>
</summary>
</member>
</members> </members>
</doc> </doc>

@ -4,4 +4,7 @@
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
[assembly:InternalsVisibleTo("Test.LightweightIocContainer")] [assembly:InternalsVisibleTo("LightweightIocContainer.Validation")]
[assembly:InternalsVisibleTo("Test.LightweightIocContainer")]
[assembly:InternalsVisibleTo("Test.LightweightIocContainer.Validation")]

@ -57,28 +57,6 @@ or you can use the [`.NET CLI`](https://github.com/SimonG96/LightweightIocContai
container.Dispose(); 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 ### 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. There is a [demo project][demoProjectLink] available where you can check out how different functions of the Lightweight IOC Container can be used.

@ -36,6 +36,14 @@ public class IocValidatorTest
{ {
public Test(IParameter parameter) => parameter.Method(); 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); ITest2 Create(ITest test);
} }
private class Test2 : ITest2
{
public Test2(ITest parameter)
{
}
}
[UsedImplicitly] [UsedImplicitly]
public interface IInvalidFactory public interface IInvalidFactory
@ -149,13 +150,13 @@ public class IocValidatorTest
if (aggregateException?.InnerExceptions[0] is not NoMatchingConstructorFoundException noMatchingConstructorFoundException) 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; return;
} }
if (noMatchingConstructorFoundException.InnerExceptions[0] is not ConstructorNotMatchingException iTest2CtorNotMatchingException) 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; return;
} }
@ -181,6 +182,6 @@ public class IocValidatorTest
if (exception is NoMatchingConstructorFoundException noMatchingConstructorFoundException) if (exception is NoMatchingConstructorFoundException noMatchingConstructorFoundException)
Assert.AreEqual(typeof(T), noMatchingConstructorFoundException.Type); Assert.AreEqual(typeof(T), noMatchingConstructorFoundException.Type);
else else
Assert.Fail($"Exception is no NoMatchingConstructorFoundException, actual type: {exception?.GetType()}"); Assert.Fail($"Exception is no {nameof(NoMatchingConstructorFoundException)}, actual type: {exception?.GetType()}");
} }
} }

@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>
<Authors>SimonG</Authors>
<LangVersion>default</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2022.1.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.1" />
<PackageReference Include="Moq" Version="4.18.2" />
<PackageReference Include="nunit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LightweightIocContainer.Validation\LightweightIocContainer.Validation.csproj" />
</ItemGroup>
</Project>
Loading…
Cancel
Save