1

使用 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

我不想删除其他文件的规则。
我不想手动编辑生成的设计器文件。

我可以以某种方式避免此消息,然后在错误列表中逐个字段地抑制消息吗?

4

1 回答 1

1

将 Product.PageTitle 设为私有。如果您想在 Product 类之外公开它,请为其创建一个属性。

现在的情况:

public/internal string PageTitle;

期望的情况:

public/internal string PageTitle { get; set; }
于 2012-05-07T08:58:30.353 回答