Skip to content

Commit

Permalink
Merge pull request #1627 from seesharper/bugfix/cached-metadata-resolver
Browse files Browse the repository at this point in the history
Use ConcurrentDictionary in CachingScriptMetadataResolver
  • Loading branch information
filipw authored Oct 10, 2019
2 parents ae687ff + eb359ca commit 10655bc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
9 changes: 5 additions & 4 deletions src/OmniSharp.Cake/CachingScriptMetadataResolver.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.Immutable;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Scripting;
Expand All @@ -7,8 +8,8 @@ namespace OmniSharp.Cake
{
internal class CachingScriptMetadataResolver : MetadataReferenceResolver
{
private static readonly Dictionary<string, ImmutableArray<PortableExecutableReference>> DirectReferenceCache = new Dictionary<string, ImmutableArray<PortableExecutableReference>>();
private static readonly Dictionary<string, PortableExecutableReference> MissingReferenceCache = new Dictionary<string, PortableExecutableReference>();
private static readonly ConcurrentDictionary<string, ImmutableArray<PortableExecutableReference>> DirectReferenceCache = new ConcurrentDictionary<string, ImmutableArray<PortableExecutableReference>>();
private static readonly ConcurrentDictionary<string, PortableExecutableReference> MissingReferenceCache = new ConcurrentDictionary<string, PortableExecutableReference>();
private static readonly MetadataReferenceResolver DefaultRuntimeResolver = ScriptMetadataResolver.Default;

public override bool Equals(object other)
Expand Down Expand Up @@ -56,4 +57,4 @@ public override ImmutableArray<PortableExecutableReference> ResolveReference(str
return result;
}
}
}
}
6 changes: 3 additions & 3 deletions src/OmniSharp.Script/CachingScriptMetadataResolver.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Concurrent;
using System.Collections.Immutable;
using Microsoft.CodeAnalysis;

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

public CachingScriptMetadataResolver(MetadataReferenceResolver defaultReferenceResolver)
{
Expand Down

0 comments on commit 10655bc

Please sign in to comment.