Skip to content

Add [SuppressGCTransition] to p/invoke calls#126

Open
nikeee wants to merge 1 commit into
jingwood:masterfrom
nikeee:SuppressGCTransition
Open

Add [SuppressGCTransition] to p/invoke calls#126
nikeee wants to merge 1 commit into
jingwood:masterfrom
nikeee:SuppressGCTransition

Conversation

@nikeee

@nikeee nikeee commented Oct 30, 2024

Copy link
Copy Markdown
Contributor

See:
https://devblogs.microsoft.com/dotnet/improvements-in-native-code-interop-in-net-5-0/#suppressgctransition

This is a backport of what I've been using in nud2dlib:
nikeee/nud2dlib@79361de

Didn't encouter any issues in real-world uses.

@jingwood

jingwood commented Nov 2, 2024

Copy link
Copy Markdown
Owner

Thanks, @nikeee!

But our d2dlibexport project is targeted to net462 and netstandard2.0, the SuppressGCTransition attribute is not included in these .NET frameworks. And this PR will build failed.

(Seems in your forked project you have .NET6 Desktop framework.)

@nikeee

nikeee commented Nov 2, 2024

Copy link
Copy Markdown
Contributor Author

Oh yes, I didn't think of that. Then maybe this is something for a version far in the future that may target only .NET >= 6. If this is even planned. Just close this PR or shelve it, I don't mind.

@drewnoakes

Copy link
Copy Markdown
Collaborator

We could add a newer target and ifdef the attribute.

@jingwood jingwood mentioned this pull request Apr 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants