Exemplo n.º 1
0
        public void InvokingParamArrayGenericMethodThatExpandsArgumentsInExpandedFormWorks()
        {
            SourceVerifier.AssertSourceCorrect(
                @"using System.Runtime.CompilerServices;
public class B { [ExpandParams] public virtual void F<T>(int x, int y, params int[] args) {} }
public class C : B {
	[ExpandParams] public override void F<T>(int x, int y, params int[] args) {}
	public void M() {
		// BEGIN
		base.F<int>(4, 8, 59, 12, 4);
		// END
	}
}",
                @"			$B.prototype.f(ss.Int32).call(this, 4, 8, 59, 12, 4);
");
        }
Exemplo n.º 2
0
        public void DynamicAppearsAsObjectAsGenericArgument()
        {
            SourceVerifier.AssertSourceCorrect(@"
using System;
class G<T> {}
class C {
	public void M() {
		// BEGIN
		var f = new G<dynamic>();
		// END
	}
}
",
                                               @"			var f = new (ss.makeGenericType($$G$1, [Object]))();
");
        }
Exemplo n.º 3
0
        public void CastingToDynamicIsANoOp()
        {
            SourceVerifier.AssertSourceCorrect(@"
using System;
class C {
	public void M() {
		object o = null;
		// BEGIN
		var t = (dynamic)o;
		// END
	}
}
",
                                               @"			var t = o;
");
        }
        public void ArrayTypeAppearsAsArrayAsTypeArgumentInInlineCode()
        {
            SourceVerifier.AssertSourceCorrect(@"
using System;
class C {
	[System.Runtime.CompilerServices.InlineCode(""{T}"")] public object F<T>() {}
	public void M() {
		// BEGIN
		var x = F<int[]>();
		// END
	}
}
",
                                               @"			var x = Array;
");
        }
Exemplo n.º 5
0
        public void InvokingStaticMethodOfImportedTypeDefinitionThatObeysTheTypeSystemWorks()
        {
            SourceVerifier.AssertSourceCorrect(@"
using System;
[System.Runtime.CompilerServices.Imported(ObeysTypeSystem=true)] public class X { public static void M() {} }
class C {
	public void M() {
		// BEGIN
		X.M();
		// END
	}
}
",
                                               @"			X.m();
");
        }
        public void ArrayTypeAppearsAsArrayAsGenericArgument()
        {
            SourceVerifier.AssertSourceCorrect(@"
using System;
class G<T> {}
class C {
	public void M() {
		// BEGIN
		var f = new G<int[]>();
		// END
	}
}
",
                                               @"			var f = new (ss.makeGenericType($$G$1, [Array]))();
");
        }
        public void TypeOfImportedTypeDefinitionThatObeysTheTypeSystemReturnsItself()
        {
            SourceVerifier.AssertSourceCorrect(@"
using System;
[System.Runtime.CompilerServices.Imported(ObeysTypeSystem=true)] public class X {}
class C {
	public void M() {
		// BEGIN
		var t = typeof(X);
		// END
	}
}
",
                                               @"			var t = X;
");
        }
        public void ImportedEnumThatObeysTypeSystemIsItselfAsTypeArgument()
        {
            SourceVerifier.AssertSourceCorrect(@"
[System.Runtime.CompilerServices.Imported(ObeysTypeSystem = true)] public enum E {}
public class G<T> {}
class C {
	public void M() {
		// BEGIN
		var f = new G<E>();
		// END
	}
}
",
                                               @"			var f = new (ss.makeGenericType($G$1, [E]))();
");
        }
        public void CastingToParameterizedTypeWorks()
        {
            SourceVerifier.AssertSourceCorrect(@"
public class G<T1, T2> { public void M() {} }
class C {
	public void M() {
		object o = null;
		// BEGIN
		var g = (G<object, string>)o;
		// END
	}
}
",
                                               @"			var g = ss.cast(o, ss.makeGenericType($G$2, [Object, String]));
");
        }
Exemplo n.º 10
0
        public void TypeOfEnumIsTheEnum()
        {
            SourceVerifier.AssertSourceCorrect(@"
public enum E {}
class C {
	public void M() {
		object o = null;
		// BEGIN
		var t = typeof(E);
		// END
	}
}
",
                                               @"			var t = $E;
");
        }
Exemplo n.º 11
0
        public void DelegateTypeAppearsAsFunctionAsTypeArgumentInInlineCode()
        {
            SourceVerifier.AssertSourceCorrect(@"
using System;
class C {
	[System.Runtime.CompilerServices.InlineCode(""{T}"")] public object F<T>() {}
	public void M() {
		// BEGIN
		var x = F<Func<int, string>>();
		// END
	}
}
",
                                               @"			var x = Function;
");
        }
Exemplo n.º 12
0
        public void CastToEnumIsCastToInt()
        {
            SourceVerifier.AssertSourceCorrect(@"
public enum E {}
class C {
	public void M() {
		object o = null;
		// BEGIN
		var f = (E)o;
		// END
	}
}
",
                                               @"			var f = ss.cast(o, ss.Int32);
");
        }
Exemplo n.º 13
0
        public void EnumAsGenericArgumentWorks()
        {
            SourceVerifier.AssertSourceCorrect(@"
public enum E {}
public class G<T> {}
class C {
	public void M() {
		// BEGIN
		var f = new G<E>();
		// END
	}
}
",
                                               @"			var f = new (ss.makeGenericType($G$1, [$E]))();
");
        }
Exemplo n.º 14
0
        public void TypeOfOpenGenericTypeWorks()
        {
            SourceVerifier.AssertSourceCorrect(@"
using System;
public class G<T1, T2> {}
class C {
	public void M() {
		// BEGIN
		var t = typeof(G<,>);
		// END
	}
}
",
                                               @"			var t = $G$2;
");
        }
Exemplo n.º 15
0
        public void SerializableParameterizedTypeWithIgnoreGenericArgumentsAppearsAsItselfWhenUsedAsInlineCodeGenericArgument()
        {
            SourceVerifier.AssertSourceCorrect(@"
[System.Serializable, System.Runtime.CompilerServices.IncludeGenericArguments(false)] public class G2<T1> {}
class C {
	[System.Runtime.CompilerServices.InlineCode(""{T}"")] public object F<T>() {}
	public void M() {
		// BEGIN
		var x = F<G2<int>>();
		// END
	}
}
",
                                               @"			var x = $G2;
");
        }
Exemplo n.º 16
0
        public void ImportedParameterizedTypeAppearsAsObjectWhenUsedAsGenericArgument()
        {
            SourceVerifier.AssertSourceCorrect(@"
public class G<T1> {}
[System.Runtime.CompilerServices.Imported] public class G2<T1> {}
class C {
	public void M() {
		// BEGIN
		var f = new G<G2<int>>();
		// END
	}
}
",
                                               @"			var f = new (ss.makeGenericType($G$1, [Object]))();
");
        }
Exemplo n.º 17
0
        public void CastingToSerializableParameterizedTypeWithIgnoreGenericArgumentsIsANoOp()
        {
            SourceVerifier.AssertSourceCorrect(@"
[System.Serializable, System.Runtime.CompilerServices.IncludeGenericArguments(false)] public class G<T1, T2> { public void M() {} }
class C {
	public void M() {
		object o = null;
		// BEGIN
		var g = (G<object, string>)o;
		// END
	}
}
",
                                               @"			var g = o;
");
        }
Exemplo n.º 18
0
        public void CastingToImportedParameterizedTypeIsANoOp()
        {
            SourceVerifier.AssertSourceCorrect(@"
[System.Runtime.CompilerServices.Imported] public class G<T1, T2> { public void M() {} }
class C {
	public void M() {
		object o = null;
		// BEGIN
		var g = (G<object, string>)o;
		// END
	}
}
",
                                               @"			var g = o;
");
        }
Exemplo n.º 19
0
        public void TypeOfTypeDefinitionWorks()
        {
            SourceVerifier.AssertSourceCorrect(@"
using System;
public class X {}
class C {
	public void M() {
		// BEGIN
		var t = typeof(X);
		// END
	}
}
",
                                               @"			var t = $X;
");
        }
Exemplo n.º 20
0
        public void SerializableParameterizedTypeAppearsAsItselfWhenUsedAsGenericArgument()
        {
            SourceVerifier.AssertSourceCorrect(@"
public class G<T1> {}
[System.Serializable] public class G2<T1> {}
class C {
	public void M() {
		// BEGIN
		var f = new G<G2<int>>();
		// END
	}
}
",
                                               @"			var f = new (ss.makeGenericType($G$1, [ss.makeGenericType($G2$1, [ss.Int32])]))();
");
        }
Exemplo n.º 21
0
        public void TypeOfSerializableTypeDefinitionWorks()
        {
            SourceVerifier.AssertSourceCorrect(@"
using System;
[System.Serializable] public class X {}
class C {
	public void M() {
		// BEGIN
		var f = typeof(X);
		// END
	}
}
",
                                               @"			var f = $X;
");
        }
Exemplo n.º 22
0
        public void SerializableParameterizedTypeAppearsAsItselfWhenUsedAsGenericArgumentInInlineCode()
        {
            SourceVerifier.AssertSourceCorrect(@"
[System.Serializable] public class G<T1> {}
class C {
	[System.Runtime.CompilerServices.InlineCode(""{T}"")] public object F<T>() {}
	public void M() {
		// BEGIN
		var x = F<G<int>>();
		// END
	}
}
",
                                               @"			var x = ss.makeGenericType($G$1, [ss.Int32]);
");
        }
Exemplo n.º 23
0
        public void DelegateTypeAppearsAsFunctionAsGenericArgument()
        {
            SourceVerifier.AssertSourceCorrect(@"
using System;
class G<T> {}
class C {
	public void M() {
		// BEGIN
		var f = new G<Func<int, string>>();
		// END
	}
}
",
                                               @"			var f = new (ss.makeGenericType($$G$1, [Function]))();
");
        }
Exemplo n.º 24
0
        public void CastingToDelegateTypeCastsToFunction()
        {
            SourceVerifier.AssertSourceCorrect(@"
using System;
class C {
	public void M() {
		object o = null;
		// BEGIN
		var t = (Func<int, string>)o;
		// END
	}
}
",
                                               @"			var t = ss.cast(o, Function);
");
        }
Exemplo n.º 25
0
        public void InvokingStaticMethodOfSerializableTypeDefinitionWorks()
        {
            SourceVerifier.AssertSourceCorrect(@"
using System;
[System.Serializable] public class X { public static void M() {} }
class C {
	public void M() {
		// BEGIN
		X.M();
		// END
	}
}
",
                                               @"			$X.m();
");
        }
Exemplo n.º 26
0
        public void CastingToSerializableParameterizedTypeIsANoOp()
        {
            SourceVerifier.AssertSourceCorrect(@"
[System.Serializable] public class G<T1, T2> { public void M() {} }
class C {
	public void M() {
		object o = null;
		// BEGIN
		var g = (G<object, string>)o;
		// END
	}
}
",
                                               @"			var g = o;
");
        }
Exemplo n.º 27
0
        public void DynamicAppearsAsObjectAsTypeArgumentInInlineCode()
        {
            SourceVerifier.AssertSourceCorrect(@"
using System;
class C {
	[System.Runtime.CompilerServices.InlineCode(""{T}"")] public object F<T>() {}
	public void M() {
		// BEGIN
		var x = F<dynamic>();
		// END
	}
}
",
                                               @"			var x = Object;
");
        }
Exemplo n.º 28
0
        public void SerializableParameterizedTypeWithIgnoreGenericArgumentsAppearsAsItselfWhenUsedAsGenericArgument()
        {
            SourceVerifier.AssertSourceCorrect(@"
public class G<T1> {}
[System.Serializable, System.Runtime.CompilerServices.IncludeGenericArguments(false)] public class G2<T1> {}
class C {
	public void M() {
		// BEGIN
		var f = new G<G2<int>>();
		// END
	}
}
",
                                               @"			var f = new (ss.makeGenericType($G$1, [$G2]))();
");
        }
Exemplo n.º 29
0
        public void CastingToArrayTypeCastsToArray()
        {
            SourceVerifier.AssertSourceCorrect(@"
using System;
class C {
	public void M() {
		object o = null;
		// BEGIN
		var t = (int[])o;
		// END
	}
}
",
                                               @"			var t = ss.cast(o, Array);
");
        }
Exemplo n.º 30
0
        public void ConvertingDynamicToBoolUsesDoubleNegation()
        {
            SourceVerifier.AssertSourceCorrect(@"
using System;

public class C {
	private void M() {
		dynamic d = null;
		// BEGIN
		bool b = d;
		// END
	}
}",
                                               @"			var b = !!d;
");
        }