-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Source Generator Analyzer Rules (#1048)
Add analyzer rules for the source-generated function metadata preview
- Loading branch information
Showing
6 changed files
with
100 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# AZFW0005: Multiple Azure Functions Binding Attributes grouped together | ||
|
||
| | Value | | ||
|-|-| | ||
| **Rule ID** |AZFW0005| | ||
| **Category** |[AzureFunctionsSyntax]| | ||
| **Severity** |Error| | ||
|
||
## Cause | ||
|
||
This rule is triggered when multiple Azure Functions Binding Attributes are grouped together on a method, parameter, or property syntax. | ||
|
||
## Rule description | ||
|
||
Azure Functions Binding Attributes are used to decorate a method, parameter, or property syntax. Only one binding can be associated with any syntax. | ||
|
||
## How to fix violations | ||
|
||
If you have multiple bindings on a property syntax, refactor your code to create new properties to handle the different bindings. Create only one binding per property. | ||
|
||
If you have multiple bindings on a parameter syntax, refactor your code to add new parameters to handle the different bindings. Create only one binding per parameter. | ||
|
||
If you have multiple bindings on a method, create a custom return type with the Output Binding attributes decorating the custom return type's properties. Create only one binding per property. See the documented guidance for [multiple Output Bindings](https://learn.microsoft.com/en-us/azure/azure-functions/dotnet-isolated-process-guide#multiple-output-bindings) for more information. | ||
|
||
## When to suppress warnings | ||
|
||
This rule should not be suppressed because this error will prevent your Azure Functions from running. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# AZFW0006: Symbol Not Found | ||
|
||
| | Value | | ||
|-|-| | ||
| **Rule ID** |AZFW0006| | ||
| **Category** |[AzureFunctionsSyntax]| | ||
| **Severity** |Warning| | ||
|
||
## Cause | ||
|
||
This rule is triggered when a Symbol necessary for Azure Function metadata generation cannot be found in the user compilation. | ||
|
||
## Rule description | ||
|
||
Symbols are searched for and loaded from the user compilation to gather Function metadata information. If the are not found, then the user's Azure Function will not run. | ||
|
||
## How to fix violations | ||
|
||
Make sure you have added all necessary imports to your compilation. | ||
|
||
## When to suppress warnings | ||
|
||
This rule should not be suppressed because this error will prevent your Azure Functions from running. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# AZFW0007: Multiple HTTP response binding types for Azure Function | ||
|
||
| | Value | | ||
|-|-| | ||
| **Rule ID** |AZFW0007| | ||
| **Category** |[AzureFunctionsSyntax]| | ||
| **Severity** |Error| | ||
|
||
## Cause | ||
|
||
This rule is triggered when there are multiple HTTP response binding types associated with an Azure Function. | ||
|
||
## Rule description | ||
|
||
Each Azure Function can have only one HTTP response binding type. | ||
|
||
## How to fix violations | ||
|
||
Make sure you have only one HTTP response binding type associated with an Azure Function. If you have a custom return type, please check all of the properties to verify that there is only one HTTP response binding type. | ||
|
||
## When to suppress warnings | ||
|
||
This rule should not be suppressed because this error will prevent your Azure Functions from running. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# AZFW0008: Invalid EventHubs Trigger | ||
|
||
| | Value | | ||
|-|-| | ||
| **Rule ID** |AZFW0008| | ||
| **Category** |[AzureFunctionsSyntax]| | ||
| **Severity** |Error| | ||
|
||
## Cause | ||
|
||
This rule is triggered when the EventHubs trigger of an Azure Function is invalid. | ||
|
||
## Rule description | ||
|
||
EventHubs triggers must correctly declare a compatible "IsBatched" value and parameter input type. For example, for EventHubs triggers where `IsBatched = true`, the input parameter type must be an iterable collection. | ||
|
||
_**Note:**_ The default value of IsBatched is true. If you are not explicitly providing a value, the parameter type should be a collection type. | ||
|
||
## How to fix violations | ||
|
||
If you have an EventHubs trigger where `IsBatched = true` (it is true by default), make sure your input parameter type is an iterable collection. | ||
|
||
## When to suppress warnings | ||
|
||
This rule should not be suppressed because this error will prevent your Azure Functions from running. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters