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

Upgrade analyzer version to 0.1.1-dev.20230613.1 #37037

Closed
wants to merge 27 commits into from

Conversation

pshao25
Copy link
Member

@pshao25 pshao25 commented Jun 15, 2023

@azure-pipelines
Copy link

Pull request contains merge conflicts.

@pshao25
Copy link
Member Author

pshao25 commented Jul 31, 2023

/azp run net - compute - mgmt

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

public virtual AsyncPageable<AssetConversion> GetConversionsAync(CancellationToken cancellationToken = default)
#pragma warning restore AZC0004 // DO provide both asynchronous and synchronous variants for all service methods.
{
Copy link
Member Author

Choose a reason for hiding this comment

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

There is a typo here GetConversionsAync should be GetConversionsAsync. Therefore these two async/sync pair cannot find each other. I have to suppress here. This library is GAed.

Copy link
Member

Choose a reason for hiding this comment

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

Thank you for finding this! It might be helpful to file an issue for this library to let them know - they could introduce a correctly-spelled method and mark the misspelled one with "EditorBrowsableState.Never"

@@ -811,7 +815,7 @@ private void SetNameFieldsIfNull()
/// </remarks>
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual async Task<Response<BlobDownloadInfo>> DownloadAsync(
CancellationToken cancellationToken) =>
CancellationToken cancellationToken = default) =>
await DownloadAsync(
Copy link
Member Author

Choose a reason for hiding this comment

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

It's corresponding sync method Download has optional CancellationToken.

@@ -1875,7 +1883,7 @@ private void SetNameFieldsIfNull()
/// </list>
/// </remarks>
public virtual async Task<Response<BlobDownloadResult>> DownloadContentAsync(
CancellationToken cancellationToken) =>
CancellationToken cancellationToken = default) =>
Copy link
Member Author

Choose a reason for hiding this comment

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

It's corresponding sync method DownloadContent has optional cancellationToken.

public virtual async Task<Response<bool>> GroupExistsAsync(string group, RequestContext context = default)
#pragma warning restore AZC0018 // Protocol method should take a RequestContext parameter called `context` and not use a model as parameter or return types.
{
Copy link
Member Author

Choose a reason for hiding this comment

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

I don't know why there is a RequestContext and a Response<bool>. But this one is GAed. I have to suppress.

Copy link
Member

Choose a reason for hiding this comment

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

I think we allow this one for HEAD requests -- it would be worth checking the generator code to confirm my memory that this is what the generator will write in all cases for a HEAD request . It might make sense to update the PR for this so it doesn't confuse client authors in the future, but I'm happy for us to track this as future work in a separate issue.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, you are correct. I fixed in this PR.

@@ -2316,7 +2328,9 @@ private void SetNameFieldsIfNull()
/// A <see cref="RequestFailedException"/> will be thrown if
/// a failure occurs.
/// </remarks>
#pragma warning disable AZC0002 // Client method should have an optional CancellationToken (both name and it being optional matters) or a RequestContext as the last parameter.
Copy link
Member

Choose a reason for hiding this comment

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

I am happy to see these being added in line, rather than in a GlobalSuppressions file, because it means the analyzer will still catch issues in the future. Out of curiosity, what has changed in the analyzer for AZC0002 that made it start catching these where it didn't before? For these overloads that call through to a method that takes a cancellation token, could we identify those in the analyzer? I think the goal of the analyzer is to ensure that there is an overload that takes a cancellation token in the public API.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I changed the logic to look for overloads. Then the suppression could be removed.

@@ -2355,9 +2371,11 @@ private void SetNameFieldsIfNull()
/// A <see cref="RequestFailedException"/> will be thrown if
/// a failure occurs.
/// </remarks>
#pragma warning disable AZC0002 // Client method should have an optional CancellationToken (both name and it being optional matters) or a RequestContext as the last parameter.
Copy link
Member

Choose a reason for hiding this comment

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

Would it be possible to make this cancellationToken optional, or would that be a breaking change?

Why must the cancellationToken be optional if there is an overload that doesn't take one?

@@ -2799,7 +2799,9 @@ public new DataLakeFileClient WithCustomerProvidedKey(Models.DataLakeCustomerPro
/// A <see cref="RequestFailedException"/> will be thrown if
/// a failure occurs.
/// </remarks>
#pragma warning disable AZC0002 // Client method should have an optional CancellationToken (both name and it being optional matters) or a RequestContext as the last parameter.
Copy link
Member

Choose a reason for hiding this comment

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

These look like valid exemptions - do we know why the analyzer didn't catch this one before?

@@ -10,7 +10,7 @@ public partial class ChatClient
protected ChatClient() { }
public ChatClient(System.Uri endpoint, Azure.Communication.CommunicationTokenCredential communicationTokenCredential, Azure.Communication.Chat.ChatClientOptions options = null) { }
public virtual Azure.Response<Azure.Communication.Chat.CreateChatThreadResult> CreateChatThread(string topic, System.Collections.Generic.IEnumerable<Azure.Communication.Chat.ChatParticipant> participants, string idempotencyToken = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Communication.Chat.CreateChatThreadResult>> CreateChatThreadAsync(string topic, System.Collections.Generic.IEnumerable<Azure.Communication.Chat.ChatParticipant> participants = null, string idempotencyToken = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Communication.Chat.CreateChatThreadResult>> CreateChatThreadAsync(string topic, System.Collections.Generic.IEnumerable<Azure.Communication.Chat.ChatParticipant> participants, string idempotencyToken = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
Copy link
Member

Choose a reason for hiding this comment

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

Is this a breaking change to a GA library?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it is OK. See #37037 (comment)

Copy link
Member

Choose a reason for hiding this comment

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

@tg-msft, can you confirm this is an acceptable change?

Copy link
Member

Choose a reason for hiding this comment

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

Given that we're effectively replacing a runtime NullRefEx with a compile time break per https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/communication/Azure.Communication.Chat/src/ChatClient.cs#L59-L95, I think we should take this.

+@glorialimicrosoft as an FYI of the change and that we might also want an Argument.AssertNotNull(participants, nameof(participants)) here (which isn't considered breaking to add either).

Copy link
Member

@heaths heaths left a comment

Choose a reason for hiding this comment

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

LGTM for my owned files now

@m-nash
Copy link
Member

m-nash commented Aug 15, 2023

@pshao25 I assume we can close this since we have simplified it into this one? #38207

@github-actions
Copy link

Hi @pshao25. 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.

@github-actions github-actions bot added the no-recent-activity There has been no recent activity on this issue. label Oct 20, 2023
@pshao25 pshao25 closed this Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

6 participants