Skip to content

Commit

Permalink
Check for V2 shapes on string marshallers (dotnet#71730)
Browse files Browse the repository at this point in the history
  • Loading branch information
elinor-fung authored Jul 6, 2022
1 parent 6d384fc commit 3d0a8bc
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ private MarshallingInfo CreateNativeMarshallingInfo_V1(
GetMarshallingInfo(elementType, useSiteAttributes, indirectionLevel + 1, inspectedElements, ref maxIndirectionDepthUsed));
}

return CreateNativeMarshallingInfoForValue(
return CreateNativeMarshallingInfoForValue_V1(
type,
nativeType,
attrData,
Expand All @@ -746,7 +746,7 @@ private MarshallingInfo CreateNativeMarshallingInfo_V1(
useDefaultMarshalling: !isMarshalUsingAttribute);
}

private MarshallingInfo CreateNativeMarshallingInfoForValue(
private MarshallingInfo CreateNativeMarshallingInfoForValue_V1(
ITypeSymbol type,
INamedTypeSymbol nativeType,
AttributeData attrData,
Expand Down Expand Up @@ -974,10 +974,21 @@ private MarshallingInfo CreateStringMarshallingInfo(
if (stringMarshaller is null)
return new MissingSupportMarshallingInfo();

if (ManualTypeMarshallingHelper.HasEntryPointMarshallerAttribute(stringMarshaller))
{
if (ManualTypeMarshallingHelper.TryGetValueMarshallersFromEntryType(stringMarshaller, type, _compilation, out CustomTypeMarshallers? marshallers))
{
return new NativeMarshallingAttributeInfo(
EntryPointType: ManagedTypeInfo.CreateTypeInfoForTypeSymbol(stringMarshaller),
Marshallers: marshallers.Value,
IsPinnableManagedType: false);
}
}

var (_, _, customTypeMarshallerData) = ManualTypeMarshallingHelper_V1.GetMarshallerShapeInfo(stringMarshaller);
Debug.Assert(customTypeMarshallerData is not null);

return CreateNativeMarshallingInfoForValue(
return CreateNativeMarshallingInfoForValue_V1(
type,
stringMarshaller,
null,
Expand Down

0 comments on commit 3d0a8bc

Please sign in to comment.