我的代码分析工具(Sonarqube)从我的代码分析工具(Sonarqube)中收到关于以下函数中的设置器的错误“实际上并未引用该字段”。我怀疑这是因为我有该类的静态引用但不完全确定。什么是正确的在给定以下上下文的情况下制作setter的方法?
public class Configuration {
public static bool MyField {
get => _ref._myField;
set => _ref._myField = value; // Sonarqube: "Refactor this setter so that it actually refers to the field '_myField '.
}
// Static reference for configuration.
private static Configuration _ref = new Configuration();
private Configuration() {
// constructor to intialize some fields
_myField = 0;
}
[JsonProperty(PropertyName = "my_field")]
private int _myField;
}