public TypeMetadata(Type type) { TypeEnum = TypeEnumFactory.CreateTypeMetadataClass(type); FullTypeName = type.FullName; TypeName = type.Name; NamespaceName = type.Namespace; GenericArguments = !type.IsGenericTypeDefinition && !type.IsConstructedGenericType ? null : EmitGenericArguments(type.GetGenericArguments()); Modifiers = EmitModifiers(type); Attributes = AttributeMetadata.EmitAttributes(type); DeclaringType = EmitDeclaringType(type.DeclaringType); BaseType = EmitExtends(type.BaseType); ImplementedInterfaces = EmitImplements(type.GetInterfaces()); BindingFlags flagsToGetAll = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly; Fields = FieldMetadata.EmitFields(type.GetFields(flagsToGetAll)); Methods = MethodMetadata.EmitMethods(type.GetMethods(flagsToGetAll)); Properties = PropertyMetadata.EmitProperties(type.GetProperties(flagsToGetAll)); Indexers = IndexerMetadata.EmitIndexers(type.GetProperties(flagsToGetAll)); Events = EventMetadata.EmitEvents(type.GetEvents(flagsToGetAll)); Constructors = ConstructorMetadata.EmitConstructors(type.GetConstructors(flagsToGetAll)); NestedTypes = EmitNestedTypes(type.GetNestedTypes(flagsToGetAll)); }
public void EmitMethodsReturnsValue() { List <MethodBase> methods = new List <MethodBase>(typeof(TestClass).GetMethods()); List <MethodMetadata> methodsMeta = new List <MethodMetadata>(MethodMetadata.EmitMethods(methods)); Assert.AreEqual(methods.Count, methodsMeta.Count); }
public void EmitMethodsTest() { Type type = typeof(TestClass); List <MethodMetadata> methods = MethodMetadata.EmitMethods(type.GetMethods()).ToList <MethodMetadata>(); MethodMetadata method = methods.Find(m => m.Name.Equals("function")); Assert.AreEqual(AccessLevel.IsPublic, method.AccessLevel); Assert.AreEqual(AbstractEnum.NotAbstract, method.AbstractEnum); Assert.AreEqual(StaticEnum.NotStatic, method.StaticEnum); Assert.AreEqual(VirtualEnum.Virtual, method.VirtualEnum); Assert.AreEqual("Void", method.ReturnType.Name); }
public void EmitMethodsTest() { Type type = typeof(mockClass); List <MethodMetadata> methods = MethodMetadata.EmitMethods(type.GetMethods()).ToList <MethodMetadata>(); MethodMetadata method = methods.Find(m => m.m_Name.Equals("Method")); Assert.IsNotNull(method); Assert.AreEqual("Method", method.m_Name); Assert.AreEqual("Void", method.m_ReturnType.m_typeName); Assert.AreEqual(AccessLevelEnum.IsPublic, method.m_Modifiers.Item1); Assert.AreEqual(AbstractEnum.NotAbstract, method.m_Modifiers.Item2); Assert.AreEqual(StaticEnum.NotStatic, method.m_Modifiers.Item3); Assert.AreEqual(VirtualEnum.Virtual, method.m_Modifiers.Item4); List <ParameterMetadata> parameters = method.m_Parameters.ToList <ParameterMetadata>(); Assert.AreEqual(1, parameters.Count()); Assert.AreEqual("parameter", parameters[0].m_Name); }
public void EmitMethodsThrowsOnNull() { MethodMetadata.EmitMethods(null); }