Skip to content

Commit

Permalink
BUGFIX: Handle empty setter body.
Browse files Browse the repository at this point in the history
  • Loading branch information
JohanLarsson committed Nov 20, 2020
1 parent 6f3016a commit 0e4ac71
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions ValidCode/Repro/Issue291.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace ValidCode.Repro
{
using System.Windows.Controls;

public class Issue291 : Control
{
public bool IsAcknowledged
{
get { return false; }
set { }
}
}
}
2 changes: 1 addition & 1 deletion WpfAnalyzers/Helpers/DependencyObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ private SetCurrentValue(InvocationExpressionSyntax invocation, IMethodSymbol tar
=> Match(invocation, semanticModel, cancellationToken),
{ ExpressionBody: { } expressionBody } => Walk(expressionBody),
{ Body: { Statements: { } statements } }
when statements.Last() is ReturnStatementSyntax { Expression: InvocationExpressionSyntax invocation }
when statements.LastOrDefault() is ReturnStatementSyntax { Expression: InvocationExpressionSyntax invocation }
=> Match(invocation, semanticModel, cancellationToken),
{ Body: { } body } => Walk(body),
_ => null,
Expand Down

0 comments on commit 0e4ac71

Please sign in to comment.