-
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
GenAPI needs to account for ref fields #63751
Comments
Tagging subscribers to this area: @dotnet/area-system-reflection Issue DetailsSupport for Ideally a This means it's advantageous if The semantics of how we need to describe a
A method for achieving that is as follows: // Impl assembly
ref struct S<T> {
ref T _field;
}
// Ref assembly
ref struct S<T> {
object _o; // force unmanaged
T _f; // maintain generic expansion protections
}
|
@jkoritzinsky and @elinor-fung We should make sure the DllImport source generator is updated to understand this. |
I already pre-confirmed with @jaredpar that Roslyn will treat structs with ref fields as "not unmanaged", so as long as GenAPI produces accurate ref assemblies, DllImportGenerator will be fine. (Once we make the switch to unmanaged==blittable) |
Tagging subscribers to this area: @dotnet/area-infrastructure-libraries Issue DetailsSupport for Ideally a This means it's advantageous if The semantics of how we need to describe a
A method for achieving that is as follows: // Impl assembly
ref struct S<T> {
ref T _field;
}
// Ref assembly
ref struct S<T> {
object _o; // force unmanaged
T _f; // maintain generic expansion protections
}
|
FYI: @ericstj @carlossanlop |
We use reference assemblies for inbox libraries, but not for our packages. This would mean that the use of Additionally ASP.NET and WinForms do not use GenAPI to produce their reference assemblies. They use I suppose this transformation is only needed for any public structs that intend to have From a compatibility perspective, I suppose it might be breaking to add a |
A number of types are likely:
Undecided but most likely the C# compiler will expose it directly as a |
I see. Your examples seem to be cases where the ref field was private/internal. I don't suppose we'd want to transform a public |
Here's the relevant code to which this issue applies: https://github.com/dotnet/arcade/blob/e7ede87875f41a9b3df898ae08da5ebc96e24f56/src/Microsoft.Cci.Extensions/Writers/CSharp/CSharpWriter.cs#L159-L216 |
Correct
There aren't any instances of |
Support for
ref
fields is being added in .NET 7 / C# 11.0. This will impact reference assembly generation asref
fields impact how C# consumes types that contain them.Ideally a
ref
field in a reference assembly would just appear as a normal field of the same type would appear but with theref
modifier. However aref
field represents a change to the metadata format and that can cause issues with tool chains that are not updated to understand this metadata change. A concrete example is C++/CLI which will likely error if it consumes aref
field.This means it's advantageous if
ref
fields can be omitted from reference assemblies in our core libraries. That removes an ask on the C++/CLI team in the short term and possibly avoids issues in other toolsets.The semantics of how we need to describe a
ref
field in a reference assembly are described in the ref field proposal. In short though when omittingref
we need to be careful to maintain the other properties it conveys:unmanaged
ref
, is still important for generic expansion calculationsA method for achieving that is as follows:
The text was updated successfully, but these errors were encountered: