Skip to content

Commit 0550056

Browse files
committed
C#: Minor adjustment to limiting the number of extractor messages
1 parent 0dfdee7 commit 0550056

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

csharp/extractor/Semmle.Extraction.CSharp/Entities/Compilations/CompilerDiagnostic.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ public CompilerDiagnostic(Context cx, Microsoft.CodeAnalysis.Diagnostic diag, Co
2121

2222
protected override void Populate(TextWriter trapFile)
2323
{
24-
// The below doesn't limit the extractor messages to the exact limit, but it's good enough.
2524
var key = diagnostic.Id;
2625
var messageCount = compilation.messageCounts.AddOrUpdate(key, 1, (_, c) => c + 1);
2726
if (messageCount > limit)

csharp/extractor/Semmle.Extraction/Entities/ExtractionMessage.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@ public ExtractionMessage(Context cx, Message msg) : base(cx)
1919

2020
protected override void Populate(TextWriter trapFile)
2121
{
22-
// The below doesn't limit the extractor messages to the exact limit, but it's good enough.
23-
Interlocked.Increment(ref messageCount);
24-
if (messageCount > limit)
22+
var val = Interlocked.Increment(ref messageCount);
23+
if (val > limit)
2524
{
26-
if (messageCount == limit + 1)
25+
if (val == limit + 1)
2726
{
2827
Context.ExtractionContext.Logger.LogWarning($"Stopped logging extractor messages after reaching {limit}");
2928
}

0 commit comments

Comments
 (0)