Imported Upstream version 5.2.0.175

Former-commit-id: bb0468d0f257ff100aa895eb5fe583fb5dfbf900
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-06-07 13:16:24 +00:00
parent 4bdbaf4a88
commit 966bba02bb
8776 changed files with 346420 additions and 149650 deletions

View File

@@ -57,18 +57,22 @@ namespace System.Diagnostics.TraceSourceTests
var listener = new TestTraceListener();
trace.Listeners.Add(listener);
trace.Close();
// NOTE: this assertion fails on .net 4.5
// where TraceSource.Close calls TraceListener.Close, not Dispose.
Assert.Equal(1, listener.GetCallCount(Method.Dispose));
Assert.Equal(1, listener.GetCallCount(Method.Close));
// Assert that writing to a closed TraceSource is not an error.
trace.TraceEvent(TraceEventType.Critical, 0);
}
[System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.NoInlining)]
static WeakReference PruneMakeRef()
{
return new WeakReference(new TraceSource("TestTraceSource"));
}
[Fact]
public void PruneTest()
{
var strongTrace = new TraceSource("TestTraceSource");
var traceRef = new WeakReference(new TraceSource("TestTraceSource"));
var traceRef = PruneMakeRef();
Assert.True(traceRef.IsAlive);
GC.Collect(2);
Trace.Refresh();
@@ -127,8 +131,20 @@ namespace System.Diagnostics.TraceSourceTests
[Fact]
public void EmptySourceName()
{
Assert.Throws<ArgumentException>("name", () => new TraceSource(string.Empty));
Assert.Throws<ArgumentException>("name", () => new TraceSource(string.Empty, SourceLevels.All));
ArgumentException exception1 = Assert.Throws<ArgumentException>(() => new TraceSource(string.Empty));
ArgumentException exception2 = Assert.Throws<ArgumentException>(() => new TraceSource(string.Empty, SourceLevels.All));
// In Desktop in TraceSource.ctor we create the ArgumentException without param name, just with Message = "name", so ParamName is null
if (PlatformDetection.IsFullFramework)
{
Assert.Null(exception1.ParamName);
Assert.Null(exception2.ParamName);
}
else
{
Assert.Equal("name", exception1.ParamName);
Assert.Equal("name", exception2.ParamName);
}
}
}