Roslyn analyzers for common Azure Functions patterns.
| 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 |
class UserGetter
{
[{|#0:Function("GetUsers")|}] // warning: Class name 'UserGetter' does not match function name 'GetUsers', expected 'GetUsersFunction'
public void Run()
{
//...
}
}[Function("GetUsers")]
public void Run(FunctionContext context)
{
var logger = {|#0:context.GetLogger("GetUsersFunction")|}; // warning: 'logger' should be typed 'ILogger<GetUsersFunction>' instead of 'ILogger'
//...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'
//...
}
}