コード例 #1
0
        public void PreserveTypesReferencedFromFieldDeclaration()
        {
            var output = GetJavascriptWithDCE(@"DCETests\PreserveTypesReferencedFromFieldDeclaration.cs");

            DceAssert.Has(output, MemberType.Class, "PreservedType", false);
            DceAssert.HasNo(output, MemberType.Mention, "StrippedType");
        }
コード例 #2
0
        public void DCEMetaAttributesOnProxies()
        {
            var output = GetJavascriptWithDCE(@"DCETests\DCEMetaAttributesOnProxies.cs");

            DceAssert.Has(output, MemberType.Field, "UnusedFieldWithAttribute", true);
            DceAssert.Has(output, MemberType.Method, "UnusedMethodWithAttribute", true);

            DceAssert.Has(output, MemberType.Class, "UnusedClassWithAttribute", false);
            DceAssert.HasNo(output, MemberType.Mention, "MethodInUnusedClassWithAttribute", false);

            DceAssert.Has(output, MemberType.Class, "UnusedClassWithClassEntryPointAttribute", false);
            DceAssert.Has(output, MemberType.Method, "MethodInUnusedClassWithClassEntryPointAttribute", false);

            DceAssert.Has(output, MemberType.Class, "UnusedClassWithHierarchyEntryPointAttribute", false);
            DceAssert.Has(output, MemberType.Method, "MethodInUnusedClassWithHierarchyEntryPointAttribute", false);

            DceAssert.HasNo(output, MemberType.Mention, "DerivedUnusedClassWithAttribute", false);
            DceAssert.HasNo(output, MemberType.Mention, "MethodInDerivedUnusedClassWithAttribute", false);

            DceAssert.HasNo(output, MemberType.Mention, "DerivedUnusedClassWithClassEntryPointAttribute", false);
            DceAssert.HasNo(output, MemberType.Mention, "MethodInDerivedUnusedClassWithClassEntryPointAttribute", false);

            DceAssert.Has(output, MemberType.Class, "DerivedUnusedClassWithHierarchyEntryPointAttribute", false);
            DceAssert.Has(output, MemberType.Method, "MethodInDerivedUnusedClassWithHierarchyEntryPointAttribute", false);
        }
コード例 #3
0
        public void PreserveVirtualMethodImplementation()
        {
            var output = GetJavascriptWithDCE(@"DCETests\PreserveVirtualMethodImplementation.cs");

            // Stripped Method from UsedDerivedType that hides used method from BaseType.
            StringAssert.Contains("BaseType.Method - used", output, "BaseType.Method eliminated, should be preserved");
            StringAssert.DoesNotContain("UsedDerivedType.Method - used", output, "UsedDerivedType.Method preserved, should be eliminated");

            // Preserve virtual method from used type.
            StringAssert.Contains("BaseType.MethodFromBaseType - used", output, "BaseType.MethodFromBaseType, should be preserved");
            StringAssert.Contains("UsedDerivedType.MethodFromBaseType - used", output, "UsedDerivedType.MethodFromBaseType, should be preserved");

            // Preserve used method from used interface from used type.
            DceAssert.Has(output, MemberType.Interface, "IIterface", false);
            StringAssert.Contains("UsedDerivedType.MethodFromIIterface - used", output, "UsedDerivedType.MethodFromIIterface eliminated, should be preserved");

            // Stripped not-used method virtual method.
            StringAssert.DoesNotContain("BaseType.UnusedMethodFromBaseType - used", output, "BaseType.UnusedMethodFromBaseType preserved, should be eliminated");
            StringAssert.DoesNotContain("UsedDerivedType.UnusedMethodFromBaseType - used", output, "UsedDerivedType.UnusedMethodFromBaseType preserved, should be eliminated");

            // Stripped not-used interface and members.
            DceAssert.HasNo(output, MemberType.Interface, "IIterfaceNotUsed", false);
            DceAssert.HasNo(output, MemberType.Method, "UnusedMethodFromIIterfaceNotUsed", false);
            StringAssert.DoesNotContain("UsedDerivedType.UnusedMethodFromIIterfaceNotUsed - used", output, "UsedDerivedType.UnusedMethodFromIIterfaceNotUsed preserved, should be eliminated");

            // Preserved used members - implementation for not-used interface.
            StringAssert.DoesNotContain("UsedDerivedType.UsedMethodFromIIterfaceNotUsed - used", output, "UsedDerivedType.UsedMethodFromIIterfaceNotUsed preserved, should be eliminated");

            // Striped fully not-used type
            StringAssert.DoesNotContain("UnusedDerivedType.Method - used", output, "UnusedDerivedType.Method preserved, should be eliminated");
            StringAssert.DoesNotContain("UnusedDerivedType.MethodFromIIterface - used", output, "UnusedDerivedType.MethodFromIIterface, should be eliminated");
            StringAssert.DoesNotContain("UnusedDerivedType.MethodFromBaseType - used", output, "UnusedDerivedType.MethodFromBaseType, should be eliminated");
        }
コード例 #4
0
        public void PreserveUsageThroughConstraint()
        {
            var output = GetJavascriptWithDCE(@"DCETests\PreserveUsageThroughConstraint.cs");

            DceAssert.Has(output, MemberType.Interface, "IIterfaceForGenericMethodTest", false);
            DceAssert.Has(output, MemberType.Interface, "IIterfaceForGenericClassTest", false);
        }
コード例 #5
0
        public void BasicDCEFunctions()
        {
            var output = GetJavascriptWithDCE(@"DCETests\BasicDCEFunctions.cs");

            // Check that we preserved starting point and members it reference is Program.
            DceAssert.Has(output, MemberType.Class, "Program", true);
            DceAssert.Has(output, MemberType.Method, "Main", true);
            DceAssert.Has(output, MemberType.Method, "UsedFunctionInProgram", true);
            DceAssert.Has(output, MemberType.Field, "UsedFieldInProgram", true);
            DceAssert.Has(output, MemberType.Property, "UsedPropertyInProgram", true);
            DceAssert.Has(output, MemberType.Event, "UsedEventInProgram", true);

            // Check that we eliminated unused Program members.
            DceAssert.HasNo(output, MemberType.Mention, "UnusedFunctionInProgram");
            DceAssert.HasNo(output, MemberType.Mention, "UnusedFieldInProgram");
            DceAssert.HasNo(output, MemberType.Mention, "UnusedPropertyInProgram");
            DceAssert.HasNo(output, MemberType.Event, "UnusedEventInProgram", true);

            // Check that we eliminated UnusedStaticClass and UnusedClass.
            DceAssert.HasNo(output, MemberType.Mention, "UnusedStaticClass");
            DceAssert.HasNo(output, MemberType.Mention, "UnusedFunctionInUnusedStaticClass");
            DceAssert.HasNo(output, MemberType.Mention, "UnusedFieldInUnusedStaticClass");
            DceAssert.HasNo(output, MemberType.Mention, "UnusedPropertyInUnusedStaticClass");

            DceAssert.HasNo(output, MemberType.Mention, "UnusedClass");
            DceAssert.HasNo(output, MemberType.Mention, "UnusedFunctionInUnusedClass");
            DceAssert.HasNo(output, MemberType.Mention, "UnusedFieldInUnusedStaticClass");
            DceAssert.HasNo(output, MemberType.Mention, "UnusedStaticPropertyInUnusedClass");
            DceAssert.HasNo(output, MemberType.Mention, "UnusedPropertyInUnusedClass");

            // Check that we preserved members in UsedClass and UsedStaticClass reachable from Program.Main.
            DceAssert.Has(output, MemberType.Class, "UsedStaticClass", true);
            DceAssert.Has(output, MemberType.Method, "UsedFunctionInUsedStaticClass", true);
            DceAssert.Has(output, MemberType.Field, "UsedFieldInUsedStaticClass", true);

            DceAssert.Has(output, MemberType.Class, "UsedClass", false);
            DceAssert.Has(output, MemberType.Method, "UsedStaticFunctionInUsedClass", true);
            DceAssert.Has(output, MemberType.Method, "UsedFunctionInUsedClass", false);
            DceAssert.Has(output, MemberType.Field, "UsedStaticFieldInUsedClass", true);
            DceAssert.Has(output, MemberType.Field, "UsedFieldInUsedClass", false);
            DceAssert.Has(output, MemberType.Property, "UsedStaticPropertyInUsedClass", true);
            DceAssert.Has(output, MemberType.Property, "UsedPropertyInUsedClass", false);
            DceAssert.Has(output, MemberType.Event, "UsedStaticEventInUsedClass", true);
            DceAssert.Has(output, MemberType.Event, "UsedEventInUsedClass", false);

            // Check that we eliminated members in UsedClass and UsedStaticClass non-reachable from Program.Main.
            DceAssert.HasNo(output, MemberType.Mention, "UnusedFunctionInUsedStaticClass");
            DceAssert.HasNo(output, MemberType.Mention, "UnusedFieldInUsedStaticClass");

            DceAssert.HasNo(output, MemberType.Mention, "UnusedStaticFunctionInUsedClass");
            DceAssert.HasNo(output, MemberType.Mention, "UnusedFunctionInUsedClass");
            DceAssert.HasNo(output, MemberType.Mention, "UnusedStaticFieldInUsedClass");
            DceAssert.HasNo(output, MemberType.Mention, "UnusedFieldInUsedClass");
            DceAssert.HasNo(output, MemberType.Mention, "UnusedPropertyInUsedClass");
            DceAssert.HasNo(output, MemberType.Mention, "UnusedStaticPropertyInUsedClass");
            DceAssert.HasNo(output, MemberType.Event, "UnusedStaticEventInUsedClass", true);
            DceAssert.HasNo(output, MemberType.Event, "UnusedEventInUsedClass", false);
        }
