예제 #1
0
        private MethodInfo GetEmittableMethodInstantiation(MethodInstantiation methodInstantiation)
        {
            var emittableGenericMethodDefinition = GetEmittableMethod(methodInstantiation.GetGenericMethodDefinition());
            var emittableTypeArguments           = methodInstantiation.GetGenericArguments().Select(GetEmittableType).ToArray();

            // Should *not* be MakeTypePipeGenericMethod.
            return(emittableGenericMethodDefinition.MakeGenericMethod(emittableTypeArguments));
        }
예제 #2
0
        public void Initialization()
        {
            Assert.That(_instantiation.DeclaringType, Is.SameAs(_genericMethodDefinition.DeclaringType));
            Assert.That(_instantiation.Name, Is.EqualTo(_genericMethodDefinition.Name));
            Assert.That(_instantiation.Attributes, Is.EqualTo(_genericMethodDefinition.Attributes));
            Assert.That(_instantiation.IsGenericMethod, Is.True);
            Assert.That(_instantiation.GetGenericMethodDefinition(), Is.SameAs(_genericMethodDefinition));
            Assert.That(_instantiation.GetGenericArguments(), Is.EqualTo(new[] { _typeArgument }));

            var returnParameter = _instantiation.ReturnParameter;

            Assertion.IsNotNull(returnParameter);
            Assert.That(returnParameter, Is.TypeOf <MemberParameterOnInstantiation>());
            Assert.That(returnParameter.Member, Is.SameAs(_instantiation));
            Assert.That(returnParameter.As <MemberParameterOnInstantiation>().MemberParameterOnGenericDefinition, Is.SameAs(_genericMethodDefinition.ReturnParameter));

            var parameter = _instantiation.GetParameters().Single();

            Assert.That(parameter, Is.TypeOf <MemberParameterOnInstantiation>());
            Assert.That(parameter.Member, Is.SameAs(_instantiation));
            Assert.That(parameter.As <MemberParameterOnInstantiation>().MemberParameterOnGenericDefinition, Is.SameAs(_parameter));
        }