-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
ref
field support in .NET runtimes
#63768
Comments
/cc @mangod9 @jaredpar @davidwrighton @steveharter @lambdageek @dotnet/interop-contrib @fanyang-mono |
I am not sure what this is about. The runtime does not have any special handling of these types. (Roslyn does - but you have it under separate check box.) Also in the list should be: Delete the internal |
I believe @davidwrighton believes there is some spec work necessary before we can remove the notion of special types. Likely I think we will also need a feature flag in corelib to identify runtimes where Roslyn is safe to remove the notion of restricted types and depend solely on the type definition being correct. But agree bulk of the work here is in Roslyn. |
We may possibly need dotnet/linker and mono/cecil work - it needs to be able to roundtrip assembly with ref fields correctly. I know it's not specifically about runtime - but it will be needed in order to use it in the runtime (since we run the code through linker during build). |
This was brought up in the initial planning meeting. If I recall, @davidwrighton wasn't sure there should be any impact. |
I created dotnet/linker#2519 to track the validation on the linker side - at the very least we should add some tests for this in the linker. |
How big is the size of a |
@John0King That is likely going to be fixed, see dotnet/roslyn#62098. |
Just a question, if |
At present, users would need to create |
I hope this gets implemented in the future. I think a good solution would be to make a new generic constraint that allows these things (e.g. allow pointer, allow ref, allow ref struct, allow any other appropriate types, allow all, which could be expressed through a modopt or attribute), which doesn't allow boxing i.e. no calls to methods on object (ToString, GetHashCode etc., GetType of some form should still exist though). This would still allow many operations to work, just not the ones that wouldn't necessarily make sense for the types specified as allowed. |
The issue goes deeper. In order for a generic anti-constraint, like It's certainly doable but it does come with a significant complexity cost. At the core I think the following three features are tied together:
Doing one pretty much pulls you into doing the other two very quickly. |
@AaronRobinsonMSFT are there items pending for 7 or does this need to be moved to 8? |
Nope, this is done. Tests that can/should be in C# have been converted. |
We haven't look at linker yet though... dotnet/linker#2519 |
Shoot. That wasn't a checkbox :( |
is this expected to be complete this week? |
Yes - @jtschuster is working on it in the linker repo right now. |
ref itself seem's being cut ? eg. public struct TreeNode
{
public ref TreeNode Left;
public ref TreeNode Right;
....
} |
@John0King , ref fields should be in a ref struct, and is only .NET 7+, C# 11+ |
@hamarb123 so there still no way to write a |
(As far as I can tell) No, because a |
I think the
|
|
There are several moving parts to support
ref
fields, this issue represents work in the actual runtime.The high-level tasks for the runtime are below to address the ref fields work.
ref
fields #63985IntPtr
and ByRef field overlap #65246ref
fields #63985IntPtr
and ByRef field overlap #65246ref
field feature support toRuntimeFeature
class #64165ref
fields linker#2519ByReference<T>
type and replace its use withref
fields.ref
fields support #71498GetTypeFields
should returnELEMENT_TYPE_BYREF
. #65880ref
fields as expected. roslyn#62157Span<T>
safetynet7
This contributes to enabling #45152.
The text was updated successfully, but these errors were encountered: