| Property | Value |
|---|---|
| Package | Philips.CodeAnalysis.MaintainabilityAnalyzers |
| Diagnostic ID | PH2134 |
| Category | Maintainability |
| Analyzer | NamespaceMatchAssemblyNameAnalyzer |
| CodeFix | No |
| Severity | Error |
| Enabled By Default | Yes |
The user of your class should not need to know the internals of your class. This includes any behavior around the order in which you set its properties.
One sign of ordering issues in property setters is that they depend on getter of other properties that are not constants.
Make your setters independent of other properties. If that is not possible, include the setting of the affected property in the constructor of the class.
Code that triggers a diagnostic:
public class BadExample {
public int One { get; set; }
public int Two {
set {
One = value - 1;
}
}
}And the replacement code:
public class GoodExample {
public int One { get; set; }
public int Two { get; set; }
}This analyzer does not offer any special configuration. The general ways of suppressing diagnostics apply.