未验证 提交 08d22664 编写于 作者: C CyrusNajmabadi 提交者: GitHub

Merge pull request #42806 from CyrusNajmabadi/makePrivate

Remove TestNotificationService.
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
Imports System.Collections.Immutable Imports System.Collections.Immutable
Imports Microsoft.CodeAnalysis.CSharp Imports Microsoft.CodeAnalysis.CSharp
Imports Microsoft.CodeAnalysis.Diagnostics Imports Microsoft.CodeAnalysis.Diagnostics
Imports Microsoft.CodeAnalysis.Editor.UnitTests
Imports Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces Imports Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces
Imports Microsoft.CodeAnalysis.Shared.Options Imports Microsoft.CodeAnalysis.Shared.Options
Imports Microsoft.CodeAnalysis.SolutionCrawler Imports Microsoft.CodeAnalysis.SolutionCrawler
...@@ -38,7 +37,7 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.Diagnostics.UnitTests ...@@ -38,7 +37,7 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.Diagnostics.UnitTests
<Project Language="C#" CommonReferences="true"> <Project Language="C#" CommonReferences="true">
<Document FilePath="Test.cs"> <Document FilePath="Test.cs">
class Goo { } class Goo { }
</Document> </Document>
</Project> </Project>
</Workspace> </Workspace>
...@@ -51,7 +50,7 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.Diagnostics.UnitTests ...@@ -51,7 +50,7 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.Diagnostics.UnitTests
<Project Language="C#" CommonReferences="true"> <Project Language="C#" CommonReferences="true">
<Document FilePath="Test.cs"> <Document FilePath="Test.cs">
class Goo { dontcompile } class Goo { dontcompile }
</Document> </Document>
</Project> </Project>
</Workspace> </Workspace>
Dim diagnostics = <Diagnostics> Dim diagnostics = <Diagnostics>
...@@ -72,7 +71,7 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.Diagnostics.UnitTests ...@@ -72,7 +71,7 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.Diagnostics.UnitTests
class Goo2 { dontcompile } class Goo2 { dontcompile }
#line default #line default
class Goo4 { dontcompile } class Goo4 { dontcompile }
</Document> </Document>
</Project> </Project>
</Workspace> </Workspace>
Dim diagnostics = <Diagnostics> Dim diagnostics = <Diagnostics>
...@@ -93,7 +92,7 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.Diagnostics.UnitTests ...@@ -93,7 +92,7 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.Diagnostics.UnitTests
<Project Language="C#" CommonReferences="true"> <Project Language="C#" CommonReferences="true">
<Document FilePath="Test.cs"> <Document FilePath="Test.cs">
class Goo { int a = "test"; } class Goo { int a = "test"; }
</Document> </Document>
</Project> </Project>
</Workspace> </Workspace>
...@@ -114,7 +113,7 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.Diagnostics.UnitTests ...@@ -114,7 +113,7 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.Diagnostics.UnitTests
class Goo2 { as; } class Goo2 { as; }
class Goo3 { long q = 1l; } class Goo3 { long q = 1l; }
#pragma disable 9999999" #pragma disable 9999999"
</Document> </Document>
</Project> </Project>
</Workspace> </Workspace>
...@@ -142,7 +141,7 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.Diagnostics.UnitTests ...@@ -142,7 +141,7 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.Diagnostics.UnitTests
<Project Language="C#" CommonReferences="true"> <Project Language="C#" CommonReferences="true">
<Document FilePath="Test.cs"> <Document FilePath="Test.cs">
class Program { void Main() { - } } class Program { void Main() { - } }
</Document> </Document>
</Project> </Project>
</Workspace> </Workspace>
...@@ -170,14 +169,14 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.Diagnostics.UnitTests ...@@ -170,14 +169,14 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.Diagnostics.UnitTests
int a = 5 - "2"; int a = 5 - "2";
} }
} }
</Document> </Document>
</Project> </Project>
<Project Language="Visual Basic" CommonReferences="true"> <Project Language="Visual Basic" CommonReferences="true">
<Document FilePath="Test.vb"> <Document FilePath="Test.vb">
Class GooClass Class GooClass
Sub Blah() End Sub Sub Blah() End Sub
End Class End Class
</Document> </Document>
</Project> </Project>
</Workspace> </Workspace>
...@@ -208,14 +207,14 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.Diagnostics.UnitTests ...@@ -208,14 +207,14 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.Diagnostics.UnitTests
int a = 5 - "2"; int a = 5 - "2";
} }
} }
</Document> </Document>
</Project> </Project>
<Project Language="Visual Basic" CommonReferences="true"> <Project Language="Visual Basic" CommonReferences="true">
<Document FilePath="Test.vb"> <Document FilePath="Test.vb">
Class GooClass Class GooClass
Sub Blah() End Sub Sub Blah() End Sub
End Class End Class
</Document> </Document>
</Project> </Project>
</Workspace> </Workspace>
...@@ -311,8 +310,6 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.Diagnostics.UnitTests ...@@ -311,8 +310,6 @@ Namespace Microsoft.CodeAnalysis.Editor.Implementation.Diagnostics.UnitTests
Private Function GetDiagnosticProvider(workspace As TestWorkspace) As DiagnosticAnalyzerService Private Function GetDiagnosticProvider(workspace As TestWorkspace) As DiagnosticAnalyzerService
Dim snapshot = workspace.CurrentSolution Dim snapshot = workspace.CurrentSolution
Dim notificationService = New TestForegroundNotificationService()
Dim compilerAnalyzersMap = DiagnosticExtensions.GetCompilerDiagnosticAnalyzersMap().Add( Dim compilerAnalyzersMap = DiagnosticExtensions.GetCompilerDiagnosticAnalyzersMap().Add(
NoCompilationConstants.LanguageName, ImmutableArray.Create(Of DiagnosticAnalyzer)(New NoCompilationDocumentDiagnosticAnalyzer())) NoCompilationConstants.LanguageName, ImmutableArray.Create(Of DiagnosticAnalyzer)(New NoCompilationDocumentDiagnosticAnalyzer()))
......
// 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.
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Shared.TestHooks;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.Editor.UnitTests
{
internal class TestForegroundNotificationService : IForegroundNotificationService
{
private readonly object _gate = new object();
private readonly List<Task> _tasks = new List<Task>();
private readonly TaskQueue _queue = new TaskQueue(AsynchronousOperationListenerProvider.NullListener, TaskScheduler.Default);
public void RegisterNotification(Func<bool> action, IAsyncToken asyncToken, CancellationToken cancellationToken = default)
{
RegisterNotification(action, 0, asyncToken, cancellationToken);
}
#pragma warning disable CS0618 // Type or member is obsolete (ScheduleTaskInProgress: https://github.com/dotnet/roslyn/issues/42742)
public void RegisterNotification(Func<bool> action, int delayInMS, IAsyncToken asyncToken, CancellationToken cancellationToken = default)
{
Task task;
lock (_gate)
{
task = _queue.ScheduleTaskInProgress(() => Execute_NoLock(action, asyncToken, cancellationToken), cancellationToken);
_tasks.Add(task);
}
task.Wait(cancellationToken);
}
private void Execute_NoLock(Func<bool> action, IAsyncToken asyncToken, CancellationToken cancellationToken)
{
if (action())
{
asyncToken.Dispose();
}
else
{
_tasks.Add(_queue.ScheduleTaskInProgress(() => Execute_NoLock(action, asyncToken, cancellationToken), cancellationToken));
}
}
public void RegisterNotification(Action action, IAsyncToken asyncToken, CancellationToken cancellationToken = default)
{
RegisterNotification(action, 0, asyncToken, cancellationToken);
}
public void RegisterNotification(Action action, int delayInMS, IAsyncToken asyncToken, CancellationToken cancellationToken = default)
{
Task task;
lock (_gate)
{
task = _queue.ScheduleTaskInProgress(action, cancellationToken).CompletesAsyncOperation(asyncToken);
_tasks.Add(task);
}
task.Wait(cancellationToken);
}
#pragma warning restore
}
}
...@@ -11,7 +11,6 @@ Imports Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces ...@@ -11,7 +11,6 @@ Imports Microsoft.CodeAnalysis.Editor.UnitTests.Workspaces
Imports Microsoft.CodeAnalysis.Test.Utilities Imports Microsoft.CodeAnalysis.Test.Utilities
Imports Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem Imports Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem
Imports Microsoft.VisualStudio.LanguageServices.Implementation.TaskList Imports Microsoft.VisualStudio.LanguageServices.Implementation.TaskList
Imports Microsoft.VisualStudio.LanguageServices.UnitTests.ProjectSystemShim.Framework
Imports Roslyn.Test.Utilities Imports Roslyn.Test.Utilities
Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.ProjectSystemShim Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.ProjectSystemShim
......
...@@ -46,7 +46,7 @@ private IAsyncToken BeginOperation(string taskName) ...@@ -46,7 +46,7 @@ private IAsyncToken BeginOperation(string taskName)
} }
#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods (Task wrappers, not asynchronous methods) #pragma warning disable VSTHRD200 // Use "Async" suffix for async methods (Task wrappers, not asynchronous methods)
#pragma warning disable CS0618 // Type or member is obsolete (https://github.com/dotnet/roslyn/issues/42742)
/// <summary> /// <summary>
/// Enqueue specified <paramref name="operation"/> and notify <see cref="Listener"/> of its start and completion. /// Enqueue specified <paramref name="operation"/> and notify <see cref="Listener"/> of its start and completion.
/// </summary> /// </summary>
...@@ -72,8 +72,7 @@ public Task<T> ScheduleTask<T>(string taskName, Func<Task<T>> operation, Cancell ...@@ -72,8 +72,7 @@ public Task<T> ScheduleTask<T>(string taskName, Func<Task<T>> operation, Cancell
/// </summary> /// </summary>
/// <returns>The <see cref="Task"/> that executes the operation.</returns> /// <returns>The <see cref="Task"/> that executes the operation.</returns>
[PerformanceSensitive("https://developercommunity.visualstudio.com/content/problem/854696/changing-target-framework-takes-10-minutes-with-10.html", AllowCaptures = false)] [PerformanceSensitive("https://developercommunity.visualstudio.com/content/problem/854696/changing-target-framework-takes-10-minutes-with-10.html", AllowCaptures = false)]
[Obsolete("Should be private: https://github.com/dotnet/roslyn/issues/42742")] private Task ScheduleTaskInProgress(Action operation, CancellationToken cancellationToken)
public Task ScheduleTaskInProgress(Action operation, CancellationToken cancellationToken)
{ {
lock (_gate) lock (_gate)
{ {
...@@ -85,8 +84,7 @@ public Task ScheduleTaskInProgress(Action operation, CancellationToken cancellat ...@@ -85,8 +84,7 @@ public Task ScheduleTaskInProgress(Action operation, CancellationToken cancellat
/// <inheritdoc cref="ScheduleTaskInProgress(Action, CancellationToken)"/> /// <inheritdoc cref="ScheduleTaskInProgress(Action, CancellationToken)"/>
[PerformanceSensitive("https://developercommunity.visualstudio.com/content/problem/854696/changing-target-framework-takes-10-minutes-with-10.html", AllowCaptures = false)] [PerformanceSensitive("https://developercommunity.visualstudio.com/content/problem/854696/changing-target-framework-takes-10-minutes-with-10.html", AllowCaptures = false)]
[Obsolete("Should be private: https://github.com/dotnet/roslyn/issues/42742")] private Task<T> ScheduleTaskInProgress<T>(Func<T> operation, CancellationToken cancellationToken)
public Task<T> ScheduleTaskInProgress<T>(Func<T> operation, CancellationToken cancellationToken)
{ {
lock (_gate) lock (_gate)
{ {
...@@ -98,8 +96,7 @@ public Task<T> ScheduleTaskInProgress<T>(Func<T> operation, CancellationToken ca ...@@ -98,8 +96,7 @@ public Task<T> ScheduleTaskInProgress<T>(Func<T> operation, CancellationToken ca
/// <inheritdoc cref="ScheduleTaskInProgress(Action, CancellationToken)"/> /// <inheritdoc cref="ScheduleTaskInProgress(Action, CancellationToken)"/>
[PerformanceSensitive("https://developercommunity.visualstudio.com/content/problem/854696/changing-target-framework-takes-10-minutes-with-10.html", AllowCaptures = false)] [PerformanceSensitive("https://developercommunity.visualstudio.com/content/problem/854696/changing-target-framework-takes-10-minutes-with-10.html", AllowCaptures = false)]
[Obsolete("Should be private: https://github.com/dotnet/roslyn/issues/42742")] private Task ScheduleTaskInProgress(Func<Task> operation, CancellationToken cancellationToken)
public Task ScheduleTaskInProgress(Func<Task> operation, CancellationToken cancellationToken)
{ {
lock (_gate) lock (_gate)
{ {
...@@ -111,8 +108,7 @@ public Task ScheduleTaskInProgress(Func<Task> operation, CancellationToken cance ...@@ -111,8 +108,7 @@ public Task ScheduleTaskInProgress(Func<Task> operation, CancellationToken cance
/// <inheritdoc cref="ScheduleTaskInProgress(Action, CancellationToken)"/> /// <inheritdoc cref="ScheduleTaskInProgress(Action, CancellationToken)"/>
[PerformanceSensitive("https://developercommunity.visualstudio.com/content/problem/854696/changing-target-framework-takes-10-minutes-with-10.html", AllowCaptures = false)] [PerformanceSensitive("https://developercommunity.visualstudio.com/content/problem/854696/changing-target-framework-takes-10-minutes-with-10.html", AllowCaptures = false)]
[Obsolete("Should be private: https://github.com/dotnet/roslyn/issues/42742")] private Task<T> ScheduleTaskInProgress<T>(Func<Task<T>> operation, CancellationToken cancellationToken)
public Task<T> ScheduleTaskInProgress<T>(Func<Task<T>> operation, CancellationToken cancellationToken)
{ {
lock (_gate) lock (_gate)
{ {
...@@ -121,6 +117,7 @@ public Task<T> ScheduleTaskInProgress<T>(Func<Task<T>> operation, CancellationTo ...@@ -121,6 +117,7 @@ public Task<T> ScheduleTaskInProgress<T>(Func<Task<T>> operation, CancellationTo
return task; return task;
} }
} }
#pragma warning restore #pragma warning restore
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册