C#: Address C# code comments.

This commit is contained in:
Cornelius Riemenschneider
2024-05-22 11:42:44 +02:00
parent b744f9fab9
commit 09f60e3e45
2 changed files with 17 additions and 15 deletions

View File

@@ -109,7 +109,7 @@ namespace Semmle.Extraction
{
// the attribute for the git information are always attached to the entry assembly by our build system
var assembly = Assembly.GetEntryAssembly();
var versionString = assembly!.GetCustomAttribute<AssemblyInformationalVersionAttribute>();
var versionString = assembly?.GetCustomAttribute<AssemblyInformationalVersionAttribute>();
if (versionString == null)
{
return "unknown (not built from internal bazel workspace)";

View File

@@ -63,23 +63,25 @@ public class Testrunner
public int RunTests()
{
var assembly = Assembly.GetExecutingAssembly();
var testrunner = AssemblyRunner.WithoutAppDomain(assembly.Location);
testrunner.OnDiscoveryComplete = OnDiscoveryComplete;
testrunner.OnExecutionComplete = OnExecutionComplete;
testrunner.OnTestFailed = OnTestFailed;
testrunner.OnTestSkipped = OnTestSkipped;
using (var testrunner = AssemblyRunner.WithoutAppDomain(assembly.Location))
{
testrunner.OnDiscoveryComplete = OnDiscoveryComplete;
testrunner.OnExecutionComplete = OnExecutionComplete;
testrunner.OnTestFailed = OnTestFailed;
testrunner.OnTestSkipped = OnTestSkipped;
Console.WriteLine("Discovering tests...");
testrunner.Start(parallelAlgorithm: null);
Console.WriteLine("Discovering tests...");
testrunner.Start(parallelAlgorithm: null);
Finished.WaitOne();
Finished.Dispose();
Finished.WaitOne();
Finished.Dispose();
// Wait for assembly runner to finish.
// If we try to dispose while runner is executing,
// it will throw an error.
while (testrunner.Status != AssemblyRunnerStatus.Idle)
Thread.Sleep(100);
// Wait for assembly runner to finish.
// If we try to dispose while runner is executing,
// it will throw an error.
while (testrunner.Status != AssemblyRunnerStatus.Idle)
Thread.Sleep(100);
}
return Result;
}