public MethodDefinition GetVirtualizedAttribute(AssemblyDefinition assembly, IAssemblyTracker tracker)
        {
            if (!_useAttribute)
            {
                return(null);
            }
            if (_attributeCtor == null)
            {
                var attributeCtorID = _infoProvider.GetVirtualizedAttribute();
                _attributeCtor = CecilResolver.ResolveToMethodDefinition(attributeCtorID, tracker, out _customAttributeAssembly);
                if (_attributeCtor == null)
                {
                    _useAttribute = false;
                    return(null);
                }
                if (_attributeCtor.Parameters.Count != 1)
                {
                    throw new ArgumentException("MethodVirtualizer: The given custom attribute does not have one (string) ctor parameter.");
                }
            }

            if (_customAttributeAssembly != null)
            {
                tracker.TrackNewReference(assembly, _customAttributeAssembly);
            }
            return(_attributeCtor);
        }
Beispiel #2
0
 public MethodDefinition GetFactoryMethod(MethodReference ctor, AssemblyDefinition assembly, IAssemblyTracker tracker)
 {
     if (!_factoryMethods.ContainsKey(ctor))
     {
         var memberId = CecilResolver.CreateMemberID(ctor.Resolve());
         AssemblyNameReference containingTrackedAssembly;
         _factoryMethods[ctor] = CecilResolver.ResolveToMethodDefinition(_infoProvider.GetFactoryMethodFunc(memberId), tracker, out containingTrackedAssembly);
         if (containingTrackedAssembly != null)
         {
             tracker.TrackNewReference(assembly, containingTrackedAssembly);
         }
     }
     return(_factoryMethods[ctor]);
 }
Beispiel #3
0
        public string GetWrapperMethodName(MethodReference ctor)
        {
            var memberId = CecilResolver.CreateMemberID(ctor);

            return(_infoProvider.GetWrapperName(memberId));
        }
 public string GetUnspeakableMethodName(MethodDefinition targetMethod)
 {
     return(_infoProvider.GetUnspeakableMethodName(CecilResolver.CreateMemberID(targetMethod), targetMethod.Name));
 }
 public bool ShouldVirtualizeMethod(MethodDefinition targetMethod)
 {
     return(_infoProvider.ShouldVirtualizeMethod(CecilResolver.CreateMemberID(targetMethod)));
 }
 public bool ShouldVirtualizeType(TypeReference targetType)
 {
     return(_infoProvider.ShouldVirtualizeType(CecilResolver.CreateMemberID(targetType)));
 }