-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Refactor runtime-specific logic out of CustomAttributeData #55870
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
c1bb326
6d6274e
00aa646
10890e0
24ba08c
9a3841d
7825aab
26f880a
2275e34
0bcb0f1
dcd0e38
e9b68dc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
CustomAttributeData is meant to be abstract base class of reflection object model. Move the runtime-specific part into a separate RuntimeCustomAttributeData type.
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ | |
|
|
||
| namespace System.Reflection | ||
| { | ||
| public partial class CustomAttributeData | ||
| public class CustomAttributeData | ||
| { | ||
| #region Public Static Members | ||
| public static IList<CustomAttributeData> GetCustomAttributes(MemberInfo target) | ||
|
|
@@ -42,6 +42,10 @@ public static IList<CustomAttributeData> GetCustomAttributes(ParameterInfo targe | |
| } | ||
| #endregion | ||
|
|
||
| protected CustomAttributeData() | ||
| { | ||
| } | ||
|
|
||
| #region Object Override | ||
| public override string ToString() | ||
| { | ||
|
|
@@ -51,22 +55,26 @@ public override string ToString() | |
| vsb.Append(Constructor.DeclaringType!.FullName); | ||
| vsb.Append('('); | ||
|
|
||
| bool first = true; | ||
|
|
||
| int count = ConstructorArguments.Count; | ||
| IList<CustomAttributeTypedArgument> constructorArguments = ConstructorArguments; | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cache in locals to avoid redundant interface calls. |
||
| int count = constructorArguments.Count; | ||
| for (int i = 0; i < count; i++) | ||
| { | ||
| if (!first) vsb.Append(", "); | ||
| vsb.Append(ConstructorArguments[i].ToString()); | ||
| first = false; | ||
| if (i != 0) | ||
| { | ||
| vsb.Append(", "); | ||
| } | ||
| vsb.Append(constructorArguments[i].ToString()); | ||
jkotas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| count = NamedArguments.Count; | ||
| IList<CustomAttributeNamedArgument> namedArguments = NamedArguments; | ||
| count = namedArguments.Count; | ||
| for (int i = 0; i < count; i++) | ||
| { | ||
| if (!first) vsb.Append(", "); | ||
| vsb.Append(NamedArguments[i].ToString()); | ||
| first = false; | ||
| if (i != 0) | ||
| { | ||
| vsb.Append(", "); | ||
| } | ||
| vsb.Append(namedArguments[i].ToString()); | ||
| } | ||
|
|
||
| vsb.Append(")]"); | ||
|
|
@@ -79,6 +87,11 @@ public override string ToString() | |
|
|
||
| #region Public Members | ||
| public virtual Type AttributeType => Constructor.DeclaringType!; | ||
|
|
||
| // Expected to be overriden | ||
| public virtual ConstructorInfo Constructor => null!; | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This matches the existing Mono behavior. The existing CoreCLR behavior is to throw NullReferenceException in some of these. |
||
| public virtual IList<CustomAttributeTypedArgument> ConstructorArguments => null!; | ||
| public virtual IList<CustomAttributeNamedArgument> NamedArguments => null!; | ||
| #endregion | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.