c# - 在 c# 项目中定义了 'private accessors'

标签 c# .net visual-studio

在 Visual Studio 2015 中构建遗留 C# 应用程序后,出现以下警告:

This task to create private accessor is deprecated and will be removed in a future version of visual studio.

警告引用了解决方案中仅包含单元测试的项目。

Microsoft 文档说明:

Previous versions of Visual Studio, you could use Publicize.exe to specify an internal application programming interfaces (API) and create public counterpart API that you can call in your tests, which would in turn, call into the internal APIs of your product. You could then use code generation to create test stubs and generate code snippet inside that stub.

此功能已在 Visual Studio 2012 中删除。

搜索解决方案,在任何构建文件中都没有对 publicize.exe 的引用。

在 C# 项目中的哪个位置定义创建私有(private)访问器的任务?

最佳答案

您应该在单元测试项目的 .csproj 文件中找到访问器。

在 Visual Studio 中,右键单击您的测试项目并选择“卸载项目”。 然后再次右键单击项目并选择“Edit project-name.csproj

访问器看起来像这样:

  <ItemGroup>
    <Shadow Include="Test References\some-name.accessor" />
  </ItemGroup>

关于c# - 在 c# 项目中定义了 'private accessors',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39436276/

相关文章:

c# - 如何让我的应用程序有 30 天的试用期

c# - Visual Studio 中的 TestContext - 它有什么作用?

c# - 使用 Parallel.ForEach() 线程安全吗?

c# - 跨 AppDomains 的多个服务实例

c# - 使用 .mdf 数据库的 C# 表单应用程序中的 Linq to sql 问题

c# - 在 .Net C# 中释放资源

c# - 如何创建具有 2 个具有不同比例的数据系列的图表?

c# - 将 C++ map 数据传递给 C#

c# - 在属性下方生成构造函数

visual-studio - Visual Studio 2015 社区安装更新 1 失败