-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Copy ctor handling for crossgen2 #40113
Conversation
- Add IL based test for copy ctor to allow testing in Crossgen2 which doesn't yet support IJW - Add api to determine proper EmbeddedSignatureData index for these - And tests to ensure this remains functional - Marshaller changes to recognize copy constructor cases - Note that there isn't actual marshaller support. Instead the compiler can now able to detect when copy ctors should be used, and falls back to the runtime interop layer
@dotnet/crossgen-contrib |
@jkoritzinsky I've added this IL only copy ctor test in order to get coverage on this form of marshalling in crossgen2. |
internal static MarshallerKind GetMarshallerKind( | ||
TypeDesc type, | ||
MarshalAsDescriptor marshalAs, | ||
int? parameterIndex, |
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.
Indentation looks off.
@@ -183,6 +214,12 @@ public static partial class MarshalHelpers | |||
|
|||
type = type.GetParameterType(); | |||
|
|||
if (!type.IsPrimitive && type.IsValueType && !(marshallerType == MarshallerType.Field) |
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.
if (!type.IsPrimitive && type.IsValueType && !(marshallerType == MarshallerType.Field) | |
if (!type.IsPrimitive && type.IsValueType && marshallerType != MarshallerType.Field |
// Parameter index 0 represents the return type, and indices 1-n represent the parameters to the signature | ||
public static string GetIndexOfCustomModifierOnPointedAtTypeByParameterIndex(int parameterIndex) | ||
{ | ||
return $"0.1.1.2.{(parameterIndex + 1).ToStringInvariant()}.1"; |
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.
Not reviewing this part. I don't want to spend time learning how this address is computed because that code upsets me.
@@ -444,7 +481,15 @@ public static partial class MarshalHelpers | |||
else if (type.IsPointer) | |||
{ | |||
if (nativeType == NativeTypeKind.Default) | |||
{ | |||
var pointedAtType = type.GetParameterType(); | |||
if (!pointedAtType.IsPrimitive && !type.IsEnum && !(marshallerType == MarshallerType.Field) |
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.
if (!pointedAtType.IsPrimitive && !type.IsEnum && !(marshallerType == MarshallerType.Field) | |
if (!pointedAtType.IsPrimitive && !type.IsEnum && marshallerType != MarshallerType.Field |
- Add IL based test for copy ctor to allow testing in Crossgen2 which doesn't yet support IJW - Add api to determine proper EmbeddedSignatureData index for these - And tests to ensure this remains functional - Marshaller changes to recognize copy constructor cases - Note that there isn't actual marshaller support. Instead the compiler can now able to detect when copy ctors should be used, and falls back to the runtime interop layer
Fixes #39423
Note that with this change there is only one more case of custom modifier examination that is used to affect runtime codegen. (The use of the IsCXXReferenceModifier type when searching for destructors to implement this form of marshalling.) Also, as that syntax hasn't been generated from a C++/CLI compiler in many years, it is unlikely that it will ever need to be implemented.