C# Version of S1996 in Java: One top-level class or interface per file

I’ve been searching for a C# version of the rule in Java: 1996 that prevents more than one class or interface per file at the top-level. Is there a reason this rule isn’t viable in C#, or I’m missing the place to find it?

Hello @UWMSeanSherman,

Indeed, there’s no such rule for C#.

Although this rule does make sense, it’s not a priority for us to implement and I don’t know when we’ll have the capacity to do so.

Thanks for the understanding!

Mary

As far as I know the .NET team of Sonar did never aim to re implement the rules defined by StyleCop. And StyleCop has a rule that does this: SA1402.

1 Like