Skip to content

Commit

Permalink
Add GetCustomAttributes method to MemberInfo and derived classes (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
josesimoes authored Sep 28, 2018
1 parent f7a31df commit 05aa51b
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 2 deletions.
12 changes: 11 additions & 1 deletion source/System/Reflection/ConstructorInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

namespace System.Reflection
{
using System;
using Runtime.CompilerServices;
using System;

/// <summary>
/// Discovers the attributes of a class constructor and provides access to constructor metadata.
Expand Down Expand Up @@ -38,5 +38,15 @@ public override MemberTypes MemberType
[Diagnostics.DebuggerHidden]
[MethodImpl(MethodImplOptions.InternalCall)]
public extern Object Invoke(Object[] parameters);

/// <summary>
/// When overridden in a derived class, returns an array of all custom attributes applied to this member.
/// </summary>
/// <param name="inherit">true to search this member's inheritance chain to find the attributes; otherwise, false. This parameter is ignored for properties and events.</param>
/// <returns>An array that contains all the custom attributes applied to this member, or an array with zero elements if no attributes are defined.</returns>
/// <remarks>This method is not implemented in nanoFramework.</remarks>
/// <exception cref="NotImplementedException"/>
[MethodImpl(MethodImplOptions.InternalCall)]
public extern override object[] GetCustomAttributes(bool inherit);
}
}
13 changes: 12 additions & 1 deletion source/System/Reflection/FieldInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

namespace System.Reflection
{
using System;
using Runtime.CompilerServices;
using System;

/// <summary>
/// Discovers the attributes of a field and provides access to field metadata.
Expand Down Expand Up @@ -59,6 +59,17 @@ public abstract Type FieldType
[Diagnostics.DebuggerHidden]
[MethodImpl(MethodImplOptions.InternalCall)]
public virtual extern void SetValue(Object obj, Object value);

/// <summary>
/// When overridden in a derived class, returns an array of all custom attributes applied to this member.
/// </summary>
/// <param name="inherit">true to search this member's inheritance chain to find the attributes; otherwise, false. This parameter is ignored for properties and events.</param>
/// <returns>An array that contains all the custom attributes applied to this member, or an array with zero elements if no attributes are defined.</returns>
/// <remarks>This method is not implemented in nanoFramework.</remarks>
/// <exception cref="NotImplementedException">This method is not implemente.</exception>
/// <exception cref="NotImplementedException"/>
[MethodImpl(MethodImplOptions.InternalCall)]
public extern override object[] GetCustomAttributes(bool inherit);
}
}

Expand Down
7 changes: 7 additions & 0 deletions source/System/Reflection/MemberInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,12 @@ public abstract Type DeclaringType
{
get;
}

/// <summary>
/// When overridden in a derived class, returns an array of all custom attributes applied to this member.
/// </summary>
/// <param name="inherit">true to search this member's inheritance chain to find the attributes; otherwise, false. This parameter is ignored for properties and events.</param>
/// <returns>An array that contains all the custom attributes applied to this member, or an array with zero elements if no attributes are defined.</returns>
public abstract object[] GetCustomAttributes(bool inherit);
}
}
3 changes: 3 additions & 0 deletions source/System/Reflection/RuntimeMethodInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@ public override extern Type ReturnType
[MethodImpl(MethodImplOptions.InternalCall)]
get;
}

[MethodImpl(MethodImplOptions.InternalCall)]
public override extern object[] GetCustomAttributes(bool inherit);
}
}
2 changes: 2 additions & 0 deletions source/System/RuntimeType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,7 @@ public override extern Type BaseType
[MethodImpl(MethodImplOptions.InternalCall)]
public override extern Type GetElementType();

[MethodImpl(MethodImplOptions.InternalCall)]
public override extern object[] GetCustomAttributes(bool inherit);
}
}

0 comments on commit 05aa51b

Please sign in to comment.