internal QueryableModule(ModuleDefinition moduleDefinition, QueryableAssembly assembly) { _assembly = assembly; _name = Utility.ToString(_getName(moduleDefinition)); _fullPath = Utility.ToString(moduleDefinition.FullyQualifiedName); _moduleType = _getModuleType(moduleDefinition); _targetRuntimeVersion = Utility.ToString(_getTargetRuntimeVersion(moduleDefinition)); _targetPlatform = _getTargetPlatform(moduleDefinition); _hasNativeCode = _getHasNativeCode(moduleDefinition); _isStrongNameSigned = _getIsStrongNameSigned(moduleDefinition); if (moduleDefinition.Assembly != null && moduleDefinition == moduleDefinition.Assembly.MainModule) { _assembly.MainModule = this; } foreach (Resource resource in moduleDefinition.Resources) { _resources.Add(new QueryableResource(resource, this)); } foreach (TypeDefinition typeDefinition in moduleDefinition.Types) { QueryableType type = new QueryableType(typeDefinition, this, null); _addTypesAndMethods(type); } }
public CodeAnalysis(params string[] assemblyPaths) { if (assemblyPaths != null && assemblyPaths.Length > 0) { foreach (string assemblyPath in assemblyPaths) { if (!File.Exists(assemblyPath)) { throw new ArgumentException("Assembly not found at the specified path: " + assemblyPath); } } foreach (string assemblyPath in assemblyPaths) { QueryableAssembly assembly = new QueryableAssembly(assemblyPath); _assemblies.Add(assembly); _modules.AddRange(assembly.Modules); _resources.AddRange(assembly.Resources); _types.AddRange(assembly.Types); _methods.AddRange(assembly.Methods); } } else { throw new ArgumentException("No assemblies specified for code analysis"); } }
internal QueryableResource(Resource resource, QueryableModule module) { _assembly = module.Assembly; _module = module; _name = Utility.ToString(resource.Name); _resourceType = Utility.ConvertEnum<ResourceType>(resource.ResourceType); _isPublic = resource.IsPublic; }
internal QueryableMethod(MethodDefinition methodDefinition, QueryableType type) { _assembly = type.Assembly; _module = type.Module; _type = type; _name = methodDefinition.Name; _fullName = methodDefinition.FullName; if (methodDefinition == methodDefinition.Module.EntryPoint) { _module.EntryPointMethod = this; } }
internal QueryableType(TypeDefinition typeDefinition, QueryableModule module, QueryableType declaringType) { _assembly = module.Assembly; _module = module; _declaringType = declaringType; _name = typeDefinition.Name; _fullName = typeDefinition.FullName; foreach (TypeDefinition nestedType in typeDefinition.NestedTypes) { _nestedTypes.Add(new QueryableType(nestedType, module, this)); } foreach (MethodDefinition methodDefinition in typeDefinition.Methods) { _methods.Add(new QueryableMethod(methodDefinition, this)); } }