コード例 #6
0
        public void PreserveStaticConstructorAndReferences()
        {
            var output = GetJavascriptWithDCE(@"DCETests\PreserveStaticConstructorAndReferences.cs");

            DceAssert.Has(output, MemberType.Class, "PreservedFromTypeReference", false);
            StringAssert.Contains("Hello from .cctor", output, "Static constructor eliminated, should be preserved.");

            DceAssert.HasNo(output, MemberType.Mention, "StrippedType");
        }
コード例 #7
0
        public void StripInterfaceImplementation()
        {
            var output = GetJavascriptWithDCE(@"DCETests\StripInterfaceImplementation.cs");

            // Generic type constructor.
            DceAssert.Has(output, MemberType.Interface, "IUsedInterface", false);
            DceAssert.Has(output, MemberType.Class, "UsedType", false);

            DceAssert.HasNo(output, MemberType.Mention, "IUnUsedInterface");
        }
コード例 #8
0
        public void StripOuterTypes()
        {
            var output = GetJavascriptWithDCE(@"DCETests\StripOuterTypes.cs");

            // Generic type constructor.
            DceAssert.Has(output, MemberType.Class, "OuterType+InnerType", false);
            DceAssert.HasNo(output, MemberType.Class, "OuterType", false);

            DceAssert.HasNo(output, MemberType.Mention, "StrippedType");
        }
コード例 #9
0
        public void PreserveTypesReferencedFromMethodDeclaration()
        {
            var output = GetJavascriptWithDCE(@"DCETests\PreserveTypesReferencedFromMethodDeclaration.cs");

            DceAssert.Has(output, MemberType.Class, "PreservedMethodDeclarationType", false);
            DceAssert.Has(output, MemberType.Class, "PreservedMethodReturnType", false);
            DceAssert.Has(output, MemberType.Class, "PreservedMethodFirstArgumentType", false);
            DceAssert.Has(output, MemberType.Class, "PreservedMethodSecondArgumentType", false);
            DceAssert.HasNo(output, MemberType.Mention, "StrippedType");
        }
コード例 #10
0
        public void PreserveTypesGenericBase()
        {
            var output = GetJavascriptWithDCE(@"DCETests\PreserveTypesGenericBase.cs");

            DceAssert.Has(output, MemberType.Class, "BaseGenericType`2", false);
            DceAssert.Has(output, MemberType.Class, "DerivedGenericType`1", false);
            DceAssert.Has(output, MemberType.Class, "NonGenericDerivedType", false);
            DceAssert.Has(output, MemberType.Class, "TypeForT", false);
            DceAssert.Has(output, MemberType.Class, "TypeForK", false);

            DceAssert.HasNo(output, MemberType.Mention, "StrippedType");
        }
