Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regenerate CDN SDK for Swagger bugfixes. #16481

Closed
wants to merge 3 commits into from

Conversation

fore5fire
Copy link
Contributor

Regenerates the CDN SDK to include the following fixes: Azure/azure-rest-api-specs#11046, Azure/azure-rest-api-specs#10950

/// <param name="transforms">List of transforms</param>
public CookiesMatchConditionParameters(string selector, string operatorProperty, IList<string> matchValues, bool? negateCondition = default(bool?), IList<string> transforms = default(IList<string>))
public CookiesMatchConditionParameters(string operatorProperty, string selector = default(string), bool? negateCondition = default(bool?), IList<string> matchValues = default(IList<string>), IList<string> transforms = default(IList<string>))
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to a be a breaking change. A caller passing in string, string, Ilist, bool into this will now fail since the 3rd parameter is now a bool and not an IList.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, you're right. Unfortunately it's a bug that needs to be fixed, and this wasn't a breaking change for the REST API specs since REST parameters aren't positional, so it has already been accepted there. What's the procedure for getting a breaking change released?

Copy link
Member

@bquantump bquantump Nov 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Swapping the params around in swagger ought to fix it, since you are just swapping around optional params.

Since swagger is merged, may be able to do some customization.

Customization options are here:

https://github.com/Azure/autorest.csharp#customizing-the-generated-code

If you do customization, follow the path structure as is done in DNS:

https://github.com/Azure/azure-sdk-for-net/tree/master/sdk/dns/Azure.ResourceManager.Dns/src

Basically can make your custom class, it won't build because naming conflicts, but then re-run the generator and should pick this customization file up and regenerate based on it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've done some work trying to use a customization to correct this issue, but it seems that only data plane libraries are currently using customizations, and I'm having a difficult time referencing Azure.Core like in the example you provided as required by the autorest .Net code generator for removing the backwards-incompatible constructor.

Are customizations of generated code supported for management modules? Adding Azure.Core requires different .Net versions than the management modules are supposed to reference, as stated in CONTRIBUTING.md.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example I gave of DNS is management, although it is track 2.

I think all that may need done is to make a file call /Customization/Models/CookiesMatchConditionParameters.cs

And then in there, change CookiesMatchConditionParameters to:

public CookiesMatchConditionParameters(string selector, string selector = default(string), IList matchValues = default(IList), bool? negateCondition = default(bool?), IList transforms = default(IList))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh I see, the difference between track 2 management and data plane wasn't quite clear from the doc I read, makes sense though.

Your solution will work as long as you're ok with having redundant constructors - The issue with importing Azure.Core only applies for deleting the non backwards compatible constructor. I'll push the change with both constructors, just let me know if that isn't acceptable.

/// or not</param>
/// <param name="transforms">List of transforms</param>
public CookiesMatchConditionParameters(string selector = null, string operatorProperty = null, IList<string> matchValues = null, bool? negateCondition = null, IList<string> transforms = null)
{
Copy link
Member

@bquantump bquantump Nov 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would think we would do this here:

public CookiesMatchConditionParameters(string operatorProperty, string selector = default(string), IList<string> matchValues = default(IList<string>), bool? negateCondition = default(bool?), IList<string> transforms = default(IList<string>))
{
      this.CookiesMatchConditionParameters(operatorProperty, selector, negateCondition, matchValues, transforms);
}

I the this.CookiesMatchConditionParameters above should also be defined here identical to the generated one but marked internal so it is not exposed outside of this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work with Autorest C# v2 generator? I'm able to add the new constructor because that doesn't require any change for the generated code, but the generator isn't removing the existing constructor when I replace it with an internal one in my customizations partial class. I can't find any documentation about customization using v2 of the C# generator, only for v3.

@fore5fire
Copy link
Contributor Author

@bquantump, does the Autorest C# v2 generator support customizations? I can't find any customization documentation for it, only for v3, and it doesn't appear to respond to any of the v3 customizations.

@bquantump
Copy link
Member

@bquantump Steve Schilinski FTE, does the Autorest C# v2 generator support customizations? I can't find any customization documentation for it, only for v3, and it doesn't appear to respond to any of the v3 customizations.

hmm, yes it looks like it won't work in V2.

So I guess let's try writing a few test cases here to test the new constructor you made the new generated one which utilized both optional and non-optional parameters.

@bquantump bquantump assigned allenjzhang and unassigned bquantump Dec 8, 2020
@fore5fire fore5fire requested a review from bquantump December 9, 2020 04:53
@jsquire
Copy link
Member

jsquire commented Jan 8, 2021

Hi @bquantump. There hasn't been recent engagement on this PR. Would you please be so kind as to let us know if this is still an active work stream or if the PR should be closed out?

@jsquire jsquire added the no-recent-activity There has been no recent activity on this issue. label Jan 8, 2021
@jsquire
Copy link
Member

jsquire commented Jan 15, 2021

Since there hasn't been recent engagement, I'm going to close this out. Please feel free to reopen if you'd like to continue working on these changes.

@jsquire jsquire closed this Jan 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change no-recent-activity There has been no recent activity on this issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants