Просмотр исходного кода

Added debugger display information to TestScheduler and HistoricalScheduler

(cherry picked from commit 72c3b7d9551db2851b3b577b7682915b059552dd)
Paulo Morgado 7 лет назад
Родитель
Сommit
8de749f5a6

+ 5 - 0
Rx.NET/Source/src/Microsoft.Reactive.Testing/TestScheduler.cs

@@ -3,6 +3,7 @@
 // See the LICENSE file in the project root for more information. 
 
 using System;
+using System.Diagnostics;
 using System.Reactive;
 using System.Reactive.Concurrency;
 using System.Reactive.Disposables;
@@ -12,6 +13,10 @@ namespace Microsoft.Reactive.Testing
     /// <summary>
     /// Virtual time scheduler used for testing applications and libraries built using Reactive Extensions.
     /// </summary>
+    [DebuggerDisplay("\\{ " +
+        nameof(Clock) + " = {" + nameof(Clock) + "} " +
+        nameof(Now) + " = {" + nameof(Now) + ".ToString(\"O\")} " +
+    "\\}")]
     public class TestScheduler : VirtualTimeScheduler<long, long>
     {
         /// <summary>

+ 5 - 0
Rx.NET/Source/src/System.Reactive/Concurrency/HistoricalScheduler.cs

@@ -3,6 +3,7 @@
 // See the LICENSE file in the project root for more information. 
 
 using System.Collections.Generic;
+using System.Diagnostics;
 
 namespace System.Reactive.Concurrency
 {
@@ -67,6 +68,10 @@ namespace System.Reactive.Concurrency
     /// <summary>
     /// Provides a virtual time scheduler that uses <see cref="DateTimeOffset"/> for absolute time and <see cref="TimeSpan"/> for relative time.
     /// </summary>
+    [DebuggerDisplay("\\{ " +
+        nameof(Clock) + " = {" + nameof(Clock) + "} " +
+        nameof(Now) + " = {" + nameof(Now) + ".ToString(\"O\")} " +
+    "\\}")]
     public class HistoricalScheduler : HistoricalSchedulerBase
     {
         private readonly SchedulerQueue<DateTimeOffset> _queue = new SchedulerQueue<DateTimeOffset>();

+ 1 - 0
Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/ApiApprovalTests.Core.approved.txt

@@ -267,6 +267,7 @@ namespace System.Reactive.Concurrency
         public System.IDisposable SchedulePeriodic<TState>(TState state, System.TimeSpan period, System.Func<TState, TState> action) { }
         public override System.Reactive.Concurrency.IStopwatch StartStopwatch() { }
     }
+    [System.Diagnostics.DebuggerDisplayAttribute("\\{ Clock = {Clock} Now = {Now.ToString(\"O\")} \\}")]
     public class HistoricalScheduler : System.Reactive.Concurrency.HistoricalSchedulerBase
     {
         public HistoricalScheduler() { }

+ 1 - 0
Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/ApiApprovalTests.Testing.approved.txt

@@ -71,6 +71,7 @@ namespace Microsoft.Reactive.Testing
         public override int GetHashCode() { }
         public override string ToString() { }
     }
+    [System.Diagnostics.DebuggerDisplayAttribute("\\{ Clock = {Clock} Now = {Now.ToString(\"O\")} \\}")]
     public class TestScheduler : System.Reactive.Concurrency.VirtualTimeScheduler<long, long>
     {
         public TestScheduler() { }