diff --git a/ICSharpCode.Decompiler/TypeSystem/TypeSystemExtensions.cs b/ICSharpCode.Decompiler/TypeSystem/TypeSystemExtensions.cs index b14cc73a1..ba6e4fe47 100644 --- a/ICSharpCode.Decompiler/TypeSystem/TypeSystemExtensions.cs +++ b/ICSharpCode.Decompiler/TypeSystem/TypeSystemExtensions.cs @@ -439,6 +439,31 @@ namespace ICSharpCode.Decompiler.TypeSystem } #endregion + #region IParameter.GetAttribute + /// + /// Gets whether the parameter has an attribute of the specified attribute type (or derived attribute types). + /// + /// The parameter on which the attributes are declared. + /// The attribute type to look for. + public static bool HasAttribute(this IParameter parameter, KnownAttribute attrType) + { + return GetAttribute(parameter, attrType) != null; + } + + /// + /// Gets the attribute of the specified attribute type (or derived attribute types). + /// + /// The parameter on which the attributes are declared. + /// The attribute type to look for. + /// + /// Returns the attribute that was found; or null if none was found. + /// + public static IAttribute GetAttribute(this IParameter parameter, KnownAttribute attributeType) + { + return parameter.GetAttributes().FirstOrDefault(a => a.AttributeType.IsKnownType(attributeType)); + } + #endregion + #region IAssembly.GetTypeDefinition(string,string,int) /// /// Gets the type definition for a top-level type.