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); }
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]; }
private AssemblyNameReference GetOrCreateRemotionInterfacesReference(AssemblyDefinition assemblyDef, ModuleDefinition moduleDefinition, IAssemblyTracker tracker) { var tempRef = moduleDefinition.AssemblyReferences.FirstOrDefault(r => r.FullName == _remotionInterfacesReference.FullName); if (tempRef == null) { var assm = AssemblyDefinition.ReadAssembly(_workingDir + _remotionInterfacesReference.Name + ".dll"); moduleDefinition.AssemblyReferences.Add(_remotionInterfacesReference); tracker.TrackNewReference(assemblyDef, _remotionInterfacesReference); return(_remotionInterfacesReference); } return(tempRef); }
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]); }
public AssemblyNameReference GetOrCreateRemotionInterfacesReference(AssemblyDefinition assemblyDef, ModuleDefinition moduleDefinition, IAssemblyTracker tracker) { var tempRef = moduleDefinition.AssemblyReferences.FirstOrDefault(r => r.FullName == _remotionInterfacesAssemblyName); if (tempRef == null) { tempRef = AssemblyNameReference.Parse(_remotionInterfacesAssemblyName); // ugly workaround for Cecils (wrong) behaviour concerning Culture if (tempRef.Culture == "neutral") { tempRef.Culture = null; } moduleDefinition.AssemblyReferences.Add(tempRef); tracker.TrackNewReference(assemblyDef, tempRef); } return(tempRef); }
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; }
public AssemblyNameReference GetOrCreateRemotionInterfacesReference(AssemblyDefinition assemblyDef, ModuleDefinition moduleDefinition, IAssemblyTracker tracker) { var tempRef = moduleDefinition.AssemblyReferences.FirstOrDefault (r => r.FullName == _remotionInterfacesAssemblyName); if (tempRef == null) { tempRef = AssemblyNameReference.Parse (_remotionInterfacesAssemblyName); // ugly workaround for Cecils (wrong) behaviour concerning Culture if (tempRef.Culture == "neutral") tempRef.Culture = null; moduleDefinition.AssemblyReferences.Add (tempRef); tracker.TrackNewReference (assemblyDef, tempRef); } return tempRef; }
private AssemblyNameReference GetOrCreateRemotionInterfacesReference(AssemblyDefinition assemblyDef, ModuleDefinition moduleDefinition, IAssemblyTracker tracker) { var tempRef = moduleDefinition.AssemblyReferences.FirstOrDefault (r => r.FullName == _remotionInterfacesReference.FullName); if (tempRef == null) { var assm = AssemblyDefinition.ReadAssembly (_workingDir + _remotionInterfacesReference.Name + ".dll"); moduleDefinition.AssemblyReferences.Add (_remotionInterfacesReference); tracker.TrackNewReference (assemblyDef, _remotionInterfacesReference); return _remotionInterfacesReference; } return tempRef; }