Compare commits

..

11 Commits

  1. 3
      Debug.LightweightIocContainer.FactoryGenerator/SampleInstaller.cs
  2. 14
      Debug.LightweightIocContainer.FactoryGenerator/Samples/Factories/ISampleClassFactory.cs
  3. 3
      Debug.LightweightIocContainer.FactoryGenerator/Samples/Interfaces/ISampleClass.cs
  4. 9
      Debug.LightweightIocContainer.FactoryGenerator/Samples/SampleClass.cs
  5. 102
      LightweightIocContainer.FactoryGenerator/FactoryGenerator.cs
  6. 6
      LightweightIocContainer.sln
  7. 1
      LightweightIocContainer/Properties/AssemblyInfo.cs
  8. 60
      Test.LightweightIocContainer.FactoryGenerator/AsyncFactoryTest.cs
  9. 212
      Test.LightweightIocContainer.FactoryGenerator/FluentFactoryRegistrationTest.cs
  10. 40
      Test.LightweightIocContainer.FactoryGenerator/MultiLayerResolveTest.cs
  11. 41
      Test.LightweightIocContainer.FactoryGenerator/OpenGenericRegistrationTest.cs
  12. 33
      Test.LightweightIocContainer.FactoryGenerator/Test.LightweightIocContainer.FactoryGenerator.csproj
  13. 10
      Test.LightweightIocContainer.FactoryGenerator/TestClasses/A.cs
  14. 13
      Test.LightweightIocContainer.FactoryGenerator/TestClasses/AsyncMultitonTest.cs
  15. 14
      Test.LightweightIocContainer.FactoryGenerator/TestClasses/AsyncTest.cs
  16. 10
      Test.LightweightIocContainer.FactoryGenerator/TestClasses/B.cs
  17. 9
      Test.LightweightIocContainer.FactoryGenerator/TestClasses/C.cs
  18. 9
      Test.LightweightIocContainer.FactoryGenerator/TestClasses/Constraint.cs
  19. 11
      Test.LightweightIocContainer.FactoryGenerator/TestClasses/CtorGenericTest.cs
  20. 5
      Test.LightweightIocContainer.FactoryGenerator/TestClasses/DefaultTest.cs
  21. 8
      Test.LightweightIocContainer.FactoryGenerator/TestClasses/Factories/IAFactory.cs
  22. 8
      Test.LightweightIocContainer.FactoryGenerator/TestClasses/Factories/IAsyncMultitonTestFactory.cs
  23. 8
      Test.LightweightIocContainer.FactoryGenerator/TestClasses/Factories/IAsyncTestFactory.cs
  24. 9
      Test.LightweightIocContainer.FactoryGenerator/TestClasses/Factories/IBFactory.cs
  25. 8
      Test.LightweightIocContainer.FactoryGenerator/TestClasses/Factories/ICtorGenericTestFactory.cs
  26. 11
      Test.LightweightIocContainer.FactoryGenerator/TestClasses/Factories/IDefaultTestFactory.cs
  27. 8
      Test.LightweightIocContainer.FactoryGenerator/TestClasses/Factories/IGenericTestFactory.cs
  28. 9
      Test.LightweightIocContainer.FactoryGenerator/TestClasses/Factories/IInvalidMultitonTestFactory.cs
  29. 9
      Test.LightweightIocContainer.FactoryGenerator/TestClasses/Factories/IMultitonTestFactory.cs
  30. 8
      Test.LightweightIocContainer.FactoryGenerator/TestClasses/Factories/ITestDefaultFactory.cs
  31. 3
      Test.LightweightIocContainer.FactoryGenerator/TestClasses/Factories/ITestFactoryNoCreate.cs
  32. 6
      Test.LightweightIocContainer.FactoryGenerator/TestClasses/Factories/ITestFactoryWrongReturn.cs
  33. 8
      Test.LightweightIocContainer.FactoryGenerator/TestClasses/Factories/ITestNullFactory.cs
  34. 5
      Test.LightweightIocContainer.FactoryGenerator/TestClasses/GenericTest.cs
  35. 6
      Test.LightweightIocContainer.FactoryGenerator/TestClasses/Interfaces/IA.cs
  36. 7
      Test.LightweightIocContainer.FactoryGenerator/TestClasses/Interfaces/IAsyncTest.cs
  37. 6
      Test.LightweightIocContainer.FactoryGenerator/TestClasses/Interfaces/IB.cs
  38. 3
      Test.LightweightIocContainer.FactoryGenerator/TestClasses/Interfaces/IConstraint.cs
  39. 3
      Test.LightweightIocContainer.FactoryGenerator/TestClasses/Interfaces/IDefaultTest.cs
  40. 3
      Test.LightweightIocContainer.FactoryGenerator/TestClasses/Interfaces/IGenericTest.cs
  41. 3
      Test.LightweightIocContainer.FactoryGenerator/TestClasses/MultitonScope.cs
  42. 10
      Test.LightweightIocContainer.FactoryGenerator/TestClasses/TestByte.cs
  43. 16
      Test.LightweightIocContainer.FactoryGenerator/TestClasses/TestConstructor.cs
  44. 11
      Test.LightweightIocContainer.FactoryGenerator/TestClasses/TestMultiton.cs
  45. 23
      Test.LightweightIocContainer.FactoryGenerator/TestClasses/TestNull.cs
  46. 2
      Test.LightweightIocContainer.Validation/Test.LightweightIocContainer.Validation.csproj
  47. 2
      Test.LightweightIocContainer/Test.LightweightIocContainer.csproj

@ -2,6 +2,9 @@
// Created: 2025-12-01 // Created: 2025-12-01
// Copyright(c) 2025 SimonG. All Rights Reserved. // Copyright(c) 2025 SimonG. All Rights Reserved.
using Debug.LightweightIocContainer.FactoryGenerator.Samples;
using Debug.LightweightIocContainer.FactoryGenerator.Samples.Factories;
using Debug.LightweightIocContainer.FactoryGenerator.Samples.Interfaces;
using LightweightIocContainer.FactoryGenerator; using LightweightIocContainer.FactoryGenerator;
using LightweightIocContainer.Interfaces.Installers; using LightweightIocContainer.Interfaces.Installers;
using LightweightIocContainer.Interfaces.Registrations; using LightweightIocContainer.Interfaces.Registrations;

@ -1,11 +1,6 @@
// Author: Simon.Gockner using Debug.LightweightIocContainer.FactoryGenerator.Samples.Interfaces;
// Created: 2025-12-01
// Copyright(c) 2025 SimonG. All Rights Reserved.
namespace Debug.LightweightIocContainer.FactoryGenerator; namespace Debug.LightweightIocContainer.FactoryGenerator.Samples.Factories;
public class SampleClass : ISampleClass;
public interface ISampleClass;
public interface ISampleClassFactory public interface ISampleClassFactory
{ {
@ -17,5 +12,10 @@ public interface ISampleClassFactory
T Create<T, U, V>(U param1, V param2) where T : ISampleClass where U : class, new() where V : struct; T Create<T, U, V>(U param1, V param2) where T : ISampleClass where U : class, new() where V : struct;
Task<T> CreateAsync<T, U>(U parameter) where T : ISampleClass where U : class; Task<T> CreateAsync<T, U>(U parameter) where T : ISampleClass where U : class;
ISampleClass Create<T>(Task<T> task) where T : Task<ISampleClass?>;
Task<T?> Create<T>(ISampleClass? sampleClass) where T : class, ISampleClass;
ISampleClass? Create(int id);
void ClearMultitonInstance<T>() where T : ISampleClass; void ClearMultitonInstance<T>() where T : ISampleClass;
} }

@ -0,0 +1,3 @@
namespace Debug.LightweightIocContainer.FactoryGenerator.Samples.Interfaces;
public interface ISampleClass;

@ -0,0 +1,9 @@
// Author: Simon.Gockner
// Created: 2025-12-01
// Copyright(c) 2025 SimonG. All Rights Reserved.
using Debug.LightweightIocContainer.FactoryGenerator.Samples.Interfaces;
namespace Debug.LightweightIocContainer.FactoryGenerator.Samples;
public class SampleClass : ISampleClass;

