在Visual Studio 2010中使用内置的代码分析我在aspx文件的设计器文件的所有字段上获得CA1051。
Warning 111
CA1051 : Microsoft.Design : Because field 'Product.PageTitle' is visible
outside of its declaring type, change its accessibility to private
and add a property, with the same accessibility as the field has
currently, to provide access to it.
Product.aspx.designer.cs 22
我不想删除其他文件的规则 我不想手动编辑生成的设计器文件。
我可以以任何其他方式以某种方式避免此消息,然后在错误列表中按字段抑制消息字段吗?
答案 0 :(得分:0)
将Product.PageTitle设为私有。如果要在Product类之外公开它,请为其创建属性。
现状:
public/internal string PageTitle;
期望的情况:
public/internal string PageTitle { get; set; }