C#: Minor adjustment to limiting the number of extractor messages

This commit is contained in:
Tamas Vajk
2024-08-13 16:22:19 +02:00
parent 0dfdee775b
commit 05500568c9
2 changed files with 3 additions and 5 deletions

View File

@@ -21,7 +21,6 @@ namespace Semmle.Extraction.CSharp.Entities
protected override void Populate(TextWriter trapFile)
{
// The below doesn't limit the extractor messages to the exact limit, but it's good enough.
var key = diagnostic.Id;
var messageCount = compilation.messageCounts.AddOrUpdate(key, 1, (_, c) => c + 1);
if (messageCount > limit)

View File

@@ -19,11 +19,10 @@ namespace Semmle.Extraction.Entities
protected override void Populate(TextWriter trapFile)
{
// The below doesn't limit the extractor messages to the exact limit, but it's good enough.
Interlocked.Increment(ref messageCount);
if (messageCount > limit)
var val = Interlocked.Increment(ref messageCount);
if (val > limit)
{
if (messageCount == limit + 1)
if (val == limit + 1)
{
Context.ExtractionContext.Logger.LogWarning($"Stopped logging extractor messages after reaching {limit}");
}