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

C# needs real unit/void support #4102

Merged
merged 2 commits into from
Oct 16, 2018

Conversation

davkean
Copy link
Member

@davkean davkean commented Oct 11, 2018

Add Task overloads for downstream consumers (latter PR)

@davkean davkean requested a review from a team as a code owner October 11, 2018 01:26
@davkean davkean changed the title C# needs a real unit/void support C# needs real unit/void support Oct 11, 2018
Copy link
Member

@drewnoakes drewnoakes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree it would often be nicer to have a void type that the type system understood.

@@ -71,6 +108,30 @@ protected Task ExecuteUnderLockAsync(Func<CancellationToken, Task> action, Cance
return ExecuteUnderLockCoreAsync(action, cancellationToken);
}

private async Task<T> ExecuteUnderLockCoreAsync<T>(Func<CancellationToken, Task<T>> action, CancellationToken cancellationToken = default)
{
Requires.NotNull(action, nameof(action));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Callers already check this. Can remove one or the other.

@@ -71,6 +108,30 @@ protected Task ExecuteUnderLockAsync(Func<CancellationToken, Task> action, Cance
return ExecuteUnderLockCoreAsync(action, cancellationToken);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you could merge the two ExecuteUnderLockCoreAsync methods, keeping only the generic Task<T> overload and passing a lambda here that produces an ignored return value. Would that introduce significant overhead?

@davkean davkean merged commit 477fc48 into dotnet:features/LanguageService Oct 16, 2018
@davkean davkean deleted the ActiveContext branch July 3, 2019 02:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants