Open Zenexer opened 5 years ago
@AaronRobinsonMSFT, @jkoritzinsky can you guys help with this feedback? Is there anything we can add to the docs about this API behavior in .NET Core? Thanks.
I've just checked to confirm, and the DllImportSearchPath
enumeration values are ignored on non-Windows. We should add that to the docs.
https://github.com/dotnet/dotnet-api-docs/blob/8adb892bc4a3f45fdeaa24f716d2dbd4ba0365ab/xml/System.Runtime.InteropServices/DefaultDllImportSearchPathsAttribute.xml
.NET Core 3.0 will bring
DefaultDllImportSearchPathsAttribute
, and the Roslyn analyzers will flag P/Invokes that lackDefaultDllImportSearchPathsAttribute
by default. However, the documentation onDefaultDllImportSearchPathsAttribute
is Windows-centric; it doesn't describe howDefaultDllImportSearchPathsAttribute
works on Linux, for example.This is a problem for code such at the following snippet taken from https://github.com/dotnet/corefx/blob/master/src/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.RAND.cs (with a constant replaced with a literal):
The options available for
DefaultDllImportSearchPathsAttribute
are aimed at Windows, and the documentation doesn't make it clear how to handle this. Is the attribute completely ignored? Are only certain options available?