예제 #1
0
        public void CleanupUnusedClassesTest()
        {
            ILStrip.ILStrip strip = new ILStrip.ILStrip(TestHelper.TranslatePath("ILStripTest.dll"));

            strip.ScanUsedClasses();
            strip.ScanUnusedClasses();
            strip.CleanupUnusedClasses();

            AssemblyDefinition def = SaveAssembly(strip);

            AssemblyAsserts.AssertNoClass(def, "ILStripTest.RegularClass");
            AssemblyAsserts.AssertNoClass(def, "ILStripTest.EmptyClass");
            AssemblyAsserts.AssertNoClass(def, "ILStripTest.EmptyClass2");
            AssemblyAsserts.AssertNoClass(def, "ILStripTest.Form1");
            AssemblyAsserts.AssertNoClass(def, "ILStripTest.ClassWithNestedClass");
            AssemblyAsserts.AssertNoClass(def, "ILStripTest.ClassWithNestedClass/NestedClass");
            AssemblyAsserts.AssertNoClass(def, "ILStripTest.ClassWithNestedClass2");
            AssemblyAsserts.AssertNoClass(def, "ILStripTest.CustomAttribute");
            AssemblyAsserts.AssertNoClass(def, "ILStripTest.ClassWithNestedClass2/NestedClass");
            AssemblyAsserts.AssertNoClass(def, "ILStripTest.ClassWithGeneric");
            AssemblyAsserts.AssertNoClass(def, "ILStripTest.IInterface");
            AssemblyAsserts.AssertNoClass(def, "ILStripTest.UnusedPrivateClass");
            AssemblyAsserts.AssertResource(def, "ILStripTest.Form1.resources");
            AssemblyAsserts.AssertReference(def, "mscorlib");
            AssemblyAsserts.AssertReference(def, "System.Drawing");
            AssemblyAsserts.AssertReference(def, "System.Windows.Forms");
        }
예제 #2
0
        public void CleanupUnusedReferencesTest()
        {
            ILStrip.ILStrip strip = new ILStrip.ILStrip(TestHelper.TranslatePath("ILStripTest.dll"));

            strip.ScanUsedClasses();
            strip.ScanUnusedClasses();
            strip.CleanupUnusedClasses();
            strip.CleanupUnusedReferences();

            AssemblyDefinition def = SaveAssembly(strip);

            AssemblyAsserts.AssertNoClass(def, "ILStripTest.RegularClass");
            AssemblyAsserts.AssertNoClass(def, "ILStripTest.EmptyClass");
            AssemblyAsserts.AssertNoClass(def, "ILStripTest.EmptyClass2");
            AssemblyAsserts.AssertNoClass(def, "ILStripTest.Form1");
            AssemblyAsserts.AssertResource(def, "ILStripTest.Form1.resources");
            AssemblyAsserts.AssertReference(def, "mscorlib"); // can't be removed
            AssemblyAsserts.AssertNoReference(def, "System.Drawing");
            AssemblyAsserts.AssertNoReference(def, "System.Windows.Forms");
        }