void InitMembers(IKVM.Reflection.Type typeDefinition, IUnresolvedTypeDefinition td, IList<IUnresolvedMember> members) { foreach (var method in typeDefinition.__GetDeclaredMethods ()) { if (method.IsConstructor) { if (IsVisible(method.Attributes)) { SymbolKind type = SymbolKind.Constructor; members.Add(ReadConstructor(method, td, type)); } continue; } if (IsVisible(method.Attributes) && !IsAccessor(method)) { SymbolKind type = SymbolKind.Method; if (method.IsSpecialName) { if (method.Name.StartsWith("op_", StringComparison.Ordinal)) type = SymbolKind.Operator; } members.Add(ReadMethod(method, td, type)); } } foreach (var field in typeDefinition.__GetDeclaredFields ()) { if (IsVisible(field.Attributes) && !field.IsSpecialName) { members.Add(ReadField(field, td)); } } string defaultMemberName = null; var defaultMemberAttribute = typeDefinition.CustomAttributes.FirstOrDefault( a => { var dt = a.Constructor.DeclaringType; return dt.__Name == "DefaultMemberAttribute" && dt.Namespace == "System.Reflection"; }); if (defaultMemberAttribute != null && defaultMemberAttribute.ConstructorArguments.Count == 1) { defaultMemberName = defaultMemberAttribute.ConstructorArguments[0].Value as string; } foreach (var property in typeDefinition.__GetDeclaredProperties ()) { bool getterVisible = property.GetMethod != null && IsVisible(property.GetMethod.Attributes); bool setterVisible = property.SetMethod != null && IsVisible(property.SetMethod.Attributes); if (getterVisible || setterVisible) { SymbolKind type = SymbolKind.Property; if (property.GetIndexParameters () != null) { // Try to detect indexer: if (property.Name == defaultMemberName) { type = SymbolKind.Indexer; // normal indexer } // TODO: HasOverrides ? else if (property.Name.EndsWith(".Item", StringComparison.Ordinal) /*&& (property.GetMethod ?? property.SetMethod).HasOverrides*/) { // explicit interface implementation of indexer type = SymbolKind.Indexer; // We can't really tell parameterized properties and indexers apart in this case without // resolving the interface, so we rely on the "Item" naming convention instead. } } members.Add(ReadProperty(property, td, type)); } } foreach (var ev in typeDefinition.__GetDeclaredEvents ()) { if (ev.AddMethod != null && IsVisible(ev.AddMethod.Attributes)) { members.Add(ReadEvent(ev, td)); } } }
void InitBaseTypes(IKVM.Reflection.Type typeDefinition, ICollection<ITypeReference> baseTypes) { // set base classes if (typeDefinition.IsEnum) { foreach (var enumField in typeDefinition.__GetDeclaredFields ()) { if (!enumField.IsStatic) { baseTypes.Add(ReadTypeReference(enumField.FieldType)); break; } } } else { if (typeDefinition.BaseType != null) { baseTypes.Add(ReadTypeReference(typeDefinition.BaseType)); } foreach (var iface in typeDefinition.__GetDeclaredInterfaces ()) { baseTypes.Add(ReadTypeReference(iface)); } } }