public DynamicLib(string fileName, DLOpenMode flags) { if (fileName == null) { throw new ArgumentNullException(nameof(fileName)); } if (flags == DLOpenMode.None) { throw new ArgumentOutOfRangeException(nameof(flags)); } string selfPath = Path.GetDirectoryName(typeof(DynamicLib).Assembly.Location); string [] possibleFiles = new string [] { fileName, Path.Combine(selfPath, Path.Combine($"Frameworks/{fileName}.framework/{fileName}")) }; var sb = new StringBuilder(); foreach (string file in possibleFiles) { FileName = file; handle = DLOpen(file, flags); if (handle == IntPtr.Zero) { sb.Append('\n'); sb.Append($"+{file} {(File.Exists (file) ? "(exists)" : " (does not exist)")}"); string err = DLError; if (err != null) { sb.Append(": "); sb.Append(err); } } else { break; } } if (handle == IntPtr.Zero) { string sbbuff = sb.ToString(); throw new ArgumentException($"Unable to load library {fileName}:{sbbuff}", nameof(fileName)); } }
static extern IntPtr DLOpen([MarshalAs(UnmanagedType.LPStr)] string file, DLOpenMode flags);
internal static IntPtr ProtocolWitnessTableFromDylibFile(string path, DLOpenMode mode, string witnessSymbolName) { using (DynamicLib lib = new DynamicLib(path, mode)) { return(ProtocolWitnessTableFromDylib(lib, witnessSymbolName)); } }
internal static SwiftValueWitnessTable FromDylibFile(string path, DLOpenMode mode, string witnessSymbolName) { using (DynamicLib lib = new DynamicLib(path, mode)) { return(FromDylib(lib, witnessSymbolName)); } }
internal static SwiftMetatype?FromDylib(string pathName, DLOpenMode openMode, string metaDescName) { using (DynamicLib dylib = new DynamicLib(pathName, openMode)) { return(FromDylib(dylib, metaDescName)); } }
internal static SwiftNominalTypeDescriptor?FromDylibFile(string pathName, DLOpenMode openMode, string nomDescSymbolName) { using (DynamicLib dylib = new DynamicLib(pathName, openMode)) { return(FromDylib(dylib, nomDescSymbolName)); } }
public static NominalSizeStride FromDylibFile(string file, DLOpenMode mode, string witnessTableName) { using (DynamicLib lib = new DynamicLib(file, mode)) { return(FromDylib(lib, witnessTableName)); } }