-
Notifications
You must be signed in to change notification settings - Fork 5k
Make specifying just DllImportSearchPath.AssemblyDirectory
only search in assembly directory
#114756
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
Make specifying just DllImportSearchPath.AssemblyDirectory
only search in assembly directory
#114756
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates the runtime behavior so that specifying only DllImportSearchPath.AssemblyDirectory limits native library lookup to the assembly directory without falling back to OS search paths. Key changes include:
- Updating tests to validate the no-fallback scenario.
- Propagating a new user-specified flag in the native library lookup code across mono, coreclr, and NativeAOT.
- Adjusting function signatures and conditional logic to differentiate explicit from default search flag behavior.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
src/tests/Interop/DllImportSearchPaths/DllImportSearchPathsTest.cs | Updated test name and assertions to verify no fallback to OS search. |
src/mono/mono/metadata/native-library.c | Modified function signatures and conditions to track user-specified flags. |
src/coreclr/vm/nativelibrary.cpp | Updated API and inline logic to separately pass user-specified flag information. |
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/NativeLibrary.NativeAot.cs | Adjusted method signatures and parameter handling to propagate the new flag. |
src/coreclr/nativeaot/System.Private.CoreLib/src/Internal/Runtime/CompilerHelpers/InteropHelpers.cs | Passed the additional flag for DllImportSearchPath in helper functions. |
Tagging subscribers to this area: @dotnet/interop-contrib |
...tiveaot/System.Private.CoreLib/src/System/Runtime/InteropServices/NativeLibrary.NativeAot.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Aaron Robinson <arobins@microsoft.com>
Update coreclr, mono, and nativeaot to treat specifying only
DllImportSearchPath.AssemblyDirectory
as only searching the assembly directory - no fallback to the OS search behaviour.Since the default behaviour (search assembly directory and then fall back to the OS search) is represented with the same flags/values as if the user specified only
DllImportSearchPath.AssemblyDirectory
, this implementation tracks whether the flags were user-specified.Fixes #107040