Skip to content

Commit

Permalink
Add more test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastien-marichal committed Jun 26, 2024
1 parent 35df44a commit f462780
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ private static HashSet<ISymbol> GetUnusedSymbols(CSharpSymbolUsageCollector usag

private static bool IsDeconstructMethod(ISymbol symbol) =>
symbol is IMethodSymbol { Name: "Deconstruct", Parameters.Length: > 0 } method
&& method.ReturnType.Is(KnownType.Void)
&& method.Parameters.All(x => x.RefKind == RefKind.Out);

private static bool IsAccessorUsed(ISymbol symbol, CSharpSymbolUsageCollector usageCollector) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,18 @@ private class NotUsedNotVisible
private void Deconstruct(out string a, out string b) { a = b = null; } // Compliant, Deconstruct methods are ignored
}

public class InvalidDeconstruct
{
private void Deconstruct(object a, out object b, out object c) { b = c = a; } // Noncompliant
private void Deconstruct() { } // Noncompliant

private int Deconstruct(out object a, out object b, out object c) // Noncompliant
{
a = b = c = null;
return 42;
}
}

private ForMethod ReturnFromMethod() => null;
private sealed class ForMethod
{
Expand Down

0 comments on commit f462780

Please sign in to comment.