Beispiel #1
0
        public void VisitType(TypeDefinition type)
        {
            DBC.Assert(m_state == State.Types, "state is {0}", m_state);
            Log.DebugLine(this, "{0}", type.FullName);

            if (!type.ExternallyVisible(Cache) && DoInstantiable(type) && DoValidType(type))
            {
                if (!type.IsCompilerGenerated())
                {
                    var key = new AssemblyCache.TypeKey(type);
                    DBC.Assert(m_keys.IndexOf(key) < 0, "{0} is already in types", type.FullName);
                    Log.DebugLine(this, "adding {0}", type.FullName);

                    m_keys.Add(key);
                }
            }
        }
Beispiel #2
0
		public void VisitType(TypeDefinition type)
		{						
			DBC.Assert(m_state == State.Types, "state is {0}", m_state);
			Log.DebugLine(this, "{0}", type.FullName);

			if (!type.ExternallyVisible(Cache) && DoInstantiable(type) && DoValidType(type))
			{	
				if (!type.IsCompilerGenerated())
				{
					var key = new AssemblyCache.TypeKey(type);
					DBC.Assert(m_keys.IndexOf(key) < 0, "{0} is already in types", type.FullName);
					Log.DebugLine(this, "adding {0}", type.FullName);
					
					m_keys.Add(key);
				}
			}
		}
Beispiel #3
0
		/// <summary>Returns true if lhs is a subclass of rhs. Returns false if they are the same class.
		/// Interfaces are ignored.</summary>
		public static bool IsSubclassOf(this TypeReference lhs, TypeReference rhs, AssemblyCache cache)
		{			
			DBC.Pre(lhs != null, "lhs is null");				
			DBC.Pre(rhs != null, "rhs is null");
			DBC.Pre(cache != null, "cache is null");
				
			if (lhs.FullName != "System.Object" && rhs.FullName == "System.Object")	// everything is a subclass of object
				return true;
	
			while (lhs != null)
			{
				TypeDefinition type = cache.FindType(lhs);
					
				lhs = type != null && !type.IsInterface ? type.BaseType : null;
				if (lhs != null)
				{
					var key1 = new AssemblyCache.TypeKey(lhs);
					var key2 = new AssemblyCache.TypeKey(rhs);
					if (key1 == key2)
						return true;
				}
			}
			 
			return false;
		}