Visual Studio 2019 需要几分钟时间才能开始运行单元测试。这是一个大型(>300 个项目).NET Framework x86 解决方案。
感觉就像VS在等待什么,但是断开网络适配器并不会让测试变得更快。
在空项目中运行测试从单击“测试资源管理器”播放按钮到完成大约需要 6 秒。
这是详细的测试日志
[5/10/2021 9:22:45.934 PM] Interrupt: Enqueueing RunSelectedOperation
[5/10/2021 9:22:45.934 PM] Enqueue operation 'RunSelectedOperation', hashcode:11243619
[5/10/2021 9:22:45.935 PM] Operation left in the the queue: 1
[5/10/2021 9:22:45.935 PM] 'RunSelectedOperation', hashcode:11243619
[5/10/2021 9:22:45.935 PM]
[5/10/2021 9:22:45.935 PM] Operation Dequeue : 'RunSelectedOperation'
[5/10/2021 9:24:01.053 PM] test container discoverer executor://orderedtestadapter/v1, discovered 1 containers
[5/10/2021 9:24:01.053 PM] Containers from 'Microsoft.VisualStudio.MSTest.TestWindow.OrderedTestContainerDiscoverer' :
[5/10/2021 …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用C#泛型和基于此答案的策略模式实现类似c ++的模板
这是模式的一个示例:
interface ISomePolicy<T,U>
{
void _doSomething(U u);
}
class MyClass<T,U>:
ISomePolicy<int, double>,
ISomePolicy<int, int>
{
internal T myElement {get;set;}
public MyClass(T Element) {
myElement = Element;
}
void ISomePolicy<int, double>._doSomething(double u)
{
Console.WriteLine("this is int, double");
}
void ISomePolicy<int, int>._doSomething(int u)
{
Console.WriteLine("this is int, int");
}
}
static class MyClassExtension
{
//What I want to do
public static void doSomething<P, T, U>(this P oTh, U u) where P : MyClass<T, U>, ISomePolicy<T, U>
{
oTh._doSomething(u); …
Run Code Online (Sandbox Code Playgroud) c# generics extension-methods template-specialization implicit-conversion
我需要在 bcc32 项目上使用 C++11 库。该库不能用 bcc32 编译,但可以用 bcc32c 编译。
我想防止在 DLL 上公开这个库。该库使用 bcc32c 编译,但我无法在 bcc32 项目上使用 bcc32c 静态库。
这是一个有效的 C#6 测试代码。它在 VS2015 上编译
namespace testcode
{
class Program
{
static void Main(string[] args)
{
string x = null ;
string y = x?.Substring(0, 2);
return;
}
}
}
Run Code Online (Sandbox Code Playgroud)
该cproj
有toolsversion14.0
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
Run Code Online (Sandbox Code Playgroud)
这就是我试图通过Visual Studio SDK用MSBUILD编译它的方式
//References Microsoft.Build and Microsoft.Build.Framework
namespace MSBuildTest
{
class Program
{
static void Main(string[] args)
{
var pc = new Microsoft.Build.Evaluation.ProjectCollection(Microsoft.Build.Evaluation.ToolsetDefinitionLocations.Registry);
pc.DefaultToolsVersion = "14.0";
pc.RegisterLogger(new Microsoft.Build.Logging.ConsoleLogger(Microsoft.Build.Framework.LoggerVerbosity.Detailed));
var pr = pc.LoadProject(@"C:\path\to\testcode.cproj");
pr.Build();
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是错误信息
Run Code Online (Sandbox Code Playgroud)Program.cs(8,26): …
msbuild microsoft.build visual-studio-sdk c#-6.0 visual-studio-2015
整数数据[3][5];
是 5 元素数组的 3 元素数组。
为什么?对我来说,直觉上 ifint[3]
是一个 3 元素数组,而int[3][5]
应该是3 元素数组的 5 元素数组。
我有一个 bin 数据表,用于示例目的:
static const unsigned char test_bin[28800] = {0};
#define TEST_DATA_COLUMNS 2
#define TEST_DATA_ROWS (sizeof(test_bin)/sizeof(float)/TEST_DATA_COLUMNS);
static const float (* test_data)[TEST_DATA_COLUMNS] = (const float (*)[TEST_DATA_COLUMNS]) test_bin;
Run Code Online (Sandbox Code Playgroud)
这失败了error: expected expression before ';' token
:
for(size_t i = 0; i < TEST_DATA_ROWS ; i++);
Run Code Online (Sandbox Code Playgroud)
但这有效
size_t nrows = TEST_DATA_ROWS;
for(size_t i = 0; i < nrows ; i++);
Run Code Online (Sandbox Code Playgroud)
为什么?