Description
Description
When dealing with F#-async workflows and exposing these APIs as public, we often forget about our C#-dev friends (that prefer Task-based alternatives, which should be suffixed with "Async").
Now, if there's already a FooAsync(): Task<'Bar>
method, this rule should also suggest adding F#-friendly AsyncFoo(): Async<'Bar>
.
Testcases
module Foo =
let AsyncBar(): Async<int> =
async { return 0 }
Should give linter warning offering creation of BarAsync(): Task<int>
.
module Foo =
let private AsyncBar(): Async<int> =
async { return 0 }
Should not give any linter warnings (because it's not public).
module Foo =
let internal AsyncBar(): Async<int> =
async { return 0 }
Should not give any linter warnings (because it's not public).
module Foo =
let AsyncBar(): Async<int> =
async { return 0 }
let BarAsync(): Task<int> =
null
Should not give any linter warnings (because it complies with conventions).
module Foo =
let Bar(): Async<int> =
{ return 1 }
Should give linter warning offering creation of BarAsync(): Task<int>
and rename Bar to AsyncBar.
module Foo =
let Bar(): Async<int> =
async { return 0 }
let BarAsync(): Task<int> =
null
Should give linter warning offering renaming Bar to AsyncBar.
module Foo =
let AsyncBar(): int =
1
let BarAsync(): Task<int> =
null
Should give linter warning offering renaming AsyncBar to Bar.
module Foo =
let AsyncBar(): Async<int> =
async { return 0 }
let Bar(): Task<int> =
null
Should give linter warning offering renaming Bar to BarAsync.
module Foo =
let AsyncBar(): Async<unit> =
Async.Sleep 5.0
Should give linter warning offering creation of BarAsync(): Task
(because unit in C# doesn't exist).
module Foo =
let Bar(): Async<unit> =
Async.Sleep 5.0
Should give linter warning offering creation of BarAsync(): Task
(because unit in C# doesn't exist), and rename Bar to AsyncBar.