Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 13, 2025

Problem

This PR fixes a regression introduced in #1508 where the code generator produces invalid C# code when declaring a breaking change with changeInEfectByDate.

The GenericBreakingChangeAttribute constructor has four positional parameters:

public GenericBreakingChangeAttribute(string message, string deprecateByAzVersion, string deprecateByVersion, string changeInEfectByDate)

However, the generator was producing attributes with incorrect parameter ordering:

// BEFORE (invalid - positional arg after named arg):
[GenericBreakingChange("", "10.0.0", "2.0.0", ChangeDescription = "Deprecated", "2025-12-31")]
//                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  ^^^^^^^^^^^^
//                                                   named argument              positional arg
// Error CS1016: Named attribute argument expected

According to the C# language specification, positional arguments must precede named arguments in attribute declarations.

Solution

Reordered the parameter generation in powershell/cmdlets/class.ts to ensure changeInEfectByDate (positional) is added before ChangeDescription (named):

// AFTER (valid - all positional args before named args):
[GenericBreakingChange("", "10.0.0", "2.0.0", "2025-12-31", ChangeDescription = "Deprecated")]
//                                             ^^^^^^^^^^^^  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//                                             positional    named argument

Validation

  • ✅ Generated C# code compiles successfully with 0 errors, 0 warnings
  • ✅ All unit tests pass (3/3)
  • ✅ Comprehensive SDK validation test passes (52/52 test cases)
  • ✅ ESLint validation passes with no errors
  • ✅ Minimal change: only swapped 2 lines of code

The variant and output breaking change sections already had the correct parameter ordering and were not affected.

Fixes the issue reported where breaking change declarations with change-effective-date would cause compilation errors.

Original prompt

This section details on the original issue you should resolve

<issue_title>[Bug] "error CS1016: Named attribute argument expected" when declaring breaking change with "changeInEffectByDate"</issue_title>
<issue_description>Regression introduced by #1508

The constructor of GenericBreakingChangeAttribute has four parameters: string message, string deprecateByAzVersion, string deprecateByVersion, string changeInEfectByDate.
According to spec, the positional arguments (if any) precede the named arguments..

The issue can be fixed by change the order of the parameters at

parameters.push('""');
parameters.push(`"${breakingChange.cmdlet.deprecateByAzVersion}"`);
parameters.push(`"${breakingChange.cmdlet.deprecateByVersion}"`);
parameters.push(`ChangeDescription = "${breakingChange.cmdlet.changeDescription}"`);
if (breakingChange.cmdlet.changeInEfectByDate) parameters.push(`"${breakingChange.cmdlet.changeInEfectByDate}"`);
return new Attribute(ClientRuntime.GenericBreakingChangeAttribute, { parameters: parameters });
</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #1527


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Fix named attribute argument ordering issue Fix CS1016 error: Reorder breaking change attribute parameters to place positional args before named args Oct 13, 2025
Copilot AI requested a review from isra-fel October 13, 2025 03:54
@isra-fel isra-fel marked this pull request as ready for review October 13, 2025 04:14
@VeryEarly VeryEarly merged commit 904bae3 into main Oct 13, 2025
4 checks passed
@VeryEarly VeryEarly deleted the copilot/fix-attribute-parameter-order branch October 13, 2025 04:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] "error CS1016: Named attribute argument expected" when declaring breaking change with "changeInEffectByDate"

3 participants