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
{{ message }}
Repository navigation
SA1600 triggers for private interface members #3551
Interface members are public by default, and you can explicitly specify accessibility modifiers, such as public, protected, internal, private, protected internal, or private protected. A private member must have a default implementation.
SA1600 requires documentation of these members when documentPrivateElements: false. For example, PrivateMethod here is triggering SA1600:
/// <summary>/// An interface with private members./// </summary>publicinterfaceIInterfaceWithPrivateMembers{privatevoidPrivateMethod(){}/// <summary>/// A public method./// </summary>publicvoidPublicMethod()=>this.PrivateMethod();}
It makes sense for documentInterfaces: true to ignore documentInternalMembers since that appears to be its goal. However, I think private interface members should still consider documentPrivateElements in this case since the members are not accessible outside of the interface.
Personally, I think the behaviour for internal members with bodies is correct, since implementors of the interface still needs to understand what the method is supposed to do to be able to override it when necesssary.
Private methods with bodies is a different matter, since they can not be overridden or used by anyone else. I would find it reasonable if documentInterfaces did not apply to private members.
@bjornhellander What you're saying about internal interface members definitely makes sense in regards to documentInterfaces. I will update the title/description to only mention private members. I agree that private members should probably be treated as a special case.
Activity
bjornhellander commentedon Aug 20, 2022
See the description of
documentInterfacesin https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/Configuration.md?plain=1#L577:Specifies whether interface members need to be documented. When true, all interface members require documentation, regardless of accessibility.
Seems to be why this is happening.
bjornhellander commentedon Aug 20, 2022
Personally, I think the behaviour for internal members with bodies is correct, since implementors of the interface still needs to understand what the method is supposed to do to be able to override it when necesssary.
Private methods with bodies is a different matter, since they can not be overridden or used by anyone else. I would find it reasonable if
documentInterfacesdid not apply to private members.gtbuchanan commentedon Aug 30, 2022
@bjornhellander What you're saying about internal interface members definitely makes sense in regards to
documentInterfaces. I will update the title/description to only mention private members. I agree that private members should probably be treated as a special case.[-]SA1600 triggers for private/internal interface members[/-][+]SA1600 triggers for private interface members[/+]bjornhellander commentedon Jan 22, 2023
Any thoughts on @gtbuchanan's suggestion, @sharwell?
Update SA1600 for default interface members