Skip to content
David Mitchell edited this page Mar 2, 2019 · 1 revision

WorkState.None and WorkState.ToDo must not be used when an IWorkState is available.

WorkState.None and WorkState.ToDo are placeholders that should only be used when no other IWorkState is available.

Some possible sources of IWorkStates include:

  • AsyncWorkItem.Current, for methods that return IEnumerable<AsyncAction>.
  • An instance of IWorkState that is passed as a parameter.
  • A CancellationToken, via WorkState.FromCancellationToken.
  • An AsyncMethodContext, via AsyncMethodContext.WorkState.

This analyzer prohibits the usage of WorkState.None and WorkState.ToDo in methods that return IEnumerable<AsyncAction> and any method that has a parameter that could be used to obtain an IWorkState.

The analyzer does not recurse on call sites of methods that make use of WorkState.None and WorkState.ToDo. When evaluating new code that uses one of these properties, reviewers SHOULD perform this step manually to determine if an IWorkState could be provided to the method.

Clone this wiki locally