From 1d5245c4217d5640603e8117de1e4ce98417f694 Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Tue, 8 May 2018 15:36:33 -0700 Subject: [PATCH] Reorganize file tracker This is precursor to a much bigger change. Pushing out some of the changes that have broad impact early to make it easier to review the real change. --- .../ProjectSystem/DefaultDocumentSnapshot.cs | 6 +- .../ProjectSystem/DefaultProjectSnapshot.cs | 6 +- .../DefaultProjectSnapshotManager.cs | 4 +- .../ProjectSystem/DocumentSnapshot.cs | 2 +- .../ProjectSystem/EphemeralProjectSnapshot.cs | 4 +- .../ProjectSystem/ProjectSnapshot.cs | 2 +- .../ProjectSystem/ProjectState.cs | 4 +- .../RazorServiceBase.cs | 2 +- .../DefaultImportDocumentManager.cs | 2 +- .../DefaultImportDocumentManagerFactory.cs | 3 +- .../Documents/DefaultFileChangeTracker.cs | 37 ++++++++++++ .../DefaultFileChangeTrackerFactory.cs | 22 +++++++ .../{ => Documents}/FileChangeEventArgs.cs | 2 +- .../{ => Documents}/FileChangeKind.cs | 2 +- .../{ => Documents}/FileChangeTracker.cs | 2 +- .../FileChangeTrackerFactory.cs | 4 +- .../ImportChangedEventArgs.cs | 1 + .../VisaulStudioFileChangeTracker.cs} | 8 +-- .../VisualStudioFileChangeTrackerFactory.cs} | 9 ++- ...lStudioFileChangeTrackerFactoryFactory.cs} | 20 +++---- .../VisualStudioMacFileChangeTracker.cs} | 7 +-- ...isualStudioMacFileChangeTrackerFactory.cs} | 9 ++- ...udioMacFileChangeTrackerFactoryFactory.cs} | 17 +++--- .../DefaultProjectSnapshotTest.cs | 6 +- .../ProjectSystem/ProjectStateTest.cs | 58 +++++++++---------- ...ultImportDocumentManagerIntegrationTest.cs | 4 +- .../DefaultImportDocumentManagerTest.cs | 1 + .../DefaultVisualStudioDocumentTrackerTest.cs | 1 + .../VisualStudioFileChangeTrackerTest.cs} | 15 +++-- .../VisualStudioMacFileChangeTrackerTest.cs} | 10 +--- 30 files changed, 159 insertions(+), 111 deletions(-) create mode 100644 src/Microsoft.VisualStudio.Editor.Razor/Documents/DefaultFileChangeTracker.cs create mode 100644 src/Microsoft.VisualStudio.Editor.Razor/Documents/DefaultFileChangeTrackerFactory.cs rename src/Microsoft.VisualStudio.Editor.Razor/{ => Documents}/FileChangeEventArgs.cs (89%) rename src/Microsoft.VisualStudio.Editor.Razor/{ => Documents}/FileChangeKind.cs (82%) rename src/Microsoft.VisualStudio.Editor.Razor/{ => Documents}/FileChangeTracker.cs (89%) rename src/Microsoft.VisualStudio.Editor.Razor/{ => Documents}/FileChangeTrackerFactory.cs (69%) rename src/Microsoft.VisualStudio.LanguageServices.Razor/{DefaultFileChangeTracker.cs => Documents/VisaulStudioFileChangeTracker.cs} (94%) rename src/Microsoft.VisualStudio.LanguageServices.Razor/{DefaultFileChangeTrackerFactory.cs => Documents/VisualStudioFileChangeTrackerFactory.cs} (80%) rename src/Microsoft.VisualStudio.LanguageServices.Razor/{DefaultFileChangeTrackerFactoryFactory.cs => Documents/VisualStudioFileChangeTrackerFactoryFactory.cs} (56%) rename src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/{DefaultFileChangeTracker.cs => Documents/VisualStudioMacFileChangeTracker.cs} (94%) rename src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/{DefaultFileChangeTrackerFactory.cs => Documents/VisualStudioMacFileChangeTrackerFactory.cs} (69%) rename src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/{DefaultFileChangeTrackerFactoryFactory.cs => Documents/VisualStudioMacFileChangeTrackerFactoryFactory.cs} (51%) rename test/Microsoft.VisualStudio.LanguageServices.Razor.Test/{DefaultFileChangeTrackerTest.cs => Documents/VisualStudioFileChangeTrackerTest.cs} (84%) rename test/Microsoft.VisualStudio.Mac.LanguageServices.Razor.Test/{DefaultFileChangeTrackerTest.cs => Documents/VisualStudioMacFileChangeTrackerTest.cs} (89%) diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultDocumentSnapshot.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultDocumentSnapshot.cs index eb1c8be640..6ce3edb596 100644 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultDocumentSnapshot.cs +++ b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultDocumentSnapshot.cs @@ -39,15 +39,15 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem return State.GeneratedOutput.GetGeneratedOutputInitializationTask(Project, this); } - public override bool TryGetGeneratedOutput(out RazorCodeDocument results) + public override bool TryGetGeneratedOutput(out RazorCodeDocument result) { if (State.GeneratedOutput.IsResultAvailable) { - results = State.GeneratedOutput.GetGeneratedOutputInitializationTask(Project, this).Result; + result = State.GeneratedOutput.GetGeneratedOutputInitializationTask(Project, this).Result; return true; } - results = null; + result = null; return false; } } diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshot.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshot.cs index 2b644e182c..aba5e7a916 100644 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshot.cs +++ b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshot.cs @@ -69,15 +69,15 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem return State.TagHelpers.GetTagHelperInitializationTask(this); } - public override bool TryGetTagHelpers(out IReadOnlyList results) + public override bool TryGetTagHelpers(out IReadOnlyList result) { if (State.TagHelpers.IsResultAvailable) { - results = State.TagHelpers.GetTagHelperInitializationTask(this).Result; + result = State.TagHelpers.GetTagHelperInitializationTask(this).Result; return true; } - results = null; + result = null; return false; } } diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotManager.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotManager.cs index 8c3a5484a0..174b669c86 100644 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotManager.cs +++ b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DefaultProjectSnapshotManager.cs @@ -149,7 +149,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem if (_projects.TryGetValue(hostProject.FilePath, out var entry)) { - var state = entry.State.AddHostDocument(document); + var state = entry.State.WithAddedHostDocument(document); // Document updates can no-op. if (!object.ReferenceEquals(state, entry.State)) @@ -175,7 +175,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem _foregroundDispatcher.AssertForegroundThread(); if (_projects.TryGetValue(hostProject.FilePath, out var entry)) { - var state = entry.State.RemoveHostDocument(document); + var state = entry.State.WithRemovedHostDocument(document); // Document updates can no-op. if (!object.ReferenceEquals(state, entry.State)) diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DocumentSnapshot.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DocumentSnapshot.cs index 736d09c65c..5a86527bc9 100644 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DocumentSnapshot.cs +++ b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/DocumentSnapshot.cs @@ -14,6 +14,6 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem public abstract Task GetGeneratedOutputAsync(); - public abstract bool TryGetGeneratedOutput(out RazorCodeDocument results); + public abstract bool TryGetGeneratedOutput(out RazorCodeDocument result); } } diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/EphemeralProjectSnapshot.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/EphemeralProjectSnapshot.cs index c05c4f6e32..cd87c074de 100644 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/EphemeralProjectSnapshot.cs +++ b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/EphemeralProjectSnapshot.cs @@ -66,9 +66,9 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem return EmptyTagHelpers; } - public override bool TryGetTagHelpers(out IReadOnlyList results) + public override bool TryGetTagHelpers(out IReadOnlyList result) { - results = EmptyTagHelpers.Result; + result = EmptyTagHelpers.Result; return true; } diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshot.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshot.cs index 1b6ce7abff..418d117ff2 100644 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshot.cs +++ b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectSnapshot.cs @@ -27,6 +27,6 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem public abstract Task> GetTagHelpersAsync(); - public abstract bool TryGetTagHelpers(out IReadOnlyList results); + public abstract bool TryGetTagHelpers(out IReadOnlyList result); } } \ No newline at end of file diff --git a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectState.cs b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectState.cs index e25da4db2d..53e6cc3b15 100644 --- a/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectState.cs +++ b/src/Microsoft.CodeAnalysis.Razor.Workspaces/ProjectSystem/ProjectState.cs @@ -126,7 +126,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem } } - public ProjectState AddHostDocument(HostDocument hostDocument) + public ProjectState WithAddedHostDocument(HostDocument hostDocument) { if (hostDocument == null) { @@ -153,7 +153,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem return state; } - public ProjectState RemoveHostDocument(HostDocument hostDocument) + public ProjectState WithRemovedHostDocument(HostDocument hostDocument) { if (hostDocument == null) { diff --git a/src/Microsoft.CodeAnalysis.Remote.Razor/RazorServiceBase.cs b/src/Microsoft.CodeAnalysis.Remote.Razor/RazorServiceBase.cs index 91ac18ae16..289d75cc0f 100644 --- a/src/Microsoft.CodeAnalysis.Remote.Razor/RazorServiceBase.cs +++ b/src/Microsoft.CodeAnalysis.Remote.Razor/RazorServiceBase.cs @@ -86,7 +86,7 @@ namespace Microsoft.CodeAnalysis.Remote.Razor throw new NotImplementedException(); } - public override bool TryGetTagHelpers(out IReadOnlyList results) + public override bool TryGetTagHelpers(out IReadOnlyList result) { throw new NotImplementedException(); } diff --git a/src/Microsoft.VisualStudio.Editor.Razor/DefaultImportDocumentManager.cs b/src/Microsoft.VisualStudio.Editor.Razor/DefaultImportDocumentManager.cs index 68985bc9c6..b095cfdbb7 100644 --- a/src/Microsoft.VisualStudio.Editor.Razor/DefaultImportDocumentManager.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/DefaultImportDocumentManager.cs @@ -4,10 +4,10 @@ using System; using System.Collections.Generic; using System.Diagnostics; -using System.IO; using System.Linq; using Microsoft.AspNetCore.Razor.Language; using Microsoft.CodeAnalysis.Razor; +using Microsoft.VisualStudio.Editor.Razor.Documents; namespace Microsoft.VisualStudio.Editor.Razor { diff --git a/src/Microsoft.VisualStudio.Editor.Razor/DefaultImportDocumentManagerFactory.cs b/src/Microsoft.VisualStudio.Editor.Razor/DefaultImportDocumentManagerFactory.cs index c44417d69f..1a0596d25e 100644 --- a/src/Microsoft.VisualStudio.Editor.Razor/DefaultImportDocumentManagerFactory.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/DefaultImportDocumentManagerFactory.cs @@ -6,6 +6,7 @@ using System.Composition; using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.Razor; +using Microsoft.VisualStudio.Editor.Razor.Documents; namespace Microsoft.VisualStudio.Editor.Razor { @@ -34,7 +35,7 @@ namespace Microsoft.VisualStudio.Editor.Razor } var errorReporter = languageServices.WorkspaceServices.GetRequiredService(); - var fileChangeTrackerFactory = languageServices.GetRequiredService(); + var fileChangeTrackerFactory = languageServices.WorkspaceServices.GetRequiredService(); return new DefaultImportDocumentManager(_foregroundDispatcher, errorReporter, fileChangeTrackerFactory); } diff --git a/src/Microsoft.VisualStudio.Editor.Razor/Documents/DefaultFileChangeTracker.cs b/src/Microsoft.VisualStudio.Editor.Razor/Documents/DefaultFileChangeTracker.cs new file mode 100644 index 0000000000..95cfcfa5eb --- /dev/null +++ b/src/Microsoft.VisualStudio.Editor.Razor/Documents/DefaultFileChangeTracker.cs @@ -0,0 +1,37 @@ +// 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; + +namespace Microsoft.VisualStudio.Editor.Razor.Documents +{ + // A noop implementation for non-ide cases + internal class DefaultFileChangeTracker : FileChangeTracker + { + public override event EventHandler Changed; + + public DefaultFileChangeTracker(string filePath) + { + if (filePath == null) + { + throw new ArgumentNullException(nameof(filePath)); + } + + FilePath = filePath; + + GC.KeepAlive(Changed); + } + + public override string FilePath { get; } + + public override void StartListening() + { + // Do nothing + } + + public override void StopListening() + { + // Do nothing + } + } +} diff --git a/src/Microsoft.VisualStudio.Editor.Razor/Documents/DefaultFileChangeTrackerFactory.cs b/src/Microsoft.VisualStudio.Editor.Razor/Documents/DefaultFileChangeTrackerFactory.cs new file mode 100644 index 0000000000..6a982d119d --- /dev/null +++ b/src/Microsoft.VisualStudio.Editor.Razor/Documents/DefaultFileChangeTrackerFactory.cs @@ -0,0 +1,22 @@ +// 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 Microsoft.CodeAnalysis.Host.Mef; + +namespace Microsoft.VisualStudio.Editor.Razor.Documents +{ + [ExportWorkspaceService(typeof(FileChangeTrackerFactory), layer: ServiceLayer.Editor)] + internal class DefaultFileChangeTrackerFactory : FileChangeTrackerFactory + { + public override FileChangeTracker Create(string filePath) + { + if (filePath == null) + { + throw new ArgumentNullException(nameof(filePath)); + } + + return new DefaultFileChangeTracker(filePath); + } + } +} diff --git a/src/Microsoft.VisualStudio.Editor.Razor/FileChangeEventArgs.cs b/src/Microsoft.VisualStudio.Editor.Razor/Documents/FileChangeEventArgs.cs similarity index 89% rename from src/Microsoft.VisualStudio.Editor.Razor/FileChangeEventArgs.cs rename to src/Microsoft.VisualStudio.Editor.Razor/Documents/FileChangeEventArgs.cs index 508c27381a..b7541308d4 100644 --- a/src/Microsoft.VisualStudio.Editor.Razor/FileChangeEventArgs.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/Documents/FileChangeEventArgs.cs @@ -3,7 +3,7 @@ using System; -namespace Microsoft.VisualStudio.Editor.Razor +namespace Microsoft.VisualStudio.Editor.Razor.Documents { internal sealed class FileChangeEventArgs : EventArgs { diff --git a/src/Microsoft.VisualStudio.Editor.Razor/FileChangeKind.cs b/src/Microsoft.VisualStudio.Editor.Razor/Documents/FileChangeKind.cs similarity index 82% rename from src/Microsoft.VisualStudio.Editor.Razor/FileChangeKind.cs rename to src/Microsoft.VisualStudio.Editor.Razor/Documents/FileChangeKind.cs index f5be58db77..7c3fff9d8f 100644 --- a/src/Microsoft.VisualStudio.Editor.Razor/FileChangeKind.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/Documents/FileChangeKind.cs @@ -1,7 +1,7 @@ // 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. -namespace Microsoft.VisualStudio.Editor.Razor +namespace Microsoft.VisualStudio.Editor.Razor.Documents { internal enum FileChangeKind { diff --git a/src/Microsoft.VisualStudio.Editor.Razor/FileChangeTracker.cs b/src/Microsoft.VisualStudio.Editor.Razor/Documents/FileChangeTracker.cs similarity index 89% rename from src/Microsoft.VisualStudio.Editor.Razor/FileChangeTracker.cs rename to src/Microsoft.VisualStudio.Editor.Razor/Documents/FileChangeTracker.cs index 3c51bebdf6..d34c42572a 100644 --- a/src/Microsoft.VisualStudio.Editor.Razor/FileChangeTracker.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/Documents/FileChangeTracker.cs @@ -3,7 +3,7 @@ using System; -namespace Microsoft.VisualStudio.Editor.Razor +namespace Microsoft.VisualStudio.Editor.Razor.Documents { internal abstract class FileChangeTracker { diff --git a/src/Microsoft.VisualStudio.Editor.Razor/FileChangeTrackerFactory.cs b/src/Microsoft.VisualStudio.Editor.Razor/Documents/FileChangeTrackerFactory.cs similarity index 69% rename from src/Microsoft.VisualStudio.Editor.Razor/FileChangeTrackerFactory.cs rename to src/Microsoft.VisualStudio.Editor.Razor/Documents/FileChangeTrackerFactory.cs index f3b57f72a0..febad89890 100644 --- a/src/Microsoft.VisualStudio.Editor.Razor/FileChangeTrackerFactory.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/Documents/FileChangeTrackerFactory.cs @@ -3,9 +3,9 @@ using Microsoft.CodeAnalysis.Host; -namespace Microsoft.VisualStudio.Editor.Razor +namespace Microsoft.VisualStudio.Editor.Razor.Documents { - internal abstract class FileChangeTrackerFactory : ILanguageService + internal abstract class FileChangeTrackerFactory : IWorkspaceService { public abstract FileChangeTracker Create(string filePath); } diff --git a/src/Microsoft.VisualStudio.Editor.Razor/ImportChangedEventArgs.cs b/src/Microsoft.VisualStudio.Editor.Razor/ImportChangedEventArgs.cs index 8444943bd6..ffe70a4788 100644 --- a/src/Microsoft.VisualStudio.Editor.Razor/ImportChangedEventArgs.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/ImportChangedEventArgs.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using Microsoft.VisualStudio.Editor.Razor.Documents; namespace Microsoft.VisualStudio.Editor.Razor { diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultFileChangeTracker.cs b/src/Microsoft.VisualStudio.LanguageServices.Razor/Documents/VisaulStudioFileChangeTracker.cs similarity index 94% rename from src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultFileChangeTracker.cs rename to src/Microsoft.VisualStudio.LanguageServices.Razor/Documents/VisaulStudioFileChangeTracker.cs index e2d164e806..86e0fab955 100644 --- a/src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultFileChangeTracker.cs +++ b/src/Microsoft.VisualStudio.LanguageServices.Razor/Documents/VisaulStudioFileChangeTracker.cs @@ -2,15 +2,13 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Diagnostics; using System.Runtime.InteropServices; using Microsoft.CodeAnalysis.Razor; -using Microsoft.VisualStudio.Editor.Razor; using Microsoft.VisualStudio.Shell.Interop; -namespace Microsoft.VisualStudio.LanguageServices.Razor +namespace Microsoft.VisualStudio.Editor.Razor.Documents { - internal class DefaultFileChangeTracker : FileChangeTracker, IVsFileChangeEvents + internal class VisualStudioFileChangeTracker : FileChangeTracker, IVsFileChangeEvents { private const uint FileChangeFlags = (uint)(_VSFILECHANGEFLAGS.VSFILECHG_Time | _VSFILECHANGEFLAGS.VSFILECHG_Size | _VSFILECHANGEFLAGS.VSFILECHG_Del | _VSFILECHANGEFLAGS.VSFILECHG_Add); @@ -21,7 +19,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor public override event EventHandler Changed; - public DefaultFileChangeTracker( + public VisualStudioFileChangeTracker( string filePath, ForegroundDispatcher foregroundDispatcher, ErrorReporter errorReporter, diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultFileChangeTrackerFactory.cs b/src/Microsoft.VisualStudio.LanguageServices.Razor/Documents/VisualStudioFileChangeTrackerFactory.cs similarity index 80% rename from src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultFileChangeTrackerFactory.cs rename to src/Microsoft.VisualStudio.LanguageServices.Razor/Documents/VisualStudioFileChangeTrackerFactory.cs index 6c6515be4a..820d79fbbe 100644 --- a/src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultFileChangeTrackerFactory.cs +++ b/src/Microsoft.VisualStudio.LanguageServices.Razor/Documents/VisualStudioFileChangeTrackerFactory.cs @@ -3,18 +3,17 @@ using System; using Microsoft.CodeAnalysis.Razor; -using Microsoft.VisualStudio.Editor.Razor; using Microsoft.VisualStudio.Shell.Interop; -namespace Microsoft.VisualStudio.LanguageServices.Razor +namespace Microsoft.VisualStudio.Editor.Razor.Documents { - internal partial class DefaultFileChangeTrackerFactory : FileChangeTrackerFactory + internal class VisualStudioFileChangeTrackerFactory : FileChangeTrackerFactory { private readonly ForegroundDispatcher _foregroundDispatcher; private readonly ErrorReporter _errorReporter; private readonly IVsFileChangeEx _fileChangeService; - public DefaultFileChangeTrackerFactory( + public VisualStudioFileChangeTrackerFactory( ForegroundDispatcher foregroundDispatcher, ErrorReporter errorReporter, IVsFileChangeEx fileChangeService) @@ -46,7 +45,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, nameof(filePath)); } - var fileChangeTracker = new DefaultFileChangeTracker(filePath, _foregroundDispatcher, _errorReporter, _fileChangeService); + var fileChangeTracker = new VisualStudioFileChangeTracker(filePath, _foregroundDispatcher, _errorReporter, _fileChangeService); return fileChangeTracker; } } diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultFileChangeTrackerFactoryFactory.cs b/src/Microsoft.VisualStudio.LanguageServices.Razor/Documents/VisualStudioFileChangeTrackerFactoryFactory.cs similarity index 56% rename from src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultFileChangeTrackerFactoryFactory.cs rename to src/Microsoft.VisualStudio.LanguageServices.Razor/Documents/VisualStudioFileChangeTrackerFactoryFactory.cs index 4ecc2a7230..705f1b3e52 100644 --- a/src/Microsoft.VisualStudio.LanguageServices.Razor/DefaultFileChangeTrackerFactoryFactory.cs +++ b/src/Microsoft.VisualStudio.LanguageServices.Razor/Documents/VisualStudioFileChangeTrackerFactoryFactory.cs @@ -6,21 +6,20 @@ using System.Composition; using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.Razor; -using Microsoft.VisualStudio.Editor.Razor; using Microsoft.VisualStudio.Shell; using Microsoft.VisualStudio.Shell.Interop; -namespace Microsoft.VisualStudio.LanguageServices.Razor +namespace Microsoft.VisualStudio.Editor.Razor.Documents { [Shared] - [ExportLanguageServiceFactory(typeof(FileChangeTrackerFactory), RazorLanguage.Name, ServiceLayer.Default)] - internal class DefaultFileChangeTrackerFactoryFactory : ILanguageServiceFactory + [ExportWorkspaceServiceFactory(typeof(FileChangeTrackerFactory), ServiceLayer.Host)] + internal class VisualStudioFileChangeTrackerFactoryFactory : IWorkspaceServiceFactory { private readonly IVsFileChangeEx _fileChangeService; private readonly ForegroundDispatcher _foregroundDispatcher; [ImportingConstructor] - public DefaultFileChangeTrackerFactoryFactory(ForegroundDispatcher foregroundDispatcher, SVsServiceProvider serviceProvider) + public VisualStudioFileChangeTrackerFactoryFactory(ForegroundDispatcher foregroundDispatcher, SVsServiceProvider serviceProvider) { if (foregroundDispatcher == null) { @@ -35,16 +34,15 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor _foregroundDispatcher = foregroundDispatcher; _fileChangeService = serviceProvider.GetService(typeof(SVsFileChangeEx)) as IVsFileChangeEx; } - - public ILanguageService CreateLanguageService(HostLanguageServices languageServices) + public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices) { - if (languageServices == null) + if (workspaceServices == null) { - throw new ArgumentNullException(nameof(languageServices)); + throw new ArgumentNullException(nameof(workspaceServices)); } - var errorReporter = languageServices.WorkspaceServices.GetRequiredService(); - return new DefaultFileChangeTrackerFactory(_foregroundDispatcher, errorReporter, _fileChangeService); + var errorReporter = workspaceServices.GetRequiredService(); + return new VisualStudioFileChangeTrackerFactory(_foregroundDispatcher, errorReporter, _fileChangeService); } } } diff --git a/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/DefaultFileChangeTracker.cs b/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/Documents/VisualStudioMacFileChangeTracker.cs similarity index 94% rename from src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/DefaultFileChangeTracker.cs rename to src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/Documents/VisualStudioMacFileChangeTracker.cs index 2848dadb88..327f632e36 100644 --- a/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/DefaultFileChangeTracker.cs +++ b/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/Documents/VisualStudioMacFileChangeTracker.cs @@ -3,12 +3,11 @@ using System; using Microsoft.CodeAnalysis.Razor; -using Microsoft.VisualStudio.Editor.Razor; using MonoDevelop.Core; -namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor +namespace Microsoft.VisualStudio.Editor.Razor.Documents { - internal class DefaultFileChangeTracker : FileChangeTracker + internal class VisualStudioMacFileChangeTracker : FileChangeTracker { private readonly ForegroundDispatcher _foregroundDispatcher; private readonly string _normalizedFilePath; @@ -16,7 +15,7 @@ namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor public override event EventHandler Changed; - public DefaultFileChangeTracker( + public VisualStudioMacFileChangeTracker( string filePath, ForegroundDispatcher foregroundDispatcher) { diff --git a/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/DefaultFileChangeTrackerFactory.cs b/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/Documents/VisualStudioMacFileChangeTrackerFactory.cs similarity index 69% rename from src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/DefaultFileChangeTrackerFactory.cs rename to src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/Documents/VisualStudioMacFileChangeTrackerFactory.cs index 33aa73fd41..81c6e4431c 100644 --- a/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/DefaultFileChangeTrackerFactory.cs +++ b/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/Documents/VisualStudioMacFileChangeTrackerFactory.cs @@ -3,15 +3,14 @@ using System; using Microsoft.CodeAnalysis.Razor; -using Microsoft.VisualStudio.Editor.Razor; -namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor +namespace Microsoft.VisualStudio.Editor.Razor.Documents { - internal class DefaultFileChangeTrackerFactory : FileChangeTrackerFactory + internal class VisualStudioMacFileChangeTrackerFactory : FileChangeTrackerFactory { private readonly ForegroundDispatcher _foregroundDispatcher; - public DefaultFileChangeTrackerFactory(ForegroundDispatcher foregroundDispatcher) + public VisualStudioMacFileChangeTrackerFactory(ForegroundDispatcher foregroundDispatcher) { if (foregroundDispatcher == null) { @@ -28,7 +27,7 @@ namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, nameof(filePath)); } - var fileChangeTracker = new DefaultFileChangeTracker(filePath, _foregroundDispatcher); + var fileChangeTracker = new VisualStudioMacFileChangeTracker(filePath, _foregroundDispatcher); return fileChangeTracker; } } diff --git a/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/DefaultFileChangeTrackerFactoryFactory.cs b/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/Documents/VisualStudioMacFileChangeTrackerFactoryFactory.cs similarity index 51% rename from src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/DefaultFileChangeTrackerFactoryFactory.cs rename to src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/Documents/VisualStudioMacFileChangeTrackerFactoryFactory.cs index d30ae0e667..7eb83a3a48 100644 --- a/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/DefaultFileChangeTrackerFactoryFactory.cs +++ b/src/Microsoft.VisualStudio.Mac.LanguageServices.Razor/Documents/VisualStudioMacFileChangeTrackerFactoryFactory.cs @@ -6,18 +6,17 @@ using System.Composition; using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.Razor; -using Microsoft.VisualStudio.Editor.Razor; -namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor +namespace Microsoft.VisualStudio.Editor.Razor.Documents { [Shared] - [ExportLanguageServiceFactory(typeof(FileChangeTrackerFactory), RazorLanguage.Name, ServiceLayer.Default)] - internal class DefaultFileChangeTrackerFactoryFactory : ILanguageServiceFactory + [ExportWorkspaceService(typeof(FileChangeTrackerFactory), ServiceLayer.Host)] + internal class VisualStudioMacFileChangeTrackerFactoryFactory : IWorkspaceServiceFactory { private readonly ForegroundDispatcher _foregroundDispatcher; [ImportingConstructor] - public DefaultFileChangeTrackerFactoryFactory(ForegroundDispatcher foregroundDispatcher) + public VisualStudioMacFileChangeTrackerFactoryFactory(ForegroundDispatcher foregroundDispatcher) { if (foregroundDispatcher == null) { @@ -27,14 +26,14 @@ namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor _foregroundDispatcher = foregroundDispatcher; } - public ILanguageService CreateLanguageService(HostLanguageServices languageServices) + public IWorkspaceService CreateService(HostWorkspaceServices workspaceServices) { - if (languageServices == null) + if (workspaceServices == null) { - throw new ArgumentNullException(nameof(languageServices)); + throw new ArgumentNullException(nameof(workspaceServices)); } - return new DefaultFileChangeTrackerFactory(_foregroundDispatcher); + return new VisualStudioMacFileChangeTrackerFactory(_foregroundDispatcher); } } } diff --git a/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/DefaultProjectSnapshotTest.cs b/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/DefaultProjectSnapshotTest.cs index b3b0ba50d7..611a110435 100644 --- a/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/DefaultProjectSnapshotTest.cs +++ b/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/DefaultProjectSnapshotTest.cs @@ -77,9 +77,9 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem { // Arrange var state = new ProjectState(Workspace.Services, HostProject, WorkspaceProject) - .AddHostDocument(Documents[0]) - .AddHostDocument(Documents[1]) - .AddHostDocument(Documents[2]); + .WithAddedHostDocument(Documents[0]) + .WithAddedHostDocument(Documents[1]) + .WithAddedHostDocument(Documents[2]); var snapshot = new DefaultProjectSnapshot(state); // Act diff --git a/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/ProjectStateTest.cs b/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/ProjectStateTest.cs index 1641639e1a..53e3f000de 100644 --- a/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/ProjectStateTest.cs +++ b/test/Microsoft.CodeAnalysis.Razor.Workspaces.Test/ProjectSystem/ProjectStateTest.cs @@ -106,7 +106,7 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem var original = new ProjectState(Workspace.Services, HostProject, WorkspaceProject); // Act - var state = original.AddHostDocument(Documents[0]); + var state = original.WithAddedHostDocument(Documents[0]); // Assert Assert.NotEqual(original.Version, state.Version); @@ -121,11 +121,11 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem { // Arrange var original = new ProjectState(Workspace.Services, HostProject, WorkspaceProject) - .AddHostDocument(Documents[2]) - .AddHostDocument(Documents[1]); + .WithAddedHostDocument(Documents[2]) + .WithAddedHostDocument(Documents[1]); // Act - var state = original.AddHostDocument(Documents[0]); + var state = original.WithAddedHostDocument(Documents[0]); // Assert Assert.NotEqual(original.Version, state.Version); @@ -142,15 +142,15 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem { // Arrange var original = new ProjectState(Workspace.Services, HostProject, WorkspaceProject) - .AddHostDocument(Documents[2]) - .AddHostDocument(Documents[1]); + .WithAddedHostDocument(Documents[2]) + .WithAddedHostDocument(Documents[1]); // Force init GC.KeepAlive(original.ProjectEngine); GC.KeepAlive(original.TagHelpers); // Act - var state = original.AddHostDocument(Documents[0]); + var state = original.WithAddedHostDocument(Documents[0]); // Assert Assert.Same(original.ProjectEngine, state.ProjectEngine); @@ -165,11 +165,11 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem { // Arrange var original = new ProjectState(Workspace.Services, HostProject, WorkspaceProject) - .AddHostDocument(Documents[2]) - .AddHostDocument(Documents[1]); + .WithAddedHostDocument(Documents[2]) + .WithAddedHostDocument(Documents[1]); // Act - var state = original.AddHostDocument(new HostDocument(Documents[1].FilePath, "SomePath.cshtml")); + var state = original.WithAddedHostDocument(new HostDocument(Documents[1].FilePath, "SomePath.cshtml")); // Assert Assert.Same(original, state); @@ -180,11 +180,11 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem { // Arrange var original = new ProjectState(Workspace.Services, HostProject, WorkspaceProject) - .AddHostDocument(Documents[2]) - .AddHostDocument(Documents[1]); + .WithAddedHostDocument(Documents[2]) + .WithAddedHostDocument(Documents[1]); // Act - var state = original.RemoveHostDocument(Documents[1]); + var state = original.WithRemovedHostDocument(Documents[1]); // Assert Assert.NotEqual(original.Version, state.Version); @@ -199,15 +199,15 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem { // Arrange var original = new ProjectState(Workspace.Services, HostProject, WorkspaceProject) - .AddHostDocument(Documents[2]) - .AddHostDocument(Documents[1]); + .WithAddedHostDocument(Documents[2]) + .WithAddedHostDocument(Documents[1]); // Force init GC.KeepAlive(original.ProjectEngine); GC.KeepAlive(original.TagHelpers); // Act - var state = original.RemoveHostDocument(Documents[2]); + var state = original.WithRemovedHostDocument(Documents[2]); // Assert Assert.Same(original.ProjectEngine, state.ProjectEngine); @@ -221,11 +221,11 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem { // Arrange var original = new ProjectState(Workspace.Services, HostProject, WorkspaceProject) - .AddHostDocument(Documents[2]) - .AddHostDocument(Documents[1]); + .WithAddedHostDocument(Documents[2]) + .WithAddedHostDocument(Documents[1]); // Act - var state = original.RemoveHostDocument(Documents[0]); + var state = original.WithRemovedHostDocument(Documents[0]); // Assert Assert.Same(original, state); @@ -236,8 +236,8 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem { // Arrange var original = new ProjectState(Workspace.Services, HostProject, WorkspaceProject) - .AddHostDocument(Documents[2]) - .AddHostDocument(Documents[1]); + .WithAddedHostDocument(Documents[2]) + .WithAddedHostDocument(Documents[1]); // Force init GC.KeepAlive(original.ProjectEngine); @@ -262,8 +262,8 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem { // Arrange var original = new ProjectState(Workspace.Services, HostProject, WorkspaceProject) - .AddHostDocument(Documents[2]) - .AddHostDocument(Documents[1]); + .WithAddedHostDocument(Documents[2]) + .WithAddedHostDocument(Documents[1]); // Force init GC.KeepAlive(original.ProjectEngine); @@ -281,8 +281,8 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem { // Arrange var original = new ProjectState(Workspace.Services, HostProject, WorkspaceProject) - .AddHostDocument(Documents[2]) - .AddHostDocument(Documents[1]); + .WithAddedHostDocument(Documents[2]) + .WithAddedHostDocument(Documents[1]); // Force init GC.KeepAlive(original.ProjectEngine); @@ -307,8 +307,8 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem { // Arrange var original = new ProjectState(Workspace.Services, HostProject, null) - .AddHostDocument(Documents[2]) - .AddHostDocument(Documents[1]); + .WithAddedHostDocument(Documents[2]) + .WithAddedHostDocument(Documents[1]); // Force init GC.KeepAlive(original.ProjectEngine); @@ -333,8 +333,8 @@ namespace Microsoft.CodeAnalysis.Razor.ProjectSystem { // Arrange var original = new ProjectState(Workspace.Services, HostProject, WorkspaceProject) - .AddHostDocument(Documents[2]) - .AddHostDocument(Documents[1]); + .WithAddedHostDocument(Documents[2]) + .WithAddedHostDocument(Documents[1]); // Force init GC.KeepAlive(original.ProjectEngine); diff --git a/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultImportDocumentManagerIntegrationTest.cs b/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultImportDocumentManagerIntegrationTest.cs index 941a7c7645..9fd3cf04ea 100644 --- a/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultImportDocumentManagerIntegrationTest.cs +++ b/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultImportDocumentManagerIntegrationTest.cs @@ -1,16 +1,14 @@ // 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.IO; -using Microsoft.AspNetCore.Mvc.Razor.Extensions; using Microsoft.AspNetCore.Razor.Language; using Microsoft.CodeAnalysis.Razor; using Microsoft.CodeAnalysis.Razor.ProjectSystem; using Moq; using Xunit; -namespace Microsoft.VisualStudio.Editor.Razor +namespace Microsoft.VisualStudio.Editor.Razor.Documents { public class DefaultImportDocumentManagerIntegrationTest : ForegroundDispatcherTestBase { diff --git a/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultImportDocumentManagerTest.cs b/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultImportDocumentManagerTest.cs index fc6e83f8e6..a84a26fb04 100644 --- a/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultImportDocumentManagerTest.cs +++ b/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultImportDocumentManagerTest.cs @@ -6,6 +6,7 @@ using System.IO; using Microsoft.AspNetCore.Razor.Language; using Microsoft.CodeAnalysis.Razor; using Microsoft.CodeAnalysis.Razor.ProjectSystem; +using Microsoft.VisualStudio.Editor.Razor.Documents; using Moq; using Xunit; diff --git a/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultVisualStudioDocumentTrackerTest.cs b/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultVisualStudioDocumentTrackerTest.cs index f14f8bbfd8..352c49ecc3 100644 --- a/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultVisualStudioDocumentTrackerTest.cs +++ b/test/Microsoft.VisualStudio.Editor.Razor.Test/DefaultVisualStudioDocumentTrackerTest.cs @@ -10,6 +10,7 @@ using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.Razor; using Microsoft.CodeAnalysis.Razor.Editor; using Microsoft.CodeAnalysis.Razor.ProjectSystem; +using Microsoft.VisualStudio.Editor.Razor.Documents; using Microsoft.VisualStudio.Text; using Microsoft.VisualStudio.Text.Editor; using Microsoft.VisualStudio.Utilities; diff --git a/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/DefaultFileChangeTrackerTest.cs b/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Documents/VisualStudioFileChangeTrackerTest.cs similarity index 84% rename from test/Microsoft.VisualStudio.LanguageServices.Razor.Test/DefaultFileChangeTrackerTest.cs rename to test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Documents/VisualStudioFileChangeTrackerTest.cs index bb7d32669d..fcef648173 100644 --- a/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/DefaultFileChangeTrackerTest.cs +++ b/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Documents/VisualStudioFileChangeTrackerTest.cs @@ -3,14 +3,13 @@ using System; using Microsoft.CodeAnalysis.Razor; -using Microsoft.VisualStudio.Editor.Razor; using Microsoft.VisualStudio.Shell.Interop; using Moq; using Xunit; -namespace Microsoft.VisualStudio.LanguageServices.Razor +namespace Microsoft.VisualStudio.Editor.Razor.Documents { - public class DefaultFileChangeTrackerTest : ForegroundDispatcherTestBase + public class VisualStudioFileChangeTrackerTest : ForegroundDispatcherTestBase { private ErrorReporter ErrorReporter { get; } = new DefaultErrorReporter(); @@ -24,7 +23,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor .Setup(f => f.AdviseFileChange(It.IsAny(), It.IsAny(), It.IsAny(), out cookie)) .Returns(VSConstants.S_OK) .Verifiable(); - var tracker = new DefaultFileChangeTracker("C:/_ViewImports.cshtml", Dispatcher, ErrorReporter, fileChangeService.Object); + var tracker = new VisualStudioFileChangeTracker("C:/_ViewImports.cshtml", Dispatcher, ErrorReporter, fileChangeService.Object); // Act tracker.StartListening(); @@ -44,7 +43,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor .Setup(f => f.AdviseFileChange(It.IsAny(), It.IsAny(), It.IsAny(), out cookie)) .Returns(VSConstants.S_OK) .Callback(() => callCount++); - var tracker = new DefaultFileChangeTracker("C:/_ViewImports.cshtml", Dispatcher, ErrorReporter, fileChangeService.Object); + var tracker = new VisualStudioFileChangeTracker("C:/_ViewImports.cshtml", Dispatcher, ErrorReporter, fileChangeService.Object); tracker.StartListening(); // Act @@ -68,7 +67,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor .Setup(f => f.UnadviseFileChange(cookie)) .Returns(VSConstants.S_OK) .Verifiable(); - var tracker = new DefaultFileChangeTracker("C:/_ViewImports.cshtml", Dispatcher, ErrorReporter, fileChangeService.Object); + var tracker = new VisualStudioFileChangeTracker("C:/_ViewImports.cshtml", Dispatcher, ErrorReporter, fileChangeService.Object); tracker.StartListening(); // Start listening for changes. // Act @@ -87,7 +86,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor fileChangeService .Setup(f => f.UnadviseFileChange(cookie)) .Throws(new InvalidOperationException()); - var tracker = new DefaultFileChangeTracker("C:/_ViewImports.cshtml", Dispatcher, ErrorReporter, fileChangeService.Object); + var tracker = new VisualStudioFileChangeTracker("C:/_ViewImports.cshtml", Dispatcher, ErrorReporter, fileChangeService.Object); // Act & Assert tracker.StopListening(); @@ -107,7 +106,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor fileChangeService .Setup(f => f.AdviseFileChange(It.IsAny(), It.IsAny(), It.IsAny(), out cookie)) .Returns(VSConstants.S_OK); - var tracker = new DefaultFileChangeTracker(filePath, Dispatcher, ErrorReporter, fileChangeService.Object); + var tracker = new VisualStudioFileChangeTracker(filePath, Dispatcher, ErrorReporter, fileChangeService.Object); var called = false; tracker.Changed += (sender, args) => diff --git a/test/Microsoft.VisualStudio.Mac.LanguageServices.Razor.Test/DefaultFileChangeTrackerTest.cs b/test/Microsoft.VisualStudio.Mac.LanguageServices.Razor.Test/Documents/VisualStudioMacFileChangeTrackerTest.cs similarity index 89% rename from test/Microsoft.VisualStudio.Mac.LanguageServices.Razor.Test/DefaultFileChangeTrackerTest.cs rename to test/Microsoft.VisualStudio.Mac.LanguageServices.Razor.Test/Documents/VisualStudioMacFileChangeTrackerTest.cs index a605ae7258..6fc7306986 100644 --- a/test/Microsoft.VisualStudio.Mac.LanguageServices.Razor.Test/DefaultFileChangeTrackerTest.cs +++ b/test/Microsoft.VisualStudio.Mac.LanguageServices.Razor.Test/Documents/VisualStudioMacFileChangeTrackerTest.cs @@ -1,16 +1,12 @@ // 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 Microsoft.CodeAnalysis.Razor; -using Microsoft.VisualStudio.Editor.Razor; -using MonoDevelop.Core; -using Moq; using Xunit; -namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor +namespace Microsoft.VisualStudio.Editor.Razor.Documents { - public class DefaultFileChangeTrackerTest : ForegroundDispatcherTestBase + public class VisualStudioMacFileChangeTrackerTest : ForegroundDispatcherTestBase { [ForegroundFact] public void StartListening_AdvisesForFileChange() @@ -69,7 +65,7 @@ namespace Microsoft.VisualStudio.Mac.LanguageServices.Razor Assert.Equal(0, tracker.DetachFromFileServiceEventsCount); } - private class TestFileChangeTracker : DefaultFileChangeTracker + private class TestFileChangeTracker : VisualStudioMacFileChangeTracker { public TestFileChangeTracker( string filePath,