@ -29,7 +29,7 @@ public class FactoryGenerator : IIncrementalGenerator
IncrementalValuesProvider<ITypeSymbol?> syntaxProvider = context.SyntaxProvider.CreateSyntaxProvider(IsCallToGenerateFactory, GetTypeArgument); IncrementalValuesProvider<ITypeSymbol?> syntaxProvider = context.SyntaxProvider.CreateSyntaxProvider(IsCallToGenerateFactory, GetTypeArgument);
context.RegisterSourceOutput(syntaxProvider.Collect(), GenerateTypeDependentClasses); context.RegisterSourceOutput(syntaxProvider.Collect(), GenerateTypeDependentClasses);
context.RegisterSourceOutput(syntaxProvider, GenerateFactory); context.RegisterSourceOutput(syntaxProvider.Collect(), GenerateFactory);
} }
private string GenerateFactoryExtensionsClass(string? classNamespace, string className) private string GenerateFactoryExtensionsClass(string? classNamespace, string className)
@ -99,12 +99,15 @@ public class FactoryGenerator : IIncrementalGenerator
context.AddSource($"{BUILDER_CLASS_NAME}.g.cs", GenerateBuilderClassSourceCode(classNamespace, types)); context.AddSource($"{BUILDER_CLASS_NAME}.g.cs", GenerateBuilderClassSourceCode(classNamespace, types));
} }
private void GenerateFactory(SourceProductionContext context, ITypeSymbol? typeSymbol) private void GenerateFactory(SourceProductionContext context, ImmutableArray<ITypeSymbol?> types)
{ {
if (typeSymbol is null) foreach (ISymbol? symbol in types.Distinct(SymbolEqualityComparer.IncludeNullability))
return; {
if (symbol is not ITypeSymbol typeSymbol)
continue;
context.AddSource($"Generated{typeSymbol.Name}.g.cs", GenerateFactorySourceCode(typeSymbol)); context.AddSource($"Generated{typeSymbol.Name}.g.cs", GenerateFactorySourceCode(typeSymbol));
}
} }
private string GenerateBuilderClassSourceCode(string? classNamespace, ImmutableArray<ITypeSymbol?> types) private string GenerateBuilderClassSourceCode(string? classNamespace, ImmutableArray<ITypeSymbol?> types)
@ -132,9 +135,9 @@ public class FactoryGenerator : IIncrementalGenerator
stringBuilder.AppendLine($"{INDENT}public TFactory Create<TFactory>(IocContainer container)"); stringBuilder.AppendLine($"{INDENT}public TFactory Create<TFactory>(IocContainer container)");
stringBuilder.AppendLine($"{INDENT}{{"); stringBuilder.AppendLine($"{INDENT}{{");
foreach (ITypeSymbol? type in types) foreach (ISymbol? symbol in types.Distinct(SymbolEqualityComparer.IncludeNullability))
{ {
if (type is null) if (symbol is not ITypeSymbol type)
continue; continue;
stringBuilder.AppendLine($"{INDENT}{INDENT}if (typeof(TFactory) == typeof({type.Name}))"); stringBuilder.AppendLine($"{INDENT}{INDENT}if (typeof(TFactory) == typeof({type.Name}))");
@ -166,6 +169,34 @@ public class FactoryGenerator : IIncrementalGenerator
stringBuilder.AppendLine(); stringBuilder.AppendLine();
stringBuilder.AppendLine("using LightweightIocContainer;"); stringBuilder.AppendLine("using LightweightIocContainer;");
ImmutableArray<ISymbol> members = typeSymbol.GetMembers();
List<string?> namespaces = [];
foreach (ISymbol? member in members)
{
if (member is not IMethodSymbol method)
continue;
if (!method.ReturnsVoid)
{
if (method.ReturnType is INamedTypeSymbol { IsGenericType: true } namedTypeSymbol)
{
namespaces.AddRange(namedTypeSymbol.TypeArguments.Select(GetNamespaceOfType));
if (method.ReturnType.Name != "Task")
namespaces.Add(GetNamespaceOfType(method.ReturnType));
}
else
namespaces.Add(GetNamespaceOfType(method.ReturnType));
}
namespaces.AddRange(method.Parameters.Select(p => GetNamespaceOfType(p.Type)));
}
foreach (string @namespace in namespaces.Distinct().OfType<string>().OrderBy(n => n))
stringBuilder.AppendLine($"using {@namespace};");
stringBuilder.AppendLine(); stringBuilder.AppendLine();
if (typeNamespace is not null) if (typeNamespace is not null)
@ -177,7 +208,6 @@ public class FactoryGenerator : IIncrementalGenerator
stringBuilder.AppendLine($"public class Generated{typeName}(IocContainer container) : {typeName}"); stringBuilder.AppendLine($"public class Generated{typeName}(IocContainer container) : {typeName}");
stringBuilder.AppendLine("{"); stringBuilder.AppendLine("{");
ImmutableArray<ISymbol> members = typeSymbol.GetMembers();
foreach (ISymbol? member in members) foreach (ISymbol? member in members)
{ {
if (member is not IMethodSymbol method) if (member is not IMethodSymbol method)
@ -187,11 +217,8 @@ public class FactoryGenerator : IIncrementalGenerator
{ {
stringBuilder.Append($"{INDENT}public {method.ReturnType.Name}"); stringBuilder.Append($"{INDENT}public {method.ReturnType.Name}");
if (method.ReturnType.Name == "Task") if (method.ReturnType is INamedTypeSymbol { IsGenericType: true } namedReturnType)
{ stringBuilder.Append(GetGenericArguments(namedReturnType));
if (method.ReturnType is INamedTypeSymbol { IsGenericType: true } namedTypeSymbol)
stringBuilder.Append($"<{string.Join(", ", namedTypeSymbol.TypeArguments.Select(a => a.Name))}>");
}
stringBuilder.Append($" {method.Name}"); stringBuilder.Append($" {method.Name}");
@ -223,17 +250,15 @@ public class FactoryGenerator : IIncrementalGenerator
stringBuilder.AppendLine(); stringBuilder.AppendLine();
} }
if (method.ReturnType.Name == "Task") if (method.ReturnType is INamedTypeSymbol { IsGenericType: true } namedTypeSymbol)
{ {
stringBuilder.Append($"{INDENT}{INDENT}return container.ResolveAsync"); if (method.ReturnType.Name == "Task")
stringBuilder.Append($"{INDENT}{INDENT}return container.FactoryResolveAsync{GetGenericArguments(namedTypeSymbol)}(");
if (method.ReturnType is INamedTypeSymbol { IsGenericType: true } namedTypeSymbol) else
stringBuilder.Append($"<{string.Join(", ", namedTypeSymbol.TypeArguments.Select(a => a.Name))}>"); stringBuilder.Append($"{INDENT}{INDENT}return container.FactoryResolve<{method.ReturnType.Name}{GetGenericArguments(namedTypeSymbol)}>(");
stringBuilder.Append("(");
} }
else else
stringBuilder.Append($"{INDENT}{INDENT}return container.Resolve<{method.ReturnType.Name}>("); stringBuilder.Append($"{INDENT}{INDENT}return container.FactoryResolve<{method.ReturnType.Name}>(");
stringBuilder.Append(string.Join(", ", method.Parameters.Select(p => $"{p.Name}Value"))); stringBuilder.Append(string.Join(", ", method.Parameters.Select(p => $"{p.Name}Value")));
stringBuilder.AppendLine(");"); stringBuilder.AppendLine(");");
@ -265,9 +290,10 @@ public class FactoryGenerator : IIncrementalGenerator
return stringBuilder.ToString(); return stringBuilder.ToString();
} }
private string? GetNamespaceOfType(ITypeSymbol s) => s.ContainingNamespace.IsGlobalNamespace ? null : s.ContainingNamespace.ToString();
private IEnumerable<string> GetNamespacesOfTypes(ImmutableArray<ITypeSymbol?> types) => private IEnumerable<string> GetNamespacesOfTypes(ImmutableArray<ITypeSymbol?> types) =>
types.OfType<ITypeSymbol>() types.OfType<ITypeSymbol>()
.Select(s => s.ContainingNamespace.IsGlobalNamespace ? null : s.ContainingNamespace.ToString()) .Select(GetNamespaceOfType)
.OfType<string>() .OfType<string>()
.Distinct(); .Distinct();
@ -276,20 +302,34 @@ public class FactoryGenerator : IIncrementalGenerator
StringBuilder stringBuilder = new(); StringBuilder stringBuilder = new();
stringBuilder.Append(parameter.Type.Name); stringBuilder.Append(parameter.Type.Name);
if (parameter.Type is INamedTypeSymbol { IsGenericType: true } namedTypeSymbol)
stringBuilder.Append(GetGenericArguments(namedTypeSymbol));
if (parameter.NullableAnnotation == NullableAnnotation.Annotated) if (parameter.NullableAnnotation == NullableAnnotation.Annotated)
stringBuilder.Append("?"); stringBuilder.Append("?");
stringBuilder.Append($" {parameter.Name}"); stringBuilder.Append($" {parameter.Name}");
return stringBuilder.ToString(); return stringBuilder.ToString();
} }
private string GetGenericArguments(INamedTypeSymbol namedTypeSymbol) => $"<{string.Join(", ", namedTypeSymbol.TypeArguments.Select(GetGenericArgument))}>";
private string GetGenericArgument(ITypeSymbol argument)
{
StringBuilder stringBuilder = new();
stringBuilder.Append(argument.Name);
if (argument is INamedTypeSymbol { IsGenericType: true } namedTypeSymbol)
stringBuilder.Append(GetGenericArguments(namedTypeSymbol));
if (argument.NullableAnnotation == NullableAnnotation.Annotated)
stringBuilder.Append("?");
return stringBuilder.ToString();
}
private List<string> GetParameterConstraints(ITypeParameterSymbol typeParameterSymbol) private List<string> GetParameterConstraints(ITypeParameterSymbol typeParameterSymbol)
{ {
List<string> constraints = []; List<string> constraints = [];
foreach (ITypeSymbol constraintType in typeParameterSymbol.ConstraintTypes)
constraints.Add(constraintType.Name);
if (typeParameterSymbol.HasReferenceTypeConstraint) if (typeParameterSymbol.HasReferenceTypeConstraint)
constraints.Add("class"); constraints.Add("class");
@ -305,6 +345,14 @@ public class FactoryGenerator : IIncrementalGenerator
if (typeParameterSymbol.HasNotNullConstraint) if (typeParameterSymbol.HasNotNullConstraint)
constraints.Add("notnull"); constraints.Add("notnull");
foreach (ITypeSymbol constraintType in typeParameterSymbol.ConstraintTypes)
{
if (constraintType is INamedTypeSymbol { IsGenericType: true } namedTypeSymbol)
constraints.Add($"{constraintType.Name}{GetGenericArguments(namedTypeSymbol)}");
else
constraints.Add(constraintType.Name);
}
return constraints; return constraints;
} }
} }

@ -15,6 +15,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LightweightIocContainer.Fac
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Debug.LightweightIocContainer.FactoryGenerator", "Debug.LightweightIocContainer.FactoryGenerator\Debug.LightweightIocContainer.FactoryGenerator.csproj", "{578ED8B2-A2BE-4E10-9422-4D5AF2E605E0}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Debug.LightweightIocContainer.FactoryGenerator", "Debug.LightweightIocContainer.FactoryGenerator\Debug.LightweightIocContainer.FactoryGenerator.csproj", "{578ED8B2-A2BE-4E10-9422-4D5AF2E605E0}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test.LightweightIocContainer.FactoryGenerator", "Test.LightweightIocContainer.FactoryGenerator\Test.LightweightIocContainer.FactoryGenerator.csproj", "{0CB46F2E-5429-40BB-9F9F-31606B212E81}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -45,6 +47,10 @@ Global
{578ED8B2-A2BE-4E10-9422-4D5AF2E605E0}.Debug|Any CPU.Build.0 = Debug|Any CPU {578ED8B2-A2BE-4E10-9422-4D5AF2E605E0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{578ED8B2-A2BE-4E10-9422-4D5AF2E605E0}.Release|Any CPU.ActiveCfg = Release|Any CPU {578ED8B2-A2BE-4E10-9422-4D5AF2E605E0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{578ED8B2-A2BE-4E10-9422-4D5AF2E605E0}.Release|Any CPU.Build.0 = Release|Any CPU {578ED8B2-A2BE-4E10-9422-4D5AF2E605E0}.Release|Any CPU.Build.0 = Release|Any CPU
{0CB46F2E-5429-40BB-9F9F-31606B212E81}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0CB46F2E-5429-40BB-9F9F-31606B212E81}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0CB46F2E-5429-40BB-9F9F-31606B212E81}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0CB46F2E-5429-40BB-9F9F-31606B212E81}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

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

@ -0,0 +1,60 @@
// Author: Simon.Gockner
// Created: 2025-12-03
// Copyright(c) 2025 SimonG. All Rights Reserved.
using LightweightIocContainer;
using LightweightIocContainer.FactoryGenerator;
using Test.LightweightIocContainer.FactoryGenerator.TestClasses;
using Test.LightweightIocContainer.FactoryGenerator.TestClasses.Factories;
using Test.LightweightIocContainer.FactoryGenerator.TestClasses.Interfaces;
namespace Test.LightweightIocContainer.FactoryGenerator;
[TestFixture]
public class AsyncFactoryTest
{
[Test]
public async Task TestAsyncFactoryResolve()
{
IocContainer container = new();
container.Register(r => r.Add<IAsyncTest, AsyncTest>().WithGeneratedFactory<IAsyncTestFactory>());
IAsyncTestFactory testFactory = container.Resolve<IAsyncTestFactory>();
IAsyncTest test = await testFactory.Create();
Assert.That(test, Is.InstanceOf<AsyncTest>());
}
[Test]
public async Task TestAsyncFactoryResolveOnCreateCalled()
{
IocContainer container = new();
container.Register(r => r.Add<IAsyncTest, AsyncTest>().OnCreateAsync(t => t.Initialize()).WithGeneratedFactory<IAsyncTestFactory>());
IAsyncTestFactory testFactory = container.Resolve<IAsyncTestFactory>();
IAsyncTest test = await testFactory.Create();
Assert.That(test, Is.InstanceOf<AsyncTest>());
Assert.That(test.IsInitialized, Is.True);
}
[Test]
public async Task TestAsyncMultitonFactoryResolveOnCreateCalledCorrectly()
{
IocContainer container = new();
container.Register(r => r.AddMultiton<IAsyncTest, AsyncMultitonTest, int>().OnCreateAsync(t => t.Initialize()).WithGeneratedFactory<IAsyncMultitonTestFactory>());
IAsyncMultitonTestFactory testFactory = container.Resolve<IAsyncMultitonTestFactory>();
IAsyncTest test1 = await testFactory.Create(1);
IAsyncTest test2 = await testFactory.Create(2);
IAsyncTest anotherTest1 = await testFactory.Create(1);
Assert.That(test1, Is.InstanceOf<AsyncTest>());
Assert.That(test1.IsInitialized, Is.True);
Assert.That(test2, Is.InstanceOf<AsyncTest>());
Assert.That(test2.IsInitialized, Is.True);
Assert.That(test1, Is.SameAs(anotherTest1));
}
}

