Skip to content

Commit 10655bc

Browse files
authored
Merge pull request #1627 from seesharper/bugfix/cached-metadata-resolver
Use ConcurrentDictionary in CachingScriptMetadataResolver
2 parents ae687ff + eb359ca commit 10655bc

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

src/OmniSharp.Cake/CachingScriptMetadataResolver.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Collections.Generic;
1+
using System.Collections.Concurrent;
2+
using System.Collections.Generic;
23
using System.Collections.Immutable;
34
using Microsoft.CodeAnalysis;
45
using Microsoft.CodeAnalysis.Scripting;
@@ -7,8 +8,8 @@ namespace OmniSharp.Cake
78
{
89
internal class CachingScriptMetadataResolver : MetadataReferenceResolver
910
{
10-
private static readonly Dictionary<string, ImmutableArray<PortableExecutableReference>> DirectReferenceCache = new Dictionary<string, ImmutableArray<PortableExecutableReference>>();
11-
private static readonly Dictionary<string, PortableExecutableReference> MissingReferenceCache = new Dictionary<string, PortableExecutableReference>();
11+
private static readonly ConcurrentDictionary<string, ImmutableArray<PortableExecutableReference>> DirectReferenceCache = new ConcurrentDictionary<string, ImmutableArray<PortableExecutableReference>>();
12+
private static readonly ConcurrentDictionary<string, PortableExecutableReference> MissingReferenceCache = new ConcurrentDictionary<string, PortableExecutableReference>();
1213
private static readonly MetadataReferenceResolver DefaultRuntimeResolver = ScriptMetadataResolver.Default;
1314

1415
public override bool Equals(object other)
@@ -56,4 +57,4 @@ public override ImmutableArray<PortableExecutableReference> ResolveReference(str
5657
return result;
5758
}
5859
}
59-
}
60+
}

src/OmniSharp.Script/CachingScriptMetadataResolver.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Collections.Generic;
1+
using System.Collections.Concurrent;
22
using System.Collections.Immutable;
33
using Microsoft.CodeAnalysis;
44

@@ -7,8 +7,8 @@ namespace OmniSharp.Script
77
public class CachingScriptMetadataResolver : MetadataReferenceResolver
88
{
99
private readonly MetadataReferenceResolver _defaultReferenceResolver;
10-
private static Dictionary<string, ImmutableArray<PortableExecutableReference>> DirectReferenceCache = new Dictionary<string, ImmutableArray<PortableExecutableReference>>();
11-
private static Dictionary<string, PortableExecutableReference> MissingReferenceCache = new Dictionary<string, PortableExecutableReference>();
10+
private static ConcurrentDictionary<string, ImmutableArray<PortableExecutableReference>> DirectReferenceCache = new ConcurrentDictionary<string, ImmutableArray<PortableExecutableReference>>();
11+
private static ConcurrentDictionary<string, PortableExecutableReference> MissingReferenceCache = new ConcurrentDictionary<string, PortableExecutableReference>();
1212

1313
public CachingScriptMetadataResolver(MetadataReferenceResolver defaultReferenceResolver)
1414
{

0 commit comments

Comments
 (0)