Giter Site home page Giter Site logo

capgemini / cauldron Goto Github PK

View Code? Open in Web Editor NEW

This project forked from reflection-emit/cauldron

76.0 76.0 19.0 124.13 MB

C# Toolkit

License: MIT License

C# 99.86% Batchfile 0.01% PowerShell 0.13%
aop aspect capgemini cauldron csharp fody interception interceptor netcore uwp uwp-applications

cauldron's People

Contributors

delmoskito avatar reflection-emit avatar seconddata avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cauldron's Issues

OutOfMemoryException on build intercepted project

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.

Constructor interception feature

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.

Property interception for regular properties

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.

HWND cannot be IntPtr.Zero

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

Issues with Microsoft.IdentityModel

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

Autogenerated CreateInstance convertion from object to Enum is incorrect

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; }

Better Auth2 in Desktop

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

  • The user waits too long to enter the credentials
  • The user closes the browser tab
  • The user cancels the Auth2

Copied from original issue: reflection-emit#4

CreateType has problems with previous calls

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.

Init method in interceptor pulling in method/property/etc information for use in the interception

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.

As<> Implicit Explicit convertion breaks if multiple methods with the same parameter exists

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;
    }

Better Auth2 in Desktop

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

  • The user waits too long to enter the credentials
  • The user closes the browser tab
  • The user cancels the Auth2

Copied from original issue: reflection-emit#4

System.ServiceModel referencing System.XAML breaks Weaver

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);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.