FxCop - 在适当的地方使用属性

Joz*_*zso 9 c# code-analysis fxcop

我在服务层有接口,有几个方法,从Get和FxCop的Use属性开始,适当的规则抱怨我应该考虑使用属性.

我尝试使用SuppressMessageAttribute,但是当它在接口上定义时,它对成员方法没有影响.我是否需要将SuppressMessageAttribute放到每个方法中,还是有办法抑制整个类型的CA1024

[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate"]
public interface IProjectService
{
    // Information and statistics about projects
    IList<ProjectInfo> GetProjects();
    ProjectsDashboard GetProjectsDashboard();

    // Project's settings
    ProjectSettings GetProjectSettings(Guid id);

    void SaveProjectSettings(ProjectSettings settings);
}
Run Code Online (Sandbox Code Playgroud)

Ses*_*esh 4

您必须为每个方法添加属性。