Skip to content
This repository has been archived by the owner on Jan 16, 2022. It is now read-only.

Commit

Permalink
Fix detecting private setters
Browse files Browse the repository at this point in the history
  • Loading branch information
cezarypiatek committed May 14, 2018
1 parent d813405 commit 9a096a4
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,14 @@ public static bool CanBeSetOnlyFromConstructor(this IPropertySymbol property)
{
return false;
}
if (propertyDeclaration.AccessorList.Accessors.Count > 1)

var hasPrivateSetter = propertyDeclaration.AccessorList.Accessors.Any(x =>x.Keyword.Kind() == SyntaxKind.SetKeyword && x.Modifiers.Any(m => m.Kind() == SyntaxKind.PrivateKeyword));
if (hasPrivateSetter)
{
return true;
}

return propertyDeclaration.AccessorList.Accessors.SingleOrDefault(IsAutoGetter) != null;
return propertyDeclaration.AccessorList.Accessors.Count == 1 && propertyDeclaration.AccessorList.Accessors.SingleOrDefault(IsAutoGetter) != null;
}

private static bool IsAutoGetter(AccessorDeclarationSyntax x)
Expand Down

0 comments on commit 9a096a4

Please sign in to comment.