public void AddAccessor(ButlerAccessorType accessorType, ButlerAccessibility accessibility) { if (accessorType == ButlerAccessorType.Set && !_definedAccessors.Contains(ButlerAccessorType.Get)) { throw new Exception("Cannot define a set accessor without a get accessor."); } AccessorDeclarationSyntax accessor = SyntaxFactory.AccessorDeclaration(RoslynUtilities.FromAccessorType(accessorType)); accessor = accessor.WithSemicolonToken(SyntaxFactory.Token(SyntaxKind.SemicolonToken)); if (accessibility > _accessibility) { throw new Exception($"The accessibility modifier of the {accessorType.ToString ()} accessor must be more restrictive than the property"); } if (accessibility != _accessibility) { accessor = accessor.AddModifiers(SyntaxFactory.Token(RoslynUtilities.FromAccessibility(accessibility))); } Info = Info.AddAccessorListAccessors(accessor); _definedAccessors.Add(accessorType); }