unsafe static CorPropertyInfo ReadPropertyInfo(IMetaDataImport mdi, uint token, CorType type) { if (mdi == null) { return(null); } var name = MDAPI.GetPropertyName(mdi, token); if (name == null) { return(null); } if (!MDAPI.GetPropertyGetterSetter(mdi, token, out uint mdGetter, out uint mdSetter)) { return(null); } var getSig = GetMethodSignature(mdi, mdGetter); var setSig = GetMethodSignature(mdi, mdSetter); if (getSig == null) { return(null); } if (getSig.ParamsAfterSentinel != null) { return(null); } if (getSig.GenParamCount != 0) { return(null); } if (getSig.Params.Count != 0) { return(null); } if (getSig.RetType.RemovePinnedAndModifiers().GetElementType() == ElementType.Void) { return(null); } if (setSig != null && setSig.ParamsAfterSentinel != null) { setSig = null; } if (setSig != null && setSig.GenParamCount != 0) { setSig = null; } if (setSig != null && setSig.Params.Count != 1) { setSig = null; } if (setSig != null && setSig.RetType.RemovePinnedAndModifiers().GetElementType() != ElementType.Void) { setSig = null; } if (setSig != null && getSig.HasThis != setSig.HasThis) { setSig = null; } if (setSig != null && !Equals(getSig.RetType.RemovePinnedAndModifiers(), setSig.Params[0].RemovePinnedAndModifiers())) { setSig = null; } if (setSig == null) { mdSetter = 0; } if (!MDAPI.GetMethodAttributes(mdi, mdGetter, out var getMethodAttrs, out var getMethodImplAttrs)) { return(null); } var browseState = GetDebuggerBrowsableState(mdi, token); return(new CorPropertyInfo(type, token, mdGetter, mdSetter, name, getSig, setSig, getMethodAttrs, browseState)); }
void InitNameAndAttrs_NoLock() { var mdi = readerModule.MetaDataImport; uint token = OriginalToken.Raw; Name = Utils.GetUTF8String(MDAPI.GetUtf8Name(mdi, OriginalToken.Raw), MDAPI.GetFieldName(mdi, token) ?? string.Empty); this.Attributes = origAttrs = MDAPI.GetFieldAttributes(mdi, token); }
public static int GetCountGenericParameters(IMetaDataImport mdi, uint token) => MDAPI.GetGenericParamTokens(mdi as IMetaDataImport2, token).Length;
static bool GetCompilerGeneratedAttribute(IMetaDataImport mdi, uint token) => MDAPI.HasAttribute(mdi, token, "System.Runtime.CompilerServices.CompilerGeneratedAttribute");
public FieldAttributes GetAttributes() => MDAPI.GetFieldAttributes(Module?.GetMetaDataInterface <IMetaDataImport>(), Token);
public string GetName() => MDAPI.GetFieldName(Module?.GetMetaDataInterface <IMetaDataImport>(), Token);
/// <summary> /// Returns true if an attribute is present /// </summary> /// <param name="attributeName">Full name of attribute type</param> /// <returns></returns> public bool HasAttribute(string attributeName) => MDAPI.HasAttribute(Module?.GetMetaDataInterface <IMetaDataImport>(), Token, attributeName);
public TypeAttributes GetTypeAttributes() { var mdi = Module?.GetMetaDataInterface <IMetaDataImport>(); return(MDAPI.GetTypeDefAttributes(mdi, token) ?? 0); }
public MethodAttributes GetAttributes() { MDAPI.GetMethodAttributes(Module?.GetMetaDataInterface <IMetaDataImport>(), Token, out var attributes, out var implAttributes); return(attributes); }
// When a dynamic assembly is created with option Run, a module gets created and its // metadata name is "RefEmit_InMemoryManifestModule". Shortly thereafter, its name // gets changed to the name the user chose. // This name is also saved in ModuleIds, and used when setting breakpoints... // There's code that caches ModuleIds, but they don't cache it if IsDynamic is true. // This method updates the ModuleId and resets breakpoints in the module. void UpdateDynamicModuleIds(DnModule dnModule) { debuggerThread.VerifyAccess(); if (!dnModule.IsDynamic) { return; } var module = TryGetModule(dnModule.CorModule); if (module == null || !TryGetModuleData(module, out var data) || data.HasUpdatedModuleId) { return; } List <(DbgModule dbgModule, DnModule dnModule)> updatedModules = null; lock (lockObj) { if (toAssemblyModules.TryGetValue(dnModule.Assembly, out var modules)) { for (int i = 0; i < modules.Count; i++) { dnModule = modules[i]; if (!dnModule.IsDynamic) { continue; } if (!toEngineModule.TryGetValue(dnModule.CorModule, out var em)) { continue; } if (!TryGetModuleData(em.Module, out data)) { continue; } dnModule.CorModule.ClearCachedDnlibName(); var moduleId = dnModule.DnModuleId.ToModuleId(); if (data.ModuleId == moduleId) { continue; } data.UpdateModuleId(moduleId); if (dnModule.CorModuleDef != null) { //TODO: This doesn't update the treeview node dnModule.CorModuleDef.Name = moduleId.ModuleName; } if (updatedModules == null) { updatedModules = new List <(DbgModule, DnModule)>(); } updatedModules.Add((em.Module, dnModule)); } } } if (updatedModules != null) { foreach (var info in updatedModules) { var mdi = info.dnModule.CorModule.GetMetaDataInterface <IMetaDataImport2>(); var scopeName = MDAPI.GetModuleName(mdi) ?? string.Empty; ((DbgCorDebugInternalModuleImpl)info.dbgModule.InternalModule).ReflectionModule.ScopeName = scopeName; } dbgModuleMemoryRefreshedNotifier.RaiseModulesRefreshed(updatedModules.Select(a => a.dbgModule).ToArray()); } }
void InitNameAndAttrs_NoLock() { var mdi = readerModule.MetaDataImport; uint token = OriginalToken.Raw; Name = Utils.GetUTF8String(MDAPI.GetUtf8Name(mdi, OriginalToken.Raw), MDAPI.GetPropertyName(mdi, token) ?? string.Empty); Attributes = MDAPI.GetPropertyAttributes(mdi, token); Type = readerModule.ReadSignature(MDAPI.GetPropertySignatureBlob(mdi, token), new GenericParamContext(ownerType)); }
void Initialize_NoLock() { uint ifaceToken = MDAPI.GetInterfaceImplInterfaceToken(readerModule.MetaDataImport, OriginalToken.Raw); @interface = readerModule.ResolveTypeDefOrRefInternal(ifaceToken, gpContext); }
void InitNameAndAttrs_NoLock() { var mdi = readerModule.MetaDataImport; uint token = OriginalToken.Raw; Name = Utils.GetUTF8String(MDAPI.GetUtf8Name(mdi, OriginalToken.Raw), MDAPI.GetEventName(mdi, token) ?? string.Empty); Attributes = MDAPI.GetEventAttributes(mdi, token); uint eventType = MDAPI.GetEventTypeToken(mdi, token); EventType = readerModule.ResolveTypeDefOrRefInternal(eventType, new GenericParamContext(ownerType)); }
public PropertyAttributes GetAttributes() => MDAPI.GetPropertyAttributes(Module?.GetMetaDataInterface <IMetaDataImport>(), Token);
public void GetAttributes(out MethodImplAttributes implAttributes, out MethodAttributes attributes) => MDAPI.GetMethodAttributes(Module?.GetMetaDataInterface <IMetaDataImport>(), Token, out attributes, out implAttributes);