-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
TypeSystem: Support ref structs within generics #65112
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
@AaronRobinsonMSFT , assume this is ok to close or is there more work required here? |
@AaronRobinsonMSFT ping again. Anything remaining for this in 8? |
Only the bare minimum has been done. Moving this to .NET 9. |
This feature request would be extremely valuable for unit testing. Right now, when using mocking frameworks like NSubstitute it's impossible to mock out a function that takes a ref-struct type like ReadOnlySpan as an argument. For example doing the following gives a CS0306 error:
NSubstitute and its parent library Castle.Core have investigated this issue in the past and any fixes seem to have stalled out due to the difficulty of doing this without this language feature. I believe this feature would fix this unit-testing gap and be a big improvement to the dotnet ecosystem. |
cc @steveisok |
@AaronRobinsonMSFT - did somebody look if this works with Cecil/Trimmer? It uses different type system and it could get confused on the new pattern. |
Not that I am aware of. Can I get someone from your side to try this out? What do we need to do to exercise this path? We have several IL based assemblies with the feature enabled we can pass to other tools. |
@sbomer - we should be able to add tests for illink - the infra has the setup for IL-based tests. |
Cecil work is at jbevain/cecil#945 |
It looks like everything is done and this issue can be closed. If I'm mistaken, feel free to reopen. |
No, sadly this isn't done. After updating the design and ECMA, more work is needed. I moved to 10. |
This is a top-level issue to track supporting ref structs within generics. For additional details refer to dotnet/csharplang#7608 and the older dotnet/csharplang#1148.
ref
fields -ref
field support in .NET runtimes #63768gpAcceptByRefLike
metadata generic param attributeref structs
to implement interfacesref structs
to use DIM implementations - CoreCLR NativeAOT - ByRef generics and ByRef implementing interfaces #98070ref structs
to use DIM implementationsSystem.Activator.CreateInstance<T>()
to include theallows ref struct
constraint.Activator.CreateInstance
supports ByRefLike types #102636The text was updated successfully, but these errors were encountered: