Topic | Value |
---|---|
Id | GU0008 |
Severity | Hidden |
Enabled | False |
Category | Gu.Analyzers.Correctness |
Code | PropertyDeclarationAnalyzer |
Avoid relay properties.
This is just a refactoring aid and disabled by default. Relay properties can be a sign of service locator complicating the graph. Example:
public class Foo
{
private readonly Bar bar;
public Foo()
{
this.bar = new Bar();
}
public int Value => this.bar.Value;
}
Where appropriate inject Bar where it is needed.
Configure the severity per project, for more info see MSDN.
#pragma warning disable GU0008 // Avoid relay properties
Code violating the rule here
#pragma warning restore GU0008 // Avoid relay properties
Or put this at the top of the file to disable all instances.
#pragma warning disable GU0008 // Avoid relay properties
[System.Diagnostics.CodeAnalysis.SuppressMessage("Gu.Analyzers.Correctness",
"GU0008:Avoid relay properties",
Justification = "Reason...")]