You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
csharpsquid:S1168 (Empty arrays and collections should be returned instead of null) raises an issue when the returned type is not a collection/array, but the roslyn IArrayTypeSymbol.
Repro steps
Create a method that returns IEnumerable and returns a not-null result
Inside this method, create a local function that returns a non-enumerable type
Return null inside the local function
private IEnumerable<Instruction> Foo()
{
var instructions = new List<Instruction>();
// some logic
return instructions;
IArrayTypeSymbol LocalBar(SyntaxNode parent)
{
return null; // FP
}
}
Expected behavior
Should not raise issue.
Actual behavior
csharpsquid:S1168 "Return an empty collection instead of null."
Related information
SonarC# Version "7.9 (build 7566)"
The text was updated successfully, but these errors were encountered:
Evangelink
changed the title
Fix S1168: should not raise when return type of local function is not enumerable
Fix S1168: FP with local function
Dec 14, 2018
Description
csharpsquid:S1168 (Empty arrays and collections should be returned instead of null) raises an issue when the returned type is not a collection/array, but the roslyn IArrayTypeSymbol.
Repro steps
Expected behavior
Should not raise issue.
Actual behavior
csharpsquid:S1168 "Return an empty collection instead of null."
Related information
The text was updated successfully, but these errors were encountered: