|
|
|
@ -269,10 +269,9 @@ namespace ICSharpCode.Decompiler.Ast
@@ -269,10 +269,9 @@ namespace ICSharpCode.Decompiler.Ast
|
|
|
|
|
foreach (var i in typeDef.Interfaces) |
|
|
|
|
astType.AddChild(ConvertType(i), TypeDeclaration.BaseTypeRole); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AddTypeMembers(astType, typeDef); |
|
|
|
|
|
|
|
|
|
if (astType.Members.Any(m => m is IndexerDeclaration)) { |
|
|
|
|
if (astType.Members.OfType<IndexerDeclaration>().Any(idx => idx.PrivateImplementationType.IsNull)) { |
|
|
|
|
// Remove the [DefaultMember] attribute if the class contains indexers
|
|
|
|
|
foreach (AttributeSection section in astType.Attributes) { |
|
|
|
|
foreach (Ast.Attribute attr in section.Attributes) { |
|
|
|
@ -775,39 +774,12 @@ namespace ICSharpCode.Decompiler.Ast
@@ -775,39 +774,12 @@ namespace ICSharpCode.Decompiler.Ast
|
|
|
|
|
} |
|
|
|
|
ConvertCustomAttributes(astProp, propDef); |
|
|
|
|
|
|
|
|
|
// Check whether the property is an indexer:
|
|
|
|
|
if (propDef.HasParameters) { |
|
|
|
|
PropertyDefinition basePropDef = propDef; |
|
|
|
|
if (accessor.HasOverrides) { |
|
|
|
|
// if the property is explicitly implementing an interface, look up the property in the interface:
|
|
|
|
|
MethodDefinition baseAccessor = accessor.Overrides.First().Resolve(); |
|
|
|
|
if (baseAccessor != null) { |
|
|
|
|
foreach (PropertyDefinition baseProp in baseAccessor.DeclaringType.Properties) { |
|
|
|
|
if (baseProp.GetMethod == baseAccessor || baseProp.SetMethod == baseAccessor) { |
|
|
|
|
basePropDef = baseProp; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// figure out the name of the indexer:
|
|
|
|
|
string defaultMemberName = null; |
|
|
|
|
var defaultMemberAttribute = basePropDef.DeclaringType.CustomAttributes.FirstOrDefault(IsDefaultMemberAttribute); |
|
|
|
|
if (defaultMemberAttribute != null && defaultMemberAttribute.ConstructorArguments.Count == 1) { |
|
|
|
|
defaultMemberName = defaultMemberAttribute.ConstructorArguments[0].Value as string; |
|
|
|
|
} |
|
|
|
|
if (basePropDef.Name == defaultMemberName) { |
|
|
|
|
if(propDef.IsIndexer()) |
|
|
|
|
return ConvertPropertyToIndexer(astProp, propDef); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
return astProp; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool IsDefaultMemberAttribute(CustomAttribute ca) |
|
|
|
|
{ |
|
|
|
|
return ca.AttributeType.Name == "DefaultMemberAttribute" && ca.AttributeType.Namespace == "System.Reflection"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
IndexerDeclaration ConvertPropertyToIndexer(PropertyDeclaration astProp, PropertyDefinition propDef) |
|
|
|
|
{ |
|
|
|
|
var astIndexer = new IndexerDeclaration(); |
|
|
|
@ -1313,18 +1285,5 @@ namespace ICSharpCode.Decompiler.Ast
@@ -1313,18 +1285,5 @@ namespace ICSharpCode.Decompiler.Ast
|
|
|
|
|
|
|
|
|
|
return type.CustomAttributes.Any(attr => attr.AttributeType.FullName == "System.FlagsAttribute"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the name of the default member of the type pointed by the <see cref="System.Reflection.DefaultMemberAttribute"/> attribute.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="type">The type definition.</param>
|
|
|
|
|
/// <returns>The name of the default member or null if no <see cref="System.Reflection.DefaultMemberAttribute"/> attribute has been found.</returns>
|
|
|
|
|
private static Tuple<string, CustomAttribute> GetDefaultMember(TypeDefinition type) |
|
|
|
|
{ |
|
|
|
|
foreach (CustomAttribute ca in type.CustomAttributes) |
|
|
|
|
if (ca.Constructor.FullName == "System.Void System.Reflection.DefaultMemberAttribute::.ctor(System.String)") |
|
|
|
|
return Tuple.Create(ca.ConstructorArguments.Single().Value as string, ca); |
|
|
|
|
return new Tuple<string,CustomAttribute>(null, null); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|