Skip to content
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

Emit a stable reference to the interface guid #767

Merged
merged 2 commits into from
Nov 12, 2022
Merged

Emit a stable reference to the interface guid #767

merged 2 commits into from
Nov 12, 2022

Conversation

AArnott
Copy link
Member

@AArnott AArnott commented Nov 11, 2022

This way, the reference can be converted by others into a pointer and passed around without fear that the data will move.

The new property looks like this:

static ref readonly Guid IComIID.Guid
{
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    get
    {
        ReadOnlySpan<byte> data = new byte[] {
            0x0B,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46 };
        return ref Unsafe.As<byte, Guid>(ref MemoryMarshal.GetReference(data));
    }
}

Also add non-marshaling runtime test project so we can verify the emitted guid has the right value.

@AArnott AArnott added the enhancement New feature or request label Nov 11, 2022
@AArnott
Copy link
Member Author

AArnott commented Nov 11, 2022

CC: @tannergooding @JeremyKuhne

Copy link
Member

@JeremyKuhne JeremyKuhne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 Nice!

@AArnott
Copy link
Member Author

AArnott commented Nov 12, 2022

/azp run

@azure-pipelines
Copy link

Azure Pipelines could not run because the pipeline triggers exclude this branch/path.

This way, the reference can be converted by others into a pointer and passed around without fear that the data will move.

See #752
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants