Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move to an expeditable delay to help out tests. #67196

Merged
merged 1 commit into from
Mar 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using Microsoft.CodeAnalysis.LanguageService;
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Shared.TestHooks;
using Roslyn.Utilities;

namespace Microsoft.CodeAnalysis.DesignerAttribute
Expand All @@ -30,6 +31,8 @@ internal sealed partial class DesignerAttributeDiscoveryService : IDesignerAttri
/// </summary>
private static readonly ConditionalWeakTable<IReadOnlyList<MetadataReference>, AsyncLazy<bool>> s_metadataReferencesToDesignerAttributeInfo = new();

private readonly IAsynchronousOperationListener _listener;

/// <summary>
/// Protects mutable state in this type.
/// </summary>
Expand All @@ -43,8 +46,9 @@ internal sealed partial class DesignerAttributeDiscoveryService : IDesignerAttri

[ImportingConstructor]
[Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public DesignerAttributeDiscoveryService()
public DesignerAttributeDiscoveryService(IAsynchronousOperationListenerProvider listenerProvider)
{
_listener = listenerProvider.GetListener(FeatureAttribute.DesignerAttributes);
}

private static AsyncLazy<bool> GetLazyHasDesignerCategoryType(Project project)
Expand Down Expand Up @@ -79,7 +83,7 @@ public async ValueTask ProcessSolutionAsync(
await ProcessProjectAsync(priorityDocument.Project, priorityDocument, useFrozenSnapshots, callback, cancellationToken).ConfigureAwait(false);

// Wait a little after the priority document and process the rest at a lower priority.
await Task.Delay(DelayTimeSpan.NonFocus, cancellationToken).ConfigureAwait(false);
await _listener.Delay(DelayTimeSpan.NonFocus, cancellationToken).ConfigureAwait(false);

// Process the rest of the projects in dependency order so that their data is ready when we hit the
// projects that depend on them.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ internal interface IExpeditableDelaySource
/// <para>The <paramref name="delay"/> argument's <see cref="TimeSpan.TotalMilliseconds"/> property is greater than <see cref="int.MaxValue"/>.</para>
/// </exception>
/// <exception cref="OperationCanceledException">The delay has been canceled.</exception>
[SuppressMessage("Style", "VSTHRD200:Use \"Async\" suffix for async methods", Justification = "Named after 'Task.Delay'")]
[SuppressMessage("Style", """VSTHRD200:Use "Async" suffix for async methods""", Justification = "Named after 'Task.Delay'")]
Task<bool> Delay(TimeSpan delay, CancellationToken cancellationToken);
}
}