diff --git a/src/Draco.Compiler/Internal/Diagnostics/DiagnosticBag.cs b/src/Draco.Compiler/Internal/Diagnostics/DiagnosticBag.cs
index 109d13c03..5dd4879c3 100644
--- a/src/Draco.Compiler/Internal/Diagnostics/DiagnosticBag.cs
+++ b/src/Draco.Compiler/Internal/Diagnostics/DiagnosticBag.cs
@@ -1,4 +1,5 @@
using System.Collections;
+using System.Collections.Concurrent;
using System.Collections.Generic;
using Draco.Compiler.Api.Diagnostics;
@@ -7,7 +8,7 @@ namespace Draco.Compiler.Internal.Diagnostics;
///
/// Holds diagnostic messages.
///
-internal sealed class DiagnosticBag : ICollection
+internal sealed class DiagnosticBag : IReadOnlyCollection
{
///
/// True, if the bad contains errors.
@@ -15,9 +16,8 @@ internal sealed class DiagnosticBag : ICollection
public bool HasErrors { get; private set; }
public int Count => this.diagnostics.Count;
- public bool IsReadOnly => false;
- private readonly List diagnostics = new();
+ private readonly ConcurrentBag diagnostics = new();
public void Add(Diagnostic diagnostic)
{
@@ -39,8 +39,4 @@ public void AddRange(IEnumerable diagnostics)
public IEnumerator GetEnumerator() => this.diagnostics.GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => this.GetEnumerator();
-
- bool ICollection.Contains(Diagnostic item) => this.diagnostics.Contains(item);
- void ICollection.CopyTo(Diagnostic[] array, int arrayIndex) => this.diagnostics.CopyTo(array, arrayIndex);
- bool ICollection.Remove(Diagnostic item) => this.diagnostics.Remove(item);
}