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

Fix compile error when Azure SDK is targeting .NET 6. #2245

Merged
merged 18 commits into from
Jan 13, 2023

Conversation

AraHaan
Copy link
Contributor

@AraHaan AraHaan commented May 22, 2022

Description

When I tried to do Azure/azure-sdk-for-net#28911 which basically adds .NET 6 to the .NET Azure SDK, it resulted in compile errors due to the code in this repository. As such this change is a prerequisite of that pr.

Checklist

To ensure a quick review and merge, please ensure:

  • The PR has a understandable title and description explaining the why and what.
  • The PR is opened in draft if not ready for review yet.
    • If opened in draft, please allocate sufficient time (24 hours) after moving out of draft for review
  • The branch is recent enough to not have merge conflicts upon creation.

Ready to Land?

  • Build is completely green
    • Submissions with test failures require tracking issue and approval of a CODEOWNER
  • At least one +1 review by a CODEOWNER
  • All -1 reviews are confirmed resolved by the reviewer
    • Override/Marking reviews stale must be discussed with CODEOWNERS first

@ghost ghost added the customer-reported Issues that are reported by GitHub users external to the Azure organization. label May 22, 2022
@ghost
Copy link

ghost commented May 22, 2022

Thank you for your contribution @AraHaan! We will review the pull request and get back to you soon.

@ghost ghost added the Community Contribution Community members are working on the issue label May 22, 2022
@AraHaan
Copy link
Contributor Author

AraHaan commented May 22, 2022

cc: @annelo-msft for reviews.

@AraHaan
Copy link
Contributor Author

AraHaan commented May 22, 2022

I have made changes above to use the ReadOnlyMemory version of WriteAsync where the framework provides it for Stream when it implements .NET Standard 2.1. Since Core > 2.1 implements it and that the Azure SDK targets .NET Framework, Standard 2.0, Core 3.1, and now .NET 6 I think it should be fine after this.

Copy link
Member

@annelo-msft annelo-msft left a comment

Choose a reason for hiding this comment

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

These are Azure.Core types, one of @christothes, @JoshLove-msft, or myself will need to approve them. @AlexanderSher, @jsquire FYI.

@AraHaan
Copy link
Contributor Author

AraHaan commented May 30, 2022

This should be ready for review, just waiting on when you all have time to review.

@ghost ghost added the no-recent-activity There has been no recent activity on this issue. label Aug 5, 2022
@ghost
Copy link

ghost commented Aug 5, 2022

Hi @AraHaan. Thank you for your interest in helping to improve the Azure SDK experience and for your contribution. We've noticed that there hasn't been recent engagement on this pull request. If this is still an active work stream, please let us know by pushing some changes or leaving a comment. Otherwise, we'll close this out in 7 days.

@AraHaan
Copy link
Contributor Author

AraHaan commented Aug 5, 2022

Still working on this.

@ghost ghost removed the no-recent-activity There has been no recent activity on this issue. label Aug 5, 2022
@AraHaan
Copy link
Contributor Author

AraHaan commented Aug 16, 2022

cc: @annelo-msft any thoughts on anything else that may cause compile errors when targeting .NET 6 on the Azure SDK (before this gets merged and we find that there was some that were missed)?

@ArthurMa1978
Copy link
Member

Thank you @AraHaan for your contribution, let me ping @christothes, @AlexanderSher, @annelo-msft, @JoshLove-msft , @m-nash @jsquire .

Copy link
Member

@jsquire jsquire left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution, @AraHaan!

The changes look good to me. I'll defer to @m-nash for final approval.

src/AutoRest.CSharp/AutoRest.CSharp.csproj Outdated Show resolved Hide resolved
@AraHaan
Copy link
Contributor Author

AraHaan commented Sep 30, 2022

I have made the requested changes.

@archerzz
Copy link
Member

archerzz commented Dec 7, 2022

@AraHaan Sorry for the late response. This PR is different after a series of changes. I have a question: why await stream.WriteAsync(_bytes, 0, _bytes.Length, cancellation).ConfigureAwait(false); doesn't compile under .Net 6? I checked the API doc and it should still work under .Net 6.

Is there any benefit to use await stream.WriteAsync(_bytes.AsMemory(), cancellation).ConfigureAwait(false);? The former one seems more performant. Thanks.

@AraHaan
Copy link
Contributor Author

AraHaan commented Dec 7, 2022

The former still compiles for programs not set to warn as error, but it generates Visual Studio warnings about using the span versions instead of them (and if warnings as error is enabled it ends up emitting errors instead). Also, I think the span ones are a smidge faster as I think the ones without span end up calling into the span ones which could waste at least a few cpu clock cycles when using .NET 6+ (or even the .NET versions that have the span versions of them).

src/AutoRest.CSharp/AutoRest.CSharp.csproj Outdated Show resolved Hide resolved
src/assets/Generator.Shared/FormUrlEncodedContent.cs Outdated Show resolved Hide resolved
src/AutoRest.CSharp/AutoRest.CSharp.csproj Outdated Show resolved Hide resolved
src/assets/Generator.Shared/FormUrlEncodedContent.cs Outdated Show resolved Hide resolved
src/assets/Generator.Shared/FormUrlEncodedContent.cs Outdated Show resolved Hide resolved
src/assets/Generator.Shared/StringRequestContent.cs Outdated Show resolved Hide resolved
src/assets/Generator.Shared/StringRequestContent.cs Outdated Show resolved Hide resolved
@AraHaan
Copy link
Contributor Author

AraHaan commented Jan 10, 2023

github automatically removed the other pending reviewers ^.

@m-nash
Copy link
Member

m-nash commented Jan 10, 2023

@AraHaan branch is out of date with feature/v3 can you please sync to the latest so the CI can run and validate?

@archerzz
Copy link
Member

/azp run autorest.csharp

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@AraHaan
Copy link
Contributor Author

AraHaan commented Jan 11, 2023

I wish I could see why that smoketest is failing.

@archerzz
Copy link
Member

archerzz commented Jan 12, 2023

I wish I could see why that smoketest is failing.

@AraHaan Normally it's due to timeout:

ECONNRESET

I've restarted the failed task.

@archerzz
Copy link
Member

/azp run autorest.csharp

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@m-nash m-nash left a comment

Choose a reason for hiding this comment

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

Changes are fine but branch still says out of date with feature/v3 which will block merge

@archerzz
Copy link
Member

/azp run autorest.csharp

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@archerzz archerzz enabled auto-merge (squash) January 13, 2023 01:37
@archerzz archerzz merged commit 3e79c4f into Azure:feature/v3 Jan 13, 2023
@AraHaan AraHaan deleted the patch-1 branch January 13, 2023 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Azure.Core Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants