You've already forked linux-packaging-mono
Imported Upstream version 5.16.0.100
Former-commit-id: 38faa55fb9669e35e7d8448b15c25dc447f25767
This commit is contained in:
parent
0a9828183b
commit
7d7f676260
@@ -35,7 +35,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp' or '$(TargetGroup)' == 'uap'">
|
||||
<Compile Include="System\Diagnostics\StackTraceSymbols.CoreCLR.cs" />
|
||||
<ProjectReference Include="..\..\System.Collections\src\System.Collections.csproj" />
|
||||
<ProjectReference Include="..\..\System.Collections.Concurrent\src\System.Collections.Concurrent.csproj" />
|
||||
<ProjectReference Include="..\..\System.Diagnostics.Debug\src\System.Diagnostics.Debug.csproj" />
|
||||
<ProjectReference Include="..\..\System.IO\src\System.IO.csproj" />
|
||||
<ProjectReference Include="..\..\System.IO.FileSystem\src\System.IO.FileSystem.csproj" />
|
||||
@@ -57,4 +57,4 @@
|
||||
<Reference Include="mscorlib" />
|
||||
</ItemGroup>
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
|
||||
</Project>
|
||||
</Project>
|
||||
|
@@ -2,7 +2,7 @@
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Concurrent;
|
||||
using System.IO;
|
||||
using System.Reflection.Metadata;
|
||||
using System.Reflection.Metadata.Ecma335;
|
||||
@@ -12,14 +12,14 @@ namespace System.Diagnostics
|
||||
{
|
||||
internal class StackTraceSymbols : IDisposable
|
||||
{
|
||||
private readonly Dictionary<IntPtr, MetadataReaderProvider> _metadataCache;
|
||||
private readonly ConcurrentDictionary<IntPtr, MetadataReaderProvider> _metadataCache;
|
||||
|
||||
/// <summary>
|
||||
/// Create an instance of this class.
|
||||
/// </summary>
|
||||
public StackTraceSymbols()
|
||||
{
|
||||
_metadataCache = new Dictionary<IntPtr, MetadataReaderProvider>();
|
||||
_metadataCache = new ConcurrentDictionary<IntPtr, MetadataReaderProvider>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -29,7 +29,7 @@ namespace System.Diagnostics
|
||||
{
|
||||
foreach (MetadataReaderProvider provider in _metadataCache.Values)
|
||||
{
|
||||
provider.Dispose();
|
||||
provider?.Dispose();
|
||||
}
|
||||
|
||||
_metadataCache.Clear();
|
||||
@@ -123,20 +123,21 @@ namespace System.Diagnostics
|
||||
MetadataReaderProvider provider;
|
||||
if (_metadataCache.TryGetValue(cacheKey, out provider))
|
||||
{
|
||||
return provider.GetMetadataReader();
|
||||
return provider?.GetMetadataReader();
|
||||
}
|
||||
|
||||
provider = (inMemoryPdbAddress != IntPtr.Zero) ?
|
||||
TryOpenReaderForInMemoryPdb(inMemoryPdbAddress, inMemoryPdbSize) :
|
||||
TryOpenReaderFromAssemblyFile(assemblyPath, loadedPeAddress, loadedPeSize);
|
||||
|
||||
// This may fail as another thread might have beaten us to it, but it doesn't matter
|
||||
_metadataCache.TryAdd(cacheKey, provider);
|
||||
|
||||
if (provider == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
_metadataCache.Add(cacheKey, provider);
|
||||
|
||||
// The reader has already been open, so this doesn't throw:
|
||||
return provider.GetMetadataReader();
|
||||
}
|
||||
|
@@ -85,6 +85,7 @@ namespace System.Diagnostics.Tests
|
||||
[InlineData(null, StackFrame.OFFSET_UNKNOWN)]
|
||||
[InlineData("", 0)]
|
||||
[InlineData("FileName", 1)]
|
||||
[ActiveIssue(28853, TargetFrameworkMonikers.NetFramework)]
|
||||
public void Ctor_Filename_LineNumber(string fileName, int lineNumber)
|
||||
{
|
||||
var stackFrame = new StackFrame(fileName, lineNumber);
|
||||
@@ -99,6 +100,7 @@ namespace System.Diagnostics.Tests
|
||||
[InlineData(null, StackFrame.OFFSET_UNKNOWN, 0)]
|
||||
[InlineData("", 0, StackFrame.OFFSET_UNKNOWN)]
|
||||
[InlineData("FileName", 1, 2)]
|
||||
[ActiveIssue(28853, TargetFrameworkMonikers.NetFramework)]
|
||||
public void Ctor_Filename_LineNumber_ColNumber(string fileName, int lineNumber, int columnNumber)
|
||||
{
|
||||
var stackFrame = new StackFrame(fileName, lineNumber, columnNumber);
|
||||
|
@@ -274,20 +274,20 @@ namespace System.Diagnostics.Tests
|
||||
{
|
||||
// Debug mode and Release mode give different results.
|
||||
#if DEBUG
|
||||
yield return new object[] { new StackTrace(InvokeException()), " at System.Diagnostics.Tests.StackTraceTests.ThrowException()" };
|
||||
yield return new object[] { new StackTrace(InvokeException()), "System.Diagnostics.Tests.StackTraceTests.ThrowException()" };
|
||||
yield return new object[] { new StackTrace(new Exception()), "" };
|
||||
yield return new object[] { NoParameters(), " at System.Diagnostics.Tests.StackTraceTests.NoParameters()" };
|
||||
yield return new object[] { OneParameter(1), " at System.Diagnostics.Tests.StackTraceTests.OneParameter(Int32 x)" };
|
||||
yield return new object[] { TwoParameters(1, null), " at System.Diagnostics.Tests.StackTraceTests.TwoParameters(Int32 x, String y)" };
|
||||
yield return new object[] { Generic<int>(), " at System.Diagnostics.Tests.StackTraceTests.Generic[T]()" };
|
||||
yield return new object[] { Generic<int, string>(), " at System.Diagnostics.Tests.StackTraceTests.Generic[T,U]()" };
|
||||
yield return new object[] { new ClassWithConstructor().StackTrace, " at System.Diagnostics.Tests.StackTraceTests.ClassWithConstructor..ctor()" };
|
||||
yield return new object[] { NoParameters(), "System.Diagnostics.Tests.StackTraceTests.NoParameters()" };
|
||||
yield return new object[] { OneParameter(1), "System.Diagnostics.Tests.StackTraceTests.OneParameter(Int32 x)" };
|
||||
yield return new object[] { TwoParameters(1, null), "System.Diagnostics.Tests.StackTraceTests.TwoParameters(Int32 x, String y)" };
|
||||
yield return new object[] { Generic<int>(), "System.Diagnostics.Tests.StackTraceTests.Generic[T]()" };
|
||||
yield return new object[] { Generic<int, string>(), "System.Diagnostics.Tests.StackTraceTests.Generic[T,U]()" };
|
||||
yield return new object[] { new ClassWithConstructor().StackTrace, "System.Diagnostics.Tests.StackTraceTests.ClassWithConstructor..ctor()" };
|
||||
|
||||
// Methods belonging to the System.Diagnostics namespace are ignored.
|
||||
yield return new object[] { InvokeIgnoredMethod(), " at System.Diagnostics.Tests.StackTraceTests.InvokeIgnoredMethod()" };
|
||||
yield return new object[] { InvokeIgnoredMethod(), "System.Diagnostics.Tests.StackTraceTests.InvokeIgnoredMethod()" };
|
||||
#endif
|
||||
|
||||
yield return new object[] { InvokeIgnoredMethodWithException(), " at System.Diagnostics.Ignored.MethodWithException()" };
|
||||
yield return new object[] { InvokeIgnoredMethodWithException(), "System.Diagnostics.Ignored.MethodWithException()" };
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -309,7 +309,7 @@ namespace System.Diagnostics.Tests
|
||||
else
|
||||
{
|
||||
string toString = stackTrace.ToString();
|
||||
Assert.StartsWith(expectedToString, toString);
|
||||
Assert.Contains(expectedToString, toString);
|
||||
Assert.EndsWith(Environment.NewLine, toString);
|
||||
|
||||
string[] frames = toString.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
Reference in New Issue
Block a user