Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Don't emit the assingment to the Value property in the Unmarshal stag…
…e when using [Out]
  • Loading branch information
jkoritzinsky committed Nov 15, 2021
commit 5eb62da890c12b7ed66c666d4b99aba17ac1af2b
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,10 @@ public IEnumerable<StatementSyntax> GenerateUnmarshalStatements(TypePositionInfo
{
var subContext = new CustomNativeTypeWithValuePropertyStubContext(context);

yield return GenerateValuePropertyAssignment(info, context, subContext);
if (!info.IsByRef && info.ByValueContentsMarshalKind.HasFlag(ByValueContentsMarshalKind.Out))
{
yield return GenerateValuePropertyAssignment(info, context, subContext);
}

foreach (StatementSyntax statement in _innerMarshaller.GenerateUnmarshalStatements(info, subContext))
{
Expand Down Expand Up @@ -450,7 +453,7 @@ public bool UsesNativeIdentifier(TypePositionInfo info, StubCodeContext context)
}

/// <summary>
/// Marshaller that enables support for a GetPinnableReference method on a native type, with a Value property fallback.
/// Marshaller that calls the GetPinnableReference method on the marshaller value and enables support for the Value property.
/// </summary>
internal sealed class PinnableMarshallerTypeMarshalling : ICustomNativeTypeMarshallingStrategy
{
Expand Down Expand Up @@ -482,8 +485,11 @@ public IEnumerable<StatementSyntax> GenerateCleanupStatements(TypePositionInfo i
{
var subContext = new CustomNativeTypeWithValuePropertyStubContext(context);

// <marshalerIdentifier>.Value = <nativeIdentifier>;
yield return GenerateValuePropertyAssignment(info, context, subContext);
if (!context.AdditionalTemporaryStateLivesAcrossStages)
{
// <marshalerIdentifier>.Value = <nativeIdentifier>;
yield return GenerateValuePropertyAssignment(info, context, subContext);
}

foreach (StatementSyntax statement in _innerMarshaller.GenerateCleanupStatements(info, subContext))
{
Expand Down Expand Up @@ -562,8 +568,11 @@ public IEnumerable<StatementSyntax> GenerateUnmarshalStatements(TypePositionInfo
{
var subContext = new CustomNativeTypeWithValuePropertyStubContext(context);

// <marshalerIdentifier>.Value = <nativeIdentifier>;
yield return GenerateValuePropertyAssignment(info, context, subContext);
if (!info.IsByRef && info.ByValueContentsMarshalKind.HasFlag(ByValueContentsMarshalKind.Out))
{
// <marshalerIdentifier>.Value = <nativeIdentifier>;
yield return GenerateValuePropertyAssignment(info, context, subContext);
}

foreach (StatementSyntax statement in _innerMarshaller.GenerateUnmarshalStatements(info, subContext))
{
Expand Down