azure-functions-host
azure-functions-host copied to clipboard
Support C# discard parameters binding
What problem would the feature you're requesting solve? Please describe.
In some cases, the trigger binding parameter is not actually used in the function body, often with TimerTrigger and occasionally HttpRequest where the binding itself has already provided us all the information we need. This unused parameter causes C# analyzers to notify developers that it can be deleted, but obviously it's required for the function to work. Typically a resolution for this would be to make the parameter a discard parameter (named '_', '_1', '_2', etc.), but these names fail the binding name validation check.
Describe the solution you'd like
Allow parameter bindings to be named with a preceding underscore.
Describe alternatives you've considered
Disabling/Ignoring analyzer rule: The rule is on by default, and is usually helpful, so I'd not like to disable it. I can add a pragma ignore for affected functions, but this is frequent enough the ignores would become clutter. Finding a use for the parameter: In the case of Http Triggers, I could do some header inspection to search for correlation id or some other value, which would silence the warning. Correlation Id is a good practice anyway. Does not resolve Timer Trigger issue, however.
Hi @aj-patterson, Thank you for your feedback! We will check for the possibilities internally and update you with the findings.
Hi @aj-patterson, Discussed this request internally, adding this issue as a feature request to consider this in future implementations.
It would also be useful for Python code to accept snake case binding names, as mentioned in the Stack Overflow question What is a valid binding name for azure function?. So, all underscores should be accepted, not preceding ones only.