d2dlib icon indicating copy to clipboard operation
d2dlib copied to clipboard

Add [SuppressGCTransition] to p/invoke calls

Open nikeee opened this issue 1 year ago • 3 comments

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: https://github.com/nikeee/nud2dlib/commit/79361decc048f71184268754c9ba295c5859ad85

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

nikeee avatar Oct 30 '24 16:10 nikeee

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.)

jingwood avatar Nov 02 '24 04:11 jingwood

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.

nikeee avatar Nov 02 '24 04:11 nikeee

We could add a newer target and ifdef the attribute.

drewnoakes avatar Nov 02 '24 12:11 drewnoakes