Skip to content

Commit

Permalink
Include NullableResponse<T> as an accepted response type (#4512)
Browse files Browse the repository at this point in the history
* Include NullableResponse<T> as an accepted response type
  • Loading branch information
christothes authored Jan 31, 2023
1 parent 965e7ad commit 63c91f7
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ await Verifier.CreateAnalyzer(code)
[InlineData("public Response<int> ClientMethodAsync() { return default; }")]
[InlineData("public Response<int[]> ClientMethodAsync() { return default; }")]
[InlineData("public Task<Response<int[]>> ClientMethodAsync() { return default; }")]
[InlineData("public NullableResponse<int[]> ClientMethodAsync() { return default; }")]
[InlineData("public Task<NullableResponse<int[]>> ClientMethodAsync() { return default; }")]
[InlineData("public Response ClientMethodAsync() { return default; }")]
[InlineData("public SomeClient ClientMethod() { return default; }")]
public async Task AZC0015NotProducedForValidReturnTypes(string usage)
Expand All @@ -65,4 +67,4 @@ await Verifier.CreateAnalyzer(code)
.RunAsync();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Azure.ClientSdk.Analyzers.Tests
{
private static readonly ReferenceAssemblies DefaultReferenceAssemblies =
ReferenceAssemblies.Default.AddPackages(ImmutableArray.Create(
new PackageIdentity("Azure.Core", "1.21.0"),
new PackageIdentity("Azure.Core", "1.26.0"),
new PackageIdentity("Microsoft.Bcl.AsyncInterfaces", "1.1.0"),
new PackageIdentity("System.Text.Json", "4.6.0"),
new PackageIdentity("Newtonsoft.Json", "12.0.3"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace Azure.ClientSdk.Analyzers.Tests
{
private static readonly ReferenceAssemblies DefaultReferenceAssemblies =
ReferenceAssemblies.Default.AddPackages(ImmutableArray.Create(
new PackageIdentity("Azure.Core", "1.21.0"),
new PackageIdentity("Azure.Core", "1.26.0"),
new PackageIdentity("Microsoft.Bcl.AsyncInterfaces", "1.1.0"),
new PackageIdentity("System.Text.Json", "4.6.0"),
new PackageIdentity("Newtonsoft.Json", "12.0.3"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static bool SupportsCancellationsParameter(IParameterSymbol parameterSymbol)
{
return (parameterSymbol.Name == "cancellationToken" && parameterSymbol.Type.Name == "CancellationToken") ||
(parameterSymbol.Name == "context" && parameterSymbol.Type.Name == "RequestContext");
}
}

CheckClientMethodReturnType(context, member);

Expand Down Expand Up @@ -100,6 +100,7 @@ bool IsOrImplements(ITypeSymbol typeSymbol, string typeName)
}

if (IsOrImplements(unwrappedType, "Response") ||
IsOrImplements(unwrappedType, "NullableResponse") ||
IsOrImplements(unwrappedType, "Operation") ||
IsOrImplements(originalType, "Pageable") ||
IsOrImplements(originalType, "AsyncPageable") ||
Expand Down

0 comments on commit 63c91f7

Please sign in to comment.