@ -0,0 +1,212 @@
// Author: Simon.Gockner
// Created: 2025-12-03
// Copyright(c) 2025 SimonG. All Rights Reserved.
using LightweightIocContainer;
using LightweightIocContainer.Exceptions;
using LightweightIocContainer.FactoryGenerator;
using Test.LightweightIocContainer.FactoryGenerator.TestClasses;
using Test.LightweightIocContainer.FactoryGenerator.TestClasses.Factories;
using Test.LightweightIocContainer.FactoryGenerator.TestClasses.Interfaces;
namespace Test.LightweightIocContainer.FactoryGenerator;
[TestFixture]
public class FluentFactoryRegistrationTest
{
private IocContainer _iocContainer;
[SetUp]
public void SetUp() => _iocContainer = new IocContainer();
[TearDown]
public void TearDown() => _iocContainer.Dispose();
[Test]
public void TestFluentFactoryRegistration()
{
_iocContainer.Register(r => r.Add<IDefaultTest, DefaultTest>().WithGeneratedFactory<IDefaultTestFactory>());
IDefaultTestFactory factory = _iocContainer.Resolve<IDefaultTestFactory>();
IDefaultTest test = factory.Create();
Assert.That(factory, Is.InstanceOf<IDefaultTestFactory>());
Assert.That(test, Is.InstanceOf<IDefaultTest>());
}
[Test]
public void TestFluentFactoryRegistrationResolveWithoutFactoryFails()
{
_iocContainer.Register(r => r.Add<IDefaultTest, DefaultTest>().WithGeneratedFactory<IDefaultTestFactory>());
Assert.Throws<DirectResolveWithRegisteredFactoryNotAllowed>(()=>_iocContainer.Resolve<IDefaultTest>());
}
[Test]
public void TestRegisterFactoryWithoutCreate() => Assert.Throws<InvalidFactoryRegistrationException>(() => _iocContainer.Register(r => r.Add<IDefaultTest, DefaultTest>().WithGeneratedFactory<ITestFactoryNoCreate>()));
[Test]
public void TestResolveFromFactory()
{
_iocContainer.Register(r => r.Add<IDefaultTest, DefaultTest>().WithGeneratedFactory<IDefaultTestFactory>());
IDefaultTestFactory testFactory = _iocContainer.Resolve<IDefaultTestFactory>();
IDefaultTest createdTest = testFactory.Create();
Assert.That(createdTest, Is.InstanceOf<DefaultTest>());
}
[Test]
public void TestResolveFromFactoryWithParams()
{
_iocContainer.Register(r => r.Add<IDefaultTest, TestConstructor>().WithGeneratedFactory<IDefaultTestFactory>());
_iocContainer.Register(r => r.Add<DefaultTest, DefaultTest>()); //this registration is abnormal and should only be used in unit tests
IDefaultTestFactory testFactory = _iocContainer.Resolve<IDefaultTestFactory>();
IDefaultTest createdTest = testFactory.Create("Test");
Assert.That(createdTest, Is.InstanceOf<TestConstructor>());
}
[Test]
public void TestResolveFromFactoryWithDefaultParamCreate()
{
_iocContainer.Register(r => r.Add<IDefaultTest, TestConstructor>().WithGeneratedFactory<IDefaultTestFactory>());
_iocContainer.Register(r => r.Add<DefaultTest, DefaultTest>()); //this registration is abnormal and should only be used in unit tests
IDefaultTestFactory testFactory = _iocContainer.Resolve<IDefaultTestFactory>();
IDefaultTest createdTest = testFactory.CreateTest();
Assert.That(createdTest, Is.InstanceOf<TestConstructor>());
}
[Test]
public void TestResolveFromFactoryWithDefaultParamCtor()
{
_iocContainer.Register(r => r.Add<IDefaultTest, TestConstructor>().WithGeneratedFactory<IDefaultTestFactory>());
_iocContainer.Register(r => r.Add<DefaultTest, DefaultTest>()); //this registration is abnormal and should only be used in unit tests
IDefaultTestFactory testFactory = _iocContainer.Resolve<IDefaultTestFactory>();
IDefaultTest createdTest = testFactory.Create();
Assert.That(createdTest, Is.InstanceOf<TestConstructor>());
}
[Test]
public void TestResolveFromFactoryWithByte()
{
_iocContainer.Register(r => r.Add<IDefaultTest, TestByte>().WithGeneratedFactory<IDefaultTestFactory>());
IDefaultTestFactory testFactory = _iocContainer.Resolve<IDefaultTestFactory>();
IDefaultTest createdTest = testFactory.Create(1);
Assert.That(createdTest, Is.InstanceOf<TestByte>());
}
[Test]
public void TestPassingNullAsMiddleParameter()
{
_iocContainer.Register(r => r.Add<IDefaultTest, TestNull>().WithGeneratedFactory<ITestNullFactory>());
ITestNullFactory testNullFactory = _iocContainer.Resolve<ITestNullFactory>();
object obj = new();
string content = "TestContent";
string optional2 = "optionalParameter2";
IDefaultTest createdTest = testNullFactory.Create(obj, content, null!, optional2);
if (createdTest is not TestNull testNull)
{
Assert.Fail();
return;
}
Assert.That(testNull.Obj, Is.SameAs(obj));
Assert.That(testNull.Content, Is.EqualTo(content));
Assert.That(testNull.Optional1, Is.Null);
Assert.That(testNull.Optional2, Is.EqualTo(optional2));
}
[Test]
public void TestPassingNullAsDefaultParameter()
{
_iocContainer.Register(r => r.Add<IDefaultTest, TestNull>().WithGeneratedFactory<ITestDefaultFactory>());
ITestDefaultFactory testDefaultFactory = _iocContainer.Resolve<ITestDefaultFactory>();
object obj = new();
string content = "TestContent";
string optional2 = "optionalParameter2";
IDefaultTest createdTest = testDefaultFactory.Create(obj, content, null!, optional2);
if (createdTest is not TestNull testNull)
{
Assert.Fail();
return;
}
Assert.That(testNull.Obj, Is.SameAs(obj));
Assert.That(testNull.Content, Is.EqualTo(content));
Assert.That(testNull.Optional1, Is.Null);
Assert.That(testNull.Optional2, Is.EqualTo(optional2));
Assert.That(testNull.TestNullFactory, Is.Null);
}
[Test]
public void TestResolveMultitonFromFactory()
{
_iocContainer.Register(r => r.AddMultiton<IDefaultTest, TestMultiton, MultitonScope>().WithGeneratedFactory<IMultitonTestFactory>());
MultitonScope scope1 = new();
MultitonScope scope2 = new();
IMultitonTestFactory testFactory = _iocContainer.Resolve<IMultitonTestFactory>();
IDefaultTest resolvedTest1 = testFactory.Create(scope1);
IDefaultTest resolvedTest2 = testFactory.Create(scope1);
IDefaultTest resolvedTest3 = testFactory.Create(scope2);
Assert.That(resolvedTest1, Is.SameAs(resolvedTest2));
Assert.That(resolvedTest1, Is.Not.SameAs(resolvedTest3));
Assert.That(resolvedTest2, Is.Not.SameAs(resolvedTest3));
}
[Test]
public void TestResolveMultitonFromFactoryClearInstances()
{
_iocContainer.Register(r => r.AddMultiton<IDefaultTest, TestMultiton, MultitonScope>().WithGeneratedFactory<IMultitonTestFactory>());
MultitonScope scope1 = new();
MultitonScope scope2 = new();
IMultitonTestFactory testFactory = _iocContainer.Resolve<IMultitonTestFactory>();
IDefaultTest resolvedTest1 = testFactory.Create(scope1);
IDefaultTest resolvedTest2 = testFactory.Create(scope1);
IDefaultTest resolvedTest3 = testFactory.Create(scope2);
Assert.That(resolvedTest1, Is.SameAs(resolvedTest2));
Assert.That(resolvedTest1, Is.Not.SameAs(resolvedTest3));
Assert.That(resolvedTest2, Is.Not.SameAs(resolvedTest3));
testFactory.ClearMultitonInstance<IDefaultTest>();
IDefaultTest resolvedTest4 = testFactory.Create(scope1);
IDefaultTest resolvedTest5 = testFactory.Create(scope2);
Assert.That(resolvedTest1, Is.Not.SameAs(resolvedTest4));
Assert.That(resolvedTest2, Is.Not.SameAs(resolvedTest4));
Assert.That(resolvedTest3, Is.Not.SameAs(resolvedTest5));
}
[Test]
public void InvalidMultitonFactoryRegistrationFactoryWithoutParameter() =>
Assert.Throws<InvalidFactoryRegistrationException>(() => _iocContainer.Register(r => r.AddMultiton<IDefaultTest, DefaultTest, MultitonScope>().WithGeneratedFactory<IDefaultTestFactory>()));
[Test]
public void InvalidMultitonFactoryRegistrationFactoryWithoutScopeAsFirstParameter() =>
Assert.Throws<InvalidFactoryRegistrationException>(() => _iocContainer.Register(r => r.AddMultiton<IDefaultTest, DefaultTest, MultitonScope>().WithGeneratedFactory<IInvalidMultitonTestFactory>()));
[Test]
public void TestInvalidCreateMethodReturnType() =>
Assert.Throws<InvalidFactoryRegistrationException>(() => _iocContainer.Register(r => r.Add<IDefaultTest, DefaultTest>().WithGeneratedFactory<ITestFactoryWrongReturn>()));
}

