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

Replace Task.FromResult by Task.CompletedTask #3162

Merged

Conversation

vgromfeld
Copy link
Contributor

@vgromfeld vgromfeld commented Mar 6, 2020

PR Type

What kind of change does this PR introduce?

  • Refactoring (no functional changes, no api changes)

What is the current behavior?

The community toolkit code is using Task.FromResult(0) to create completed task. This is not needed since we can directly use Task.CompletedTask and spare a few allocations.

What is the new behavior?

The Task.CompletedTask instance will now be used for async methods returning a completed task.

PR Checklist

  • Tested code with current supported SDKs
  • Pull Request has been submitted to the documentation repository instructions. Link:
  • Sample in sample app has been added / updated (for bug fixes / features)
  • Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Header has been added to all new source files (run build/UpdateHeaders.bat)
  • Contains NO breaking changes

@ghost
Copy link

ghost commented Mar 6, 2020

Thanks vgromfeld for opening a Pull Request! The reviewers will test the PR and highlight if there is any conflict or changes required. If the PR is approved we will proceed to merge the pull request 🙌

@ghost ghost assigned michael-hawker Mar 6, 2020
Copy link
Contributor

@azchohfi azchohfi left a comment

Choose a reason for hiding this comment

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

This code probably came from a .Net 4.5 equivalent, which don't have that property. Makes total sense to use CompletedTask!

@skendrot skendrot merged commit d85e1a7 into CommunityToolkit:master Mar 9, 2020
@vgromfeld vgromfeld deleted the u/vgromfeld/removeTaskFromResult branch March 9, 2020 16:57
@michael-hawker michael-hawker added this to the 6.1 milestone Mar 24, 2020
@michael-hawker michael-hawker mentioned this pull request Apr 1, 2020
36 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants