Azure / Azure/autorest.powershell
Remove/refactor/fix 'Class name removal from property name' feature
- Dominant language
- C#
- Stars
- 123
- Forks
- 99
- PR merge metrics
- No merged PRs in 30d
Description
There are at least 2 issues I've found so far.
# 1st issue
So, it seems that 'RouteName' becomes 'Name' in the non-expanded parameter set, but stays 'RouteName' in the expanded, because Name is an optional parameter. So, the parameter sets mis-align, and seems to cause issues. I need to look a bit further. To fix it, I can rename stuff per variant, which will work for now.
The key takeaway.... and a big problem. We don't have parameter names align between parameter sets. Meaning, the expand process needs to be aware of what parameters need to stay certain names. I think this auto-'Name' conversion thing is basically the issue. It makes this quite complicated for this specific situation.
Yeah, the only way to fix it was to rename the incorrect 'Name' parameter only in the expanded variants, because the non-expanded had it correctly.
```yaml
- where: # This parameter needs removed
verb: ^New$|^Set$
subject: RouteTableRoute
variant: ^CreateExpanded$|^CreateExpanded1$|^CreateViaIdentityExpanded$|^CreateViaIdentityExpanded1$|^UpdateExpanded$|^UpdateExpanded1$
parameter-name: Name
set:
parameter-name: ResourceName
- where:
subject: RouteTableRoute
parameter-name: RouteName
set:
parameter-name: Name
alias: RouteName
```
# 2nd issue
So, here is (yet another issue) the 'Name thing' does. So, the 'Name thing' doesn't act on only names. It acts on all properties. It checks to see if the name starts with the class name (in this case VpnGateway), and removes that part of the name if it doesn't clash. HOWEVER, the composition of that thing (meaning, it had Properties that got rolled up into it) WON'T have this logic ran on it, because the name of that thing is VpnGatewayProperties. So, in this case, the names aren't the same for the same thing. I think this also causes some issues in the expanded parameter set.

# Other
I believe this feature is causing other issues, such as https://github.com/Azure/autorest.powershell/issues/454. Any time there is a mismatched set of property/parameter names, might be caused by this feature.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.