public void TypeSubstitutor_Array() { var subst = new TypeSubstitutor(new Dictionary <Type, Type> { { typeof(int[]), typeof(long[]) } }); Assert.IsNull(subst.Visit(type: null)); Assert.AreSame(typeof(string), subst.Visit(typeof(string))); Assert.AreSame(typeof(List <string[]> [, ]), subst.Visit(typeof(List <string[]> [, ]))); Assert.AreSame(typeof(int), subst.Visit(typeof(int))); Assert.AreEqual(typeof(long[]), subst.Visit(typeof(int[]))); Assert.AreSame(typeof(int[, ]), subst.Visit(typeof(int[, ]))); Assert.AreSame(typeof(Func <int>), subst.Visit(typeof(Func <int>))); Assert.AreEqual(typeof(Func <bool, Func <object, long[]>, double>), subst.Visit(typeof(Func <bool, Func <object, int[]>, double>))); Assert.AreSame(typeof(int *), subst.Visit(typeof(int *))); Assert.AreSame(typeof(int).MakeByRefType(), subst.Visit(typeof(int).MakeByRefType())); }
/// <summary> /// Resolves a type for rewriting of the expression tree. /// </summary> /// <param name="originalType">Original type.</param> /// <returns>New type to use.</returns> protected virtual Type ResolveType(Type originalType) => _subst.Visit(originalType);
/// <summary> /// Visits the type with a substitutor. /// </summary> /// <param name="type">Type to visit.</param> /// <returns>Result of the visit.</returns> protected override Type VisitType(Type type) => _subst.Visit(type);