public OperatorInjection(Project project) { var objectTypeDef = project.Module.Cache.GetIntrinsic(IntrinsicType.Object).GetTypeDefinition(); this.staticEqualsMethod = project.Module.FindMethod(objectTypeDef, "Equals", 2); var operatorTypeDef = project.Module.Cache.GetType(typeof(Operator)).GetTypeDefinition(); this.weaveMethod = project.Module.FindMethod(operatorTypeDef, "Weave"); }
private CustomAttributeDeclaration CreateThreadStaticAttribute() { if (this.threadStaticAttributeConstructor == null) { this.threadStaticAttributeConstructor = this.module.FindMethod("System.ThreadStaticAttribute, mscorlib", ".ctor", BindingOptions.DontThrowException, 0); } return(new CustomAttributeDeclaration(this.threadStaticAttributeConstructor)); }
private IMethod FindConsoleWriteLine() { // Represents the module (= assembly) that we're modifying: ModuleDeclaration module = this.Project.Module; // Finds the System.Console type usable in that module. We don't know exactly where it comes from. It could // be mscorlib in .NET Framework or something else in .NET Core: INamedType console = (INamedType)module.FindType(typeof(Console)); // Finds the one overload that we want: System.Console.WriteLine(System.String): IGenericMethodDefinition method = module.FindMethod(console, "WriteLine", declaration => declaration.Parameters.Count == 1 && declaration.Parameters[0].ParameterType.GetReflectionName() == "System.String"); return(method); }
// ReSharper restore InconsistentNaming public MoveNextTransformation(AsyncStateMachineAspectWeaver parent) : base(parent) { ModuleDeclaration module = parent.Module; // ReSharper disable InconsistentNaming IType actor_Type = (IType)module.FindType(typeof(Actor), BindingOptions.Default); this.actor_GetDispatcher_Method = module.FindMethod(actor_Type, "get_Dispatcher"); IType dispatcher_Type = (IType)module.FindType(typeof(IDispatcher), BindingOptions.Default); this.dispatcher_CheckAccess_Method = module.FindMethod(dispatcher_Type, "CheckAccess"); this.dispatcher_getSynchronizationContext_Method = module.FindMethod(dispatcher_Type, "get_SynchronizationContext"); IType task_Type = (IType)module.FindType(typeof(Task), BindingOptions.Default); this.task_Yield_Method = module.FindMethod(task_Type, "Yield", 0); IType yieldAwaitable_Type = (IType)module.FindType("System.Runtime.CompilerServices.YieldAwaitable, mscorlib", BindingOptions.Default); this.yieldAwaitable_GetAwaiter_Method = module.FindMethod(yieldAwaitable_Type, "GetAwaiter"); this.yieldAwaiter_Type = (IType)this.yieldAwaitable_GetAwaiter_Method.ReturnType; this.asyncVoidMethodBuilder_Type = (IType)module.FindType("System.Runtime.CompilerServices.AsyncVoidMethodBuilder, mscorlib", BindingOptions.Default); this.asyncVoidMethodBuilder_AwaitUnsafeOnCompleted_Method = module.FindMethod(this.asyncVoidMethodBuilder_Type, "AwaitUnsafeOnCompleted"); this.asyncTaskMethodBuilder_Type = (IType)module.FindType("System.Runtime.CompilerServices.AsyncTaskMethodBuilder, mscorlib", BindingOptions.Default); this.asyncTaskMethodBuilder_AwaitUnsafeOnCompleted_Method = module.FindMethod(this.asyncTaskMethodBuilder_Type, "AwaitUnsafeOnCompleted"); this.asyncTaskMethodBuilderGenericType = (IType)module.FindType("System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1, mscorlib", BindingOptions.Default); this.asyncTaskMethodBuilderGeneric_AwaitUnsafeOnCompleted_Method = module.FindMethod(this.asyncTaskMethodBuilderGenericType, "AwaitUnsafeOnCompleted"); this.synchronizationContext_Type = (IType)module.FindType(typeof(SynchronizationContext), BindingOptions.Default); this.synchronizationContext_getCurrent_Method = module.FindMethod(this.synchronizationContext_Type, "get_Current"); this.synchronizationContext_SetSynchronizationContext_Method = module.FindMethod(this.synchronizationContext_Type, "SetSynchronizationContext"); // ReSharper restore InconsistentNaming }
public EqualsInjection(Project project) { this.objectType = project.Module.Cache.GetIntrinsic(IntrinsicType.Object); this.booleanType = project.Module.Cache.GetIntrinsic(IntrinsicType.Boolean); this.objectTypeDef = this.objectType.GetTypeDefinition(); this.referenceEqualsMethod = project.Module.FindMethod(objectTypeDef, "ReferenceEquals"); this.instanceEqualsMethod = project.Module.FindMethod(objectTypeDef, "Equals", 1); this.staticEqualsMethod = project.Module.FindMethod(objectTypeDef, "Equals", 2); this.getTypeMethod = project.Module.FindMethod(objectTypeDef, "GetType"); var collectionHelperTypeDef = project.Module.Cache.GetType(typeof(CollectionHelper)).GetTypeDefinition(); this.collectionEqualsMethod = project.Module.FindMethod(collectionHelperTypeDef, "Equals", declaration => declaration.IsStatic); var typeTypeDef = project.Module.Cache.GetType(typeof(Type)).GetTypeDefinition(); this.getTypeFromHandleMethod = project.Module.FindMethod(typeTypeDef, "GetTypeFromHandle"); this.equatableInterface = project.Module.Cache.GetType(typeof(IEquatable <>)); }
public override bool Execute() { if (!Debugger.IsAttached) { Debugger.Launch(); } var module = Project.Module; var importTypeDef = module.Cache.GetType(typeof(Import)).GetTypeDefinition(); _manyMethod = module.FindMethod(importTypeDef, "Many"); foreach (var method in module.Types .OfType <TypeDefDeclaration>() .Where(t => t.IsClass()) .SelectMany(t => t.Methods.Cast <MethodDefDeclaration>()) .Where(m => m.HasBody)) { method.MethodBody.ForEachInstruction(ProcessInstruction); } return(true); }
public IReadOnlyList <IMemberDefinition> GenericMethodDefinition(IGenericMethodDefinition co) { throw new NotImplementedException(); }
private CustomAttributeDeclaration CreateThreadStaticAttribute() { if ( this.threadStaticAttributeConstructor == null ) { this.threadStaticAttributeConstructor = this.module.FindMethod( "System.ThreadStaticAttribute, mscorlib", ".ctor", BindingOptions.DontThrowException, 0 ); } return new CustomAttributeDeclaration( this.threadStaticAttributeConstructor ); }
public Nothing GenericMethodDefinition(IGenericMethodDefinition co) { throw new NotImplementedException(); }
public IInterpetedOperation GenericMethodDefinition(IGenericMethodDefinition co) { throw new NotImplementedException(); }