Skip to content

Commit

Permalink
Do not support reverse direction for marshalling of VARIANT
Browse files Browse the repository at this point in the history
  • Loading branch information
kant2002 committed May 27, 2021
1 parent a729924 commit db09743
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/coreclr/tools/Common/TypeSystem/Interop/IL/Marshaller.Aot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1079,6 +1079,11 @@ protected override void AllocManagedToNative(ILCodeStream codeStream)

protected override void TransformManagedToNative(ILCodeStream codeStream)
{
if (this.MarshalDirection == MarshalDirection.Reverse)
{
throw new NotSupportedException();
}

ILEmitter emitter = _ilCodeStreams.Emitter;

LoadManagedValue(codeStream);
Expand All @@ -1090,6 +1095,11 @@ protected override void TransformManagedToNative(ILCodeStream codeStream)

protected override void TransformNativeToManaged(ILCodeStream codeStream)
{
if (this.MarshalDirection == MarshalDirection.Reverse)
{
throw new NotSupportedException();
}

ILEmitter emitter = _ilCodeStreams.Emitter;

LoadNativeAddr(codeStream);
Expand Down
3 changes: 3 additions & 0 deletions src/coreclr/tools/Common/TypeSystem/Interop/IL/Marshaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1438,6 +1438,9 @@ protected override void AllocAndTransformManagedToNative(ILCodeStream codeStream
codeStream.Emit(ILOpcode.brfalse, pLoadFalseLabel);
codeStream.EmitLdc(_trueValue);
codeStream.Emit(ILOpcode.br, pDoneLabel);
#if DEBUG
codeStream.Emit(ILOpcode.pop); // keep the simple stack level calculator happy
#endif // DEBUG

codeStream.EmitLabel(pLoadFalseLabel);
codeStream.EmitLdc(0);
Expand Down

0 comments on commit db09743

Please sign in to comment.