|
|
@ -169,7 +169,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation |
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Custom Attributes (ReadAttribute)
|
|
|
|
#region Custom Attributes (ReadAttribute)
|
|
|
|
public void Add(CustomAttributeHandleCollection attributes) |
|
|
|
public void Add(CustomAttributeHandleCollection attributes, SymbolKind target) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var metadata = module.metadata; |
|
|
|
var metadata = module.metadata; |
|
|
|
foreach (var handle in attributes) { |
|
|
|
foreach (var handle in attributes) { |
|
|
@ -177,14 +177,14 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation |
|
|
|
// Attribute types shouldn't be generic (and certainly not open), so we don't need a generic context.
|
|
|
|
// Attribute types shouldn't be generic (and certainly not open), so we don't need a generic context.
|
|
|
|
var ctor = module.ResolveMethod(attribute.Constructor, new GenericContext()); |
|
|
|
var ctor = module.ResolveMethod(attribute.Constructor, new GenericContext()); |
|
|
|
var type = ctor.DeclaringType; |
|
|
|
var type = ctor.DeclaringType; |
|
|
|
if (IgnoreAttribute(type)) { |
|
|
|
if (IgnoreAttribute(type, target)) { |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
Add(new CustomAttribute(module, ctor, handle)); |
|
|
|
Add(new CustomAttribute(module, ctor, handle)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool IgnoreAttribute(IType attributeType) |
|
|
|
bool IgnoreAttribute(IType attributeType, SymbolKind target) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (attributeType.DeclaringType != null || attributeType.TypeParameterCount != 0) |
|
|
|
if (attributeType.DeclaringType != null || attributeType.TypeParameterCount != 0) |
|
|
|
return false; |
|
|
|
return false; |
|
|
@ -199,18 +199,20 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation |
|
|
|
case "ExtensionAttribute": |
|
|
|
case "ExtensionAttribute": |
|
|
|
return (options & TypeSystemOptions.ExtensionMethods) != 0; |
|
|
|
return (options & TypeSystemOptions.ExtensionMethods) != 0; |
|
|
|
case "DecimalConstantAttribute": |
|
|
|
case "DecimalConstantAttribute": |
|
|
|
return (options & TypeSystemOptions.DecimalConstants) != 0; |
|
|
|
return (options & TypeSystemOptions.DecimalConstants) != 0 && target == SymbolKind.Field; |
|
|
|
case "IsReadOnlyAttribute": |
|
|
|
case "IsReadOnlyAttribute": |
|
|
|
return (options & TypeSystemOptions.ReadOnlyStructsAndParameters) != 0; |
|
|
|
return (options & TypeSystemOptions.ReadOnlyStructsAndParameters) != 0; |
|
|
|
case "IsByRefLikeAttribute": |
|
|
|
case "IsByRefLikeAttribute": |
|
|
|
return (options & TypeSystemOptions.RefStructs) != 0; |
|
|
|
return (options & TypeSystemOptions.RefStructs) != 0 && target == SymbolKind.TypeDefinition; |
|
|
|
|
|
|
|
case "IsUnmanagedAttribute": |
|
|
|
|
|
|
|
return (options & TypeSystemOptions.UnmanagedConstraints) != 0 && target == SymbolKind.TypeParameter; |
|
|
|
case "NullableAttribute": |
|
|
|
case "NullableAttribute": |
|
|
|
return (options & TypeSystemOptions.NullabilityAnnotations) != 0; |
|
|
|
return (options & TypeSystemOptions.NullabilityAnnotations) != 0; |
|
|
|
default: |
|
|
|
default: |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
case "System": |
|
|
|
case "System": |
|
|
|
return attributeType.Name == "ParamArrayAttribute"; |
|
|
|
return attributeType.Name == "ParamArrayAttribute" && target == SymbolKind.Parameter; |
|
|
|
default: |
|
|
|
default: |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|