-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Permit ByRefLike types with ctor to be activated.
#117940
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
Permit ByRefLike types with ctor to be activated.
#117940
Conversation
This was an oversight from dotnet#102636. Added tests.
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.
Pull Request Overview
This PR enables Activator.CreateInstance<T>() to work with ByRefLike types (ref structs) that have constructors, which was previously blocked. The change allows generic activation of ref structs while maintaining the restriction that they cannot be boxed through non-generic activation methods.
Key changes:
- Modified the validation logic to permit ByRefLike types in generic activation scenarios
- Added comprehensive tests for ref struct activation with and without constructors
- Updated existing tests to reflect the new capability
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/libraries/System.Private.CoreLib/src/System/Activator.RuntimeType.cs | Minor comment typo fix |
| src/libraries/System.Runtime/tests/System.Runtime.Tests/System/ActivatorTests.cs | Added test cases for ref struct activation and consolidated existing Span tests |
| src/coreclr/vm/runtimehandles.h | Removed unused function declaration |
| src/coreclr/vm/reflectioninvocation.cpp | Enhanced validation function to conditionally allow ByRefLike types |
| src/coreclr/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs | Added explicit ByRefLike checks in boxed activation paths |
src/libraries/System.Runtime/tests/System.Runtime.Tests/System/ActivatorTests.cs
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Runtime/tests/System.Runtime.Tests/System/ActivatorTests.cs
Show resolved
Hide resolved
jkotas
left a comment
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.
Thanks
|
/ba-g Known timeouts |
This was an oversight from #102636.
Added tests.
Fixes #117838