Skip to content
Bradley Grainger edited this page Dec 28, 2018 · 6 revisions

AsyncWorkItem.Current must only be used in methods that return IEnumerable.

The only safe location from which to access AsyncWorkItem.Current is from within a method that returns an IEnumerable<AsyncAction>. This analyzer flags any usages outside of that context.

Suggested Fixes

  • If the method in which AsyncWorkItem.Current occurs takes a parameter of type IWorkState, this parameter will be suggested.
  • A new parameter of type IWorkState on the method in which AsyncWorkItem.Current will always be suggested.
  • If the containing method takes a AsyncMethodContext context parameter, then context.WorkState is the correct fix. (This is not currently automatically suggested.)

Limitations

Currently, this analyzer only makes suggestions when AsyncWorkItem.Current is passed as a parameter to another method. If AsyncWorkItem.Current is used as the target of an assignment or in some other context, no suggestions will be provided.

Clone this wiki locally