-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add rules for convenience method and protocol method (#6934)
* Add rules for convenience method and protocol method * update * updadte
- Loading branch information
Showing
6 changed files
with
687 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
src/dotnet/Azure.ClientSdk.Analyzers/Azure.ClientSdk.Analyzers.Tests/AZC0017Tests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System.Threading.Tasks; | ||
using Xunit; | ||
using Verifier = Azure.ClientSdk.Analyzers.Tests.AzureAnalyzerVerifier<Azure.ClientSdk.Analyzers.ClientMethodsAnalyzer>; | ||
|
||
namespace Azure.ClientSdk.Analyzers.Tests | ||
{ | ||
public class AZC0017Tests | ||
{ | ||
[Fact] | ||
public async Task AZC0017ProducedForMethodsWithRequestContentParameter() | ||
{ | ||
const string code = @" | ||
using Azure; | ||
using Azure.Core; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
namespace RandomNamespace | ||
{ | ||
public class SomeClient | ||
{ | ||
public virtual Task<Response> {|AZC0017:GetAsync|}(RequestContent content, CancellationToken cancellationToken = default) | ||
{ | ||
return null; | ||
} | ||
public virtual Response {|AZC0017:Get|}(RequestContent content, CancellationToken cancellationToken = default) | ||
{ | ||
return null; | ||
} | ||
} | ||
}"; | ||
await Verifier.CreateAnalyzer(code) | ||
.RunAsync(); | ||
} | ||
|
||
[Fact] | ||
public async Task AZC0017NotProducedForMethodsWithCancellationToken() | ||
{ | ||
const string code = @" | ||
using Azure; | ||
using Azure.Core; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
namespace RandomNamespace | ||
{ | ||
public class SomeClient | ||
{ | ||
public virtual Task<Response> GetAsync(string s, CancellationToken cancellationToken = default) | ||
{ | ||
return null; | ||
} | ||
public virtual Response Get(string s, CancellationToken cancellationToken = default) | ||
{ | ||
return null; | ||
} | ||
} | ||
}"; | ||
await Verifier.CreateAnalyzer(code) | ||
.RunAsync(); | ||
} | ||
} | ||
} |
Oops, something went wrong.