diff --git a/src/VisualStudio/CSharp/Impl/ProjectSystemShim/CSharpProjectShim.ICSharpProjectSite.cs b/src/VisualStudio/CSharp/Impl/ProjectSystemShim/CSharpProjectShim.ICSharpProjectSite.cs index 56ab4f893f52c7b8551d31bb7ff358d8f7e9966c..359312726ebad589019fea6ca780ba1e46e0ed3d 100644 --- a/src/VisualStudio/CSharp/Impl/ProjectSystemShim/CSharpProjectShim.ICSharpProjectSite.cs +++ b/src/VisualStudio/CSharp/Impl/ProjectSystemShim/CSharpProjectShim.ICSharpProjectSite.cs @@ -174,7 +174,7 @@ public int GetValidStartupClasses(IntPtr[] classNames, ref int count) { // If classNames is NULL, then we need to populate the number of valid startup // classes only - var project = VisualStudioWorkspace.CurrentSolution.GetProject(Id); + var project = Workspace.CurrentSolution.GetProject(Id); var compilation = project.GetCompilationAsync(CancellationToken.None).WaitAndGetResult(CancellationToken.None); var entryPoints = GetEntryPoints(project, compilation); diff --git a/src/VisualStudio/CSharp/Impl/ProjectSystemShim/CSharpProjectShimWithServices.CodeModel.cs b/src/VisualStudio/CSharp/Impl/ProjectSystemShim/CSharpProjectShimWithServices.CodeModel.cs index 84da5e10fe060df3266eb13a7672685676762a54..4819701fdc019b729a9156e879479dc15b2d038d 100644 --- a/src/VisualStudio/CSharp/Impl/ProjectSystemShim/CSharpProjectShimWithServices.CodeModel.cs +++ b/src/VisualStudio/CSharp/Impl/ProjectSystemShim/CSharpProjectShimWithServices.CodeModel.cs @@ -15,7 +15,7 @@ public AbstractProjectCodeModel ProjectCodeModel { if (_projectCodeModel == null) { - _projectCodeModel = new CSharpProjectCodeModel(this, this.VisualStudioWorkspace, ServiceProvider); + _projectCodeModel = new CSharpProjectCodeModel(this, (VisualStudioWorkspace)this.Workspace, ServiceProvider); } return _projectCodeModel; diff --git a/src/VisualStudio/Core/Def/Implementation/EditAndContinue/VsENCRebuildableProjectImpl.cs b/src/VisualStudio/Core/Def/Implementation/EditAndContinue/VsENCRebuildableProjectImpl.cs index ee8d7a8f48f85f5c3f2c399ec3770375747576fd..b2d66784ef2afaf2f856313d61f34d19af0bcd57 100644 --- a/src/VisualStudio/Core/Def/Implementation/EditAndContinue/VsENCRebuildableProjectImpl.cs +++ b/src/VisualStudio/Core/Def/Implementation/EditAndContinue/VsENCRebuildableProjectImpl.cs @@ -102,9 +102,9 @@ internal VsENCRebuildableProjectImpl(AbstractProject project) { _vsProject = project; - _encService = _vsProject.VisualStudioWorkspace.Services.GetService(); - _trackingService = _vsProject.VisualStudioWorkspace.Services.GetService(); - _notifications = _vsProject.VisualStudioWorkspace.Services.GetService(); + _encService = _vsProject.Workspace.Services.GetService(); + _trackingService = _vsProject.Workspace.Services.GetService(); + _notifications = _vsProject.Workspace.Services.GetService(); _debugEncNotify = (IDebugEncNotify)project.ServiceProvider.GetService(typeof(ShellInterop.SVsShellDebugger)); @@ -143,11 +143,11 @@ internal bool OnEdit(DocumentId documentId) return; } - var hostProject = _vsProject.VisualStudioWorkspace.GetHostProject(documentId.ProjectId) as AbstractRoslynProject; + var visualStudioWorkspace = _vsProject.Workspace as VisualStudioWorkspaceImpl; + var hostProject = visualStudioWorkspace?.GetHostProject(documentId.ProjectId) as AbstractRoslynProject; if (hostProject?.EditAndContinueImplOpt?._metadata != null) { - var projectHierarchy = _vsProject.VisualStudioWorkspace.GetHierarchy(documentId.ProjectId); - _debugEncNotify.NotifyEncEditDisallowedByProject(projectHierarchy); + _debugEncNotify.NotifyEncEditDisallowedByProject(hostProject.Hierarchy); return; } @@ -219,7 +219,7 @@ public int StartDebuggingPE() _encService.OnBeforeDebuggingStateChanged(DebuggingState.Design, DebuggingState.Run); - _encService.StartDebuggingSession(_vsProject.VisualStudioWorkspace.CurrentSolution); + _encService.StartDebuggingSession(_vsProject.Workspace.CurrentSolution); s_encDebuggingSessionInfo = new EncDebuggingSessionInfo(); s_readOnlyDocumentTracker = new VsReadOnlyDocumentTracker(_encService, _editorAdaptersFactoryService, _vsProject); @@ -322,7 +322,7 @@ public int StopDebuggingPE() else { // an error might have been reported: - _diagnosticProvider.ClearDiagnostics(_encService.DebuggingSession, _vsProject.VisualStudioWorkspace, EditAndContinueDiagnosticUpdateSource.DebuggerErrorId, _vsProject.Id, documentId: null); + _diagnosticProvider.ClearDiagnostics(_encService.DebuggingSession, _vsProject.Workspace, EditAndContinueDiagnosticUpdateSource.DebuggerErrorId, _vsProject.Id, documentId: null); } _activeMethods = null; @@ -436,7 +436,7 @@ public int EnterBreakStateOnPE(Interop.ENC_BREAKSTATE_REASON encBreakReason, She { _encService.OnBeforeDebuggingStateChanged(DebuggingState.Run, DebuggingState.Break); - s_breakStateEntrySolution = _vsProject.VisualStudioWorkspace.CurrentSolution; + s_breakStateEntrySolution = _vsProject.Workspace.CurrentSolution; // TODO: This is a workaround for a debugger bug in which not all projects exit the break state. // Reset the project count. @@ -730,7 +730,7 @@ public int GetCurrentActiveStatementPosition(uint vsId, VsTextSpan[] ptsNewPosit return VSConstants.E_FAIL; } - Document document = _vsProject.VisualStudioWorkspace.CurrentSolution.GetDocument(id.DocumentId); + Document document = _vsProject.Workspace.CurrentSolution.GetDocument(id.DocumentId); SourceText text = document.GetTextAsync(default(CancellationToken)).Result; // Try to get spans from the tracking service first. @@ -801,7 +801,7 @@ public int GetENCBuildState(ShellInterop.ENC_BUILD_STATE[] pENCBuildState) { // Fetch the latest snapshot of the project and get an analysis summary for any changes // made since the break mode was entered. - var currentProject = _vsProject.VisualStudioWorkspace.CurrentSolution.GetProject(_vsProject.Id); + var currentProject = _vsProject.Workspace.CurrentSolution.GetProject(_vsProject.Id); if (currentProject == null) { // If the project has yet to be loaded into the solution (which may be the case, @@ -908,7 +908,7 @@ public int ExitBreakStateOnPE() Debug.Assert(s_breakStateProjectCount >= 0); _changesApplied = false; - _diagnosticProvider.ClearDiagnostics(_encService.DebuggingSession, _vsProject.VisualStudioWorkspace, EditAndContinueDiagnosticUpdateSource.EmitErrorId, _vsProject.Id, _documentsWithEmitError); + _diagnosticProvider.ClearDiagnostics(_encService.DebuggingSession, _vsProject.Workspace, EditAndContinueDiagnosticUpdateSource.EmitErrorId, _vsProject.Id, _documentsWithEmitError); _documentsWithEmitError = default(ImmutableArray); } @@ -972,7 +972,7 @@ public unsafe int BuildForEnc(object pUpdatePE) } // Clear diagnostics, in case the project was built before and failed due to errors. - _diagnosticProvider.ClearDiagnostics(_encService.DebuggingSession, _vsProject.VisualStudioWorkspace, EditAndContinueDiagnosticUpdateSource.EmitErrorId, _vsProject.Id, _documentsWithEmitError); + _diagnosticProvider.ClearDiagnostics(_encService.DebuggingSession, _vsProject.Workspace, EditAndContinueDiagnosticUpdateSource.EmitErrorId, _vsProject.Id, _documentsWithEmitError); if (!delta.EmitResult.Success) { diff --git a/src/VisualStudio/Core/Def/Implementation/EditAndContinue/VsReadOnlyDocumentTracker.cs b/src/VisualStudio/Core/Def/Implementation/EditAndContinue/VsReadOnlyDocumentTracker.cs index fb49c16441286544a1ce241a544d121bb95c7f23..558e2a5a57fc2c652a9092afac82c77947e10082 100644 --- a/src/VisualStudio/Core/Def/Implementation/EditAndContinue/VsReadOnlyDocumentTracker.cs +++ b/src/VisualStudio/Core/Def/Implementation/EditAndContinue/VsReadOnlyDocumentTracker.cs @@ -104,7 +104,8 @@ private bool AllowsReadOnly(DocumentId documentId) // while the code is running and get refreshed next time the web page is hit. // Note that Razor-like views are modelled as a ContainedDocument but normal code including code-behind are modelled as a StandardTextDocument. - var containedDocument = _vsProject.VisualStudioWorkspace.GetHostDocument(documentId) as ContainedDocument; + var visualStudioWorkspace = _vsProject.Workspace as VisualStudioWorkspaceImpl; + var containedDocument = visualStudioWorkspace?.GetHostDocument(documentId) as ContainedDocument; return containedDocument == null; } diff --git a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/AbstractProject.cs b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/AbstractProject.cs index 75db7578896038b92a106a764b43195d8fa23c24..bb7de18681744ad7ba8d01f7d74604ba680f280e 100644 --- a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/AbstractProject.cs +++ b/src/VisualStudio/Core/Def/Implementation/ProjectSystem/AbstractProject.cs @@ -229,8 +229,6 @@ private static bool TryGetProjectDisplayName(IVsHierarchy hierarchy, out string /// internal string TryGetBinOutputPath() => _binOutputPathOpt; - internal VisualStudioWorkspaceImpl VisualStudioWorkspace => _visualStudioWorkspaceOpt; - internal IRuleSetFile RuleSetFile => this.ruleSet; internal HostDiagnosticUpdateSource HostDiagnosticUpdateSource => _hostDiagnosticUpdateSourceOpt; diff --git a/src/VisualStudio/VisualBasic/Impl/ProjectSystemShim/VisualBasicProject.vb b/src/VisualStudio/VisualBasic/Impl/ProjectSystemShim/VisualBasicProject.vb index 2fb612b395e987aecde9413b86851dbb609aae1a..4fc7923cf2ae28f6ab648c90763c18ad49313a84 100644 --- a/src/VisualStudio/VisualBasic/Impl/ProjectSystemShim/VisualBasicProject.vb +++ b/src/VisualStudio/VisualBasic/Impl/ProjectSystemShim/VisualBasicProject.vb @@ -233,7 +233,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.ProjectSystemShim Public Sub GetEntryPointsList(cItems As Integer, strList() As String, ByVal pcActualItems As IntPtr) Implements IVbCompilerProject.GetEntryPointsList Try - Dim project = VisualStudioWorkspace.CurrentSolution.GetProject(Id) + Dim project = Workspace.CurrentSolution.GetProject(Id) Dim compilation = project.GetCompilationAsync(CancellationToken.None).WaitAndGetResult(CancellationToken.None) GetEntryPointsWorker(cItems, strList, pcActualItems, findFormsOnly:=False) @@ -246,7 +246,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.ProjectSystemShim strList() As String, ByVal pcActualItems As IntPtr, findFormsOnly As Boolean) - Dim project = VisualStudioWorkspace.CurrentSolution.GetProject(Id) + Dim project = Workspace.CurrentSolution.GetProject(Id) Dim compilation = project.GetCompilationAsync(CancellationToken.None).WaitAndGetResult(CancellationToken.None) ' If called with cItems = 0 and pcActualItems != NULL, GetEntryPointsList returns in pcActualItems the number of items available. diff --git a/src/VisualStudio/VisualBasic/Impl/ProjectSystemShim/VisualBasicProjectShimWithServices.CodeModel.vb b/src/VisualStudio/VisualBasic/Impl/ProjectSystemShim/VisualBasicProjectShimWithServices.CodeModel.vb index bf1a25fad02f0a4d51b7e946371af1c1993459ef..360e6cd64b6d8a3790d7dd173f09f8e2f9edf86b 100644 --- a/src/VisualStudio/VisualBasic/Impl/ProjectSystemShim/VisualBasicProjectShimWithServices.CodeModel.vb +++ b/src/VisualStudio/VisualBasic/Impl/ProjectSystemShim/VisualBasicProjectShimWithServices.CodeModel.vb @@ -10,7 +10,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.ProjectSystemShim Public ReadOnly Property ProjectCodeModel As AbstractProjectCodeModel Implements IProjectCodeModelProvider.ProjectCodeModel Get - LazyInitialization.EnsureInitialized(_projectCodeModel, Function() New VisualBasicProjectCodeModel(Me, Me.VisualStudioWorkspace, ServiceProvider)) + LazyInitialization.EnsureInitialized(_projectCodeModel, Function() New VisualBasicProjectCodeModel(Me, DirectCast(Me.Workspace, VisualStudioWorkspace), ServiceProvider)) Return _projectCodeModel End Get End Property