Closed hammdo closed 5 years ago
When creating a Decorator Library, I was able to build fine locally. When I added a ServiceRegistry to an external library and included that in my unit tests, I received this error:
/*****/ System.InvalidOperationException HResult=0x80131509 Message=Compilation failures!
CS0234: The type or namespace name 'Transformer' does not exist in the namespace 'CUDC.DataProtection' (are you missing an assembly reference?)
Code:
using System.Threading.Tasks;
namespace Jasper.Generated
{
// START: CUDC_DataProtection_Core_Interfaces_IProvideDataProtectionTransformation_provideDataProtectionTransformation
public class CUDC_DataProtection_Core_Interfaces_IProvideDataProtectionTransformation_provideDataProtectionTransformation : Lamar.IoC.Resolvers.TransientResolver
public override CUDC.DataProtection.Core.Interfaces.IProvideDataProtectionTransformation Build(Lamar.IoC.Scope scope)
{
var provideDataProtectionKey = new CUDC.DataProtection.Provider.Embeded.Key.Providers.ProvideDataProtectionKey();
var provideDataProtectionKeyList = new System.Collections.Generic.List<CUDC.DataProtection.Core.Interfaces.IProvideDataProtectionKey>{provideDataProtectionKey};
var provideDataProtection1 = new CUDC.DataProtection.Provider.AES.Providers.ProvideDataProtection(provideDataProtectionKeyList);
var provideDataProtection2 = new CUDC.DataProtection.Provider.Base64.Providers.ProvideDataProtection();
var provideDataProtectionList = new System.Collections.Generic.List<CUDC.DataProtection.Core.Interfaces.IProvideDataProtection>{provideDataProtection1, provideDataProtection2};
var transformationProvider_inline_1 = new CUDC.DataProtection.Transformer.Transformers.ProvideDataProtectionTransformation(provideDataProtectionList);
return new CUDC.DataProtection.Aspect.Logger.ProvideDataProtectionTransformationAspect(transformationProvider_inline_1);
}
}
// END: CUDC_DataProtection_Core_Interfaces_IProvideDataProtectionTransformation_provideDataProtectionTransformation
}
Source=LamarCompiler StackTrace: at LamarCompiler.AssemblyGenerator.Generate(String code) at LamarCompiler.GeneratedAssembly.CompileAll(IServiceVariableSource services) at Lamar.IoC.Instances.GeneratedInstance.buildResolver(Scope scope) at Lamar.IoC.Instances.GeneratedInstance.ToResolver(Scope topScope) at Lamar.ServiceGraph.FindResolver(Type serviceType) at Lamar.IoC.Scope.GetInstance(Type serviceType) at Lamar.IoC.Scope.GetInstance[T]() at Tests.DataProtectionLamarIoCTests.Given_Container_Validate_Transformer_Exists() in F:\Projects\play-ground\don.hamm\CUDC.DataProtection\CUDC.DataProtection.Tests\DataProtectionLamarIoCTests.cs:line 35
Basically I have a decorator Library, a Service Registry Library, and the 'interface implementation' library. All 3 are referenced in the test project. This is for .Net Standard.
Let me know what else I can provide to help.
-Don
In the top picture, why was the registration of the decorator showing up as red? Is there some problem making the reference from one lib to another? Runtime incompatibility? Binding conflict?
Can you try to take the code that is not compiling, copy/paste that to a new C# code file in your testing project, and see if it does compiler there?
Like I noted, it was resharper -- its is loading (the second image shows it actually did hit and load).
Here is the actual code it tried to compile:
Code:
using System.Threading.Tasks;
namespace Jasper.Generated
{
// START: CUDC_DataProtection_Core_Interfaces_IProvideDataProtectionTransformation_provideDataProtectionTransformation
public class CUDC_DataProtection_Core_Interfaces_IProvideDataProtectionTransformation_provideDataProtectionTransformation : Lamar.IoC.Resolvers.TransientResolver
public override CUDC.DataProtection.Core.Interfaces.IProvideDataProtectionTransformation Build(Lamar.IoC.Scope scope)
{
var provideDataProtectionKey = new CUDC.DataProtection.Provider.Embeded.Key.Providers.ProvideDataProtectionKey();
var provideDataProtectionKeyList = new System.Collections.Generic.List<CUDC.DataProtection.Core.Interfaces.IProvideDataProtectionKey>{provideDataProtectionKey};
var provideDataProtection1 = new CUDC.DataProtection.Provider.AES.Providers.ProvideDataProtection(provideDataProtectionKeyList);
var provideDataProtection2 = new CUDC.DataProtection.Provider.Base64.Providers.ProvideDataProtection();
var provideDataProtectionList = new System.Collections.Generic.List<CUDC.DataProtection.Core.Interfaces.IProvideDataProtection>{provideDataProtection1, provideDataProtection2};
var transformationProvider_inline_1 = new CUDC.DataProtection.Transformer.Transformers.ProvideDataProtectionTransformation(provideDataProtectionList);
var transformationProvider_inline_2 = new CUDC.DataProtection.Aspect.Security.ProvideDataProtectionTransformationSecurityAspect(transformationProvider_inline_1);
return new CUDC.DataProtection.Aspect.Logger.ProvideDataProtectionTransformationLoggerAspect(transformationProvider_inline_2);
}
}
// END: CUDC_DataProtection_Core_Interfaces_IProvideDataProtectionTransformation_provideDataProtectionTransformation
}
I can say the Autofac registration and Decorators load fine (those follow the same .net library pattern). It tried to test this (runtime unit test) and that is when the test ran, I got the compilation error.
So, .net standard libraries, .net core test (nUnit)
Registration is a .net standard lib (with the registration for the decorator) Interface (core) lib is a .net standard lib Implementation of interface is a .net standard lib Aspect is a .net standard lib (using the interface from core)
nUnit is a .net Core test library
I did take the code and put it in the test project and it did compile fine:
This is the 'full' jasper code generated:
And it compiles also (with a different set of decorated aspects)...
Registration:
Thanks again!
-Don
I created a fork that has the scenario that shows exactly what I'm referring too -- with a test.
https://github.com/hammdo/lamar
Resharper shows red but, its valid as I ran 'debug' test to confirm.
-Don
If you have a fork, can you just make a pull request w/ the failing test? That's the very most actionable bug report;)
Sure... will do...
Done! Let me know how I can help or if I need to restructure anything...
My guess is the 'references' passed do not contain all the libraries I created...
-Don
Thanks Jeremy! Appreciate the help -- looking forward to 2.1!
-Don
It would be great if issues could be tagged with information from which version they're fixed 😄
The comments right above you say "2.1", and I normally mark a milestone.
Below is a basic setup of the solution (.Net Standard -- ref is there -- Resharper is slow):
Registration does occur:
Error: