Reference assembly loading fixes #415
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I noticed that if I had 139 reference assemblies (in a solution memory), I ended up calling the Assembly.Load for 897 times. This is because so many assemblies have the same references like System.Memory, System.Xml, System.Buffers, System.Threading.Tasks.Extensions, ... And the code said "load all reference assemblies". Simple fix: Check already loaded reference assemblies before trying to call the slow Assembly.Load again.
The sourceAssembliesTable_ is a ConcurrentDictionary to ensure thread-safety. However, instead of code using it in thread-safe way, it was used by double-lookup. So that is fixed to actually use it properly. (It's role is to be used as a guard to sourceAssemblies_ array, which is manually lazy-loaded from the queue.)