Skip to content
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

UnsafeAccessor throws MissingFieldException on generic field (T) #92633

Closed
AoshiW opened this issue Sep 26, 2023 · 7 comments
Closed

UnsafeAccessor throws MissingFieldException on generic field (T) #92633

AoshiW opened this issue Sep 26, 2023 · 7 comments
Labels
area-System.Runtime.CompilerServices disabled-test The test is disabled in source code against the issue
Milestone

Comments

@AoshiW
Copy link

AoshiW commented Sep 26, 2023

Description

UnsafeAccessor throws MissingFieldException on generic field (T) in generic type, where genetic T is:

  • class (e.g. string)
  • struct that has class as a generic parameter (e.g. ArraySegment<string>)

Reproduction Steps

[UnsafeAccessor(UnsafeAccessorKind.Field, Name = "_items")]
static extern ref string[] GetItems(List<string> list);

GetItems(new());

Expected behavior

getting field

Actual behavior

throws exception

System.MissingFieldException: Field not found: 'System.Collections.Generic.List`1._items'.

Regression?

No response

Known Workarounds

No response

Configuration

.NET SDK: 8.0.100-rc.1.23455.8

Other information

No response

@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Sep 26, 2023
@ghost ghost added the untriaged New issue has not been triaged by the area owner label Sep 26, 2023
@AoshiW AoshiW changed the title UnsafeAccessor throws MissingFieldException on generic array field (T[]) UnsafeAccessor throws MissingFieldException on generic field (T) Sep 26, 2023
@jkotas jkotas added area-System.Runtime.CompilerServices and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Sep 26, 2023
@ghost
Copy link

ghost commented Sep 26, 2023

Tagging subscribers to this area: @dotnet/area-system-runtime-compilerservices
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

UnsafeAccessor throws MissingFieldException on generic field (T) in generic type, where genetic T is:

  • class (e.g. string)
  • struct that has class as a generic parameter (e.g. ArraySegment<string>)

Reproduction Steps

[UnsafeAccessor(UnsafeAccessorKind.Field, Name = "_items")]
static extern ref string[] GetItems(List<string> list);

GetItems(new());

Expected behavior

getting field

Actual behavior

throws exception

System.MissingFieldException: Field not found: 'System.Collections.Generic.List`1._items'.

Regression?

No response

Known Workarounds

No response

Configuration

.NET SDK: 8.0.100-rc.1.23455.8

Other information

No response

Author: AoshiW
Assignees: -
Labels:

area-System.Runtime.CompilerServices, untriaged, needs-area-label

Milestone: -

@jkotas
Copy link
Member

jkotas commented Sep 26, 2023

cc @AaronRobinsonMSFT

@AaronRobinsonMSFT
Copy link
Member

Boo. For my original implementation of the signature match this worked. When I switched to the more robust, but stricter, built-in element compare this support was lost. Le sigh. There is little chance this sort of fix meets the servicing bar. I will take a little bit to try and make it work, but this is likely a .NET 9 fix.

@AaronRobinsonMSFT
Copy link
Member

Yep, this is a future fix. If the T is anywhere in the field or method signature this is going to fail.

Let me add some tests for this.

@AaronRobinsonMSFT AaronRobinsonMSFT removed the untriaged New issue has not been triaged by the area owner label Sep 26, 2023
@AaronRobinsonMSFT AaronRobinsonMSFT added this to the 9.0.0 milestone Sep 26, 2023
@AaronRobinsonMSFT
Copy link
Member

With how this is currently implemented there is some overlap with #89439. The core issue being how we parse and compare signatures.

@AaronRobinsonMSFT AaronRobinsonMSFT added the disabled-test The test is disabled in source code against the issue label Sep 26, 2023
@AaronRobinsonMSFT
Copy link
Member

I've added disabled tests in #92657 and fixed some issues with NAOT.

@AaronRobinsonMSFT
Copy link
Member

I'm going to close this as duplicate since this work will be included in #89439. I've already got the static/instance fields working and have re-enabled the failing tests in my working branch.

@AaronRobinsonMSFT AaronRobinsonMSFT closed this as not planned Won't fix, can't repro, duplicate, stale Feb 17, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Mar 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Runtime.CompilerServices disabled-test The test is disabled in source code against the issue
Projects
None yet
Development

No branches or pull requests

3 participants