-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
c1bb326
Refactor runtime-specific logic out of CustomAttributeData
jkotas 6d6274e
Fix linker build break
jkotas 00aa646
Simplify CanonicalizeValue
jkotas 10890e0
Use pattern matching
jkotas 24ba08c
Update src/libraries/System.Private.CoreLib/src/System/Reflection/Cus…
jkotas 9a3841d
Feedback
jkotas 7825aab
Merge remote-tracking branch 'origin/customattributedata' into custom…
jkotas 26f880a
Fix bad merge
jkotas 2275e34
Revert incorrect change
jkotas 0bcb0f1
Is this hitting codegen bug?
jkotas dcd0e38
Fix Mono ICALL order
jkotas e9b68dc
Revert incorrect change
jkotas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,11 +2,12 @@ | |
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.Collections.Generic; | ||
| using System.Runtime.CompilerServices; | ||
| using System.Text; | ||
|
|
||
| namespace System.Reflection | ||
| { | ||
| public partial class CustomAttributeData | ||
| public class CustomAttributeData | ||
| { | ||
| #region Public Static Members | ||
| public static IList<CustomAttributeData> GetCustomAttributes(MemberInfo target) | ||
|
|
@@ -42,6 +43,10 @@ public static IList<CustomAttributeData> GetCustomAttributes(ParameterInfo targe | |
| } | ||
| #endregion | ||
|
|
||
| protected CustomAttributeData() | ||
| { | ||
| } | ||
|
|
||
| #region Object Override | ||
| public override string ToString() | ||
| { | ||
|
|
@@ -53,19 +58,21 @@ public override string ToString() | |
|
|
||
| bool first = true; | ||
|
|
||
| int count = ConstructorArguments.Count; | ||
| for (int i = 0; i < count; i++) | ||
| IList<CustomAttributeTypedArgument> constructorArguments = ConstructorArguments; | ||
| int constructorArgumentsCount = constructorArguments.Count; | ||
| for (int i = 0; i < constructorArgumentsCount; i++) | ||
| { | ||
| if (!first) vsb.Append(", "); | ||
| vsb.Append(ConstructorArguments[i].ToString()); | ||
| vsb.Append(constructorArguments[i].ToString()); | ||
jkotas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| first = false; | ||
| } | ||
|
|
||
| count = NamedArguments.Count; | ||
| for (int i = 0; i < count; i++) | ||
| IList<CustomAttributeNamedArgument> namedArguments = NamedArguments; | ||
| int namedArgumentsCount = namedArguments.Count; | ||
| for (int i = 0; i < namedArgumentsCount; i++) | ||
| { | ||
| if (!first) vsb.Append(", "); | ||
| vsb.Append(NamedArguments[i].ToString()); | ||
| vsb.Append(namedArguments[i].ToString()); | ||
| first = false; | ||
| } | ||
|
|
||
|
|
@@ -79,6 +86,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 | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cache in locals to avoid redundant interface calls.