【问题标题】:A lot of errors after migrate project from VS2015 to VS2017将项目从 VS2015 迁移到 VS2017 后出现很多错误
【发布时间】:2017-05-31 03:42:38
【问题描述】:

我在 Visual Studio 2015 中有 ASP .NET CORE 项目。 此外,我在整个解决方案中都有 StyleCop。 迁移到 Visual Studio 2017 后(我只是使用 VS2017 的单向迁移)我有很多错误(超过 3000 个),例如:

  • Using directive must appear within a namespace declaration
  • Tabs and spaces should be used correctly
  • Prefix local calls with this
  • Elements must be documented

更重要的是 - 使用相同的设置 - 都适用于 VS2015。 我做错了什么?

感谢您的建议

【问题讨论】:

  • 我会重新开始,将源文件复制到 vs2017 项目,然后自己设置 csproj 文件。

标签: .net visual-studio-2015 asp.net-core migration visual-studio-2017


【解决方案1】:

这些都是 stylecop 规则。您可以使用规则集文件来强制 stylecop 忽略其中一些规则。或者,您可以单击其中一个有问题的代码行,点击control + . 并在整个解决方案中应用重构(应该有一个选项可以在整个解决方案中“修复”问题)。

您可以查看如何使用此文件管理规则:https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/StyleCop.Analyzers/StyleCop.Analyzers.ruleset#L76

您可以在 csproj 中使用这些尖括号引用规则文件

<CodeAnalysisRuleSet>..\path\to\Stylecop.ruleset</CodeAnalysisRuleSet>

您可以将规则标记为错误、警告、隐藏或无。大多数人使用 None 来完全强制忽略规则。

您可以在此处查看有关规则集文件的文档:https://msdn.microsoft.com/en-us/library/dd264949.aspx

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-04-15
    • 2017-12-08
    • 2019-12-08
    • 2018-06-07
    • 2017-12-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多