Dolittle Documentation

DL0002

PrivateNotAllowed

In C#, private is implicit if no visibility modifier is specified. Therefor, to keep the codebase slimmed down from unnecessary keywords - this is not allowed, with one exception; explicit private setters for properties.

Example of not allowed:

namespace MyNamespace
{
    private class MyPrivateClass
    {
        private int _myPrivateField;

        private void MyPrivateMethod()
        {
        }

        private int MyPrivateProperty { get; set; }
    }
}

Instead you should remove the private keywords and end up with:

namespace MyNamespace
{
    class MyPrivateClass
    {
        int _myPrivateField;

        void MyPrivateMethod()
        {
        }

        int MyPrivateProperty { get; set; }
    }
}

The rule allows for properties with a public getter and a private setter:

namespace MyNamespace
{
    public class MyClass
    {
        public int MyProperty { get; private set; }
    }
}