@@ -625,7 +625,7 @@ protected override void EndProcessing() |
625 | 625 | // These dictionaries prevent reloading already loaded and unchanged code. |
626 | 626 | // We don't worry about unbounded growing of the cache because in .Net Core 2.0 we can not unload assemblies. |
627 | 627 | // TODO: review if we will be able to unload assemblies after migrating to .Net Core 2.1. |
628 | | - private static readonly Dictionary<string, int> s_sourceTypesCache = new Dictionary<string, int>(); |
| 628 | + private static readonly HashSet<string> s_sourceTypesCache = new HashSet<string>(); |
629 | 629 | private static readonly Dictionary<int, Assembly> s_sourceAssemblyCache = new Dictionary<int, Assembly>(); |
630 | 630 |
|
631 | 631 | private static readonly string s_defaultSdkDirectory = Utils.DefaultPowerShellAppBase; |
@@ -1052,7 +1052,7 @@ private void CompileToAssembly(List<SyntaxTree> syntaxTrees, CompilationOptions |
1052 | 1052 |
|
1053 | 1053 | private void CheckDuplicateTypes(Compilation compilation, out ConcurrentBag<string> newTypes) |
1054 | 1054 | { |
1055 | | - AllNamedTypeSymbolsVisitor visitor = new AllNamedTypeSymbolsVisitor(_syntaxTreesHash); |
| 1055 | + AllNamedTypeSymbolsVisitor visitor = new AllNamedTypeSymbolsVisitor(); |
1056 | 1056 | visitor.Visit(compilation.Assembly.GlobalNamespace); |
1057 | 1057 |
|
1058 | 1058 | foreach (var symbolName in visitor.DuplicateSymbols) |
@@ -1084,16 +1084,9 @@ private void CheckDuplicateTypes(Compilation compilation, out ConcurrentBag<stri |
1084 | 1084 | // Visit symbols in all namespaces and collect duplicates. |
1085 | 1085 | private class AllNamedTypeSymbolsVisitor : SymbolVisitor |
1086 | 1086 | { |
1087 | | - private readonly int _hash; |
1088 | | - |
1089 | 1087 | public readonly ConcurrentBag<string> DuplicateSymbols = new ConcurrentBag<string>(); |
1090 | 1088 | public readonly ConcurrentBag<string> UniqueSymbols = new ConcurrentBag<string>(); |
1091 | 1089 |
|
1092 | | - public AllNamedTypeSymbolsVisitor(int hash) |
1093 | | - { |
1094 | | - _hash = hash; |
1095 | | - } |
1096 | | - |
1097 | 1090 | public override void VisitNamespace(INamespaceSymbol symbol) |
1098 | 1091 | { |
1099 | 1092 | // Main cycle. |
@@ -1109,12 +1102,9 @@ public override void VisitNamedType(INamedTypeSymbol symbol) |
1109 | 1102 | // It is namespace-fully-qualified name |
1110 | 1103 | var symbolFullName = symbol.ToString(); |
1111 | 1104 |
|
1112 | | - if (s_sourceTypesCache.TryGetValue(symbolFullName, out int hash)) |
| 1105 | + if (s_sourceTypesCache.TryGetValue(symbolFullName, out _)) |
1113 | 1106 | { |
1114 | | - if (hash == _hash) |
1115 | | - { |
1116 | | - DuplicateSymbols.Add(symbolFullName); |
1117 | | - } |
| 1107 | + DuplicateSymbols.Add(symbolFullName); |
1118 | 1108 | } |
1119 | 1109 | else |
1120 | 1110 | { |
@@ -1127,7 +1117,7 @@ private void CacheNewTypes(ConcurrentBag<string> newTypes) |
1127 | 1117 | { |
1128 | 1118 | foreach (var typeName in newTypes) |
1129 | 1119 | { |
1130 | | - s_sourceTypesCache.Add(typeName, _syntaxTreesHash); |
| 1120 | + s_sourceTypesCache.Add(typeName); |
1131 | 1121 | } |
1132 | 1122 | } |
1133 | 1123 |
|
|