diff --git a/eng/Directory.Packages.props b/eng/Directory.Packages.props
index 8b0c5a473de71..d80eff6301951 100644
--- a/eng/Directory.Packages.props
+++ b/eng/Directory.Packages.props
@@ -59,7 +59,7 @@
Visual Studio
-->
-
+
diff --git a/src/Setup/DevDivInsertionFiles/DevDivInsertionFiles.csproj b/src/Setup/DevDivInsertionFiles/DevDivInsertionFiles.csproj
index 7269a9d22a04a..61bfdc1c685f5 100644
--- a/src/Setup/DevDivInsertionFiles/DevDivInsertionFiles.csproj
+++ b/src/Setup/DevDivInsertionFiles/DevDivInsertionFiles.csproj
@@ -100,6 +100,7 @@
<_Dependency Remove="@(_Dependency)" Condition="$([MSBuild]::ValueOrDefault('%(Identity)', '').StartsWith('Microsoft.ServiceHub.'))"/>
<_Dependency Remove="@(_Dependency)" Condition="$([MSBuild]::ValueOrDefault('%(Identity)', '').StartsWith('System.Composition.'))"/>
<_Dependency Remove="@(_Dependency)" Condition="$([MSBuild]::ValueOrDefault('%(Identity)', '').StartsWith('Microsoft.Internal.VisualStudio.'))"/>
+ <_Dependency Remove="Azure.Core"/>
<_Dependency Remove="EnvDTE"/>
<_Dependency Remove="EnvDTE80"/>
<_Dependency Remove="EnvDTE90"/>
@@ -128,6 +129,7 @@
<_Dependency Remove="stdole"/>
<_Dependency Remove="StreamJsonRpc"/>
<_Dependency Remove="System.Buffers" />
+ <_Dependency Remove="System.ClientModel"/>
<_Dependency Remove="System.Collections.Immutable"/>
<_Dependency Remove="System.Configuration.ConfigurationManager"/>
<_Dependency Remove="System.Diagnostics.DiagnosticSource"/>
@@ -136,6 +138,7 @@
<_Dependency Remove="System.IO.Packaging"/>
<_Dependency Remove="System.IO.Pipelines"/>
<_Dependency Remove="System.Memory"/>
+ <_Dependency Remove="System.Memory.Data"/>
<_Dependency Remove="System.Numerics.Vectors"/>
<_Dependency Remove="System.Reflection.Metadata"/>
<_Dependency Remove="System.Reflection.MetadataLoadContext"/>
diff --git a/src/VisualStudio/Core/Def/ProjectSystem/Legacy/AbstractLegacyProject_IVsReportExternalErrors.cs b/src/VisualStudio/Core/Def/ProjectSystem/Legacy/AbstractLegacyProject_IVsReportExternalErrors.cs
index 7c80eb5c5e185..65ca6b31af07b 100644
--- a/src/VisualStudio/Core/Def/ProjectSystem/Legacy/AbstractLegacyProject_IVsReportExternalErrors.cs
+++ b/src/VisualStudio/Core/Def/ProjectSystem/Legacy/AbstractLegacyProject_IVsReportExternalErrors.cs
@@ -25,7 +25,7 @@ int IVsLanguageServiceBuildErrorReporter.ClearErrors()
int IVsLanguageServiceBuildErrorReporter2.ClearErrors()
=> _externalErrorReporter.ClearErrors();
- int IVsReportExternalErrors.GetErrors(out IVsEnumExternalErrors pErrors)
+ int IVsReportExternalErrors.GetErrors(out IVsEnumExternalErrors? pErrors)
=> _externalErrorReporter.GetErrors(out pErrors);
int IVsLanguageServiceBuildErrorReporter.ReportError(string bstrErrorMessage, string bstrErrorId, VSTASKPRIORITY nPriority, int iLine, int iColumn, string bstrFileName)
diff --git a/src/VisualStudio/Core/Def/ProjectSystem/VisualStudioProjectFactory.cs b/src/VisualStudio/Core/Def/ProjectSystem/VisualStudioProjectFactory.cs
index 3d0ee67a4ede3..2994dc24bc2ab 100644
--- a/src/VisualStudio/Core/Def/ProjectSystem/VisualStudioProjectFactory.cs
+++ b/src/VisualStudio/Core/Def/ProjectSystem/VisualStudioProjectFactory.cs
@@ -16,7 +16,6 @@
using Microsoft.CodeAnalysis.Workspaces.ProjectSystem;
using Microsoft.Internal.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.LanguageServices.ExternalAccess.VSTypeScript.Api;
-using Microsoft.VisualStudio.LanguageServices.Implementation.Diagnostics;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.Telemetry;
@@ -66,9 +65,6 @@ public VisualStudioProjectFactory(
// and we don't want the case where VisualStudioProjectFactory is constructed on the main thread to block on that.
await _threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(alwaysYield: true, cancellationToken);
_visualStudioWorkspaceImpl.Services.GetRequiredService();
-
- _visualStudioWorkspaceImpl.SubscribeExternalErrorDiagnosticUpdateSourceToSolutionBuildEvents();
- _visualStudioWorkspaceImpl.SubscribeToSourceGeneratorImpactingEvents();
});
}
diff --git a/src/VisualStudio/Core/Def/ProjectSystem/VisualStudioWorkspaceImpl.cs b/src/VisualStudio/Core/Def/ProjectSystem/VisualStudioWorkspaceImpl.cs
index 7c28bdba4ec05..ec1655707d8ab 100644
--- a/src/VisualStudio/Core/Def/ProjectSystem/VisualStudioWorkspaceImpl.cs
+++ b/src/VisualStudio/Core/Def/ProjectSystem/VisualStudioWorkspaceImpl.cs
@@ -103,6 +103,8 @@ internal abstract partial class VisualStudioWorkspaceImpl : VisualStudioWorkspac
private readonly JoinableTaskCollection _updateUIContextJoinableTasks;
private readonly OpenFileTracker _openFileTracker;
+ private readonly UIContext _solutionClosingContext;
+
internal IFileChangeWatcher FileChangeWatcher { get; }
internal ProjectSystemProjectFactory ProjectSystemProjectFactory { get; }
@@ -110,10 +112,9 @@ internal abstract partial class VisualStudioWorkspaceImpl : VisualStudioWorkspac
private readonly Lazy _projectCodeModelFactory;
private readonly Lazy _lazyExternalErrorDiagnosticUpdateSource;
private readonly IAsynchronousOperationListener _workspaceListener;
- private bool _isExternalErrorDiagnosticUpdateSourceSubscribedToSolutionBuildEvents;
///
- /// Only read/written on hte UI thread.
+ /// Only read/written on the UI thread.
///
private bool _isShowingDocumentChangeErrorInfoBar = false;
private bool _ignoreDocumentTextChangeErrors;
@@ -138,6 +139,9 @@ public VisualStudioWorkspaceImpl(ExportProvider exportProvider, IAsyncServicePro
ProjectSystemProjectFactory = new ProjectSystemProjectFactory(
this, FileChangeWatcher, CheckForAddedFileBeingOpenMaybeAsync, RemoveProjectFromMaps, _threadingContext.DisposalToken);
+ _solutionClosingContext = UIContext.FromUIContextGuid(VSConstants.UICONTEXT.SolutionClosing_guid);
+ _solutionClosingContext.UIContextChanged += SolutionClosingContext_UIContextChanged;
+
_openFileTracker = new OpenFileTracker(
this,
ProjectSystemProjectFactory,
@@ -145,11 +149,7 @@ public VisualStudioWorkspaceImpl(ExportProvider exportProvider, IAsyncServicePro
_workspaceListener,
exportProvider.GetExportedValue());
- InitializeUIAffinitizedServicesAsync().Forget();
-
- _lazyExternalErrorDiagnosticUpdateSource = new Lazy(() =>
- exportProvider.GetExportedValue(),
- isThreadSafe: true);
+ _lazyExternalErrorDiagnosticUpdateSource = exportProvider.GetExport();
_updateUIContextJoinableTasks = new JoinableTaskCollection(_threadingContext.JoinableTaskContext);
@@ -160,61 +160,17 @@ public VisualStudioWorkspaceImpl(ExportProvider exportProvider, IAsyncServicePro
Logger.Log(FunctionId.Run_Environment, KeyValueLogMessage.Create(
static m => m["Version"] = FileVersionInfo.GetVersionInfo(typeof(VisualStudioWorkspace).Assembly.Location).FileVersion));
- }
-
- internal ExternalErrorDiagnosticUpdateSource ExternalErrorDiagnosticUpdateSource => _lazyExternalErrorDiagnosticUpdateSource.Value;
-
- internal void SubscribeExternalErrorDiagnosticUpdateSourceToSolutionBuildEvents()
- {
- // TODO: further understand if this needs the foreground thread for any reason. UIContexts are safe to read from the UI thread;
- // it's not clear to me why this is being asserted.
- _threadingContext.ThrowIfNotOnUIThread();
-
- if (_isExternalErrorDiagnosticUpdateSourceSubscribedToSolutionBuildEvents)
- {
- return;
- }
-
- // TODO: https://github.com/dotnet/roslyn/issues/36065
- // UIContextImpl requires IVsMonitorSelection service:
- if (ServiceProvider.GlobalProvider.GetService(typeof(IVsMonitorSelection)) == null)
- {
- return;
- }
-
- // This pattern ensures that we are called whenever the build starts/completes even if it is already in progress.
- KnownUIContexts.SolutionBuildingContext.WhenActivated(() =>
- {
- KnownUIContexts.SolutionBuildingContext.UIContextChanged += (_, e) =>
- {
- if (e.Activated)
- {
- ExternalErrorDiagnosticUpdateSource.OnSolutionBuildStarted();
- }
- else
- {
- // A real build just finished. Clear out any results from the last "run code analysis" command.
- this.Services.GetRequiredService().Clear();
- ExternalErrorDiagnosticUpdateSource.OnSolutionBuildCompleted();
- }
- };
-
- ExternalErrorDiagnosticUpdateSource.OnSolutionBuildStarted();
- });
- _isExternalErrorDiagnosticUpdateSourceSubscribedToSolutionBuildEvents = true;
+ SubscribeToSourceGeneratorImpactingEvents();
}
- public async Task InitializeUIAffinitizedServicesAsync()
+ private void SolutionClosingContext_UIContextChanged(object sender, UIContextChangedEventArgs e)
{
- // Yield the thread, so the caller can proceed and return immediately.
- // Create services that are bound to the UI thread
- await _threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(alwaysYield: true, _threadingContext.DisposalToken);
-
- var solutionClosingContext = UIContext.FromUIContextGuid(VSConstants.UICONTEXT.SolutionClosing_guid);
- solutionClosingContext.UIContextChanged += (_, e) => ProjectSystemProjectFactory.SolutionClosing = e.Activated;
+ ProjectSystemProjectFactory.SolutionClosing = e.Activated;
}
+ internal ExternalErrorDiagnosticUpdateSource ExternalErrorDiagnosticUpdateSource => _lazyExternalErrorDiagnosticUpdateSource.Value;
+
public Task CheckForAddedFileBeingOpenMaybeAsync(bool useAsync, ImmutableArray newFileNames)
=> _openFileTracker.CheckForAddedFileBeingOpenMaybeAsync(useAsync, newFileNames);
@@ -1464,10 +1420,10 @@ protected override void Dispose(bool finalize)
_textBufferFactoryService.TextBufferCreated -= AddTextBufferCloneServiceToBuffer;
_projectionBufferFactoryService.ProjectionBufferCreated -= AddTextBufferCloneServiceToBuffer;
- if (_lazyExternalErrorDiagnosticUpdateSource.IsValueCreated)
- {
- _lazyExternalErrorDiagnosticUpdateSource.Value.Dispose();
- }
+ // UIContext.FromUIContextGuid internally has a map from the GUID to the context object itself that is stored in a static;
+ // if we don't unsubscribe, it will leak our workspace object which can cause memory leaks in tests that create a whole MEF container
+ // per test.
+ _solutionClosingContext?.UIContextChanged -= SolutionClosingContext_UIContextChanged;
}
base.Dispose(finalize);
diff --git a/src/VisualStudio/Core/Def/ProjectSystem/VisualStudioWorkspaceImpl_SourceGenerators.cs b/src/VisualStudio/Core/Def/ProjectSystem/VisualStudioWorkspaceImpl_SourceGenerators.cs
index a9fb0c7357be0..6e289ea034eee 100644
--- a/src/VisualStudio/Core/Def/ProjectSystem/VisualStudioWorkspaceImpl_SourceGenerators.cs
+++ b/src/VisualStudio/Core/Def/ProjectSystem/VisualStudioWorkspaceImpl_SourceGenerators.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System.Linq;
-using Microsoft.CodeAnalysis.Editor.Shared.Extensions;
using Microsoft.CodeAnalysis.Host;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
@@ -12,20 +11,8 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem;
internal abstract partial class VisualStudioWorkspaceImpl
{
- private bool _isSubscribedToSourceGeneratorImpactingEvents;
-
- public void SubscribeToSourceGeneratorImpactingEvents()
+ protected virtual void SubscribeToSourceGeneratorImpactingEvents()
{
- _threadingContext.ThrowIfNotOnUIThread();
- if (_isSubscribedToSourceGeneratorImpactingEvents)
- return;
-
- // UIContextImpl requires IVsMonitorSelection service:
- if (ServiceProvider.GlobalProvider.GetService(typeof(IVsMonitorSelection)) == null)
- return;
-
- _isSubscribedToSourceGeneratorImpactingEvents = true;
-
// This pattern ensures that we are called whenever the build starts/completes even if it is already in progress.
KnownUIContexts.SolutionBuildingContext.WhenActivated(() =>
{
diff --git a/src/VisualStudio/Core/Def/TaskList/ExternalErrorDiagnosticUpdateSource.cs b/src/VisualStudio/Core/Def/TaskList/ExternalErrorDiagnosticUpdateSource.cs
index 5a90fc40c77fe..b364d07b7199e 100644
--- a/src/VisualStudio/Core/Def/TaskList/ExternalErrorDiagnosticUpdateSource.cs
+++ b/src/VisualStudio/Core/Def/TaskList/ExternalErrorDiagnosticUpdateSource.cs
@@ -17,16 +17,17 @@
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.LanguageServer;
using Microsoft.CodeAnalysis.PooledObjects;
-using Microsoft.CodeAnalysis.Shared.Collections;
using Microsoft.CodeAnalysis.Shared.TestHooks;
using Microsoft.CodeAnalysis.Threading;
using Microsoft.ServiceHub.Framework;
using Microsoft.VisualStudio.RpcContracts.DiagnosticManagement;
using Microsoft.VisualStudio.RpcContracts.Utilities;
+using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.ServiceBroker;
using Roslyn.Utilities;
namespace Microsoft.VisualStudio.LanguageServices.Implementation.TaskList;
+
///
/// Diagnostic source for warnings and errors reported from explicit build command invocations in Visual Studio.
/// VS workspaces calls into us when a build is invoked or completed in Visual Studio.
@@ -79,6 +80,26 @@ public ExternalErrorDiagnosticUpdateSource(
_listener,
_disposalToken
);
+
+ // This pattern ensures that we are called whenever the build starts/completes even if it is already in progress.
+ KnownUIContexts.SolutionBuildingContext.WhenActivated(() =>
+ {
+ KnownUIContexts.SolutionBuildingContext.UIContextChanged += (_, e) =>
+ {
+ if (e.Activated)
+ {
+ OnSolutionBuildStarted();
+ }
+ else
+ {
+ // A real build just finished. Clear out any results from the last "run code analysis" command.
+ _workspace.Services.GetRequiredService().Clear();
+ OnSolutionBuildCompleted();
+ }
+ };
+
+ OnSolutionBuildStarted();
+ });
}
private async ValueTask ProcessTaskQueueItemsAsync(ImmutableSegmentedList> list, CancellationToken cancellationToken)
diff --git a/src/VisualStudio/Core/Def/TaskList/ProjectExternalErrorReporter.cs b/src/VisualStudio/Core/Def/TaskList/ProjectExternalErrorReporter.cs
index 13bbdb9b5203f..1d568081d290d 100644
--- a/src/VisualStudio/Core/Def/TaskList/ProjectExternalErrorReporter.cs
+++ b/src/VisualStudio/Core/Def/TaskList/ProjectExternalErrorReporter.cs
@@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-#nullable disable
-
using System;
using System.Collections.Immutable;
using System.Diagnostics;
@@ -45,10 +43,6 @@ internal sealed class ProjectExternalErrorReporter : IVsReportExternalErrors, IV
public ProjectExternalErrorReporter(ProjectId projectId, Guid projectHierarchyGuid, string errorCodePrefix, string language, VisualStudioWorkspaceImpl workspace)
{
- Debug.Assert(projectId != null);
- Debug.Assert(errorCodePrefix != null);
- Debug.Assert(workspace != null);
-
_projectId = projectId;
_projectHierarchyGuid = projectHierarchyGuid;
_errorCodePrefix = errorCodePrefix;
@@ -83,7 +77,7 @@ public int AddNewErrors(IVsEnumExternalErrors pErrors)
using var _ = ArrayBuilder.GetInstance(out var allDiagnostics);
var errors = new ExternalError[1];
- var project = _workspace.CurrentSolution.GetProject(_projectId);
+ var project = _workspace.CurrentSolution.GetRequiredProject(_projectId);
while (pErrors.Next(1, errors, out var fetched) == VSConstants.S_OK && fetched == 1)
{
var error = errors[0];
@@ -119,21 +113,21 @@ public int ClearAllErrors()
return VSConstants.S_OK;
}
- public int GetErrors(out IVsEnumExternalErrors pErrors)
+ public int GetErrors(out IVsEnumExternalErrors? pErrors)
{
pErrors = null;
Debug.Fail("This is not implemented, because no one called it.");
return VSConstants.E_NOTIMPL;
}
- private DocumentId TryGetDocumentId(string filePath)
+ private DocumentId? TryGetDocumentId(string filePath)
{
return _workspace.CurrentSolution.GetDocumentIdsWithFilePath(filePath)
.Where(f => f.ProjectId == _projectId)
.FirstOrDefault();
}
- private DiagnosticData TryCreateDocumentDiagnosticItem(ExternalError error)
+ private DiagnosticData? TryCreateDocumentDiagnosticItem(ExternalError error)
{
var documentId = TryGetDocumentId(error.bstrFileName);
if (documentId == null)
@@ -218,8 +212,8 @@ public void ReportError2(string bstrErrorMessage, string bstrErrorId, [ComAliasN
_ => throw new ArgumentException(ServicesVSResources.Not_a_valid_value, nameof(nPriority))
};
- DocumentId documentId;
- if (bstrFileName == null || iStartLine < 0 || iStartColumn < 0)
+ DocumentId? documentId;
+ if (iStartLine < 0 || iStartColumn < 0)
{
documentId = null;
iStartLine = iStartColumn = iEndLine = iEndColumn = 0;
@@ -258,7 +252,7 @@ public int ClearErrors()
}
private static DiagnosticData GetDiagnosticData(
- DocumentId documentId,
+ DocumentId? documentId,
ProjectId projectId,
Workspace workspace,
string errorId,
@@ -268,7 +262,8 @@ private static DiagnosticData GetDiagnosticData(
FileLinePositionSpan unmappedSpan,
DiagnosticAnalyzerInfoCache analyzerInfoCache)
{
- string title, description, category, helpLink;
+ string title, description, category;
+ string? helpLink;
DiagnosticSeverity defaultSeverity;
bool isEnabledByDefault;
ImmutableArray customTags;
@@ -316,7 +311,7 @@ private static DiagnosticData GetDiagnosticData(
if (workspace.CurrentSolution.GetDocument(documentId) is Document document &&
document.SupportsSyntaxTree)
{
- var tree = document.GetSyntaxTreeSynchronously(CancellationToken.None);
+ var tree = document.GetRequiredSyntaxTreeSynchronously(CancellationToken.None);
var text = tree.GetText();
var span = diagnostic.DataLocation.UnmappedFileSpan.GetClampedTextSpan(text);
var location = diagnostic.DataLocation.WithSpan(span, tree);
diff --git a/src/VisualStudio/Core/Impl/ProjectSystem/CPS/CPSProject_ExternalErrorReporting.cs b/src/VisualStudio/Core/Impl/ProjectSystem/CPS/CPSProject_ExternalErrorReporting.cs
index ae362194aa95c..16c9ec517c4e1 100644
--- a/src/VisualStudio/Core/Impl/ProjectSystem/CPS/CPSProject_ExternalErrorReporting.cs
+++ b/src/VisualStudio/Core/Impl/ProjectSystem/CPS/CPSProject_ExternalErrorReporting.cs
@@ -29,7 +29,7 @@ public int ClearAllErrors()
public int AddNewErrors(IVsEnumExternalErrors pErrors)
=> GetExternalErrorReporter().AddNewErrors(pErrors);
- public int GetErrors(out IVsEnumExternalErrors pErrors)
+ public int GetErrors(out IVsEnumExternalErrors? pErrors)
=> GetExternalErrorReporter().GetErrors(out pErrors);
public int ReportError(string bstrErrorMessage, string bstrErrorId, VSTASKPRIORITY nPriority, int iLine, int iColumn, string bstrFileName)
diff --git a/src/VisualStudio/Core/Test/Diagnostics/ExternalDiagnosticUpdateSourceTests.vb b/src/VisualStudio/Core/Test/Diagnostics/ExternalDiagnosticUpdateSourceTests.vb
index 97db0fb8e9440..0f2b6059784be 100644
--- a/src/VisualStudio/Core/Test/Diagnostics/ExternalDiagnosticUpdateSourceTests.vb
+++ b/src/VisualStudio/Core/Test/Diagnostics/ExternalDiagnosticUpdateSourceTests.vb
@@ -3,8 +3,6 @@
' See the LICENSE file in the project root for more information.
Imports System.Collections.Immutable
-Imports System.ComponentModel.Composition
-Imports System.IO.Pipelines
Imports System.Threading
Imports Microsoft.CodeAnalysis
Imports Microsoft.CodeAnalysis.CodeActions
@@ -12,17 +10,14 @@ Imports Microsoft.CodeAnalysis.CommonDiagnosticAnalyzers
Imports Microsoft.CodeAnalysis.Diagnostics
Imports Microsoft.CodeAnalysis.Editor.[Shared].Utilities
Imports Microsoft.CodeAnalysis.Editor.UnitTests
-Imports Microsoft.CodeAnalysis.Host.Mef
Imports Microsoft.CodeAnalysis.Options
Imports Microsoft.CodeAnalysis.Shared.TestHooks
Imports Microsoft.CodeAnalysis.Test.Utilities
Imports Microsoft.CodeAnalysis.Text
-Imports Microsoft.ServiceHub.Framework
Imports Microsoft.VisualStudio.LanguageServices.Implementation.CodeModel
Imports Microsoft.VisualStudio.LanguageServices.Implementation.TaskList
Imports Microsoft.VisualStudio.LanguageServices.UnitTests.CodeModel.Mocks
Imports Microsoft.VisualStudio.RpcContracts.DiagnosticManagement
-Imports Microsoft.VisualStudio.Shell.ServiceBroker
Imports Roslyn.Test.Utilities
Imports Roslyn.Utilities
@@ -30,7 +25,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
<[UseExportProvider]>
Public Class ExternalDiagnosticUpdateSourceTests
Private Shared ReadOnly s_composition As TestComposition = VisualStudioTestCompositions.LanguageServices.AddParts(
- GetType(TestServiceBroker),
+ GetType(MockServiceBroker),
GetType(MockServiceProvider),
GetType(StubVsServiceExporter(Of )),
GetType(StubVsServiceExporter(Of ,)),
@@ -114,6 +109,9 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
Public Async Function TestExternalDiagnosticsReported() As Task
Using workspace = EditorTestWorkspace.CreateCSharp(String.Empty, composition:=s_composition)
+ Dim diagnosticManagerService = New DiagnosticManagerService()
+ workspace.GetService(Of MockServiceBroker)().RegisterService(Of IDiagnosticManagerService)(diagnosticManagerService)
+
Dim waiter = workspace.GetService(Of AsynchronousOperationListenerProvider)().GetWaiter(FeatureAttribute.ErrorList)
Dim project = workspace.CurrentSolution.Projects.First()
@@ -121,14 +119,13 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
Dim service = New TestDiagnosticAnalyzerService()
Dim threadingContext = workspace.ExportProvider.GetExportedValue(Of IThreadingContext)
- Dim testServiceBroker = workspace.ExportProvider.GetExportedValue(Of TestServiceBroker)
Dim vsWorkspace = workspace.ExportProvider.GetExportedValue(Of MockVisualStudioWorkspace)()
vsWorkspace.SetWorkspace(workspace)
Using source = workspace.ExportProvider.GetExportedValue(Of ExternalErrorDiagnosticUpdateSource)()
source.OnSolutionBuildStarted()
Await waiter.ExpeditedWaitAsync()
- Assert.True(testServiceBroker.DiagnosticManagerService.AllDiagnosticsCleared)
+ Assert.True(diagnosticManagerService.AllDiagnosticsCleared)
Dim diagnostics = {diagnostic, GetDiagnosticData(project.Id)}.ToImmutableArray()
@@ -136,7 +133,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
source.OnSolutionBuildCompleted()
Await waiter.ExpeditedWaitAsync()
- Assert.Equal(2, testServiceBroker.DiagnosticManagerService.AllDiagnostics.Count)
+ Assert.Equal(2, diagnosticManagerService.AllDiagnostics.Count)
End Using
End Using
End Function
@@ -150,20 +147,22 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
Assert.Equal(WellKnownDiagnosticTags.Build, value)
Using workspace = EditorTestWorkspace.CreateCSharp(String.Empty, composition:=s_composition)
+ Dim diagnosticManagerService = New DiagnosticManagerService()
+ workspace.GetService(Of MockServiceBroker)().RegisterService(Of IDiagnosticManagerService)(diagnosticManagerService)
+
Dim waiter = workspace.GetService(Of AsynchronousOperationListenerProvider)().GetWaiter(FeatureAttribute.ErrorList)
Dim project = workspace.CurrentSolution.Projects.First()
Dim service = New TestDiagnosticAnalyzerService()
Dim threadingContext = workspace.ExportProvider.GetExportedValue(Of IThreadingContext)
- Dim testServiceBroker = workspace.ExportProvider.GetExportedValue(Of TestServiceBroker)
Dim vsWorkspace = workspace.ExportProvider.GetExportedValue(Of MockVisualStudioWorkspace)()
vsWorkspace.SetWorkspace(workspace)
Using source = workspace.ExportProvider.GetExportedValue(Of ExternalErrorDiagnosticUpdateSource)()
source.OnSolutionBuildStarted()
Await waiter.ExpeditedWaitAsync()
- Assert.True(testServiceBroker.DiagnosticManagerService.AllDiagnosticsCleared)
+ Assert.True(diagnosticManagerService.AllDiagnosticsCleared)
Dim diagnostic = New DiagnosticData(
"id",
@@ -189,6 +188,9 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
Public Async Function TestExternalDiagnostics_AddDuplicatedErrors() As Task
Using workspace = EditorTestWorkspace.CreateCSharp(String.Empty, composition:=s_composition)
+ Dim diagnosticManagerService = New DiagnosticManagerService()
+ workspace.GetService(Of MockServiceBroker)().RegisterService(Of IDiagnosticManagerService)(diagnosticManagerService)
+
Dim globalOptions = workspace.GetService(Of IGlobalOptionService)
Dim waiter = workspace.GetService(Of AsynchronousOperationListenerProvider)().GetWaiter(FeatureAttribute.ErrorList)
@@ -197,14 +199,13 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
Dim service = New TestDiagnosticAnalyzerService()
Dim threadingContext = workspace.ExportProvider.GetExportedValue(Of IThreadingContext)
- Dim testServiceBroker = workspace.ExportProvider.GetExportedValue(Of TestServiceBroker)
Dim vsWorkspace = workspace.ExportProvider.GetExportedValue(Of MockVisualStudioWorkspace)()
vsWorkspace.SetWorkspace(workspace)
Using source = workspace.ExportProvider.GetExportedValue(Of ExternalErrorDiagnosticUpdateSource)()
source.OnSolutionBuildStarted()
Await waiter.ExpeditedWaitAsync()
- Assert.True(testServiceBroker.DiagnosticManagerService.AllDiagnosticsCleared)
+ Assert.True(diagnosticManagerService.AllDiagnosticsCleared)
' we shouldn't crash here
source.AddNewErrors(project.Id, s_projectGuid, {diagnostic}.ToImmutableArray())
@@ -213,7 +214,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
source.OnSolutionBuildCompleted()
Await waiter.ExpeditedWaitAsync()
- Assert.Equal(2, testServiceBroker.DiagnosticManagerService.AllDiagnostics.Count)
+ Assert.Equal(2, diagnosticManagerService.AllDiagnostics.Count)
End Using
End Using
End Function
@@ -221,6 +222,9 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
Public Async Function TestCompilerDiagnosticWithoutDocumentId() As Task
Using workspace = EditorTestWorkspace.CreateCSharp(String.Empty, composition:=s_composition)
+ Dim diagnosticManagerService = New DiagnosticManagerService()
+ workspace.GetService(Of MockServiceBroker)().RegisterService(Of IDiagnosticManagerService)(diagnosticManagerService)
+
Dim globalOptions = workspace.GetService(Of IGlobalOptionService)
Dim analyzer = New CompilationAnalyzer()
Dim compiler = DiagnosticExtensions.GetCompilerDiagnosticAnalyzer(LanguageNames.CSharp)
@@ -235,7 +239,6 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
Dim service = workspace.Services.GetRequiredService(Of IDiagnosticAnalyzerService)()
Dim threadingContext = workspace.ExportProvider.GetExportedValue(Of IThreadingContext)
- Dim testServiceBroker = workspace.ExportProvider.GetExportedValue(Of TestServiceBroker)
Dim vsWorkspace = workspace.ExportProvider.GetExportedValue(Of MockVisualStudioWorkspace)()
vsWorkspace.SetWorkspace(workspace)
Using source = workspace.ExportProvider.GetExportedValue(Of ExternalErrorDiagnosticUpdateSource)()
@@ -329,34 +332,6 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
End Function
End Class
-
-
-
- Private Class TestServiceBroker
- Implements IServiceBroker
-
- Friend DiagnosticManagerService As DiagnosticManagerService = New DiagnosticManagerService()
-
-
-
- Public Sub New()
- End Sub
-
- Public Event AvailabilityChanged As EventHandler(Of BrokeredServicesChangedEventArgs) Implements IServiceBroker.AvailabilityChanged
-
- Public Function GetProxyAsync(Of T As Class)(serviceDescriptor As ServiceRpcDescriptor, Optional options As ServiceActivationOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of T) Implements IServiceBroker.GetProxyAsync
- If (GetType(T) Is GetType(IDiagnosticManagerService)) Then
- Return New ValueTask(Of T)(Task.FromResult(CType(CType(DiagnosticManagerService, Object), T)))
- End If
-
- Throw New InvalidOperationException()
- End Function
-
- Public Function GetPipeAsync(serviceMoniker As ServiceMoniker, Optional options As ServiceActivationOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of IDuplexPipe) Implements IServiceBroker.GetPipeAsync
- Throw New NotImplementedException()
- End Function
- End Class
-
Private Class DiagnosticManagerService
Implements IDiagnosticManagerService
diff --git a/src/VisualStudio/TestUtilities2/CodeModel/CodeModelTestHelpers.vb b/src/VisualStudio/TestUtilities2/CodeModel/CodeModelTestHelpers.vb
index 626916dfee1c3..c50bb16f04b14 100644
--- a/src/VisualStudio/TestUtilities2/CodeModel/CodeModelTestHelpers.vb
+++ b/src/VisualStudio/TestUtilities2/CodeModel/CodeModelTestHelpers.vb
@@ -16,6 +16,7 @@ Imports Microsoft.VisualStudio.LanguageServices.Implementation.CodeModel.Externa
Imports Microsoft.VisualStudio.LanguageServices.Implementation.CodeModel.InternalElements
Imports Microsoft.VisualStudio.LanguageServices.Implementation.CodeModel.Interop
Imports Microsoft.VisualStudio.LanguageServices.Implementation.Interop
+Imports Microsoft.VisualStudio.LanguageServices.Implementation.TaskList
Imports Microsoft.VisualStudio.LanguageServices.UnitTests.CodeModel.Mocks
Imports Microsoft.VisualStudio.Shell.Interop
Imports Roslyn.Test.Utilities
@@ -28,7 +29,9 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.CodeModel
GetType(StubVsServiceExporter(Of )),
GetType(StubVsServiceExporter(Of ,)),
GetType(MockVisualStudioWorkspace),
- GetType(ProjectCodeModelFactory))
+ GetType(ProjectCodeModelFactory),
+ GetType(ExternalErrorDiagnosticUpdateSource),
+ GetType(MockServiceBroker))
Public SystemWindowsFormsPath As String
Public SystemDrawingPath As String
diff --git a/src/VisualStudio/TestUtilities2/CodeModel/Mocks/MockVisualStudioWorkspace.vb b/src/VisualStudio/TestUtilities2/CodeModel/Mocks/MockVisualStudioWorkspace.vb
index b5b5db66e8ee7..5aa8317153fe7 100644
--- a/src/VisualStudio/TestUtilities2/CodeModel/Mocks/MockVisualStudioWorkspace.vb
+++ b/src/VisualStudio/TestUtilities2/CodeModel/Mocks/MockVisualStudioWorkspace.vb
@@ -84,6 +84,12 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.CodeModel.Mocks
Public Overrides Sub EnsureEditableDocuments(documents As IEnumerable(Of DocumentId))
' Nothing to do here
End Sub
+
+ Protected Overrides Sub SubscribeToSourceGeneratorImpactingEvents()
+ ' HACK: We override this method in unit tests to do nothing. The base type uses WhenActivated which can cause a leak if those handlers don't actually
+ ' run, and that API gives us no way to unsubscribe. Further; right now raising events to update the source generator versions
+ ' causes TryApplyChanges to also fail in unit tests because of https://github.com/dotnet/roslyn/issues/79587.
+ End Sub
End Class
Public Class MockInvisibleEditor
diff --git a/src/VisualStudio/TestUtilities2/MockServiceBroker.vb b/src/VisualStudio/TestUtilities2/MockServiceBroker.vb
new file mode 100644
index 0000000000000..63c166f635e03
--- /dev/null
+++ b/src/VisualStudio/TestUtilities2/MockServiceBroker.vb
@@ -0,0 +1,48 @@
+' Licensed to the .NET Foundation under one or more agreements.
+' The .NET Foundation licenses this file to you under the MIT license.
+' See the LICENSE file in the project root for more information.
+
+Imports System.Collections.Concurrent
+Imports System.ComponentModel.Composition
+Imports System.IO.Pipelines
+Imports System.Threading
+Imports System.Threading.Tasks
+Imports Microsoft.CodeAnalysis.Host.Mef
+Imports Microsoft.ServiceHub.Framework
+Imports Microsoft.VisualStudio.Shell.ServiceBroker
+Imports Roslyn.Utilities
+
+Namespace Microsoft.VisualStudio.LanguageServices.UnitTests
+
+
+
+ Friend Class MockServiceBroker
+ Implements IServiceBroker
+
+ Private ReadOnly _services As New ConcurrentDictionary(Of Type, Object)()
+
+
+
+ Public Sub New()
+ End Sub
+
+ Public Sub RegisterService(Of T)(service As T)
+ _services.Add(GetType(T), service)
+ End Sub
+
+ Public Event AvailabilityChanged As EventHandler(Of BrokeredServicesChangedEventArgs) Implements IServiceBroker.AvailabilityChanged
+
+ Public Function GetProxyAsync(Of T As Class)(serviceDescriptor As ServiceRpcDescriptor, Optional options As ServiceActivationOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of T) Implements IServiceBroker.GetProxyAsync
+ Dim service As Object = Nothing
+ If _services.TryGetValue(GetType(T), service) Then
+ Return New ValueTask(Of T)(CType(service, T))
+ End If
+
+ Throw New InvalidOperationException("The MockServiceBroker does not have a registered service for " + GetType(T).FullName)
+ End Function
+
+ Public Function GetPipeAsync(serviceMoniker As ServiceMoniker, Optional options As ServiceActivationOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of IDuplexPipe) Implements IServiceBroker.GetPipeAsync
+ Throw New NotImplementedException()
+ End Function
+ End Class
+End Namespace
diff --git a/src/VisualStudio/TestUtilities2/MockServiceProvider.vb b/src/VisualStudio/TestUtilities2/MockServiceProvider.vb
index 9584002c56ba2..68dde06460c24 100644
--- a/src/VisualStudio/TestUtilities2/MockServiceProvider.vb
+++ b/src/VisualStudio/TestUtilities2/MockServiceProvider.vb
@@ -26,6 +26,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests
Private ReadOnly _fileChangeEx As New MockVsFileChangeEx
Public MockMonitorSelection As IVsMonitorSelection
+ Public MockRunningDocumentTable As New MockVsRunningDocumentTable
@@ -56,11 +57,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests
Return _fileChangeEx
Case GetType(SVsRunningDocumentTable)
- Dim mock = New Mock(Of IVsRunningDocumentTable)
- mock.As(Of IVsRunningDocumentTable4)()
-
- mock.Setup(Function(m) m.AdviseRunningDocTableEvents(It.IsAny(Of IVsRunningDocTableEvents), It.IsAny(Of UInteger))).Returns(VSConstants.S_OK)
- Return mock.Object
+ Return MockRunningDocumentTable
Case Else
Throw New Exception($"{NameOf(MockServiceProvider)} does not implement {serviceType.FullName}.")
diff --git a/src/VisualStudio/TestUtilities2/MockVsRunningDocumentTable.vb b/src/VisualStudio/TestUtilities2/MockVsRunningDocumentTable.vb
new file mode 100644
index 0000000000000..b6bbf3a590357
--- /dev/null
+++ b/src/VisualStudio/TestUtilities2/MockVsRunningDocumentTable.vb
@@ -0,0 +1,194 @@
+' Licensed to the .NET Foundation under one or more agreements.
+' The .NET Foundation licenses this file to you under the MIT license.
+' See the LICENSE file in the project root for more information.
+Imports Microsoft.VisualStudio.ProjectSystem.VS
+Imports Microsoft.VisualStudio.Shell.Interop
+Imports Roslyn.Test.Utilities
+
+Namespace Microsoft.VisualStudio.LanguageServices.UnitTests
+
+ Public Class MockVsRunningDocumentTable
+ Implements IVsRunningDocumentTable
+ Implements IVsRunningDocumentTable4
+ Implements SVsRunningDocumentTable
+
+ Private _lastDocTableEventsCooke As UInteger = 0
+
+ Public Function RegisterAndLockDocument(grfRDTLockType As UInteger, pszMkDocument As String, pHier As IVsHierarchy, itemid As UInteger, punkDocData As IntPtr, ByRef pdwCookie As UInteger) As Integer Implements IVsRunningDocumentTable.RegisterAndLockDocument
+ Throw New NotImplementedException()
+ End Function
+
+ Public Function LockDocument(grfRDTLockType As UInteger, dwCookie As UInteger) As Integer Implements IVsRunningDocumentTable.LockDocument
+ Throw New NotImplementedException()
+ End Function
+
+ Public Function UnlockDocument(grfRDTLockType As UInteger, dwCookie As UInteger) As Integer Implements IVsRunningDocumentTable.UnlockDocument
+ Throw New NotImplementedException()
+ End Function
+
+ Public Function FindAndLockDocument(dwRDTLockType As UInteger, pszMkDocument As String, ByRef ppHier As IVsHierarchy, ByRef pitemid As UInteger, ByRef ppunkDocData As IntPtr, ByRef pdwCookie As UInteger) As Integer Implements IVsRunningDocumentTable.FindAndLockDocument
+ Throw New NotImplementedException()
+ End Function
+
+ Public Function RenameDocument(pszMkDocumentOld As String, pszMkDocumentNew As String, pHier As IntPtr, itemidNew As UInteger) As Integer Implements IVsRunningDocumentTable.RenameDocument
+ Throw New NotImplementedException()
+ End Function
+
+ Public Function AdviseRunningDocTableEvents(pSink As IVsRunningDocTableEvents, ByRef pdwCookie As UInteger) As Integer Implements IVsRunningDocumentTable.AdviseRunningDocTableEvents
+ _lastDocTableEventsCooke = _lastDocTableEventsCooke + CType(1, UInteger)
+ pdwCookie = _lastDocTableEventsCooke
+ Return VSConstants.S_OK
+ End Function
+
+ Public Function UnadviseRunningDocTableEvents(dwCookie As UInteger) As Integer Implements IVsRunningDocumentTable.UnadviseRunningDocTableEvents
+ Return VSConstants.S_OK
+ End Function
+
+ Public Function GetDocumentInfo(docCookie As UInteger, ByRef pgrfRDTFlags As UInteger, ByRef pdwReadLocks As UInteger, ByRef pdwEditLocks As UInteger, ByRef pbstrMkDocument As String, ByRef ppHier As IVsHierarchy, ByRef pitemid As UInteger, ByRef ppunkDocData As IntPtr) As Integer Implements IVsRunningDocumentTable.GetDocumentInfo
+ Throw New NotImplementedException()
+ End Function
+
+ Public Function NotifyDocumentChanged(dwCookie As UInteger, grfDocChanged As UInteger) As Integer Implements IVsRunningDocumentTable.NotifyDocumentChanged
+ Throw New NotImplementedException()
+ End Function
+
+ Public Function NotifyOnAfterSave(dwCookie As UInteger) As Integer Implements IVsRunningDocumentTable.NotifyOnAfterSave
+ Throw New NotImplementedException()
+ End Function
+
+ Public Function GetRunningDocumentsEnum(ByRef ppenum As IEnumRunningDocuments) As Integer Implements IVsRunningDocumentTable.GetRunningDocumentsEnum
+ ppenum = New MockEnumRunningDocuments()
+ Return VSConstants.S_OK
+ End Function
+
+ Public Function SaveDocuments(grfSaveOpts As UInteger, pHier As IVsHierarchy, itemid As UInteger, docCookie As UInteger) As Integer Implements IVsRunningDocumentTable.SaveDocuments
+ Throw New NotImplementedException()
+ End Function
+
+ Public Function NotifyOnBeforeSave(dwCookie As UInteger) As Integer Implements IVsRunningDocumentTable.NotifyOnBeforeSave
+ Throw New NotImplementedException()
+ End Function
+
+ Public Function RegisterDocumentLockHolder(grfRDLH As UInteger, dwCookie As UInteger, pLockHolder As IVsDocumentLockHolder, ByRef pdwLHCookie As UInteger) As Integer Implements IVsRunningDocumentTable.RegisterDocumentLockHolder
+ Throw New NotImplementedException()
+ End Function
+
+ Public Function UnregisterDocumentLockHolder(dwLHCookie As UInteger) As Integer Implements IVsRunningDocumentTable.UnregisterDocumentLockHolder
+ Throw New NotImplementedException()
+ End Function
+
+ Public Function ModifyDocumentFlags(docCookie As UInteger, grfFlags As UInteger, fSet As Integer) As Integer Implements IVsRunningDocumentTable.ModifyDocumentFlags
+ Throw New NotImplementedException()
+ End Function
+
+ Public Function GetRelatedSaveTreeItems(cookie As UInteger, grfSave As UInteger, celt As UInteger, rgSaveTreeItems() As VSSAVETREEITEM) As UInteger Implements IVsRunningDocumentTable4.GetRelatedSaveTreeItems
+ Throw New NotImplementedException()
+ End Function
+
+ Public Sub NotifyDocumentChangedEx(cookie As UInteger, attributes As UInteger) Implements IVsRunningDocumentTable4.NotifyDocumentChangedEx
+ Throw New NotImplementedException()
+ End Sub
+
+ Public Function IsDocumentDirty(cookie As UInteger) As Boolean Implements IVsRunningDocumentTable4.IsDocumentDirty
+ Throw New NotImplementedException()
+ End Function
+
+ Public Function IsDocumentReadOnly(cookie As UInteger) As Boolean Implements IVsRunningDocumentTable4.IsDocumentReadOnly
+ Throw New NotImplementedException()
+ End Function
+
+ Public Sub UpdateDirtyState(cookie As UInteger) Implements IVsRunningDocumentTable4.UpdateDirtyState
+ Throw New NotImplementedException()
+ End Sub
+
+ Public Sub UpdateReadOnlyState(cookie As UInteger) Implements IVsRunningDocumentTable4.UpdateReadOnlyState
+ Throw New NotImplementedException()
+ End Sub
+
+ Public Function IsMonikerValid(moniker As String) As Boolean Implements IVsRunningDocumentTable4.IsMonikerValid
+ Throw New NotImplementedException()
+ End Function
+
+ Public Function IsCookieValid(cookie As UInteger) As Boolean Implements IVsRunningDocumentTable4.IsCookieValid
+ Throw New NotImplementedException()
+ End Function
+
+ Public Function GetDocumentCookie(moniker As String) As UInteger Implements IVsRunningDocumentTable4.GetDocumentCookie
+ Throw New NotImplementedException()
+ End Function
+
+ Public Function GetDocumentFlags(cookie As UInteger) As UInteger Implements IVsRunningDocumentTable4.GetDocumentFlags
+ Throw New NotImplementedException()
+ End Function
+
+ Public Function GetDocumentReadLockCount(cookie As UInteger) As UInteger Implements IVsRunningDocumentTable4.GetDocumentReadLockCount
+ Throw New NotImplementedException()
+ End Function
+
+ Public Function GetDocumentEditLockCount(cookie As UInteger) As UInteger Implements IVsRunningDocumentTable4.GetDocumentEditLockCount
+ Throw New NotImplementedException()
+ End Function
+
+ Public Function GetDocumentMoniker(cookie As UInteger) As String Implements IVsRunningDocumentTable4.GetDocumentMoniker
+ Throw New NotImplementedException()
+ End Function
+
+ Public Sub GetDocumentHierarchyItem(cookie As UInteger, ByRef hierarchy As IVsHierarchy, ByRef itemID As UInteger) Implements IVsRunningDocumentTable4.GetDocumentHierarchyItem
+ Throw New NotImplementedException()
+ End Sub
+
+ Public Function GetDocumentData(cookie As UInteger) As Object Implements IVsRunningDocumentTable4.GetDocumentData
+ Throw New NotImplementedException()
+ End Function
+
+ Public Function GetDocumentProjectGuid(cookie As UInteger) As Guid Implements IVsRunningDocumentTable4.GetDocumentProjectGuid
+ Throw New NotImplementedException()
+ End Function
+
+ Private Function IVsRunningDocumentTable3_GetRelatedSaveTreeItems(cookie As UInteger, grfSave As UInteger, celt As UInteger, rgSaveTreeItems() As VSSAVETREEITEM) As UInteger Implements IVsRunningDocumentTable3.GetRelatedSaveTreeItems
+ Return GetRelatedSaveTreeItems(cookie, grfSave, celt, rgSaveTreeItems)
+ End Function
+
+ Private Sub IVsRunningDocumentTable3_NotifyDocumentChangedEx(cookie As UInteger, attributes As UInteger) Implements IVsRunningDocumentTable3.NotifyDocumentChangedEx
+ NotifyDocumentChangedEx(cookie, attributes)
+ End Sub
+
+ Private Function IVsRunningDocumentTable3_IsDocumentDirty(cookie As UInteger) As Boolean Implements IVsRunningDocumentTable3.IsDocumentDirty
+ Return IsDocumentDirty(cookie)
+ End Function
+
+ Private Function IVsRunningDocumentTable3_IsDocumentReadOnly(cookie As UInteger) As Boolean Implements IVsRunningDocumentTable3.IsDocumentReadOnly
+ Return IsDocumentReadOnly(cookie)
+ End Function
+
+ Private Sub IVsRunningDocumentTable3_UpdateDirtyState(cookie As UInteger) Implements IVsRunningDocumentTable3.UpdateDirtyState
+ UpdateDirtyState(cookie)
+ End Sub
+
+ Private Sub IVsRunningDocumentTable3_UpdateReadOnlyState(cookie As UInteger) Implements IVsRunningDocumentTable3.UpdateReadOnlyState
+ UpdateReadOnlyState(cookie)
+ End Sub
+ End Class
+
+ Public Class MockEnumRunningDocuments
+ Implements IEnumRunningDocuments
+
+ Public Function [Next](celt As UInteger, rgelt() As UInteger, ByRef pceltFetched As UInteger) As Integer Implements IEnumRunningDocuments.Next
+ pceltFetched = 0
+ Return VSConstants.S_FALSE
+ End Function
+
+ Public Function Skip(celt As UInteger) As Integer Implements IEnumRunningDocuments.Skip
+ Throw New NotImplementedException()
+ End Function
+
+ Public Function Reset() As Integer Implements IEnumRunningDocuments.Reset
+ Throw New NotImplementedException()
+ End Function
+
+ Public Function Clone(ByRef ppenum As IEnumRunningDocuments) As Integer Implements IEnumRunningDocuments.Clone
+ Throw New NotImplementedException()
+ End Function
+ End Class
+
+End Namespace
diff --git a/src/VisualStudio/TestUtilities2/ProjectSystemShim/Framework/TestEnvironment.vb b/src/VisualStudio/TestUtilities2/ProjectSystemShim/Framework/TestEnvironment.vb
index 4b1bbf1f9a740..e2fcf746a962c 100644
--- a/src/VisualStudio/TestUtilities2/ProjectSystemShim/Framework/TestEnvironment.vb
+++ b/src/VisualStudio/TestUtilities2/ProjectSystemShim/Framework/TestEnvironment.vb
@@ -22,6 +22,7 @@ Imports Microsoft.VisualStudio.LanguageServices.Implementation.Library.ObjectBro
Imports Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem
Imports Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.CPS
Imports Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.Legacy
+Imports Microsoft.VisualStudio.LanguageServices.Implementation.TaskList
Imports Microsoft.VisualStudio.LanguageServices.Telemetry
Imports Microsoft.VisualStudio.LanguageServices.UnitTests.CodeModel
Imports Microsoft.VisualStudio.LanguageServices.UnitTests.Diagnostics
@@ -69,7 +70,9 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.ProjectSystemShim.Fr
GetType(DiagnosticAnalyzerService),
GetType(VisualStudioWorkspaceTelemetryService),
GetType(OpenTextBufferProvider),
- GetType(StubVsEditorAdaptersFactoryService))
+ GetType(StubVsEditorAdaptersFactoryService),
+ GetType(ExternalErrorDiagnosticUpdateSource),
+ GetType(MockServiceBroker))
Private ReadOnly _workspace As VisualStudioWorkspaceImpl
Private ReadOnly _projectFilePaths As New List(Of String)
diff --git a/src/VisualStudio/TestUtilities2/VisualStudioTestCompositions.vb b/src/VisualStudio/TestUtilities2/VisualStudioTestCompositions.vb
index 373374a5d3ba1..6c8e3a64cb032 100644
--- a/src/VisualStudio/TestUtilities2/VisualStudioTestCompositions.vb
+++ b/src/VisualStudio/TestUtilities2/VisualStudioTestCompositions.vb
@@ -6,6 +6,7 @@ Imports Microsoft.CodeAnalysis.Editor.Host
Imports Microsoft.CodeAnalysis.Editor.UnitTests
Imports Microsoft.CodeAnalysis.Test.Utilities
Imports Microsoft.VisualStudio.LanguageServices.CSharp
+Imports Microsoft.VisualStudio.LanguageServices.Implementation
Imports Microsoft.VisualStudio.LanguageServices.Remote
Imports Microsoft.VisualStudio.LanguageServices.VisualBasic
@@ -25,7 +26,9 @@ Namespace Microsoft.VisualStudio.LanguageServices.UnitTests
GetType(VisualStudioRemoteHostClientProvider.Factory), ' Do not use ServiceHub in VS unit tests, run services locally.
GetType(IStreamingFindUsagesPresenter), ' TODO: should we be using the actual implementation (https://github.com/dotnet/roslyn/issues/46380)?
GetType(HACK_ThemeColorFixer),
- GetType(Implementation.Notification.VSNotificationServiceFactory),
- GetType(Options.VisualStudioOptionPersisterProvider))
+ GetType(Notification.VSNotificationServiceFactory),
+ GetType(Options.VisualStudioOptionPersisterProvider),
+ GetType(VisualStudioWorkspaceStatusServiceFactory), ' Depends on other packages being loaded, and it's not really clear how it would work in unit tests anyways
+ GetType(VisualStudioDocumentTrackingServiceFactory)) ' Depends on IVsMonitorSelection, and removing it falls back to the default no-op implementation.
End Class
End Namespace
diff --git a/src/Workspaces/Core/Portable/Diagnostics/DiagnosticData.cs b/src/Workspaces/Core/Portable/Diagnostics/DiagnosticData.cs
index c358e23471480..a18295c96e5fd 100644
--- a/src/Workspaces/Core/Portable/Diagnostics/DiagnosticData.cs
+++ b/src/Workspaces/Core/Portable/Diagnostics/DiagnosticData.cs
@@ -94,8 +94,8 @@ internal sealed class DiagnosticData(
///
/// Properties for a diagnostic generated by an explicit build.
///
- internal static ImmutableDictionary PropertiesForBuildDiagnostic { get; }
- = ImmutableDictionary.Empty.Add(WellKnownDiagnosticPropertyNames.Origin, WellKnownDiagnosticTags.Build);
+ internal static ImmutableDictionary PropertiesForBuildDiagnostic { get; }
+ = ImmutableDictionary.Empty.Add(WellKnownDiagnosticPropertyNames.Origin, WellKnownDiagnosticTags.Build);
public DiagnosticData WithLocations(DiagnosticDataLocation location, ImmutableArray additionalLocations)
=> new(Id, Category, Message, Severity, DefaultSeverity, IsEnabledByDefault,