private void Build(BuildMethod method) { var cryptoMethod = method.CreateILCrypto(); var type = method.GetOwnerType(); var invokeTypeInfo = GetInvokeType(type.GenericParameters.Count); var invokeType = invokeTypeInfo.Instance; cryptoMethod.MethodID = invokeType.MethodCount++; // Delegate type var delegateGenericArguments = new List <TypeSignature>(); var delegateType = _delegateTypeBuilder.Build(method, delegateGenericArguments); if (delegateGenericArguments.Count > 0) { cryptoMethod.DelegateGenericArguments = delegateGenericArguments.ToArray(); } // Invoke method var invokeGenericArguments = new List <TypeSignature>(); var invokeMethod = BuildInvokeMethod(method, invokeTypeInfo, invokeGenericArguments); invokeMethod.DelegateType = delegateType; cryptoMethod.InvokeMethod = invokeMethod; if (invokeGenericArguments.Count > 0) { cryptoMethod.InvokeGenericArguments = invokeGenericArguments.ToArray(); } }
private void Process(BuildMethod method) { UnstripAndEnqueue((BuildType)method.GetOwnerType()); // Process references var module = method.Module; Process(method.ReturnType, module); Process(method.Parameters, module); Process(method.GenericParameters, module); Process(method.Overrides, module); Process(method.CustomAttributes, module); Process(method.SecurityAttributes, module); if (MethodBody.IsValid(method)) { var body = MethodBody.Load(method); Process(body, module); } }
private static void DevirtualizeMethod(BuildMethod method) { if (!method.DevirtualizeMethod) { return; } if (!method.IsVirtual) { return; } var ownerType = method.GetOwnerType(); if (ownerType.IsInterface) { return; } method.IsVirtual = false; method.IsNewSlot = false; }