Skip to content
This repository was archived by the owner on Dec 18, 2017. It is now read-only.

Commit f1b1379

Browse files
committed
Watch external dependent projects correctly
1 parent 34ce1f5 commit f1b1379

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

src/Microsoft.Framework.Runtime.Compilation.DesignTime/DesignTimeHostCompiler.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ public class DesignTimeHostCompiler : IDesignTimeHostCompiler
1313
private readonly IApplicationShutdown _shutdown;
1414
private readonly ConcurrentDictionary<int, TaskCompletionSource<CompileResponse>> _compileResponses = new ConcurrentDictionary<int, TaskCompletionSource<CompileResponse>>();
1515
private readonly TaskCompletionSource<Dictionary<string, int>> _projectContexts = new TaskCompletionSource<Dictionary<string, int>>();
16+
private readonly IFileWatcher _watcher;
1617

1718
public DesignTimeHostCompiler(IApplicationShutdown shutdown, IFileWatcher watcher, Stream stream)
1819
{
1920
_shutdown = shutdown;
21+
_watcher = watcher;
2022
_queue = new ProcessingQueue(stream);
2123
_queue.ProjectCompiled += OnProjectCompiled;
2224
_queue.ProjectsInitialized += ProjectContextsInitialized;
@@ -87,6 +89,8 @@ public async Task<CompileResponse> Compile(string projectPath, ILibraryKey libra
8789
ContextId = contextId
8890
});
8991

92+
_watcher.WatchProject(projectPath);
93+
9094
var task = _compileResponses.GetOrAdd(contextId, _ => new TaskCompletionSource<CompileResponse>()).Task;
9195
return await task.ConfigureAwait(false);
9296
}

src/Microsoft.Framework.Runtime.Sources/Impl/DependencyInjection/ServiceProvider.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,22 @@ public void Add(Type type, object instance, bool includeInManifest)
3939
};
4040
}
4141

42+
public bool TryAdd(Type type, object instance)
43+
{
44+
return TryAdd(type, instance, includeInManifest: true);
45+
}
46+
47+
public bool TryAdd(Type type, object instance, bool includeInManifest)
48+
{
49+
if (GetService(type) == null)
50+
{
51+
Add(type, instance, includeInManifest);
52+
return true;
53+
}
54+
55+
return false;
56+
}
57+
4258
public object GetService(Type serviceType)
4359
{
4460
ServiceEntry entry;

src/Microsoft.Framework.Runtime/ApplicationHostContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ public ApplicationHostContext(IServiceProvider serviceProvider,
108108

109109
// Default services
110110
_serviceProvider.Add(typeof(IApplicationEnvironment), new ApplicationEnvironment(Project, targetFramework, configuration));
111-
_serviceProvider.Add(typeof(IFileWatcher), NoopWatcher.Instance);
112111
_serviceProvider.Add(typeof(ILibraryManager), LibraryManager);
112+
_serviceProvider.TryAdd(typeof(IFileWatcher), NoopWatcher.Instance);
113113

114114
// Not exposed to the application layer
115115
_serviceProvider.Add(typeof(ILibraryExportProvider), LibraryExportProvider, includeInManifest: false);

0 commit comments

Comments
 (0)