Skip to content

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

Merged
merged 6 commits into from
Apr 24, 2025

Conversation

elinor-fung
Copy link
Member

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

@elinor-fung elinor-fung added area-System.Runtime.InteropServices breaking-change Issue or PR that represents a breaking API or functional change over a prerelease. labels Apr 16, 2025
@dotnet-policy-service dotnet-policy-service bot added the needs-breaking-change-doc-created Breaking changes need an issue opened with https://github.com/dotnet/docs/issues/new?template=dotnet label Apr 16, 2025
Copy link
Contributor

@Copilot Copilot AI left a 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.

Copy link
Contributor

Tagging subscribers to this area: @dotnet/interop-contrib
See info in area-owners.md if you want to be subscribed.

elinor-fung and others added 2 commits April 21, 2025 10:18
Co-authored-by: Aaron Robinson <arobins@microsoft.com>
@elinor-fung elinor-fung merged commit 199ae88 into dotnet:main Apr 24, 2025
143 of 145 checks passed
@elinor-fung elinor-fung deleted the dllImport-assemblyDirectoryOnly branch April 24, 2025 03:33
@github-actions github-actions bot locked and limited conversation to collaborators May 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Runtime.InteropServices breaking-change Issue or PR that represents a breaking API or functional change over a prerelease. needs-breaking-change-doc-created Breaking changes need an issue opened with https://github.com/dotnet/docs/issues/new?template=dotnet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make specifying just DllImportSearchPath.AssemblyDirectory only search in assembly directory
2 participants