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

Include NullableResponse<T> as an accepted response type #4512

Merged
merged 2 commits into from
Jan 31, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"),
christothes marked this conversation as resolved.
Show resolved Hide resolved
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