protected internal override IList<StaticDeclaredTypeWrapper> GetAssemblyExportedTypes(StaticAssemblyWrapper assembly)
        {
            AssemblyDefinition assemblyHandle = (AssemblyDefinition)assembly.Handle;
            List<StaticDeclaredTypeWrapper> types = new List<StaticDeclaredTypeWrapper>();
            foreach (TypeDefinition typeHandle in EnumerateAssemblyTypeDefinitions(assemblyHandle))
                if (typeHandle.IsPublic || typeHandle.IsNestedPublic)
                    types.Add(MakeDeclaredTypeWithoutSubstitution(typeHandle));

            return types;
        }
Exemple #2
0
        protected internal override StaticDeclaredTypeWrapper GetAssemblyType(StaticAssemblyWrapper assembly, string typeName)
        {
            var translatedTypeName = typeName.Replace('+', '/');

            var assemblyHandle = (AssemblyDefinition)assembly.Handle;

            foreach (var moduleHandle in assemblyHandle.Modules)
            {
                var typeHandle = moduleHandle.GetType(translatedTypeName);
                if (typeHandle != null)
                {
                    return(MakeDeclaredTypeWithoutSubstitution(typeHandle));
                }
            }

            return(null);
        }
 /// <summary>
 /// Gets the public types exported by an assembly.
 /// </summary>
 /// <param name="assembly">The assembly wrapper, not null.</param>
 /// <returns>The types.</returns>
 protected internal abstract IList<StaticDeclaredTypeWrapper> GetAssemblyExportedTypes(StaticAssemblyWrapper assembly);
 /// <summary>
 /// Gets the specified named type within an assembly.
 /// </summary>
 /// <param name="assembly">The assembly wrapper, not null.</param>
 /// <param name="typeName">The type name, not null.</param>
 /// <returns>The type, or null if none.</returns>
 protected internal abstract StaticDeclaredTypeWrapper GetAssemblyType(StaticAssemblyWrapper assembly, string typeName);
 protected override IList<StaticDeclaredTypeWrapper> GetAssemblyTypes(StaticAssemblyWrapper assembly)
 {
     IModule moduleHandle = (IModule)assembly.Handle;
     return GetAssemblyTypes(moduleHandle, true);
 }
 protected override string GetAssemblyPath(StaticAssemblyWrapper assembly)
 {
     IModule moduleHandle = (IModule)assembly.Handle;
     IAssemblyFile assemblyFile = GetAssemblyFile(moduleHandle);
     if (assemblyFile == null)
         return @"unknown";
     
     return assemblyFile.Location.FullPath;
 }
        protected override IEnumerable<StaticAttributeWrapper> GetAssemblyCustomAttributes(StaticAssemblyWrapper assembly)
        {
            IModule moduleHandle = (IModule) assembly.Handle;

            CacheManagerEx cacheManager = CacheManagerEx.GetInstance(psiManager.Solution);
            IPsiModule psiModule = GetPsiModule(moduleHandle);
            if (psiModule != null)
            {
                foreach (IAttributeInstance attrib in cacheManager.GetModuleAttributes(psiModule).GetAttributeInstances(false))
                {
                    if (IsAttributeInstanceValid(attrib))
                        yield return new StaticAttributeWrapper(this, attrib);
                }
            }
        }
Exemple #8
0
 /// <summary>
 /// Gets the references of an assembly.
 /// </summary>
 /// <param name="assembly">The assembly wrapper, not null.</param>
 /// <returns>The assembly references.</returns>
 protected internal abstract IList <AssemblyName> GetAssemblyReferences(StaticAssemblyWrapper assembly);
Exemple #9
0
 /// <summary>
 /// Gets the name of an assembly.
 /// </summary>
 /// <param name="assembly">The assembly wrapper, not null.</param>
 /// <returns>The assembly name.</returns>
 protected internal abstract AssemblyName GetAssemblyName(StaticAssemblyWrapper assembly);
        protected override IEnumerable<StaticAttributeWrapper> GetAssemblyCustomAttributes(StaticAssemblyWrapper assembly)
        {
            IModule moduleHandle = (IModule) assembly.Handle;

#if RESHARPER_31 || RESHARPER_40 || RESHARPER_41
            foreach (IAttributeInstance attrib in psiManager.GetModuleAttributes(moduleHandle).AttributeInstances)
            {
                if (IsAttributeInstanceValid(attrib))
                    yield return new StaticAttributeWrapper(this, attrib);
            }
#else
#if !RESHARPER_61_OR_NEWER
			CacheManagerEx cacheManager = CacheManagerEx.GetInstance(psiManager.Solution);
#endif
            IPsiModule psiModule = GetPsiModule(moduleHandle);
            if (psiModule != null)
            {
#if RESHARPER_60_OR_NEWER
            	var moduleAttributes = cacheManager.GetModuleAttributes(psiModule);
				if (moduleAttributes == null)
					yield break;

            	foreach (var attrib in moduleAttributes.GetAttributeInstances(true))
#else
                foreach (IAttributeInstance attrib in cacheManager.GetModuleAttributes(psiModule).AttributeInstances)
#endif
                {
                    if (IsAttributeInstanceValid(attrib))
                        yield return new StaticAttributeWrapper(this, attrib);
                }
            }
#endif
        }
 /// <summary>
 /// Returns true if the internal members of this assembly are visible to the specified assembly.
 /// </summary>
 /// <param name="other">The other assembly.</param>
 /// <returns>True if the other assembly can see internal members of this assembly.</returns>
 public bool IsAssemblyVisibleTo(StaticAssemblyWrapper other)
 {
     // FIXME: Should check InternalsVisibleTo.
     return Equals(other);
 }
 protected internal override string GetAssemblyPath(StaticAssemblyWrapper assembly)
 {
     AssemblyDefinition assemblyHandle = (AssemblyDefinition)assembly.Handle;
     return assemblyResolver.GetAssemblyPath(assemblyHandle);
 }
 protected internal override AssemblyName GetAssemblyName(StaticAssemblyWrapper assembly)
 {
     AssemblyDefinition assemblyHandle = (AssemblyDefinition)assembly.Handle;
     return new AssemblyName(assemblyHandle.Name.FullName);
 }
 protected internal override IEnumerable<StaticAttributeWrapper> GetAssemblyCustomAttributes(StaticAssemblyWrapper assembly)
 {
     var assemblyHandle = (AssemblyDefinition)assembly.Handle;
     return EnumerateAttributes(assemblyHandle.CustomAttributes);
 }
 /// <summary>
 /// Gets the path of an assembly.
 /// </summary>
 /// <param name="assembly">The assembly wrapper, not null.</param>
 /// <returns>The assembly path.</returns>
 protected internal abstract string GetAssemblyPath(StaticAssemblyWrapper assembly);
        protected internal override StaticDeclaredTypeWrapper GetAssemblyType(StaticAssemblyWrapper assembly, string typeName)
        {
            var translatedTypeName = typeName.Replace('+', '/');

            var assemblyHandle = (AssemblyDefinition)assembly.Handle;
            foreach (var moduleHandle in assemblyHandle.Modules)
            {
                var typeHandle = moduleHandle.GetType(translatedTypeName);
                if (typeHandle != null)
                    return MakeDeclaredTypeWithoutSubstitution(typeHandle);
            }

            return null;
        }
        protected override IList<AssemblyName> GetAssemblyReferences(StaticAssemblyWrapper assembly)
        {
            IProject projectHandle = assembly.Handle as IProject;
            if (projectHandle != null)
            {
#if RESHARPER_60_OR_NEWER
				if (projectHandle.IsValid())
				{
					var moduleRefs = new List<IProjectToModuleReference>(projectHandle.GetModuleReferences());
					return GenericCollectionUtils.ConvertAllToArray(moduleRefs, moduleRef => GetAssemblyName(moduleRef.ResolveResult()));
				}
#else
                if (projectHandle.IsValid)
                {
                    ICollection<IModuleReference> moduleRefs = projectHandle.GetModuleReferences();
                    return GenericCollectionUtils.ConvertAllToArray(moduleRefs, delegate(IModuleReference moduleRef)
                    {
                        return GetAssemblyName(moduleRef.ResolveReferencedModule());
                    });
                }
#endif
            }

            // FIXME! Don't know how to handle referenced assemblies for assemblies without loading them.
            //IAssembly assemblyHandle = (IAssembly)assembly.Handle;
            //return assembly.Resolve(true).GetReferencedAssemblies();
            return Common.Collections.EmptyArray<AssemblyName>.Instance;
        }
Exemple #18
0
 /// <summary>
 /// Gets the path of an assembly.
 /// </summary>
 /// <param name="assembly">The assembly wrapper, not null.</param>
 /// <returns>The assembly path.</returns>
 protected internal abstract string GetAssemblyPath(StaticAssemblyWrapper assembly);
Exemple #19
0
        protected internal override IEnumerable <StaticAttributeWrapper> GetAssemblyCustomAttributes(StaticAssemblyWrapper assembly)
        {
            var assemblyHandle = (AssemblyDefinition)assembly.Handle;

            return(EnumerateAttributes(assemblyHandle.CustomAttributes));
        }
Exemple #20
0
 /// <summary>
 /// Returns true if the internal members of this assembly are visible to the specified assembly.
 /// </summary>
 /// <param name="other">The other assembly.</param>
 /// <returns>True if the other assembly can see internal members of this assembly.</returns>
 public bool IsAssemblyVisibleTo(StaticAssemblyWrapper other)
 {
     // FIXME: Should check InternalsVisibleTo.
     return(Equals(other));
 }
Exemple #21
0
        protected internal override AssemblyName GetAssemblyName(StaticAssemblyWrapper assembly)
        {
            AssemblyDefinition assemblyHandle = (AssemblyDefinition)assembly.Handle;

            return(new AssemblyName(assemblyHandle.Name.FullName));
        }
 protected override AssemblyName GetAssemblyName(StaticAssemblyWrapper assembly)
 {
     IModule moduleHandle = (IModule) assembly.Handle;
     return GetAssemblyName(moduleHandle);
 }
