Skip to main content

K1000

Messages should not contain fields.

Fields in messages indicate that there might be some logic when there shouldn’t be. Fields also are not serialized by default. Remove any fields from message classes or replace them with properties.

Noncompliant Code Example

public class SomeRequest
{
    private string _name;
}

Compliant Solution

public class SomeRequest
{
    public SomeRequest(string name)
    {
        this.Name = name;
    }

    public string Name { get; }
}

Exceptions

None