Skip to content

Commit 09f60e3

Browse files
committed
C#: Address C# code comments.
1 parent b744f9f commit 09f60e3

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

csharp/extractor/Semmle.Extraction/Extractor/Extractor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public static string Version
109109
{
110110
// the attribute for the git information are always attached to the entry assembly by our build system
111111
var assembly = Assembly.GetEntryAssembly();
112-
var versionString = assembly!.GetCustomAttribute<AssemblyInformationalVersionAttribute>();
112+
var versionString = assembly?.GetCustomAttribute<AssemblyInformationalVersionAttribute>();
113113
if (versionString == null)
114114
{
115115
return "unknown (not built from internal bazel workspace)";

csharp/extractor/Testrunner/Testrunner.cs

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -63,23 +63,25 @@ private void OnTestSkipped(TestSkippedInfo info)
6363
public int RunTests()
6464
{
6565
var assembly = Assembly.GetExecutingAssembly();
66-
var testrunner = AssemblyRunner.WithoutAppDomain(assembly.Location);
67-
testrunner.OnDiscoveryComplete = OnDiscoveryComplete;
68-
testrunner.OnExecutionComplete = OnExecutionComplete;
69-
testrunner.OnTestFailed = OnTestFailed;
70-
testrunner.OnTestSkipped = OnTestSkipped;
71-
72-
Console.WriteLine("Discovering tests...");
73-
testrunner.Start(parallelAlgorithm: null);
74-
75-
Finished.WaitOne();
76-
Finished.Dispose();
77-
78-
// Wait for assembly runner to finish.
79-
// If we try to dispose while runner is executing,
80-
// it will throw an error.
81-
while (testrunner.Status != AssemblyRunnerStatus.Idle)
82-
Thread.Sleep(100);
66+
using (var testrunner = AssemblyRunner.WithoutAppDomain(assembly.Location))
67+
{
68+
testrunner.OnDiscoveryComplete = OnDiscoveryComplete;
69+
testrunner.OnExecutionComplete = OnExecutionComplete;
70+
testrunner.OnTestFailed = OnTestFailed;
71+
testrunner.OnTestSkipped = OnTestSkipped;
72+
73+
Console.WriteLine("Discovering tests...");
74+
testrunner.Start(parallelAlgorithm: null);
75+
76+
Finished.WaitOne();
77+
Finished.Dispose();
78+
79+
// Wait for assembly runner to finish.
80+
// If we try to dispose while runner is executing,
81+
// it will throw an error.
82+
while (testrunner.Status != AssemblyRunnerStatus.Idle)
83+
Thread.Sleep(100);
84+
}
8385
return Result;
8486
}
8587

0 commit comments

Comments
 (0)