This repository was archived by the owner on Dec 18, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleanup some of ApplicationHostContext and dependency management
- Made DependencyWalker static and internal - Pass project to GetAllExports and avoid walking the graph twice for the same project
- Loading branch information
Showing
7 changed files
with
60 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 10 additions & 20 deletions
30
src/Microsoft.Dnx.Runtime/DependencyManagement/DependencyWalker.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,41 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Runtime.Versioning; | ||
using NuGet; | ||
|
||
namespace Microsoft.Dnx.Runtime | ||
{ | ||
public class DependencyWalker | ||
internal static class DependencyWalker | ||
{ | ||
private readonly IEnumerable<IDependencyProvider> _dependencyProviders; | ||
private readonly List<LibraryDescription> _libraries = new List<LibraryDescription>(); | ||
|
||
public DependencyWalker(IEnumerable<IDependencyProvider> dependencyProviders) | ||
public static IList<LibraryDescription> Walk(IList<IDependencyProvider> providers, string name, SemanticVersion version, FrameworkName targetFramework) | ||
{ | ||
_dependencyProviders = dependencyProviders; | ||
} | ||
var libraries = new List<LibraryDescription>(); | ||
|
||
public IList<LibraryDescription> Libraries | ||
{ | ||
get { return _libraries; } | ||
} | ||
|
||
public void Walk(string name, SemanticVersion version, FrameworkName targetFramework) | ||
{ | ||
var sw = Stopwatch.StartNew(); | ||
Logger.TraceInformation("[{0}]: Walking dependency graph for '{1} {2}'.", GetType().Name, name, targetFramework); | ||
Logger.TraceInformation($"[{nameof(DependencyWalker)}]: Walking dependency graph for '{name} {targetFramework}'."); | ||
|
||
var context = new WalkContext(); | ||
|
||
var walkSw = Stopwatch.StartNew(); | ||
|
||
context.Walk( | ||
_dependencyProviders, | ||
providers, | ||
name, | ||
version, | ||
targetFramework); | ||
|
||
walkSw.Stop(); | ||
Logger.TraceInformation("[{0}]: Graph walk took {1}ms.", GetType().Name, walkSw.ElapsedMilliseconds); | ||
Logger.TraceInformation($"[{nameof(DependencyWalker)}]: Graph walk took {walkSw.ElapsedMilliseconds}ms."); | ||
|
||
context.Populate(targetFramework, Libraries); | ||
context.Populate(targetFramework, libraries); | ||
|
||
sw.Stop(); | ||
Logger.TraceInformation("[{0}]: Resolved dependencies for {1} in {2}ms", GetType().Name, name, sw.ElapsedMilliseconds); | ||
Logger.TraceInformation($"$[{ nameof(DependencyWalker)}]: Resolved dependencies for {name} in { sw.ElapsedMilliseconds}ms"); | ||
|
||
return libraries; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters