Пример #1
0
        private void TestClassDeps(string usesClass, string usedClass, ClassUse useMethod, bool testForNotFound)
        {
            TypeDefinition usesTD = dcd.TypeList.Find(delegate(TypeDefinition decl)
            {
                return(decl.Name == usesClass);
            });

            Assert.IsNotNull(usesTD, "Unable to find usesTD");
            List <UsedClass> usedClassList = dcd.FindClassDeps(usesTD);
            UsedClass        usedclass     = usedClassList.Find(delegate(UsedClass uc)
            {
                if (uc.Use == useMethod)
                {
                    ITypeReference baseTyperef = uc.Type as ITypeReference;
                    if (baseTyperef != null && baseTyperef.Name == usedClass)
                    {
                        return(true);
                    }
                }
                return(false);
            });

            if (testForNotFound)
            {
                Assert.IsNull(usedclass, "Found usedClass");
            }
            else
            {
                Assert.IsNotNull(usedclass, "Unable to find usedClass");
            }
        }
        public static void Main()
        {
            IUsedInterface p = new UsedClass();

            StaticMethodOnlyUsed.StaticMethod();
            p.Foo();
        }
Пример #3
0
 public static void Main(string[] args)
 {
     UsedFunctionInProgram();
     UsedStaticClass.UsedFunctionInUsedStaticClass();
     UsedClass.UsedStaticFunctionInUsedClass();
     new UsedClass().UsedFunctionInUsedClass();
 }
		public static void Main ()
		{
			IUsedInterface p = new UsedClass ();
			StaticMethodOnlyUsed.StaticMethod ();
			p.Foo ();

			// We are testing removing interfaces when no instance is created, we need to mark the interface types
			// so that we don't end up testing unused interface types being swept
			var tmp = typeof (IRemovable1).ToString ();
			tmp = typeof (IRemovable2).ToString ();
		}
Пример #5
0
        public void TestContains()
        {
            TypeReference tref = dcd.TypeList.Find(
                delegate(TypeDefinition decl) { return(decl.Name == "NestedClass2Deep"); });
            List <UsedClass> list = new List <UsedClass>();
            UsedClass        uc1  = new UsedClass(tref, ClassUse.Calls);
            UsedClass        uc2  = new UsedClass(tref, ClassUse.Calls);

            list.Add(uc1);
            Assert.IsTrue(list.Contains(uc1));
            Assert.IsTrue(list.Contains(uc2));
        }