diff --git a/Razor.sln b/Razor.sln index 9f65845f9c..d4272b23e4 100644 --- a/Razor.sln +++ b/Razor.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.26917.3000 +VisualStudioVersion = 15.0.26927.3 MinimumVisualStudioVersion = 15.0.26730.03 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{3C0D6505-79B3-49D0-B4C3-176F0F1836ED}" ProjectSection(SolutionItems) = preProject @@ -16,9 +16,10 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F8C12DD6-659D-405A-AA27-FB22AD92A010}" ProjectSection(SolutionItems) = preProject .editorconfig = .editorconfig + build\dependencies.props = build\dependencies.props Directory.Build.props = Directory.Build.props Directory.Build.targets = Directory.Build.targets - NuGet.config = NuGet.config + build\sources.props = build\sources.props EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RazorPageGenerator", "src\RazorPageGenerator\RazorPageGenerator.csproj", "{7BE58880-36AD-4CD5-9E16-2A5AFEA790EF}" diff --git a/build/dependencies.props b/build/dependencies.props index 916dd35c3d..e281281ac4 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -17,8 +17,8 @@ 2.1.0-preview1-25907-02 15.3.0 15.0.26606 - 15.0.26606 - 15.0.26606 + 15.6.161-preview + 15.6.161-preview 7.10.6070 15.0.26606 10.0.30319 diff --git a/build/sources.props b/build/sources.props index 181b021f88..90d086cb2a 100644 --- a/build/sources.props +++ b/build/sources.props @@ -8,6 +8,7 @@ https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json; https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json; https://dotnet.myget.org/F/roslyn/api/v3/index.json; + https://vside.myget.org/F/vssdk/api/v3/index.json $(RestoreSources); diff --git a/src/Microsoft.VisualStudio.Editor.Razor/DefaultRazorDocumentManager.cs b/src/Microsoft.VisualStudio.Editor.Razor/DefaultRazorDocumentManager.cs index 719434f23d..b095d2c87a 100644 --- a/src/Microsoft.VisualStudio.Editor.Razor/DefaultRazorDocumentManager.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/DefaultRazorDocumentManager.cs @@ -36,7 +36,7 @@ namespace Microsoft.VisualStudio.Editor.Razor _projectService = projectService; } - public override void OnTextViewOpened(ITextView textView, IList subjectBuffers) + public override void OnTextViewOpened(ITextView textView, IEnumerable subjectBuffers) { if (textView == null) { @@ -48,9 +48,8 @@ namespace Microsoft.VisualStudio.Editor.Razor throw new ArgumentNullException(nameof(subjectBuffers)); } - for (var i = 0; i < subjectBuffers.Count; i++) + foreach (var textBuffer in subjectBuffers) { - var textBuffer = subjectBuffers[i]; if (!textBuffer.IsRazorBuffer()) { continue; @@ -77,7 +76,7 @@ namespace Microsoft.VisualStudio.Editor.Razor } } - public override void OnTextViewClosed(ITextView textView, IList subjectBuffers) + public override void OnTextViewClosed(ITextView textView, IEnumerable subjectBuffers) { if (textView == null) { @@ -94,10 +93,8 @@ namespace Microsoft.VisualStudio.Editor.Razor // // Notice that this method is called *after* changes are applied to the text buffer(s). We need to check every // one of them for a tracker because the content type could have changed. - for (var i = 0; i < subjectBuffers.Count; i++) + foreach (var textBuffer in subjectBuffers) { - var textBuffer = subjectBuffers[i]; - DefaultVisualStudioDocumentTracker documentTracker; if (textBuffer.Properties.TryGetProperty(typeof(VisualStudioDocumentTracker), out documentTracker)) { diff --git a/src/Microsoft.VisualStudio.Editor.Razor/RazorDocumentManager.cs b/src/Microsoft.VisualStudio.Editor.Razor/RazorDocumentManager.cs index 1a27d94714..0e59a391bb 100644 --- a/src/Microsoft.VisualStudio.Editor.Razor/RazorDocumentManager.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/RazorDocumentManager.cs @@ -9,8 +9,8 @@ namespace Microsoft.VisualStudio.Editor.Razor { internal abstract class RazorDocumentManager { - public abstract void OnTextViewOpened(ITextView textView, IList subjectBuffers); + public abstract void OnTextViewOpened(ITextView textView, IEnumerable subjectBuffers); - public abstract void OnTextViewClosed(ITextView textView, IList subjectBuffers); + public abstract void OnTextViewClosed(ITextView textView, IEnumerable subjectBuffers); } } diff --git a/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/RazorTextViewConnectionListener.cs b/src/Microsoft.VisualStudio.Editor.Razor/RazorTextViewConnectionListener.cs similarity index 69% rename from src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/RazorTextViewConnectionListener.cs rename to src/Microsoft.VisualStudio.Editor.Razor/RazorTextViewConnectionListener.cs index df330d1000..fe1ed057a9 100644 --- a/src/Microsoft.VisualStudio.LanguageServices.Razor/Editor/RazorTextViewConnectionListener.cs +++ b/src/Microsoft.VisualStudio.Editor.Razor/RazorTextViewConnectionListener.cs @@ -2,34 +2,31 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Collections.ObjectModel; +using System.Collections.Generic; using System.ComponentModel.Composition; -using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Razor; -using Microsoft.VisualStudio.Editor.Razor; using Microsoft.VisualStudio.Text; using Microsoft.VisualStudio.Text.Editor; using Microsoft.VisualStudio.Utilities; -namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor +namespace Microsoft.VisualStudio.Editor.Razor { [ContentType(RazorLanguage.ContentType)] [TextViewRole(PredefinedTextViewRoles.Document)] - [Export(typeof(IWpfTextViewConnectionListener))] - internal class RazorTextViewConnectionListener : IWpfTextViewConnectionListener + [Export(typeof(ITextViewConnectionListener))] + internal class RazorTextViewConnectionListener : ITextViewConnectionListener { private readonly ForegroundDispatcher _foregroundDispatcher; - private readonly Workspace _workspace; private readonly RazorDocumentManager _documentManager; [ImportingConstructor] public RazorTextViewConnectionListener( - [Import(typeof(VisualStudioWorkspace))] Workspace workspace, + VisualStudioWorkspaceAccessor workspaceAccessor, RazorDocumentManager documentManager) { - if (workspace == null) + if (workspaceAccessor == null) { - throw new ArgumentNullException(nameof(workspace)); + throw new ArgumentNullException(nameof(workspaceAccessor)); } if (documentManager == null) @@ -37,15 +34,13 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor throw new ArgumentNullException(nameof(documentManager)); } - _workspace = workspace; _documentManager = documentManager; - _foregroundDispatcher = workspace.Services.GetRequiredService(); + _foregroundDispatcher = workspaceAccessor.Workspace.Services.GetRequiredService(); } // This is only for testing. We want to avoid using the actual Roslyn GetService methods in unit tests. internal RazorTextViewConnectionListener( ForegroundDispatcher foregroundDispatcher, - Workspace workspace, RazorDocumentManager documentManager) { if (foregroundDispatcher == null) @@ -53,24 +48,16 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor throw new ArgumentNullException(nameof(foregroundDispatcher)); } - if (workspace == null) - { - throw new ArgumentNullException(nameof(workspace)); - } - if (documentManager == null) { throw new ArgumentNullException(nameof(documentManager)); } _foregroundDispatcher = foregroundDispatcher; - _workspace = workspace; _documentManager = documentManager; } - public Workspace Workspace => _workspace; - - public void SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, Collection subjectBuffers) + public void SubjectBuffersConnected(ITextView textView, ConnectionReason reason, IReadOnlyCollection subjectBuffers) { if (textView == null) { @@ -87,7 +74,7 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor _documentManager.OnTextViewOpened(textView, subjectBuffers); } - public void SubjectBuffersDisconnected(IWpfTextView textView, ConnectionReason reason, Collection subjectBuffers) + public void SubjectBuffersDisconnected(ITextView textView, ConnectionReason reason, IReadOnlyCollection subjectBuffers) { if (textView == null) { diff --git a/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Editor/RazorTextViewConnectionListenerTest.cs b/test/Microsoft.VisualStudio.Editor.Razor.Test/RazorTextViewConnectionListenerTest.cs similarity index 83% rename from test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Editor/RazorTextViewConnectionListenerTest.cs rename to test/Microsoft.VisualStudio.Editor.Razor.Test/RazorTextViewConnectionListenerTest.cs index 36bc0aa4a0..11616b872a 100644 --- a/test/Microsoft.VisualStudio.LanguageServices.Razor.Test/Editor/RazorTextViewConnectionListenerTest.cs +++ b/test/Microsoft.VisualStudio.Editor.Razor.Test/RazorTextViewConnectionListenerTest.cs @@ -3,13 +3,12 @@ using System.Collections.ObjectModel; using Microsoft.CodeAnalysis; -using Microsoft.VisualStudio.Editor.Razor; using Microsoft.VisualStudio.Text; using Microsoft.VisualStudio.Text.Editor; using Moq; using Xunit; -namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor +namespace Microsoft.VisualStudio.Editor.Razor { public class RazorTextViewConnectionListenerTest : ForegroundDispatcherTestBase { @@ -17,13 +16,12 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor public void SubjectBuffersConnected_CallsRazorDocumentManager_OnTextViewOpened() { // Arrange - var textView = Mock.Of(); + var textView = Mock.Of(); var buffers = new Collection(); - var workspace = new AdhocWorkspace(); var documentManager = new Mock(MockBehavior.Strict); documentManager.Setup(d => d.OnTextViewOpened(textView, buffers)).Verifiable(); - var listener = new RazorTextViewConnectionListener(Dispatcher, workspace, documentManager.Object); + var listener = new RazorTextViewConnectionListener(Dispatcher, documentManager.Object); // Act listener.SubjectBuffersConnected(textView, ConnectionReason.BufferGraphChange, buffers); @@ -36,13 +34,13 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor public void SubjectBuffersDisonnected_CallsRazorDocumentManager_OnTextViewClosed() { // Arrange - var textView = Mock.Of(); + var textView = Mock.Of(); var buffers = new Collection(); var workspace = new AdhocWorkspace(); var documentManager = new Mock(MockBehavior.Strict); documentManager.Setup(d => d.OnTextViewClosed(textView, buffers)).Verifiable(); - var listener = new RazorTextViewConnectionListener(Dispatcher, workspace, documentManager.Object); + var listener = new RazorTextViewConnectionListener(Dispatcher, documentManager.Object); // Act listener.SubjectBuffersDisconnected(textView, ConnectionReason.BufferGraphChange, buffers);