capgemini / cauldron Goto Github PK
View Code? Open in Web Editor NEWThis project forked from reflection-emit/cauldron
C# Toolkit
License: MIT License
This project forked from reflection-emit/cauldron
C# Toolkit
License: MIT License
I have a project (ProcessManager.sll) using Cauldron.Interception. On that same project I have referenced a custom reports NuGet which itself references some ActiveRreports dll.
When building the original ProcessManager.dll project I get this error (i obfuscated project paths as Report_NuGet_Local_Path)
MSBUILD : error : Fody/Cauldron.Interception: Exception Type: Exception
1>MSBUILD : error : Source: FodyIsolated
1>MSBUILD : error : Could not read '[Report_NuGet_Local_Path]\ActiveReports.Document.dll'.
1>MSBUILD : error : ------------------------
1>MSBUILD : error : at AssemblyResolver.GetAssembly(String file, ReaderParameters parameters) in C:\projects\fody\FodyIsolated\AssemblyResolver.cs:line 46
1>MSBUILD : error : at AssemblyResolver.Resolve(AssemblyNameReference assemblyNameReference, ReaderParameters parameters) in C:\projects\fody\FodyIsolated\AssemblyResolver.cs:line 69
1>MSBUILD : error : at AssemblyResolver.Resolve(AssemblyNameReference assemblyNameReference) in C:\projects\fody\FodyIsolated\AssemblyResolver.cs:line 57
1>MSBUILD : error : at Cauldron.Interception.Cecilator.CecilatorBase.<GetAllAssemblyDefinitions>b__24_0(AssemblyNameReference x)
1>MSBUILD : error : at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
1>MSBUILD : error : at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
1>MSBUILD : error : at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection)
1>MSBUILD : error : at Cauldron.Interception.Cecilator.CecilatorBase.GetAllAssemblyDefinitions(IEnumerable`1 target, List`1 result)
1>MSBUILD : error : at Cauldron.Interception.Cecilator.CecilatorBase.GetAllAssemblyDefinitions(IEnumerable`1 target)
1>MSBUILD : error : at Cauldron.Interception.Cecilator.CecilatorBase..ctor(WeaverBase weaver)
1>MSBUILD : error : at Cauldron.Interception.Cecilator.Extension.CreateBuilder(WeaverBase weaver)
1>MSBUILD : error : at Cauldron.Interception.Cecilator.WeaverBase.Execute()
1>MSBUILD : error : ------------------------
1>MSBUILD : error : Exception Type: OutOfMemoryException
1>MSBUILD : error : Source: mscorlib
1>MSBUILD : error : Exception of type 'System.OutOfMemoryException' was thrown.
1>MSBUILD : error : ------------------------
1>MSBUILD : error : at System.IO.BinaryReader.ReadBytes(Int32 count)
1>MSBUILD : error : at Mono.Cecil.PE.ImageReader.ReadDebugHeader() in C:\projects\cecil\Mono.Cecil.PE\ImageReader.cs:line 357
1>MSBUILD : error : at Mono.Cecil.PE.ImageReader.ReadImage() in C:\projects\cecil\Mono.Cecil.PE\ImageReader.cs:line 89
1>MSBUILD : error : at Mono.Cecil.PE.ImageReader.ReadImage(Disposable`1 stream, String file_name) in C:\projects\cecil\Mono.Cecil.PE\ImageReader.cs:line 759
1>MSBUILD : error : at Mono.Cecil.ModuleDefinition.ReadModule(String fileName, ReaderParameters parameters) in C:\projects\cecil\Mono.Cecil\ModuleDefinition.cs:line 1092
1>MSBUILD : error : at AssemblyResolver.GetAssembly(String file, ReaderParameters parameters) in C:\projects\fody\FodyIsolated\AssemblyResolver.cs:line 42
1>MSBUILD : error : ------------------------
1>MSBUILD : error :
1>MSBUILD : error : Fody: An unhandled exception occurred:
1>MSBUILD : error : Exception:
1>MSBUILD : error : Could not read '[Report_NuGet_Local_Path]\ActiveReports.Document.dll'.
1>MSBUILD : error : StackTrace:
1>MSBUILD : error : at AssemblyResolver.GetAssembly(String file, ReaderParameters parameters) in C:\projects\fody\FodyIsolated\AssemblyResolver.cs:line 46
1>MSBUILD : error : at AssemblyResolver.Resolve(AssemblyNameReference assemblyNameReference, ReaderParameters parameters) in C:\projects\fody\FodyIsolated\AssemblyResolver.cs:line 69
1>MSBUILD : error : at AssemblyResolver.Resolve(AssemblyNameReference assemblyNameReference) in C:\projects\fody\FodyIsolated\AssemblyResolver.cs:line 57
1>MSBUILD : error : at Cauldron.Interception.Cecilator.CecilatorBase.<GetAllAssemblyDefinitions>b__24_0(AssemblyNameReference x)
1>MSBUILD : error : at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
1>MSBUILD : error : at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
1>MSBUILD : error : at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection)
1>MSBUILD : error : at Cauldron.Interception.Cecilator.CecilatorBase.GetAllAssemblyDefinitions(IEnumerable`1 target, List`1 result)
1>MSBUILD : error : at Cauldron.Interception.Cecilator.CecilatorBase.GetAllAssemblyDefinitions(IEnumerable`1 target)
1>MSBUILD : error : at Cauldron.Interception.Cecilator.CecilatorBase..ctor(WeaverBase weaver)
1>MSBUILD : error : at Cauldron.Interception.Cecilator.Extension.CreateBuilder(WeaverBase weaver)
1>MSBUILD : error : at Cauldron.Interception.Cecilator.WeaverBase.Execute()
1>MSBUILD : error : at lambda_method(Closure , Object )
1>MSBUILD : error : at InnerWeaver.ExecuteWeavers() in C:\projects\fody\FodyIsolated\InnerWeaver.cs:line 198
1>MSBUILD : error : at InnerWeaver.Execute() in C:\projects\fody\FodyIsolated\InnerWeaver.cs:line 100
1>MSBUILD : error : Source:
1>MSBUILD : error : FodyIsolated
1>MSBUILD : error : TargetSite:
1>MSBUILD : error : Mono.Cecil.AssemblyDefinition GetAssembly(System.String, Mono.Cecil.ReaderParameters)
1>MSBUILD : error : Exception of type 'System.OutOfMemoryException' was thrown.
1>MSBUILD : error : StackTrace:
1>MSBUILD : error : at System.IO.BinaryReader.ReadBytes(Int32 count)
1>MSBUILD : error : at Mono.Cecil.PE.ImageReader.ReadDebugHeader() in C:\projects\cecil\Mono.Cecil.PE\ImageReader.cs:line 357
1>MSBUILD : error : at Mono.Cecil.PE.ImageReader.ReadImage() in C:\projects\cecil\Mono.Cecil.PE\ImageReader.cs:line 89
1>MSBUILD : error : at Mono.Cecil.PE.ImageReader.ReadImage(Disposable`1 stream, String file_name) in C:\projects\cecil\Mono.Cecil.PE\ImageReader.cs:line 759
1>MSBUILD : error : at Mono.Cecil.ModuleDefinition.ReadModule(String fileName, ReaderParameters parameters) in C:\projects\cecil\Mono.Cecil\ModuleDefinition.cs:line 1092
1>MSBUILD : error : at AssemblyResolver.GetAssembly(String file, ReaderParameters parameters) in C:\projects\fody\FodyIsolated\AssemblyResolver.cs:line 42
1>MSBUILD : error : Source:
1>MSBUILD : error : mscorlib
1>MSBUILD : error : TargetSite:
1>MSBUILD : error : Byte[] ReadBytes(Int32)
1>MSBUILD : error :
I've googled about it and found Fody has some trouble via Cecil with certain versions of Mono. Is there any workaround for this? I've been using Cauldron.Interceptor with other projects with no problems, only get this when I combine it with those dlls.
From @reflection-emit on February 9, 2017 11:3
Move the Inject attribute from Cauldron.Injector to Cauldron.Activator and use an Interceptor to implement a lazy injection.
Copied from original issue: reflection-emit#3
Following up on #44 regarding constructor interception.
Should I add it before or after base class call…
For my personal use case, I'd need to be able to run code before anything (including the base class call).
Should it be around the original constructor body
What's the other option? Inside the actual constructor body? Don't think that changes anything for me either way but other people might prefer the injected code to be run outside of the body?
Does it make sense to have a try-catch
It does not affect my particular use case, but I'd say yes. To remain consistent with the interception API for methods and properties, for one. And because user code can always throw and they might want to handle it.
From @reflection-emit on February 12, 2017 18:25
Copied from original issue: reflection-emit#6
From @reflection-emit on February 16, 2017 17:33
... for performance reasons.
Copied from original issue: reflection-emit#23
Hi,
Thanks for this package. Helpful to have netstandard support.
I've noticed the property interception only supports auto-properties.
What would it take to make it available for regular properties as well?
Cheers.
Check for HWND IntPtr.Zero at ApplicationBase line 359
Win32Api.SendMessage(processes[0].MainWindowHandle, $"{e.Args.Join("\n")}"); this.ShutdownMode = ShutdownMode.OnExplicitShutdown; this.Shutdown();
processes[0].MainWindowHandle should be checked for Zero
multiple interceptors are applied to async methods
From @reflection-emit on February 13, 2017 9:41
Copied from original issue: reflection-emit#13
From @reflection-emit on February 15, 2017 16:35
Can be a Cecil bug... Might be a bug in Cauldron Code... -> Try catch finally implementation.
Same code works fine in Release mode... Only on debug where br_false is used ... The reference to the old jump address stay the same, even though new instructions are inserted before the code.
Copied from original issue: reflection-emit#20
From @reflection-emit on February 13, 2017 18:50
Copied from original issue: reflection-emit#16
ClassA ---|
ClassB ---|
|-- BaseClassB ---|
|-- BaseClassA -> ComponentConstructor
ComponentConstructor is found for ClassA, but not for ClassB
From @reflection-emit on February 12, 2017 18:41
Copied from original issue: reflection-emit#9
From @reflection-emit on February 13, 2017 9:29
Copied from original issue: reflection-emit#12
Loading error with Microsoft.IdentityModel
System.TypeInitializationException
Error while loading an assemblyDie Datei oder Assembly "Microsoft.IdentityModel,
Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" oder eine Ab
From @reflection-emit on February 14, 2017 16:5
Copied from original issue: reflection-emit#18
IL code is messed up if an attribute is copied to the actual code... If the attribute constructor has param arrays.
From @reflection-emit on February 14, 2017 16:7
Implement if lock if pattern to be thread safe
Copied from original issue: reflection-emit#19
Is this a Cauldron issue or .NET?
From @reflection-emit on February 12, 2017 18:26
Copied from original issue: reflection-emit#7
Idea taken from #45
Example:
https://code.videolan.org/videolan/libvlcpp/blob/master/vlcpp/MediaDiscoverer.hpp#L92
{"Der Typ mit dem Namen "{clr-namespace:Cauldron.XAML.Interactivity;assembly=Cauldron.XAML.Interactivity}ContentControlProperties" kann vom Typverweis nicht gefunden werden."}
Sample:
Wrong
public object CreateInstance(object[] array) { object result; if (array.Length == 1 && array[0] is Processes) { result = new Database((Processes)Enum.ToObject(array[0], Convert.ChangeType(typeof(Processes), Enum.GetUnderlyingType(typeof(Processes))))); } else { result = typeof(Database).CreateInstance(array); } return result; }
Should be
public object CreateInstance(object[] array) { object result; if (array.Length == 1 && array[0] is Processes) { result = new Database((Processes)Convert.ChangeType(array[0], Enum.GetUnderlyingType(typeof(Processes)))); } else { result = typeof(Database).CreateInstance(array); } return result; }
From @reflection-emit on February 12, 2017 18:6
The current implementation will open a browser and wait for it to report back the token.
There are some issues regarding this on some scenarios
Copied from original issue: reflection-emit#4
public object CreateInstance(Type type, object[] args)
{
var types = args == null || args.Length == 0 ? Type.EmptyTypes : args.Select(x => x?.GetType() ?? null).ToArray();
Example:
public static TResult Blabla<T, TResult>(this T value, Func<T, TResult> function) => function(value);
var blub = "Hi;This;Is;Me"; var huhu = blub.Split(';').Blabla(x=> new { Name = x[3], Description = x[1] }).CreateType<ISpecial>();
CreateType should check for generic resturn type on "Blabla" call and use this to create the anonymous type.
The current implementation also does not consider static methods.
Ie. pulling in MethodBase and args (for methods) like this:
public void Init(object instance, MethodBase method, object[] args) {
TestMessages.Record(string.Format("Init: {0} [{1}]", method.DeclaringType.FullName + "." + method.Name, args.Length));
}
Idea taken from MethodDecorator.Fody, but would be very useful for knowing something about the instance and method/property/anything we are weaving.
From @reflection-emit on February 13, 2017 9:26
Copied from original issue: reflection-emit#11
From @reflection-emit on February 15, 2017 19:40
Copied from original issue: reflection-emit#21
From @reflection-emit on February 12, 2017 18:19
Weave the validations directly into the viewmodels for more performance
Copied from original issue: reflection-emit#5
The added Property PropertyInterceptionInfo is not marked as NonSerialized which makes it impossible to intercept Properties of classes which shall be serialized
From @reflection-emit on February 15, 2017 20:14
Copied from original issue: reflection-emit#22
Use this instead
public static MethodInfo GetImplicitOrExplicit(this Type type, Type resultType)
{
var result = resultType.GetMethods(BindingFlags.Static | BindingFlags.Public)
.FirstOrDefault(x => (x.Name == "op_Implicit" || x.Name == "op_Explicit") && x.ReturnType == resultType && x.GetParameters()[0].ParameterType == type);
if (result == null)
return type.GetMethods(BindingFlags.Static | BindingFlags.Public)
.FirstOrDefault(x => (x.Name == "op_Implicit" || x.Name == "op_Explicit") && x.ReturnType == resultType && x.GetParameters()[0].ParameterType == type);
return result;
}
From @reflection-emit on February 12, 2017 18:6
The current implementation will open a browser and wait for it to report back the token.
There are some issues regarding this on some scenarios
Copied from original issue: reflection-emit#4
... should be also possible
:(
XAML.Validation for UWP does not build
Detection for XAML usage should be done better
if (builder.IsReferenced("Cauldron.Activator") && (builder.IsReferenced("Cauldron.XAML") || builder.IsReferenced("System.Xaml") || builder.IsReferenced("Windows.UI.Xaml")))
AddAttributeToXAMLResources(builder);
From @reflection-emit on February 13, 2017 9:41
Copied from original issue: reflection-emit#13
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.