Skip to content

Commit 172738a

Browse files
authored
Apply analyzer with updated AZC0002 (Azure#38207)
* Apply analyzer with updated AZC0002 * Update * Update * Update * update * Update
1 parent b0f4878 commit 172738a

File tree

28 files changed

+3
-120
lines changed

28 files changed

+3
-120
lines changed

eng/Packages.Data.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@
175175
-->
176176
<ItemGroup>
177177
<PackageReference Update="Microsoft.Azure.AutoRest.CSharp" Version="3.0.0-beta.20230821.3" PrivateAssets="All" />
178-
<PackageReference Update="Azure.ClientSdk.Analyzers" Version="0.1.1-dev.20230131.1" PrivateAssets="All" />
178+
<PackageReference Update="Azure.ClientSdk.Analyzers" Version="0.1.1-dev.20230822.1" PrivateAssets="All" />
179179
<PackageReference Update="coverlet.collector" Version="3.2.0" PrivateAssets="All" />
180180
<PackageReference Update="Microsoft.CodeAnalysis.NetAnalyzers" Version="7.0.1" PrivateAssets="All" />
181181
<PackageReference Update="Microsoft.CodeAnalysis.BannedApiAnalyzers" Version="3.3.2" PrivateAssets="All" />

sdk/anomalydetector/Azure.AI.AnomalyDetector/src/GlobalSuppressions.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@
55

66
[assembly: SuppressMessage("Usage", "AZC0007: A client type should have a public constructor with equivalent parameters that doesn't take a Azure.Core.ClientOptions-derived type as the last argument", Justification = "")]
77
[assembly: SuppressMessage("Usage", "AZC0006: A client type should have a public constructor with equivalent parameters that takes a Azure.Core.ClientOptions-derived type as the last argument", Justification = "")]
8-
[assembly: SuppressMessage("Usage", "AZC0002: Client method should have cancellationToken as the last optional parameter (both name and it being optional matters", Justification = "")]

sdk/appconfiguration/Azure.Data.AppConfiguration/src/ConfigurationClient.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,9 +1423,7 @@ private static RequestContext CreateRequestContext(ErrorOptions errorOptions, Ca
14231423
/// <exception cref="RequestFailedException"> Service returned a non-success status code. </exception>
14241424
/// <returns> The response returned from the service. Details of the response body schema are in the Remarks section below. </returns>
14251425
/// <include file="Generated/Docs/ConfigurationClient.xml" path="doc/members/member[@name='GetConfigurationSettingAsync(String,String,String,IEnumerable,MatchConditions,RequestContext)']/*" />
1426-
#pragma warning disable AZC0002 // DO ensure all service methods, both asynchronous and synchronous, take an optional CancellationToken parameter called cancellationToken.
14271426
internal virtual async Task<Response> GetConfigurationSettingAsync(string key, string label, string acceptDatetime, IEnumerable<string> select, MatchConditions matchConditions, RequestContext context)
1428-
#pragma warning disable AZC0002 // DO ensure all service methods, both asynchronous and synchronous, take an optional CancellationToken parameter called cancellationToken.
14291427
{
14301428
Argument.AssertNotNullOrEmpty(key, nameof(key));
14311429

@@ -1483,9 +1481,7 @@ internal virtual Response GetConfigurationSetting(string key, string label, stri
14831481
/// <exception cref="RequestFailedException"> Service returned a non-success status code. </exception>
14841482
/// <returns> The response returned from the service. Details of the response body schema are in the Remarks section below. </returns>
14851483
/// <include file="Generated/Docs/ConfigurationClient.xml" path="doc/members/member[@name='DeleteConfigurationSettingAsync(String,String,ETag,RequestContext)']/*" />
1486-
#pragma warning disable AZC0002 // DO ensure all service methods, both asynchronous and synchronous, take an optional CancellationToken parameter called cancellationToken.
14871484
internal virtual async Task<Response> DeleteConfigurationSettingAsync(string key, string label, ETag? ifMatch, RequestContext context)
1488-
#pragma warning disable AZC0002 // DO ensure all service methods, both asynchronous and synchronous, take an optional CancellationToken parameter called cancellationToken.
14891485
{
14901486
Argument.AssertNotNullOrEmpty(key, nameof(key));
14911487

sdk/cognitivelanguage/Azure.AI.Language.Conversations/src/Authoring/ConversationAuthoringClient.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,8 @@ public ConversationAuthoringClient(Uri endpoint, TokenCredential credential, Con
176176
///
177177
/// </remarks>
178178
[EditorBrowsable(EditorBrowsableState.Never)]
179-
#pragma warning disable AZC0002 // DO ensure all service methods, both asynchronous and synchronous, take an optional CancellationToken parameter called cancellationToken.
180179
public virtual async Task<Operation<BinaryData>> ExportProjectAsync(WaitUntil waitUntil, string projectName, string exportedProjectFormat, string assetKind, string stringIndexType, RequestContext context) =>
181180
await ExportProjectAsync(waitUntil, projectName, exportedProjectFormat, assetKind, stringIndexType, default, context).ConfigureAwait(false);
182-
#pragma warning restore AZC0002 // DO ensure all service methods, both asynchronous and synchronous, take an optional CancellationToken parameter called cancellationToken.
183181

184182
/// <summary> Triggers a job to export a project&apos;s data. </summary>
185183
/// <param name="waitUntil"> <see cref="WaitUntil.Completed"/> if the method should wait to return until the long-running operation has completed on the service; <see cref="WaitUntil.Started"/> if it should return after starting the operation. For more information on long-running operations, please see <see href="https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/samples/LongRunningOperations.md"> Azure.Core Long-Running Operation samples</see>. </param>
@@ -280,9 +278,7 @@ public virtual async Task<Operation<BinaryData>> ExportProjectAsync(WaitUntil wa
280278
///
281279
/// </remarks>
282280
[EditorBrowsable(EditorBrowsableState.Never)]
283-
#pragma warning disable AZC0002 // DO ensure all service methods, both asynchronous and synchronous, take an optional CancellationToken parameter called cancellationToken.
284281
public virtual Operation<BinaryData> ExportProject(WaitUntil waitUntil, string projectName, string exportedProjectFormat, string assetKind, string stringIndexType, RequestContext context) =>
285282
ExportProject(waitUntil, projectName, exportedProjectFormat, assetKind, stringIndexType, default, context);
286-
#pragma warning restore AZC0002 // DO ensure all service methods, both asynchronous and synchronous, take an optional CancellationToken parameter called cancellationToken.
287283
}
288284
}

sdk/contentsafety/Azure.AI.ContentSafety/src/Azure.AI.ContentSafety.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
<PackageTags>Azure ContentSafety</PackageTags>
77
<TargetFrameworks>$(RequiredTargetFrameworks)</TargetFrameworks>
88
<GenerateAPIListing>true</GenerateAPIListing>
9-
<NoWarn>$(NoWarn);AZC0002</NoWarn>
109
<IncludeOperationsSharedSource>true</IncludeOperationsSharedSource>
1110
</PropertyGroup>
1211

sdk/core/Azure.Core/tests/common/TestClients/LowLevelClient/PetStoreClient.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@ public PetStoreClient(Uri endpoint, TokenCredential credential, PetStoreClientOp
5656
/// <summary> Get a pet by its Id. </summary>
5757
/// <param name="id"> Id of pet to return. </param>
5858
/// <param name="context"> The request context. </param>
59-
#pragma warning disable AZC0002
6059
public virtual async Task<Response> GetPetAsync(string id, RequestContext context = null)
61-
#pragma warning restore AZC0002
6260
{
6361
using var scope = _clientDiagnostics.CreateScope("PetStoreClient.GetPet");
6462
scope.Start();
@@ -77,9 +75,7 @@ public virtual async Task<Response> GetPetAsync(string id, RequestContext contex
7775
/// <summary> Get a pet by its Id. </summary>
7876
/// <param name="id"> Id of pet to return. </param>
7977
/// <param name="context"> The request context. </param>
80-
#pragma warning disable AZC0002
8178
public virtual Response GetPet(string id, RequestContext context = null)
82-
#pragma warning restore AZC0002
8379
{
8480
using var scope = _clientDiagnostics.CreateScope("PetStoreClient.GetPet");
8581
scope.Start();
@@ -98,9 +94,7 @@ public virtual Response GetPet(string id, RequestContext context = null)
9894
/// <summary> Get a pet by its Id. </summary>
9995
/// <param name="id"> Id of pet to return. </param>
10096
/// <param name="context"> The request context. </param>
101-
#pragma warning disable AZC0002
10297
public virtual async Task<Response> CreatePetAsync(string id, RequestContent content, RequestContext context = null)
103-
#pragma warning restore AZC0002
10498
{
10599
using var scope = _clientDiagnostics.CreateScope("PetStoreClient.GetPet");
106100
scope.Start();
@@ -119,9 +113,7 @@ public virtual async Task<Response> CreatePetAsync(string id, RequestContent con
119113
/// <summary> Get a pet by its Id. </summary>
120114
/// <param name="id"> Id of pet to return. </param>
121115
/// <param name="context"> The request context. </param>
122-
#pragma warning disable AZC0002
123116
public virtual Response CreatePet(string id, RequestContent content, RequestContext context = null)
124-
#pragma warning restore AZC0002
125117
{
126118
using var scope = _clientDiagnostics.CreateScope("PetStoreClient.GetPet");
127119
scope.Start();

sdk/devcenter/Azure.Developer.DevCenter/src/GlobalSuppressions.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
using System.Diagnostics.CodeAnalysis;
55

6-
[assembly: SuppressMessage("Usage", "AZC0002:DO ensure all service methods, both asynchronous and synchronous, take an optional CancellationToken parameter called cancellationToken.", Justification = "CancellationToken can be passed through RequestOptions")]
76
[assembly: SuppressMessage("Usage", "AZC0001:Use one of the following pre-approved namespace groups (https://azure.github.io/azure-sdk/registered_namespaces.html): Azure.AI, Azure.Analytics, Azure.Communication, Azure.Data, Azure.DigitalTwins, Azure.IoT, Azure.Learn, Azure.Media, Azure.Management, Azure.Messaging, Azure.ResourceManager, Azure.Search, Azure.Security, Azure.Storage, Azure.Template, Azure.Identity, Microsoft.Extensions.Azure", Justification = "Temporary while awaiting namespace group approval", Scope = "namespace", Target = "~N:Azure.Developer.DevCenter")]
87
[assembly: SuppressMessage("Usage", "AZC0007:DO provide a minimal constructor that takes only the parameters required to connect to the service.", Justification = "False positives on minimal constructors", Scope = "namespaceanddescendants", Target = "~N:Azure.Developer.DevCenter")]
98
[assembly: SuppressMessage("Usage", "AZC0006:DO provide constructor overloads that allow specifying additional options.", Justification = "False positives on options constructors", Scope = "namespaceanddescendants", Target = "~N:Azure.Developer.DevCenter")]

sdk/eventhub/Azure.Messaging.EventHubs.Processor/src/EventProcessorClient.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ public class EventProcessorClient : EventProcessor<EventProcessorPartition>
9696
/// <exception cref="NotSupportedException">If an attempt is made to add or remove a handler while the processor is running.</exception>
9797
/// <exception cref="NotSupportedException">If an attempt is made to add a handler when one is currently registered.</exception>
9898
///
99-
[SuppressMessage("Usage", "AZC0002:Ensure all service methods take an optional CancellationToken parameter.", Justification = "Guidance does not apply; this is an event.")]
10099
[SuppressMessage("Usage", "AZC0003:DO make service methods virtual.", Justification = "This member follows the standard .NET event pattern; override via the associated On<<EVENT>> method.")]
101100
public event Func<PartitionInitializingEventArgs, Task> PartitionInitializingAsync
102101
{
@@ -143,7 +142,6 @@ public event Func<PartitionInitializingEventArgs, Task> PartitionInitializingAsy
143142
/// <exception cref="NotSupportedException">If an attempt is made to add or remove a handler while the processor is running.</exception>
144143
/// <exception cref="NotSupportedException">If an attempt is made to add a handler when one is currently registered.</exception>
145144
///
146-
[SuppressMessage("Usage", "AZC0002:Ensure all service methods take an optional CancellationToken parameter.", Justification = "Guidance does not apply; this is an event.")]
147145
[SuppressMessage("Usage", "AZC0003:DO make service methods virtual.", Justification = "This member follows the standard .NET event pattern; override via the associated On<<EVENT>> method.")]
148146
public event Func<PartitionClosingEventArgs, Task> PartitionClosingAsync
149147
{
@@ -195,7 +193,6 @@ public event Func<PartitionClosingEventArgs, Task> PartitionClosingAsync
195193
/// <exception cref="NotSupportedException">If an attempt is made to add or remove a handler while the processor is running.</exception>
196194
/// <exception cref="NotSupportedException">If an attempt is made to add a handler when one is currently registered.</exception>
197195
///
198-
[SuppressMessage("Usage", "AZC0002:Ensure all service methods take an optional CancellationToken parameter.", Justification = "Guidance does not apply; this is an event.")]
199196
[SuppressMessage("Usage", "AZC0003:DO make service methods virtual.", Justification = "This member follows the standard .NET event pattern; override via the associated On<<EVENT>> method.")]
200197
public event Func<ProcessEventArgs, Task> ProcessEventAsync
201198
{
@@ -255,7 +252,6 @@ public event Func<ProcessEventArgs, Task> ProcessEventAsync
255252
///
256253
/// <seealso href="https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/eventhub/Azure.Messaging.EventHubs/TROUBLESHOOTING.md">Troubleshoot Event Hubs issues</seealso>
257254
///
258-
[SuppressMessage("Usage", "AZC0002:Ensure all service methods take an optional CancellationToken parameter.", Justification = "Guidance does not apply; this is an event.")]
259255
[SuppressMessage("Usage", "AZC0003:DO make service methods virtual.", Justification = "This member follows the standard .NET event pattern; override via the associated On<<EVENT>> method.")]
260256
public event Func<ProcessErrorEventArgs, Task> ProcessErrorAsync
261257
{

sdk/eventhub/Azure.Messaging.EventHubs/src/Consumer/EventHubConsumerClient.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,6 @@ public virtual async Task CloseAsync(CancellationToken cancellationToken = defau
837837
///
838838
/// <returns>A task to be resolved on when the operation has completed.</returns>
839839
///
840-
[SuppressMessage("Usage", "AZC0002:Ensure all service methods take an optional CancellationToken parameter.", Justification = "This signature must match the IAsyncDisposable interface.")]
841840
public virtual async ValueTask DisposeAsync()
842841
{
843842
await CloseAsync().ConfigureAwait(false);

sdk/eventhub/Azure.Messaging.EventHubs/src/Producer/EventHubBufferedProducerClient.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,6 @@ public virtual bool IsClosed
262262
/// <exception cref="NotSupportedException">If an attempt is made to add or remove a handler while the processor is running.</exception>
263263
/// <exception cref="NotSupportedException">If an attempt is made to add a handler when one is currently registered.</exception>
264264
///
265-
[SuppressMessage("Usage", "AZC0002:Ensure all service methods take an optional CancellationToken parameter.", Justification = "Guidance does not apply; this is an event.")]
266265
[SuppressMessage("Usage", "AZC0003:DO make service methods virtual.", Justification = "This member follows the standard .NET event pattern; override via the associated On<<EVENT>> method.")]
267266
public event Func<SendEventBatchSucceededEventArgs, Task> SendEventBatchSucceededAsync
268267
{
@@ -338,7 +337,6 @@ public event Func<SendEventBatchSucceededEventArgs, Task> SendEventBatchSucceede
338337
///
339338
/// <seealso cref="EventHubsRetryOptions" />
340339
///
341-
[SuppressMessage("Usage", "AZC0002:Ensure all service methods take an optional CancellationToken parameter.", Justification = "Guidance does not apply; this is an event.")]
342340
[SuppressMessage("Usage", "AZC0003:DO make service methods virtual.", Justification = "This member follows the standard .NET event pattern; override via the associated On<<EVENT>> method.")]
343341
public event Func<SendEventBatchFailedEventArgs, Task> SendEventBatchFailedAsync
344342
{
@@ -1231,7 +1229,6 @@ public virtual async Task CloseAsync(bool flush = true,
12311229
///
12321230
/// <returns>A task to be resolved on when the operation has completed.</returns>
12331231
///
1234-
[SuppressMessage("Usage", "AZC0002:Ensure all service methods take an optional CancellationToken parameter.", Justification = "This signature must match the IAsyncDisposable interface.")]
12351232
public virtual async ValueTask DisposeAsync()
12361233
{
12371234
await CloseAsync(true).ConfigureAwait(false);

0 commit comments

Comments
 (0)