在为我的代码优先 EF 5 上下文启用迁移后,由于迁移历史字符串被添加到项目的 resx 文件中,我开始收到大量 CA1701 和 CA1703 代码分析违规。
我不在乎禁用 CA1701 和 CA1703,也不想为将要添加的每个单独迁移抑制 100ish 消息。有没有办法将 resx 的 xml 文件或单个 resx 条目标记为//
TIA
杰森
最佳答案
我自己今天才注意到这一点。您可以在您的 AssemblyInfo.cs 或 GlobalSuppressions.cs 文件中使用以下内容在资源级别抑制 CA1701 和 CA1703 警告:
[assembly: SuppressMessage("Microsoft.Naming",
"CA1701:ResourceStringCompoundWordsShouldBeCasedCorrectly",
Justification = "The auto-genererated code from code first migrations trigger this warning.",
Scope = "resource", Target = "Full.Namespace.To.Your.Migrations.NameOfYourMigration.resources")]
[assembly: SuppressMessage("Microsoft.Naming",
"CA1703:ResourceStringsShouldBeSpelledCorrectly",
Justification = "The auto-genererated code from code first migrations trigger this warning.",
Scope = "resource", Target = "Full.Namespace.To.Your.Migrations.NameOfYourMigration.resources")]
您需要为每个迁移执行此操作,但这比单独抑制每个警告要好得多。
关于entity-framework-5 - EF Code First 迁移导致 CA1701 和 CA1703,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18363665/