Add [SuppressGCTransition] to p/invoke calls
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.
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.)
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.
We could add a newer target and ifdef the attribute.