Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Bazuzi.AzureFunctionAnalyzers

NuGet NuGet Downloads Build and Test

Roslyn analyzers for common Azure Functions patterns.

Rules

Id Title
AZURE_FUNCTIONS_0001 Function class name should match the function name
AZURE_FUNCTIONS_0002 Prefer ILogger<T> over ILogger
AZURE_FUNCTIONS_0003 Prefer injecting ILogger<T> over FunctionContext.GetLogger()
AZURE_FUNCTIONS_0004 Class should contain only one Azure Function
AZURE_FUNCTIONS_0005 Route constraint is incompatible with the parameter type

Examples

class UserGetter
{
    [{|#0:Function("GetUsers")|}] // warning: Class name 'UserGetter' does not match function name 'GetUsers', expected 'GetUsersFunction'
    public void Run()
    {
        //...
    }
}

snippet source | anchor

[Function("GetUsers")]
public void Run(FunctionContext context)
{
    var logger = {|#0:context.GetLogger("GetUsersFunction")|};  // warning: 'logger' should be typed 'ILogger<GetUsersFunction>' instead of 'ILogger'
    //...

snippet source | anchor

class GetUsersFunction
{
    [Function("GetUsers")]
    public void Run(FunctionContext context)
    {
        var logger = {|#0:context.GetLogger<GetUsersFunction>()|};  // warning: Use constructor-injected ILogger<GetUsersFunction> instead of calling 'GetLogger'
        //...
    }
}

snippet source | anchor

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages