奇怪的C#单元测试语法,破坏了构建

时间:2020-09-04 14:30:12

标签: c# visual-studio unit-testing

我有一些代码被从樟脑袋中拿出并交给我。它是在Visual Studio 2015中构建的,这就是我用来构建它的方式。无法与原始开发人员联系,但有人告诉我它始终是以前构建的。我有两个无法建立的测试。令人反感的行看起来像这样:

PathUtilities.DragDropWidgetToView(mainWindow, screen, true, out bool unused, out bool unused2);

最后两个参数是时髦的。 unusedunused2在其他任何地方都没有定义。虽然这是当前.NET版本的有效语法,但IDE却在抱怨它们。

这些是它引发的错误:

CS1525 Invalid expression 'bool'
CS1003 Syntax error, ',' expected
CS1525 Invalid expression 'bool'
CS1003 Syntax error, ',' expected
CS0103 The name 'unused' does not exist in the current context
CS0103 The name 'unused2' does not exist in the current context

用法是:

using System.Collections.Generic;
using System.Threading;
using System.Windows.Automation;
using UIAutomation.ScreenUtilities;
using UIAutomation.ScreenUtilities.Screens;

它们都没有损坏。所有参考文献也完整无缺。

我已经注释掉了要构建的测试,但是生产代码确实不允许这样做。

显然,我需要升级Visual Studio使用的.NET版本。原始开发人员的说明说,可以使用VS2017,但前提是必须禁用C#7功能。我宁愿不必升级到VS2017,因为我们的PC已被锁定,并且不允许我们自己安装任何东西。

0 个答案:

没有答案