/// <summary> /// Initializes a new instance of the <see cref="DependencyContextAssemblyProvider" /> class. /// </summary> /// <param name="context">The dependency contenxt to list assemblies for.</param> /// <param name="logger">The logger to log out diagnostic information.</param> public DependencyContextAssemblyProvider(DependencyContext context, ILogger?logger = null) { _assembles = new Lazy <IEnumerable <Assembly> >( () => context.GetDefaultAssemblyNames() .Select(TryLoad) .Where(x => x != null) .ToArray() ); _logger = logger ?? NullLogger.Instance; }
public void GetRuntimeAssemblyNamesExtractsCorrectAssemblyName(string path, string expected) { var context = new DependencyContext(new TargetInfo(".NETStandard,Version=v1.3", string.Empty, string.Empty, true), compilationOptions: CompilationOptions.Default, compileLibraries: new CompilationLibrary[] { }, runtimeLibraries: new[] { new RuntimeLibrary("package", "System.Banana", "1.0.0", "hash", new [] { new RuntimeAssetGroup(string.Empty, Path.Combine("lib", path)) }, new RuntimeAssetGroup[] { }, new ResourceAssembly[] { }, new Dependency[] { }, serviceable: false) }, runtimeGraph: new RuntimeFallbacks[] { }); var assets = context.GetDefaultAssemblyNames(); assets.Should().OnlyContain(a => a.Name == expected); }