public AndConstraint <DependencyContextAssertions> HaveNoDuplicateNativeAssets(string runtimeIdentifier) { var nativeAssets = _dependencyContext.GetRuntimeNativeAssets(runtimeIdentifier); var nativeFilenames = nativeAssets.Select(n => Path.GetFileName(n)); var duplicateNativeAssets = nativeFilenames.GroupBy(n => n).Where(g => g.Count() > 1); duplicateNativeAssets.Select(g => g.Key).Should().BeEmpty(); return(new AndConstraint <DependencyContextAssertions>(this)); }
/// <summary> /// Tries to get the icu native binaries by searching the Runtime /// ID graph to find the first set of paths that have those binaries. /// </summary> /// <returns>Unique relative paths to the native assets; empty if none /// could be found.</returns> private static bool TryGetNativeAssetPaths(DependencyContext context, out string[] nativeAssetPaths) { var assetPaths = Enumerable.Empty <string>(); if (context == null) { nativeAssetPaths = assetPaths.ToArray(); return(false); } var defaultNativeAssets = context.GetDefaultNativeAssets().ToArray(); // This goes through the runtime graph and tries to find icu native // asset paths matching that runtime. foreach (var runtime in context.RuntimeGraph) { var nativeAssets = context.GetRuntimeNativeAssets(runtime.Runtime); assetPaths = nativeAssets.Except(defaultNativeAssets).Where(assetPath => IcuBinaryRegex.IsMatch(assetPath)); if (assetPaths.Any()) { break; } } nativeAssetPaths = assetPaths.ToArray(); return(nativeAssetPaths.Length > 0); }