diff --git a/src/NuGet.Core/NuGet.Packaging/ContentModel/ContentItemCollection.cs b/src/NuGet.Core/NuGet.Packaging/ContentModel/ContentItemCollection.cs index 82107ce367c..091c7060f51 100644 --- a/src/NuGet.Core/NuGet.Packaging/ContentModel/ContentItemCollection.cs +++ b/src/NuGet.Core/NuGet.Packaging/ContentModel/ContentItemCollection.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; @@ -14,8 +15,7 @@ public class ContentItemCollection private static readonly ReadOnlyMemory Winmd = ".winmd".AsMemory(); private List _assets; - private Dictionary, string> _assemblyRelatedExtensions; - + private ConcurrentDictionary, string> _assemblyRelatedExtensions; /// /// True if lib/contract exists /// @@ -309,14 +309,14 @@ internal string GetRelatedFileExtensionProperty(string assemblyPath, IEnumerable // If no related files found. if (relatedFileExtensionList is null || relatedFileExtensionList.Count == 0) { - _assemblyRelatedExtensions[assemblyPrefix] = null; + _assemblyRelatedExtensions.TryAdd(assemblyPrefix, null); return null; } else { relatedFileExtensionList.Sort(); string relatedFileExtensionsProperty = string.Join(";", relatedFileExtensionList); - _assemblyRelatedExtensions[assemblyPrefix] = relatedFileExtensionsProperty; + _assemblyRelatedExtensions.TryAdd(assemblyPrefix, relatedFileExtensionsProperty); return relatedFileExtensionsProperty; }