Azure / Azure/azure-functions-powershell-library

Bug bash: Parameter location is locked to param block in function

Open
#41 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
2
Forks
10
PR merge metrics
No merged PRs in 30d

Description

I was playing with parameter location for the new programming model.

This is the base I started from (which works):

```powershell
function HttpTriggerMinimal {
[Function()]
param(
[HttpTrigger()]
$Request,
$TriggerMetadata
)

$value = ([HttpResponseContext]@{
StatusCode = [HttpStatusCode]::OK
Body = 'New Programming Model rules! (Hero executed)'
})
$value | Push-OutputBinding -Name Response
}
```

However, I don't tend to do param blocks for functions. I like having it all as part of the signature, and the opening brace '{' indicates the start of the actual function body. The following does not work, but should, I think:

```powershell
function HttpTriggerMinimal(
[HttpTrigger()] $Request,
$TriggerMetadata
) {
[Function()]

$value = ([HttpResponseContext]@{
StatusCode = [HttpStatusCode]::OK
Body = 'New Programming Model rules! (Hero executed)'
})
$value | Push-OutputBinding -Name Response
}
```

I also don't love having the attribute sitting inside the braces, and it's especially odd given that the `HttpTrigger` attribute is really scoped within the `Function` attribute, but we require the attribute within the scope, which I think is normal for PowerShell, but it feels a little odd here.

Because we're doing module stuff, I also wonder if `Export-ModuleMember` would be the way to handle the Function attribute injection somehow. That doesn't help with the script style of things, but there, the existing model is fine. For some reason having that within the same scope doesn't bother me as much as it does within a function definition.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing how the new programming model processes the two shown PowerShell function forms, including Function and HttpTrigger attribute placement and the possible Export-ModuleMember path. Done means parameter attributes are handled consistently for signature-style functions as well as param blocks, with the expected behavior established for both examples.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell
Domain
backend, cloud
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.