Ejemplo n.º 1
0
    public void TestUncompilableCode()
    {
#pragma warning disable 0168 // warning CS0168: The variable `foo' is declared but never used
#pragma warning disable 0219 // warning CS0219: The variable `foo' is assigned but its value is never used

        ALLCAPS_UNDERSCORES a;
        using (var testRenaming = new TestRenaming())
        {
            testRenaming.name();
            testRenaming.Name();
            testRenaming.Property.GetHashCode();
        }
        new ForceCreationOfInterface().Dispose();
        new InheritsProtectedVirtualFromSecondaryBase().Dispose();
        new InheritanceBuffer().Dispose();
        new HasProtectedVirtual().Dispose();
        new Proprietor(5).Dispose();
        using (var testOverrideFromSecondaryBase = new TestOverrideFromSecondaryBase())
        {
            testOverrideFromSecondaryBase.function();
            var ok = false;
            testOverrideFromSecondaryBase.function(ref ok);
            var property = testOverrideFromSecondaryBase.property;
            testOverrideFromSecondaryBase.VirtualMember();
        }
        using (var foo = new Foo())
        {
            var isNoParams = foo.IsNoParams;
            foo.SetNoParams();
            foo.Width = 5;
            using (var hasSecondaryBaseWithAbstractWithDefaultArg = new HasSecondaryBaseWithAbstractWithDefaultArg())
            {
                hasSecondaryBaseWithAbstractWithDefaultArg.Abstract();
                hasSecondaryBaseWithAbstractWithDefaultArg.AbstractWithNoDefaultArg(foo);
            }
        }
        using (var hasOverride = new HasOverrideOfHasPropertyWithDerivedType())
            hasOverride.CauseRenamingError();
        using (var qux = new Qux())
        {
            new Bar(qux).Dispose();
        }
        using (ComplexType complexType = TestFlag.Flag1)
        {
        }
        using (var typeMappedWithOperator = new TypeMappedWithOperator())
        {
            int i = typeMappedWithOperator | 5;
        }
        using (Base <int> @base = new DerivedFromSpecializationOfUnsupportedTemplate())
        {
        }

        CSharp.CSharp.FunctionInsideInlineNamespace();
        using (CSharpTemplates.SpecialiseReturnOnly())
        {
        }

#pragma warning restore 0168
#pragma warning restore 0219
    }
Ejemplo n.º 2
0
    public void TestUncompilableCode()
    {
#pragma warning disable 0168 // warning CS0168: The variable `foo' is declared but never used
#pragma warning disable 0219 // warning CS0219: The variable `foo' is assigned but its value is never used

        ALLCAPS_UNDERSCORES a;
        new MultipleInheritance().Dispose();
        using (var testRenaming = new TestRenaming())
        {
            testRenaming.name();
            testRenaming.Name();
            testRenaming.Property.GetHashCode();
        }
        new ForceCreationOfInterface().Dispose();
        new InheritsProtectedVirtualFromSecondaryBase().Dispose();
        new InheritanceBuffer().Dispose();
        new HasProtectedVirtual().Dispose();
        new Proprietor(5).Dispose();
        new HasCtorWithMappedToEnum <TestFlag>(TestFlag.Flag1).Dispose();
        using (var testOverrideFromSecondaryBase = new TestOverrideFromSecondaryBase())
        {
            testOverrideFromSecondaryBase.function();
            var ok = false;
            testOverrideFromSecondaryBase.function(ref ok);
            var property = testOverrideFromSecondaryBase.property;
            testOverrideFromSecondaryBase.VirtualMember();
        }
        using (var foo = new Foo())
        {
            var isNoParams = foo.IsNoParams;
            foo.SetNoParams();
            foo.Width = 5;
            using (var hasSecondaryBaseWithAbstractWithDefaultArg = new HasSecondaryBaseWithAbstractWithDefaultArg())
            {
                hasSecondaryBaseWithAbstractWithDefaultArg.Abstract();
                hasSecondaryBaseWithAbstractWithDefaultArg.AbstractWithNoDefaultArg(foo);
            }
            Assert.That(foo.PublicFieldMappedToEnum, Is.EqualTo(TestFlag.Flag2));
            Assert.That(foo.ReturnConstRef(), Is.EqualTo(5));
        }
        using (var hasOverride = new HasOverrideOfHasPropertyWithDerivedType())
            hasOverride.CauseRenamingError();
        using (var qux = new Qux())
        {
            new Bar(qux).Dispose();
        }
        using (var quux = new Quux())
        {
            quux.SetterWithDefaultOverload = null;
            quux.SetSetterWithDefaultOverload();
        }
        using (ComplexType complexType = TestFlag.Flag1)
        {
        }
        using (var typeMappedWithOperator = new TypeMappedWithOperator())
        {
            int i = typeMappedWithOperator | 5;
        }
        using (Base <int> @base = new DerivedFromSpecializationOfUnsupportedTemplate())
        {
        }

        CSharp.CSharp.FunctionInsideInlineNamespace();
        using (CSharpTemplates.SpecialiseReturnOnly())
        {
        }

        using (var t1 = new T1())
            using (new IndependentFields <int>(t1))
            {
            }

        using (var t2 = new T2())
            using (new IndependentFields <int>(t2))
            {
            }

        CSharp.CSharp.ReturnCharPointer();
        int    value  = 5;
        IntPtr intPtr = CSharp.CSharp.RValueReferenceToPointer((void **)&value);
        Assert.That((int)intPtr, Is.EqualTo(value));

#pragma warning restore 0168
#pragma warning restore 0219
    }