Ejemplo n.º 1
0
        public void MethodImplementedAsInstanceMethodOnFirstArgumentDoesNotAppearOnTheType()
        {
            var metadataImporter = new MockMetadataImporter {
                GetMethodSemantics = method => MethodScriptSemantics.InstanceMethodOnFirstArgument("X")
            };

            Compile(new[] { "class C { public static void M() {} }" }, metadataImporter: metadataImporter);
            FindClass("C").InstanceMethods.Should().BeEmpty();
        }
Ejemplo n.º 2
0
        public void InstanceMethodOnFirstArgumentWorks()
        {
            AssertCorrect(
                @"class X { }
public static void F(X x, int y, string z) {}
public void M() {
	X a = null;
	int b = 0;
	string c = null;
	// BEGIN
	F(a, b, c);
	// END
}",
                @"	$a.$F($b, $c);
", metadataImporter: new MockMetadataImporter {
                GetMethodSemantics = m => m.Name == "F" ? MethodScriptSemantics.InstanceMethodOnFirstArgument("$" + m.Name) : MethodScriptSemantics.NormalMethod("$" + m.Name)
            });
        }
Ejemplo n.º 3
0
        public void InstanceMethodOnFirstArgumentWorksWithReorderedAndDefaultArguments()
        {
            AssertCorrect(
                @"static void F(int a = 1, int b = 2, int c = 3, int d = 4, int e = 5, int f = 6, int g = 7) {}
int F1() { return 0; }
int F2() { return 0; }
int F3() { return 0; }
int F4() { return 0; }
public void M() {
	// BEGIN
	F(d: F1(), g: F2(), f: F3(), a: F4());
	// END
}
",
                @"	var $tmp1 = this.$F1();
	var $tmp2 = this.$F2();
	var $tmp3 = this.$F3();
	this.$F4().$F(2, 3, $tmp1, 5, $tmp3, $tmp2);
", metadataImporter: new MockMetadataImporter {
                GetMethodSemantics = m => m.Name == "F" ? MethodScriptSemantics.InstanceMethodOnFirstArgument("$" + m.Name) : MethodScriptSemantics.NormalMethod("$" + m.Name)
            });
        }