@ -0,0 +1,40 @@
// Author: Simon.Gockner
// Created: 2025-12-03
// Copyright(c) 2025 SimonG. All Rights Reserved.
using LightweightIocContainer;
using LightweightIocContainer.FactoryGenerator;
using Test.LightweightIocContainer.FactoryGenerator.TestClasses;
using Test.LightweightIocContainer.FactoryGenerator.TestClasses.Factories;
using Test.LightweightIocContainer.FactoryGenerator.TestClasses.Interfaces;
namespace Test.LightweightIocContainer.FactoryGenerator;
[TestFixture]
public class MultiLayerResolveTest
{
[Test]
public void TestResolveFactoryAsCtorParameter()
{
IocContainer container = new();
container.Register(r => r.Add<IA, A>().WithGeneratedFactory<IAFactory>());
container.Register(r => r.Add<IB, B>().WithGeneratedFactory<IBFactory>());
IAFactory aFactory = container.Resolve<IAFactory>();
IA a = aFactory.Create();
Assert.That(a, Is.InstanceOf<A>());
}
[Test]
public void TestResolveSingleTypeRegistrationAsCtorParameter()
{
IocContainer container = new();
container.Register(r => r.Add<IA, A>());
container.Register(r => r.Add<IB, B>().WithGeneratedFactory<IBFactory>());
container.Register(r => r.Add<C>().WithFactoryMethod(_ => new C("test")));
IBFactory bFactory = container.Resolve<IBFactory>();
IB b = bFactory.Create();
Assert.That(b, Is.InstanceOf<B>());
}
}

@ -0,0 +1,41 @@
// Author: Simon.Gockner
// Created: 2025-12-03
// Copyright(c) 2025 SimonG. All Rights Reserved.
using LightweightIocContainer;
using LightweightIocContainer.FactoryGenerator;
using Test.LightweightIocContainer.FactoryGenerator.TestClasses;
using Test.LightweightIocContainer.FactoryGenerator.TestClasses.Factories;
using Test.LightweightIocContainer.FactoryGenerator.TestClasses.Interfaces;
namespace Test.LightweightIocContainer.FactoryGenerator;
[TestFixture]
public class OpenGenericRegistrationTest
{
private IocContainer _iocContainer;
[SetUp]
public void SetUp() => _iocContainer = new IocContainer();
[TearDown]
public void TearDown() => _iocContainer.Dispose();
[Test]
public void TestRegisterFactoryOfOpenGenericType()
{
_iocContainer.Register(r => r.AddOpenGenerics(typeof(IGenericTest<>), typeof(GenericTest<>)).WithGeneratedFactory<IGenericTestFactory>());
IGenericTestFactory testFactory = _iocContainer.Resolve<IGenericTestFactory>();
IGenericTest<Constraint> test = testFactory.Create<Constraint>();
Assert.That(test, Is.InstanceOf<GenericTest<Constraint>>());
}
[Test]
public void TestRegisterFactoryOfOpenGenericTypeWithCtorParameter()
{
_iocContainer.Register(r => r.AddOpenGenerics(typeof(IGenericTest<>), typeof(CtorGenericTest<>)).WithGeneratedFactory<ICtorGenericTestFactory>());
ICtorGenericTestFactory testFactory = _iocContainer.Resolve<ICtorGenericTestFactory>();
IGenericTest<Constraint> test = testFactory.Create(new Constraint());
Assert.That(test, Is.InstanceOf<CtorGenericTest<Constraint>>());
}
}

