public void GetMemberSignature_Field()
        {
            var method = NormalizingMemberInfoFromExpressionUtility.GetField((DomainType obj) => obj.Field);

            var result = MemberSignatureProvider.GetMemberSignature(method);

            Assert.That(result, Is.TypeOf <FieldSignature> ());
        }
        public void GetMemberSignature_Unsupported()
        {
            var type = typeof(object);

            Assert.That(
                () => MemberSignatureProvider.GetMemberSignature(type),
                Throws.TypeOf <NotSupportedException> ().With.Message.EqualTo(
                    "Cannot return a signature builder for member type 'TypeInfo'; only constructors, methods, fields, properties and events are supported."));
        }
        public void GetMemberSignature_Event()
        {
            var eventInfo = typeof(DomainType).GetEvent("Event");

            var result = MemberSignatureProvider.GetMemberSignature(eventInfo);

            Assert.That(result, Is.TypeOf <EventSignature> ());
            Assert.That(result.ToString(), Is.EqualTo("System.Action"));
        }
        public void GetMemberSignature_Property()
        {
            var property = NormalizingMemberInfoFromExpressionUtility.GetProperty((DomainType obj) => obj.Property);

            var result = MemberSignatureProvider.GetMemberSignature(property);

            Assert.That(result, Is.TypeOf <PropertySignature> ());
            Assert.That(result.ToString(), Is.EqualTo("System.String()"));
        }
        public void GetMemberSignature_Method()
        {
            var method = NormalizingMemberInfoFromExpressionUtility.GetMethod((DomainType obj) => obj.Method());

            var result = MemberSignatureProvider.GetMemberSignature(method);

            Assert.That(result, Is.TypeOf <MethodSignature> ());
            Assert.That(result.ToString(), Is.EqualTo("System.Double()"));
        }
        public void GetMemberSignature_Constructor()
        {
            var constructor = NormalizingMemberInfoFromExpressionUtility.GetConstructor(() => new DomainType());

            var result = MemberSignatureProvider.GetMemberSignature(constructor);

            Assert.That(result, Is.TypeOf <MethodSignature> ());
            Assert.That(result.ToString(), Is.EqualTo("System.Void()"));
        }
        public void GetMemberSignature_NestedType()
        {
            var nestedType = typeof(DomainType.NestedType);

            var result = MemberSignatureProvider.GetMemberSignature(nestedType);

            Assert.That(result, Is.TypeOf <NestedTypeSignature>());
            Assert.That(result.ToString(), Is.EqualTo("`0"));
        }
Пример #8
0
        private void BuildMapping(MutableType mutableType)
        {
            var generatedType                = (Type)_mapping[mutableType];
            var generatedMembers             = generatedType.GetMembers(c_allDeclared);
            var generatedMembersByNameAndSig = generatedMembers.ToDictionary(m => Tuple.Create(m.Name, MemberSignatureProvider.GetMemberSignature(m)));

            var addedMembers =
                new IMutableMember[] { mutableType.MutableTypeInitializer }.Where(m => m != null)
            .Concat(mutableType.AddedNestedTypes.Cast <IMutableMember>())
            .Concat(mutableType.AddedFields.Cast <IMutableMember>())
            .Concat(mutableType.AddedConstructors.Cast <IMutableMember>())
            .Concat(mutableType.AddedMethods.Cast <IMutableMember>())
            .Concat(mutableType.AddedProperties.Cast <IMutableMember>())
            .Concat(mutableType.AddedEvents.Cast <IMutableMember>());

            foreach (var addedMember in addedMembers)
            {
                var member          = (MemberInfo)addedMember;
                var nameAndSig      = Tuple.Create(member.Name, MemberSignatureProvider.GetMemberSignature(member));
                var generatedMember = generatedMembersByNameAndSig[nameAndSig];

                _mapping.Add(addedMember, generatedMember);
            }
        }