navigation

AsynchronousFunctionNames (FL0096)

Introduced in 0.26.12

Cause

Function that is asynchronous (returns Async or Task) doesn't have Async prefix (in case of Async) or suffix (in case of Task).

Rationale

By convention, Async prefix or suffix in function name means that the function is asyncronous.

Prefix is used for functions that return Async type, e.g.:

let AsyncFoo(): Async<int> =
    async { return 1 }

Suffix is used for functions that return System.Threading.Task type, e.g.:

open System.Threading

let FooAsync(): Task<int> =
    task { return 1 }

How To Fix

Add Async prefix (in case of Async) or suffix (in case of Task) to function name.

Rule Settings

{
    "asynchronousFunctionNames": { 
        "enabled": true,
        "config": {
            "mode": "OnlyPublicAPIsInLibraries"
        }
    }
}
  • mode - determines what functions are checked. Possible values: "OnlyPublicAPIsInLibraries", "AnyPublicAPIs", "AllAPIs".
    • "OnlyPublicAPIsInLibraries" only runs in projects that are likely library projects.
    • "AnyPublicAPIs" flags all public APIs.
    • "AllAPIs" also flags (gives violations about) internal, private, and nested APIs.