@ -0,0 +1,33 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.4"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageReference Include="NUnit" Version="4.4.0" />
<PackageReference Include="NUnit.Analyzers" Version="4.11.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="NUnit3TestAdapter" Version="6.0.0-beta.3" />
</ItemGroup>
<ItemGroup>
<Using Include="NUnit.Framework"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LightweightIocContainer\LightweightIocContainer.csproj" />
<ProjectReference Include="..\LightweightIocContainer.FactoryGenerator\LightweightIocContainer.FactoryGenerator.csproj"
OutputItemType="Analyzer"
ReferenceOutputAssembly="false"/>
</ItemGroup>
</Project>

@ -0,0 +1,10 @@
using Test.LightweightIocContainer.FactoryGenerator.TestClasses.Factories;
using Test.LightweightIocContainer.FactoryGenerator.TestClasses.Interfaces;
namespace Test.LightweightIocContainer.FactoryGenerator.TestClasses;
public class A : IA
{
public A(IBFactory bFactory) => BProperty = bFactory.Create(new C("from A"));
public IB BProperty { get; }
}

@ -0,0 +1,13 @@
namespace Test.LightweightIocContainer.FactoryGenerator.TestClasses;
public class AsyncMultitonTest(int id) : AsyncTest
{
public int Id { get; } = id;
public override async Task Initialize()
{
if (IsInitialized)
throw new Exception();
await base.Initialize();
}
}

@ -0,0 +1,14 @@
using Test.LightweightIocContainer.FactoryGenerator.TestClasses.Interfaces;
namespace Test.LightweightIocContainer.FactoryGenerator.TestClasses;
public class AsyncTest : IAsyncTest
{
public bool IsInitialized { get; private set; }
public virtual async Task Initialize()
{
await Task.Delay(200);
IsInitialized = true;
}
}

@ -0,0 +1,10 @@
using Test.LightweightIocContainer.FactoryGenerator.TestClasses.Interfaces;
namespace Test.LightweightIocContainer.FactoryGenerator.TestClasses;
public class B : IB
{
public B(C c) => C = c;
public C C { get; }
}

@ -0,0 +1,9 @@
namespace Test.LightweightIocContainer.FactoryGenerator.TestClasses;
public class C
{
public C(string test)
{
}
}

@ -0,0 +1,9 @@
// Author: Simon.Gockner
// Created: 2025-12-03
// Copyright(c) 2025 SimonG. All Rights Reserved.
using Test.LightweightIocContainer.FactoryGenerator.TestClasses.Interfaces;
namespace Test.LightweightIocContainer.FactoryGenerator.TestClasses;
public class Constraint : IConstraint;

@ -0,0 +1,11 @@
using Test.LightweightIocContainer.FactoryGenerator.TestClasses.Interfaces;
namespace Test.LightweightIocContainer.FactoryGenerator.TestClasses;
public class CtorGenericTest<T> : IGenericTest<T> where T : IConstraint, new()
{
public CtorGenericTest(T item)
{
}
}

@ -0,0 +1,5 @@
using Test.LightweightIocContainer.FactoryGenerator.TestClasses.Interfaces;
namespace Test.LightweightIocContainer.FactoryGenerator.TestClasses;
public class DefaultTest : IDefaultTest;

@ -0,0 +1,8 @@
using Test.LightweightIocContainer.FactoryGenerator.TestClasses.Interfaces;
namespace Test.LightweightIocContainer.FactoryGenerator.TestClasses.Factories;
public interface IAFactory
{
IA Create();
}

@ -0,0 +1,8 @@
using Test.LightweightIocContainer.FactoryGenerator.TestClasses.Interfaces;
namespace Test.LightweightIocContainer.FactoryGenerator.TestClasses.Factories;
public interface IAsyncMultitonTestFactory
{
Task<IAsyncTest> Create(int id);
}

@ -0,0 +1,8 @@
using Test.LightweightIocContainer.FactoryGenerator.TestClasses.Interfaces;
namespace Test.LightweightIocContainer.FactoryGenerator.TestClasses.Factories;
public interface IAsyncTestFactory
{
Task<IAsyncTest> Create();
}

@ -0,0 +1,9 @@
using Test.LightweightIocContainer.FactoryGenerator.TestClasses.Interfaces;
namespace Test.LightweightIocContainer.FactoryGenerator.TestClasses.Factories;
public interface IBFactory
{
IB Create();
IB Create(C c);
}

@ -0,0 +1,8 @@
using Test.LightweightIocContainer.FactoryGenerator.TestClasses.Interfaces;
namespace Test.LightweightIocContainer.FactoryGenerator.TestClasses.Factories;
public interface ICtorGenericTestFactory
{
IGenericTest<T> Create<T>(T item) where T : IConstraint, new();
}

@ -0,0 +1,11 @@
using Test.LightweightIocContainer.FactoryGenerator.TestClasses.Interfaces;
namespace Test.LightweightIocContainer.FactoryGenerator.TestClasses.Factories;
public interface IDefaultTestFactory
{
IDefaultTest Create();
IDefaultTest Create(string name);
IDefaultTest CreateTest(string name = null!);
IDefaultTest Create(byte id);
}

@ -0,0 +1,8 @@
using Test.LightweightIocContainer.FactoryGenerator.TestClasses.Interfaces;
namespace Test.LightweightIocContainer.FactoryGenerator.TestClasses.Factories;
public interface IGenericTestFactory
{
IGenericTest<T> Create<T>() where T : IConstraint, new();
}

@ -0,0 +1,9 @@
using Test.LightweightIocContainer.FactoryGenerator.TestClasses.Interfaces;
namespace Test.LightweightIocContainer.FactoryGenerator.TestClasses.Factories;
public interface IInvalidMultitonTestFactory
{
IDefaultTest Create(MultitonScope scope);
IDefaultTest Create(int number);
}

@ -0,0 +1,9 @@
using Test.LightweightIocContainer.FactoryGenerator.TestClasses.Interfaces;
namespace Test.LightweightIocContainer.FactoryGenerator.TestClasses.Factories;
public interface IMultitonTestFactory
{
IDefaultTest Create(MultitonScope scope);
void ClearMultitonInstance<T>();
}

@ -0,0 +1,8 @@
using Test.LightweightIocContainer.FactoryGenerator.TestClasses.Interfaces;
namespace Test.LightweightIocContainer.FactoryGenerator.TestClasses.Factories;
public interface ITestDefaultFactory
{
IDefaultTest Create(object obj, string content, string optional1, string optional2, ITestNullFactory testNullFactory = null!);
}

@ -0,0 +1,3 @@
namespace Test.LightweightIocContainer.FactoryGenerator.TestClasses.Factories;
public interface ITestFactoryNoCreate;

@ -0,0 +1,6 @@
namespace Test.LightweightIocContainer.FactoryGenerator.TestClasses.Factories;
public interface ITestFactoryWrongReturn
{
public MultitonScope Create();
}

@ -0,0 +1,8 @@
using Test.LightweightIocContainer.FactoryGenerator.TestClasses.Interfaces;
namespace Test.LightweightIocContainer.FactoryGenerator.TestClasses.Factories;
public interface ITestNullFactory
{
IDefaultTest Create(object obj, string content, string optional1, string optional2);
}

@ -0,0 +1,5 @@
using Test.LightweightIocContainer.FactoryGenerator.TestClasses.Interfaces;
namespace Test.LightweightIocContainer.FactoryGenerator.TestClasses;
public class GenericTest<T> : IGenericTest<T> where T : IConstraint, new();

@ -0,0 +1,6 @@
namespace Test.LightweightIocContainer.FactoryGenerator.TestClasses.Interfaces;
public interface IA
{
IB BProperty { get; }
}

@ -0,0 +1,7 @@
namespace Test.LightweightIocContainer.FactoryGenerator.TestClasses.Interfaces;
public interface IAsyncTest
{
bool IsInitialized { get; }
Task Initialize();
}

@ -0,0 +1,6 @@
namespace Test.LightweightIocContainer.FactoryGenerator.TestClasses.Interfaces;
public interface IB
{
C C { get; }
}

@ -0,0 +1,3 @@
namespace Test.LightweightIocContainer.FactoryGenerator.TestClasses.Interfaces;
public interface IConstraint;

@ -0,0 +1,3 @@
namespace Test.LightweightIocContainer.FactoryGenerator.TestClasses.Interfaces;
public interface IDefaultTest;

@ -0,0 +1,3 @@
namespace Test.LightweightIocContainer.FactoryGenerator.TestClasses.Interfaces;
public interface IGenericTest<T> where T : IConstraint, new();

@ -0,0 +1,3 @@
namespace Test.LightweightIocContainer.FactoryGenerator.TestClasses;
public class MultitonScope;

@ -0,0 +1,10 @@
using Test.LightweightIocContainer.FactoryGenerator.TestClasses.Interfaces;
namespace Test.LightweightIocContainer.FactoryGenerator.TestClasses;
public class TestByte : IDefaultTest
{
private readonly byte _id;
public TestByte(byte id) => _id = id;
}

@ -0,0 +1,16 @@
using Test.LightweightIocContainer.FactoryGenerator.TestClasses.Interfaces;
namespace Test.LightweightIocContainer.FactoryGenerator.TestClasses;
public class TestConstructor : IDefaultTest
{
public TestConstructor(string name, DefaultTest test)
{
}
public TestConstructor(DefaultTest test, string name = null!)
{
}
}

@ -0,0 +1,11 @@
using Test.LightweightIocContainer.FactoryGenerator.TestClasses.Interfaces;
namespace Test.LightweightIocContainer.FactoryGenerator.TestClasses;
public class TestMultiton : IDefaultTest
{
public TestMultiton(MultitonScope scope)
{
}
}

@ -0,0 +1,23 @@
using Test.LightweightIocContainer.FactoryGenerator.TestClasses.Factories;
using Test.LightweightIocContainer.FactoryGenerator.TestClasses.Interfaces;
namespace Test.LightweightIocContainer.FactoryGenerator.TestClasses;
public class TestNull : IDefaultTest
{
public TestNull(object obj, string content, string optional1, string optional2, ITestNullFactory testNullFactory)
{
Obj = obj;
Content = content;
Optional1 = optional1;
Optional2 = optional2;
TestNullFactory = testNullFactory;
}
public object Obj { get; }
public string Content { get; }
public string Optional1 { get; }
public string Optional2 { get; }
public ITestNullFactory TestNullFactory { get; }
}

@ -13,7 +13,7 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageReference Include="NSubstitute" Version="5.3.0" /> <PackageReference Include="NSubstitute" Version="5.3.0" />
<PackageReference Include="nunit" Version="4.4.0" /> <PackageReference Include="nunit" Version="4.4.0" />
<PackageReference Include="NUnit3TestAdapter" Version="6.0.0-beta.2.1"> <PackageReference Include="NUnit3TestAdapter" Version="6.0.0-beta.3">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>

@ -13,7 +13,7 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageReference Include="NSubstitute" Version="5.3.0" /> <PackageReference Include="NSubstitute" Version="5.3.0" />
<PackageReference Include="nunit" Version="4.4.0" /> <PackageReference Include="nunit" Version="4.4.0" />
<PackageReference Include="NUnit3TestAdapter" Version="6.0.0-beta.2.1"> <PackageReference Include="NUnit3TestAdapter" Version="6.0.0-beta.3">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>

Loading…
Cancel
Save