Small tweaks to Marshaler<T>'s static cctor#1413
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