コード例 #11
0
        public void Attributes()
        {
            var output = GetJavascriptWithDCE(@"DCETests\Attributes.cs");

            DceAssert.Has(output, MemberType.Class, "TestAttribute", false);
            StringAssert.Contains("Test arg", output, "TestAttribute application eliminated, should be preserved");
            StringAssert.Contains("TestEnum.A", output, "TestAttribute application eliminated, should be preserved");
            StringAssert.Contains("D_Usage", output, "TestEnum eliminated, should be preserved");

            DceAssert.HasNo(output, MemberType.Mention, "UnusedAttribute", false);
            StringAssert.DoesNotContain("Unused arg", output, "UnusedAttribute application preserved, should be eliminated");
            StringAssert.DoesNotContain("C_Usage", output, "UnusedEnum preserved, should be eliminated");
        }
コード例 #12
0
        public void PreserveVirtualMethodFromReallyUsedRootOnly()
        {
            var output = GetJavascriptWithDCE(@"DCETests\PreserveVirtualMethodFromReallyUsedRootOnly.cs");

            DceAssert.Has(output, MemberType.Class, "BaseType", false);
            DceAssert.Has(output, MemberType.Class, "UsedMiddleDerivedType", false);
            DceAssert.Has(output, MemberType.Class, "UsedDerivedType", false);
            DceAssert.Has(output, MemberType.Class, "DerivedTypeWithoudMethodUsage", false);

            StringAssert.DoesNotContain("BaseType.Method - used", output, "BaseType.Method preserved, should be eliminated");
            StringAssert.Contains("UsedMiddleDerivedType.Method - used", output, "UsedMiddleDerivedType.Method eliminated, should be preserved");
            StringAssert.Contains("UsedDerivedType.Method - used", output, "UsedDerivedType.Method eliminated, should be preserved");
            StringAssert.DoesNotContain("DerivedTypeWithoudMethodUsage.Method - used", output, "DerivedTypeWithoudMethodUsage.Method preserved, should be eliminated");

            StringAssert.Contains("BaseClassWithPreservedMethod.Method - used", output, "BaseClassWithPreservedMethod.Method eliminated, should be preserved");
        }
コード例 #13
0
        public void PreserveTypesReferencedFromGeneric()
        {
            var output = GetJavascriptWithDCE(@"DCETests\PreserveTypesReferencedFromGeneric.cs");

            // Generic type constructor.
            DceAssert.Has(output, MemberType.Class, "PreservedFromGenericTypeConstructorGenericTypeGen1`1", false);
            DceAssert.Has(output, MemberType.Class, "PreservedFromGenericTypeConstructorGenericTypeGen2`1", false);
            DceAssert.Has(output, MemberType.Class, "PreservedFromGenericTypeConstructor", false);

            // Generic type static method.
            DceAssert.Has(output, MemberType.Class, "PreservedFromGenericTypeStaticMethodGenericTypeGen1`1", false);
            DceAssert.Has(output, MemberType.Class, "PreservedFromGenericTypeStaticMethodGenericTypeGen2`1", false);
            DceAssert.Has(output, MemberType.Class, "PreservedFromGenericTypeStaticMethod", false);

            // Generic type static method.
            DceAssert.Has(output, MemberType.Class, "PreservedFromGenericMethodMethodGenericTypeGen1`1", false);
            DceAssert.Has(output, MemberType.Class, "PreservedFromGenericMethodGenericTypeGen2`1", false);
            DceAssert.Has(output, MemberType.Class, "PreservedFromGenericMethod", false);

            DceAssert.HasNo(output, MemberType.Mention, "StrippedType");
        }
コード例 #14
0
        public void PreserveTypesReferencedFromGenericField()
        {
            var output = GetJavascriptWithDCE(@"DCETests\PreserveTypesReferencedFromGenericField.cs");

            DceAssert.Has(output, MemberType.Class, "NonGenericType", false);
        }