Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions docs/analyzer-rules/AZFW0013.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# AZFW0013: Unable to parse binding argument

| | Value |
|-|-|
| **Rule ID** |AZFW0013|
| **Category** |[AzureFunctionsSyntax]|
| **Severity** |Error|

## Cause

This rule is triggered when a binding attribute argument is an invalid or null value.

## Rule description

[Attributes](https://learn.microsoft.com/en-us/dotnet/csharp/advanced-topics/reflection-and-attributes/) are used to define bindings, and the function metadata generator parses the arguments passed into these attributes to generate binding information during start up.

If the arguments passed in are invalid for any reason (such as being null), this rule is enforced.
Comment thread
satvu marked this conversation as resolved.

## How to fix violations

Review the binding attribute.

## When to suppress warnings

This rule should not be suppressed because this error will prevent your functions from running.
7 changes: 7 additions & 0 deletions sdk/Sdk.Generators/DiagnosticDescriptors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,12 @@ private static DiagnosticDescriptor Create(string id, string title, string messa
messageFormat: "Invalid use of a retry attribute. Check that the attribute is used on a trigger that supports function-level retry.",
category: "FunctionMetadataGeneration",
severity: DiagnosticSeverity.Error);
public static DiagnosticDescriptor InvalidBindingAttributeArgument { get; }
Comment thread
satvu marked this conversation as resolved.
= Create(id: "AZFW0013",
title: "Invalid argument in binding attribute.",
messageFormat: "Invalid argument passed in binding attribute. Check that the argument is not null.",
category: "FunctionMetadataGeneration",
severity: DiagnosticSeverity.Error);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,8 @@ private bool TryGetAttributeProperties(AttributeData attributeData, Location? at
}
else
{
// TODO: Log diagnostic error
_context.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.InvalidBindingAttributeArgument, attribLocation));
Comment thread
satvu marked this conversation as resolved.
return false;
}
}
}
Expand Down Expand Up @@ -690,7 +691,8 @@ private bool TryLoadConstructorArguments(AttributeData attributeData, IDictionar
}
else
{
// TODO: Log diagnostic error
_context.ReportDiagnostic(Diagnostic.Create(DiagnosticDescriptors.InvalidBindingAttributeArgument, attributeLocation));
return false;
}
}

Expand Down
3 changes: 2 additions & 1 deletion sdk/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@

### Microsoft.Azure.Functions.Worker.Sdk.Generators <version>

- Parse named arguments by type (#1877)
- Parse named arguments by type (#1877)
- Add diagnostic descriptor logs for parsing binding arguments in source gen (#1882)