DotNetAnalyzers / AsyncUsageAnalyzers

Now superseded by Microsoft/vs-threading
https://github.com/Microsoft/vs-threading
Other
121 stars 18 forks source link

Proposal: Properties should not be of type Task or Task<T> #23

Open vweijsters opened 9 years ago

vweijsters commented 9 years ago

Inspired by #21:

Properties should not be of type Task or Task<T>. Most people perceive properties as near instantaneous (synchronous) operations. Task and Task<T> are associated with asynchronous operations and should therefore not be used as property types, as this does not match with the expectations of the majority of developers.

ChrSteinert commented 9 years ago

While this is old, is it still up for debate?

sharwell commented 9 years ago

@ChrSteinert Sure, feedback is always welcome. :smile:

ChrSteinert commented 9 years ago

Ok, so here I go :wink:

Having a Task as the type of a property must not always be a "bad" thing. I remember some custom task runner I once wrote (with retry policies and stuff). At least the internal bits had Tasks as fields and properties. This scenario seems small, so I'd rather vote for a warning. Also, even in this scenario, having a property, which, by the semantics of a property, is supposed to be publicly exposed, with type task seems worth a warning for above mentioned reasons. So pleas, let's make it a thing ;)