-
Notifications
You must be signed in to change notification settings - Fork 122
Small tweaks to Marshaler<T>'s static cctor #1413
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
Conversation
|
@manodasanW it seems this test is very flaky, I'm getting random failures always from that one across PRs 🤔 |
Yes, that test is indeed a known flaky one. It got flakier recently for some reason (probably a timing issue). A rerun typically makes it pass. That test does needs to be looked into to make it more reliable but so far it has been hard to repro locally. |
|
How is repeating the same expression typeof(T) multiple times helping the linker? Is typeof(T) cheap enough to just repeat it a bunch of times? |
It's essentially free, yes. On .NET 8+:
So essentially it's super fast and you should never cache it, that's effectively a de-optimization. It can technically be beneficial to cache it on .NET Framework since that doesn't apply there, but I don't think we really care about that anyway. |
This PR includes two tweaks to
Marshaler<T>'s static cctor:Typein the static cctor, but rather usetypeof(T)every time to help the linkercc. @MichalStrehovsky @jkoritzinsky