-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Add reflection introspection support for function pointers #81006
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 2 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
173b84d
Add reflection introspection support for function pointers
steveharter e546ee2
Fix compiler issue; test MLC to NetFramework
steveharter 36e07d6
Fix compile issue; prep for review
steveharter e755c1c
Compile issue with MLC under certain conditions
steveharter b3b64ff
compile issue cont'd; lazy load mods on root
steveharter 3aef789
compile issues cont'd; prepare for review
steveharter f76c75d
Remove Node back reference; fix edge case test failure
steveharter 73b15b3
Increase test coverage; add missing recursive check
steveharter 1361142
Various feedback; support mods on generic type parameters
steveharter 520a3f5
Merge branch 'main' of https://github.com/steveharter/runtime into Fc…
steveharter 64a987e
Fix MLC edge case; Native AOT test enable\disable
steveharter 5f8a81e
Native AOT test enable\disable; add a generic test
steveharter 2df9d2b
Native AOT test enable\disable; fix missing overload
steveharter 0a6ff32
Add TODOs based on review discussion; MLC field optimization
steveharter 784df92
Merge branch 'main' into FcnPtr
jkotas 8c06d3c
Replace nested signature indices by TypeSignature type
jkotas f40e506
Move tests into separate classes; other misc non-functional
steveharter 4610e93
Throw NSE for modified type members than may return an unmodified type
steveharter ca45bd8
Merge branch 'main' of https://github.com/dotnet/runtime into FcnPtr
steveharter 70529f0
Throw NSE on modified type Equals() and GetHashCode()
steveharter 9770a2d
Fix tests for WASI
steveharter 14a9007
Remove unnecessary high overhead tests
steveharter 69ccd75
Merge branch 'main' of https://github.com/dotnet/runtime into FcnPtr
steveharter f76331c
Fix merge error
steveharter 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
19 changes: 19 additions & 0 deletions
19
...reclr/System.Private.CoreLib/src/System/Reflection/ModifiedFunctionPointerType.CoreCLR.cs
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 |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| namespace System.Reflection | ||
| { | ||
| internal partial class ModifiedFunctionPointerType | ||
| { | ||
| private MdSigCallingConvention GetCallingConvention() | ||
| { | ||
| Signature? signature = GetSignature(); | ||
| if (signature != null) | ||
| { | ||
| return (MdSigCallingConvention)signature.GetCallingConventionFromFunctionPointer(RootSignatureParameterIndex, NestedSignatureIndex); | ||
| } | ||
|
|
||
| return MdSigCallingConvention.Default; | ||
| } | ||
| } | ||
| } |
54 changes: 54 additions & 0 deletions
54
src/coreclr/System.Private.CoreLib/src/System/Reflection/ModifiedType.CoreCLR.cs
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 |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| namespace System.Reflection | ||
| { | ||
| internal partial class ModifiedType | ||
| { | ||
| private Signature? _signature; | ||
|
|
||
| /// <summary> | ||
| /// Called from FieldInfo, PropertyInfo and ParameterInfo to create a modified type tree. | ||
| /// </summary> | ||
| public static ModifiedType Create(Type unmodifiedType, Type[] requiredModifiers, Type[] optionalModifiers, Signature? signature, int rootSignatureParameterIndex) | ||
| { | ||
| ModifiedType modifiedType; | ||
|
|
||
| if (unmodifiedType.IsFunctionPointer) | ||
| { | ||
| modifiedType = new ModifiedFunctionPointerType(unmodifiedType, requiredModifiers, optionalModifiers, rootSignatureParameterIndex); | ||
| } | ||
| else if (unmodifiedType.HasElementType) | ||
| { | ||
| modifiedType = new ModifiedContainerType(unmodifiedType, requiredModifiers, optionalModifiers, rootSignatureParameterIndex); | ||
| } | ||
| else if (unmodifiedType.IsGenericType) | ||
| { | ||
| modifiedType = new ModifiedGenericType(unmodifiedType, requiredModifiers, optionalModifiers, rootSignatureParameterIndex); | ||
| } | ||
| else | ||
| { | ||
| modifiedType = new ModifiedStandaloneType(unmodifiedType, requiredModifiers, optionalModifiers, rootSignatureParameterIndex); | ||
| } | ||
|
|
||
| modifiedType._signature = signature; | ||
| return modifiedType; | ||
| } | ||
|
|
||
| public Signature? GetSignature() => Root._signature; | ||
|
|
||
| private Type[] GetCustomModifiers(bool required) | ||
| { | ||
| if (_nestedSignatureParameterIndex >= 0) | ||
| { | ||
| Signature? signature = GetSignature(); | ||
| if (signature != null) | ||
| { | ||
| return signature.GetCustomModifiers(RootSignatureParameterIndex, required, _nestedSignatureIndex, _nestedSignatureParameterIndex) ?? EmptyTypes; | ||
| } | ||
| } | ||
|
|
||
| return EmptyTypes; | ||
| } | ||
| } | ||
| } | ||
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
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.
Uh oh!
There was an error while loading. Please reload this page.