Exemple #23
0
        protected internal override string GetAssemblyPath(StaticAssemblyWrapper assembly)
        {
            AssemblyDefinition assemblyHandle = (AssemblyDefinition)assembly.Handle;

            return(assemblyResolver.GetAssemblyPath(assemblyHandle));
        }
        protected override IList<AssemblyName> GetAssemblyReferences(StaticAssemblyWrapper assembly)
        {
            IProject projectHandle = assembly.Handle as IProject;
            if (projectHandle != null)
            {
                if (projectHandle.IsValid())
				{
                    var moduleRefs = projectHandle.GetModuleReferences();
					return GenericCollectionUtils.ConvertAllToArray(moduleRefs, moduleRef => 
						GetAssemblyName(moduleRef.ResolveReferencedModule()));
                }
            }

            // FIXME! Don't know how to handle referenced assemblies for assemblies without loading them.
            //IAssembly assemblyHandle = (IAssembly)assembly.Handle;
            //return assembly.Resolve(true).GetReferencedAssemblies();
            return EmptyArray<AssemblyName>.Instance;
        }
Exemple #25
0
        protected internal override IList <StaticDeclaredTypeWrapper> GetAssemblyTypes(StaticAssemblyWrapper assembly)
        {
            AssemblyDefinition assemblyHandle      = (AssemblyDefinition)assembly.Handle;
            List <StaticDeclaredTypeWrapper> types = new List <StaticDeclaredTypeWrapper>();

            foreach (TypeDefinition typeHandle in EnumerateAssemblyTypeDefinitions(assemblyHandle))
            {
                types.Add(MakeDeclaredTypeWithoutSubstitution(typeHandle));
            }

            return(types);
        }
 protected override StaticDeclaredTypeWrapper GetAssemblyType(StaticAssemblyWrapper assembly, string typeName)
 {
     IModule moduleHandle = (IModule)assembly.Handle;
     IDeclarationsCache cache = GetAssemblyDeclarationsCache(moduleHandle);
     if (cache == null)
         return null;
     
     ITypeElement typeHandle = cache.GetTypeElementByCLRName(typeName);
     return typeHandle != null && typeHandle.IsValid() ?
         MakeDeclaredTypeWithoutSubstitution(typeHandle) : null;
 }
Exemple #27
0
 /// <summary>
 /// Gets all types contained in an assembly.
 /// </summary>
 /// <param name="assembly">The assembly wrapper, not null.</param>
 /// <returns>The types.</returns>
 protected internal abstract IList <StaticDeclaredTypeWrapper> GetAssemblyTypes(StaticAssemblyWrapper assembly);
 /// <summary>
 /// Gets the custom attributes of an assembly.
 /// </summary>
 /// <param name="assembly">The assembly, not null.</param>
 /// <returns>The attributes.</returns>
 protected internal abstract IEnumerable<StaticAttributeWrapper> GetAssemblyCustomAttributes(StaticAssemblyWrapper assembly);
Exemple #29
0
 /// <summary>
 /// Gets the specified named type within an assembly.
 /// </summary>
 /// <param name="assembly">The assembly wrapper, not null.</param>
 /// <param name="typeName">The type name, not null.</param>
 /// <returns>The type, or null if none.</returns>
 protected internal abstract StaticDeclaredTypeWrapper GetAssemblyType(StaticAssemblyWrapper assembly, string typeName);
 /// <summary>
 /// Gets the name of an assembly.
 /// </summary>
 /// <param name="assembly">The assembly wrapper, not null.</param>
 /// <returns>The assembly name.</returns>
 protected internal abstract AssemblyName GetAssemblyName(StaticAssemblyWrapper assembly);
Exemple #31
0
 /// <summary>
 /// Gets the custom attributes of an assembly.
 /// </summary>
 /// <param name="assembly">The assembly, not null.</param>
 /// <returns>The attributes.</returns>
 protected internal abstract IEnumerable <StaticAttributeWrapper> GetAssemblyCustomAttributes(StaticAssemblyWrapper assembly);
 /// <summary>
 /// Gets the references of an assembly.
 /// </summary>
 /// <param name="assembly">The assembly wrapper, not null.</param>
 /// <returns>The assembly references.</returns>
 protected internal abstract IList<AssemblyName> GetAssemblyReferences(StaticAssemblyWrapper assembly);
 protected internal override IList<AssemblyName> GetAssemblyReferences(StaticAssemblyWrapper assembly)
 {
     List<AssemblyName> assemblyNames = new List<AssemblyName>();
     AssemblyDefinition assemblyHandle = (AssemblyDefinition)assembly.Handle;
     foreach (ModuleDefinition moduleHandle in assemblyHandle.Modules)
         foreach (AssemblyNameReference assemblyNameRef in moduleHandle.AssemblyReferences)
             assemblyNames.Add(new AssemblyName(assemblyNameRef.FullName));
     return assemblyNames;
 }