public void InitializeDeps_LoadsExpectedDependencies() { string depsPath = Path.Combine(Directory.GetCurrentDirectory(), "Description", "DotNet", "TestFiles", "DepsFiles"); List <string> currentRidFallbacks = DependencyHelper.GetRuntimeFallbacks(); (IDictionary <string, RuntimeAsset[]> depsAssemblies, IDictionary <string, RuntimeAsset[]> nativeLibraries) = FunctionAssemblyLoadContext.InitializeDeps(depsPath, currentRidFallbacks); string testRid = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "win" : "unix"; // Ensure runtime specific dependencies are resolved, with appropriate RID FunctionAssemblyLoadContext.TryGetDepsAsset(depsAssemblies, "System.private.servicemodel", currentRidFallbacks, out string assemblyPath); Assert.Equal($"runtimes/{testRid}/lib/netstandard2.0/System.Private.ServiceModel.dll", assemblyPath); FunctionAssemblyLoadContext.TryGetDepsAsset(depsAssemblies, "System.text.encoding.codepages", currentRidFallbacks, out assemblyPath); Assert.Equal($"runtimes/{testRid}/lib/netstandard1.3/System.Text.Encoding.CodePages.dll", assemblyPath); // Ensure flattened dependency has expected path FunctionAssemblyLoadContext.TryGetDepsAsset(depsAssemblies, "Microsoft.Azure.WebJobs.Host.Storage", currentRidFallbacks, out assemblyPath); Assert.Equal($"Microsoft.Azure.WebJobs.Host.Storage.dll", assemblyPath); // Ensure native libraries are resolved, with appropriate RID and path string nativeRid; string nativePrefix; string nativeExtension; if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { nativeRid = "win-"; nativePrefix = string.Empty; nativeExtension = "dll"; } else { nativePrefix = "lib"; if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { nativeRid = "osx-"; nativeExtension = "dylib"; } else { nativeRid = "linux-"; nativeExtension = "so"; } } nativeRid += Environment.Is64BitProcess ? "x64" : "x86"; string nativeAssetFileName = $"{nativePrefix}CpuMathNative.{nativeExtension}"; FunctionAssemblyLoadContext.TryGetDepsAsset(nativeLibraries, nativeAssetFileName, currentRidFallbacks, out string assetPath); Assert.Contains($"runtimes/{nativeRid}/nativeassets/netstandard2.0/{nativeAssetFileName}", assetPath); }
public void InitializeDeps_LoadsExpectedDependencies() { string depsPath = Path.Combine(Directory.GetCurrentDirectory(), "Description", "DotNet", "TestFiles", "DepsFiles"); IDictionary <string, string> assemblies = FunctionAssemblyLoadContext.InitializeDeps(depsPath); string testRid = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "win" : "unix"; // Ensure runtime specific dependencies are resolved, with appropriate RID Assert.Contains($"runtimes/{testRid}/lib/netstandard2.0/System.Private.ServiceModel.dll", assemblies.Values); Assert.Contains($"runtimes/{testRid}/lib/netstandard1.3/System.Text.Encoding.CodePages.dll", assemblies.Values); // Ensure flattened dependency has expected path Assert.Contains($"Microsoft.Azure.WebJobs.Host.Storage.dll", assemblies.Values); }
public void InitializeDeps_WithRidSpecificNativeAssets_LoadsExpectedDependencies(string rid, string expectedNativeRid, string prefix, string suffix, bool expectMatch) { string depsPath = Path.Combine(Directory.GetCurrentDirectory(), "Description", "DotNet", "TestFiles", "DepsFiles", "RidNativeDeps"); List <string> ridFallback = DependencyHelper.GetRuntimeFallbacks(rid); (_, IDictionary <string, RuntimeAsset[]> nativeLibraries) = FunctionAssemblyLoadContext.InitializeDeps(depsPath, ridFallback); string nativeAssetFileName = $"{prefix}Cosmos.CRTCompat.{suffix}"; FunctionAssemblyLoadContext.TryGetDepsAsset(nativeLibraries, nativeAssetFileName, ridFallback, out string assetPath); string expectedMatch = expectMatch ? $"runtimes/{expectedNativeRid}/native/{nativeAssetFileName}" : null; Assert.Equal(expectedMatch, assetPath); }