Make reading custom attributes in NativeLibrary avoidable (#80677)
authorMichal Strehovský <MichalStrehovsky@users.noreply.github.com>
Mon, 16 Jan 2023 09:17:28 +0000 (18:17 +0900)
committerGitHub <noreply@github.com>
Mon, 16 Jan 2023 09:17:28 +0000 (18:17 +0900)
commitbd84e67f7be8884ab50888178becb8f7a5a433d8
tree51473378ff719c4bc6a2666dae0344505f8fd07e
parent375ee0f74775cbf0847ff14c53eb4e96b0572e5b
Make reading custom attributes in NativeLibrary avoidable (#80677)

Contributes to #80165.

Unfortunately, the `NativeLibrary` APIs contain a pattern where one can skip providing a parameter to the API and then something expensive (custom attribute reading) will happen to compute the value. We have a `TryLoad` call in a hello world that does provide the value (in GlobalizationMode.cs). Make it possible to avoid the expensive thing internally.
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/NativeLibrary.NativeAot.cs