public void MemberInfoSlimVisitor_VisitGenericMethod_AreNotSame() { var visitor = new A(); var genDef = SlimType.GetGenericDefinitionMethod("Foo", new TypeSlim[] { TypeSlim.GenericParameter("T") }.ToReadOnly(), EmptyReadOnlyCollection <TypeSlim> .Instance, returnType: null); var generic = SlimType.GetGenericMethod(genDef, new TypeSlim[] { SlimType }.ToReadOnly()); Assert.AreNotSame(generic, visitor.Visit(generic)); }
public void GenericDefinitionMethodInfoSlim_ArgumentChecks() { AssertEx.ThrowsException <ArgumentNullException>(() => TypeSlimExtensions.GetGenericDefinitionMethod(type: null, "bar", genericParameterTypes: null, parameterTypes: null, returnType: null), ex => Assert.AreEqual("type", ex.ParamName)); AssertEx.ThrowsException <ArgumentNullException>(() => SlimType.GetGenericDefinitionMethod(name: null, genericParameterTypes: null, parameterTypes: null, returnType: null), ex => Assert.AreEqual("name", ex.ParamName)); AssertEx.ThrowsException <ArgumentException>(() => SlimType.GetGenericDefinitionMethod("", genericParameterTypes: null, parameterTypes: null, returnType: null), ex => Assert.AreEqual("name", ex.ParamName)); AssertEx.ThrowsException <ArgumentNullException>(() => SlimType.GetGenericDefinitionMethod("foo", genericParameterTypes: null, parameterTypes: null, returnType: null), ex => Assert.AreEqual("parameterTypes", ex.ParamName)); AssertEx.ThrowsException <ArgumentNullException>(() => SlimType.GetGenericDefinitionMethod("foo", genericParameterTypes: null, Empty, returnType: null), ex => Assert.AreEqual("genericParameterTypes", ex.ParamName)); AssertEx.ThrowsException <ArgumentOutOfRangeException>(() => SlimType.GetGenericDefinitionMethod("foo", Empty, Empty, returnType: null), ex => Assert.AreEqual("genericParameterTypes", ex.ParamName)); }
public void GenericMethodInfoSlim_ArgumentChecks() { AssertEx.ThrowsException <ArgumentNullException>(() => TypeSlimExtensions.GetGenericMethod(type: null, methodDefinition: null, arguments: null), ex => Assert.AreEqual("type", ex.ParamName)); AssertEx.ThrowsException <ArgumentNullException>(() => SlimType.GetGenericMethod(methodDefinition: null, arguments: null), ex => Assert.AreEqual("methodDefinition", ex.ParamName)); var def = SlimType.GetGenericDefinitionMethod("Foo", new List <TypeSlim> { SlimType }.AsReadOnly(), EmptyReadOnlyCollection <TypeSlim> .Instance, returnType: null); AssertEx.ThrowsException <ArgumentNullException>(() => def.DeclaringType.GetGenericMethod(def, arguments: null), ex => Assert.AreEqual("arguments", ex.ParamName)); }
public void MemberInfoSlimVisitor_Generic_GenericMethod() { var visitor = new MyVisitor(); var genDef = SlimType.GetGenericDefinitionMethod("Foo", new TypeSlim[] { TypeSlim.GenericParameter("T") }.ToReadOnly(), EmptyReadOnlyCollection <TypeSlim> .Instance, returnType: null); var generic = SlimType.GetGenericMethod(genDef, new TypeSlim[] { SlimType }.ToReadOnly()); var res = visitor.Visit(generic); Assert.AreEqual(42, res); }
protected override MemberInfoSlim VisitGenericDefinitionMethod(GenericDefinitionMethodInfoSlim method) { return(SlimType.GetGenericDefinitionMethod("Foo", new TypeSlim[] { TypeSlim.GenericParameter("T") }.ToReadOnly(), EmptyReadOnlyCollection <TypeSlim> .Instance, returnType: null)); }