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

Merge pull request #58 from shiftbot/winrt-timespan-zero-fix

Workaround the 0ms timespan issue
Oren Novotny 9 лет назад
Родитель
Сommit
c9cefc1b56

+ 40 - 0
Rx.NET/Source/NuSpecs/System.Reactive.Core.nuspec

@@ -34,6 +34,23 @@
         <dependency id="System.Threading" version="4.0.11" />
         <dependency id="System.Threading.Tasks" version="4.0.11" />
       </group>
+      <group targetFramework="netstandard1.1">
+        <dependency id="System.Reactive.Interfaces" version="$version$" />
+        <dependency id="System.Collections" version="4.0.11" />
+        <dependency id="System.Collections.Concurrent" version="4.0.12" />
+        <dependency id="System.ComponentModel" version="4.0.1" />
+        <dependency id="System.Diagnostics.Debug" version="4.0.11" />
+        <dependency id="System.Diagnostics.Tools" version="4.0.1" />
+        <dependency id="System.Dynamic.Runtime" version="4.0.11" />
+        <dependency id="System.Globalization" version="4.0.11" />
+        <dependency id="System.Linq" version="4.1.0" />
+        <dependency id="System.Reflection" version="4.1.0" />
+        <dependency id="System.Resources.ResourceManager" version="4.0.1" />
+        <dependency id="System.Runtime" version="4.1.0" />
+        <dependency id="System.Runtime.Extensions" version="4.1.0" />
+        <dependency id="System.Threading" version="4.0.11" />
+        <dependency id="System.Threading.Tasks" version="4.0.11" />
+      </group>
       <group targetFramework="netcoreapp1.0">
         <dependency id="System.Reactive.Interfaces" version="$version$" />
         <dependency id="System.Collections" version="4.0.11" />
@@ -75,10 +92,33 @@
         <dependency id="System.Threading" version="4.0.11" />
         <dependency id="System.Threading.Tasks" version="4.0.11" />
       </group>
+      <group targetFramework="netcore451">
+        <dependency id="System.Reactive.Interfaces" version="$version$" />
+      </group>
+      <group targetFramework="uap10.0">
+        <dependency id="System.Reactive.Interfaces" version="$version$" />
+        <dependency id="System.Collections" version="4.0.11" />
+        <dependency id="System.Collections.Concurrent" version="4.0.12" />
+        <dependency id="System.ComponentModel" version="4.0.1" />
+        <dependency id="System.Diagnostics.Debug" version="4.0.11" />
+        <dependency id="System.Diagnostics.Tools" version="4.0.1" />
+        <dependency id="System.Globalization" version="4.0.11" />
+        <dependency id="System.Linq" version="4.1.0" />
+        <dependency id="System.Reflection" version="4.1.0" />
+        <dependency id="System.Resources.ResourceManager" version="4.0.1" />
+        <dependency id="System.Runtime" version="4.1.0" />
+        <dependency id="System.Runtime.Extensions" version="4.1.0" />
+        <dependency id="System.Threading" version="4.0.11" />
+        <dependency id="System.Threading.Tasks" version="4.0.11" />
+      </group>
+      <group targetFramework="wpa81">
+        <dependency id="System.Reactive.Interfaces" version="$version$" />
+      </group>
     </dependencies>
   </metadata>
   <files>
     <file src="..\System.Reactive.Core\bin\$configuration$\**\System.Reactive.Core.*" exclude="**\*.deps.json" target="lib" />
     <file src="..\System.Reactive.Core\bin\$configuration$\netstandard1.0\System.Reactive.Core.*" exclude="**\*.deps.json" target="lib\portable-win8+net45+wp8+wpa81" />
+    <file src="..\System.Reactive.Core\bin\$configuration$\netstandard1.1\System.Reactive.Core.*" exclude="**\*.deps.json" target="lib\portable-win8+net45+wpa81" />
   </files>
 </package>

+ 18 - 0
Rx.NET/Source/NuSpecs/System.Reactive.Linq.nuspec

@@ -36,6 +36,23 @@
         <dependency id="System.Threading" version="4.0.11" />
         <dependency id="System.Threading.Tasks" version="4.0.11" />
       </group>
+      <group targetFramework="netstandard1.1">
+        <dependency id="System.Reactive.Interfaces" version="$version$" />
+        <dependency id="System.Collections" version="4.0.11" />
+        <dependency id="System.Collections.Concurrent" version="4.0.12" />
+        <dependency id="System.ComponentModel" version="4.0.1" />
+        <dependency id="System.Diagnostics.Debug" version="4.0.11" />
+        <dependency id="System.Diagnostics.Tools" version="4.0.1" />
+        <dependency id="System.Globalization" version="4.0.11" />
+        <dependency id="System.Linq" version="4.1.0" />
+        <dependency id="System.Reflection" version="4.1.0" />
+        <dependency id="System.Resources.ResourceManager" version="4.0.1" />
+        <dependency id="System.Runtime" version="4.1.0" />
+        <dependency id="System.Runtime.Extensions" version="4.1.0" />
+        <dependency id="System.Runtime.InteropServices.WindowsRuntime" version="4.0.1" />
+        <dependency id="System.Threading" version="4.0.11" />
+        <dependency id="System.Threading.Tasks" version="4.0.11" />
+      </group>
       <group targetFramework="net45">
         <dependency id="System.Reactive.Interfaces" version="$version$" />
         <dependency id="System.Reactive.Core" version="$version$" />
@@ -67,5 +84,6 @@
   <files>
     <file src="..\System.Reactive.Linq\bin\$configuration$\**\System.Reactive.Linq.*" exclude="**\*.deps.json" target="lib" />
     <file src="..\System.Reactive.Linq\bin\$configuration$\netstandard1.0\System.Reactive.Linq.*" exclude="**\*.deps.json" target="lib\portable-win8+net45+wp8+wpa81" />
+    <file src="..\System.Reactive.Linq\bin\$configuration$\netstandard1.1\System.Reactive.Linq.*" exclude="**\*.deps.json" target="lib\portable-win8+net45+wpa81" />
   </files>
 </package>

+ 8 - 0
Rx.NET/Source/System.Reactive.Core/Reactive/Concurrency/Scheduler.Services.Emulation.cs

@@ -259,7 +259,15 @@ namespace System.Reactive.Concurrency
             //       events through IHostLifecycleNotifications, discovered through the PEP in order
             //       to maintain portability of the core of Rx.
             //
+
             var periodic = scheduler.AsPeriodic();
+#if WINDOWS
+            // Workaround for WinRT not supporting <1ms resolution
+            if(period < TimeSpan.FromMilliseconds(1))
+            {
+                periodic = null; // skip the periodic scheduler and use the stopwatch
+            }
+#endif
             if (periodic != null)
             {
                 return periodic.SchedulePeriodic(state, period, action);

+ 110 - 2
Rx.NET/Source/System.Reactive.Core/project.json

@@ -29,7 +29,7 @@
     "System.Diagnostics.Contracts": "4.0.1",
     "System.Dynamic.Runtime": "4.0.11"
   },
-  
+
   "frameworks": {
     "net45": {
       "buildOptions": {
@@ -88,6 +88,25 @@
         ]
       }
     },
+    "netstandard1.1": {
+      "buildOptions": {
+        "define": [
+          "NO_EVENTARGS_CONSTRAINT",
+          "HAS_EDI",
+          "HAS_WINRT",
+          "HAS_PROGRESS",
+          "PREFER_ASYNC",
+          "HAS_AWAIT",
+          "HAS_APTCA",
+          "NO_REMOTING",
+          "NO_SERIALIZABLE",
+          "NO_THREAD",
+          "CRIPPLED_REFLECTION",
+          "USE_TIMER_SELF_ROOT",
+          "PLIB"
+        ]
+      }
+    },
     "netstandard1.3": {
       "buildOptions": {
         "define": [
@@ -120,7 +139,7 @@
           "HAS_AWAIT",
           "HAS_APTCA",
           "NO_REMOTING",
-          "NO_SERIALIZABLE",          
+          "NO_SERIALIZABLE",
           "CRIPPLED_REFLECTION",
           "PLIB",
           "USE_TIMER_SELF_ROOT"
@@ -130,6 +149,95 @@
         "System.Threading.Thread": "4.0.0",
         "System.Threading.ThreadPool": "4.0.10"
       }
+    },
+    "wpa81": {
+      "buildOptions": {
+        "define": [
+          "NO_EVENTARGS_CONSTRAINT",
+          "HAS_EDI",
+          "HAS_WINRT",
+          "HAS_PROGRESS",
+          "PREFER_ASYNC",
+          "HAS_AWAIT",
+          "NO_REMOTING",
+          "NO_SERIALIZABLE",
+          "NO_THREAD",
+          "CRIPPLED_REFLECTION",
+          "USE_TIMER_SELF_ROOT",
+          "WINDOWS",
+          "WINDOWS81"
+        ]
+      },
+      "dependencies": {
+        "Microsoft.TargetingPack.Private.WinRT": {
+          "version": "1.0.1",
+          "type": "build"
+        },
+        "Microsoft.TargetingPack.Private.WindowsPhone.v8.1": {
+          "version": "1.0.1",
+          "type": "build"
+        }
+      }
+    },
+    "netcore451": {
+      "buildOptions": {
+        "define": [
+          "NO_EVENTARGS_CONSTRAINT",
+          "HAS_EDI",
+          "HAS_WINRT",
+          "HAS_PROGRESS",
+          "PREFER_ASYNC",
+          "HAS_AWAIT",
+          "NO_REMOTING",
+          "NO_SERIALIZABLE",
+          "NO_THREAD",
+          "CRIPPLED_REFLECTION",
+          "USE_TIMER_SELF_ROOT",
+          "WINDOWS",
+          "WINDOWS81"
+        ]
+      },
+      "dependencies": {
+        "Microsoft.TargetingPack.Private.WinRT": {
+          "version": "1.0.1",
+          "type": "build"
+        },
+        "Microsoft.TargetingPack.Private.NETCore.v4.5.1": {
+          "version": "1.0.0",
+          "type": "build"
+        }
+      }
+    },
+    "uap10.0": {
+      "imports": [ "dotnet5.4" ],
+      "buildOptions": {
+        "define": [
+          "NO_EVENTARGS_CONSTRAINT",
+          "HAS_EDI",
+          "HAS_WINRT",
+          "HAS_PROGRESS",
+          "PREFER_ASYNC",
+          "HAS_AWAIT",
+          "HAS_APTCA",
+          "HAS_TPL46",
+          "NO_REMOTING",
+          "NO_SERIALIZABLE",
+          "NO_THREAD",
+          "CRIPPLED_REFLECTION",
+          "WINDOWS",
+          "USE_TIMER_SELF_ROOT"
+        ]
+      },
+      "dependencies": {
+        "Microsoft.TargetingPack.Private.WinRT": {
+          "version": "1.0.1",
+          "type": "build"
+        },
+        "Microsoft.NETCore.UniversalWindowsPlatform": {
+          "version": "5.2.0",
+          "type": "build"
+        }
+      }
     }
   }
 }

+ 20 - 1
Rx.NET/Source/System.Reactive.Linq/project.json

@@ -35,7 +35,7 @@
     "System.Reactive.Core": { "target": "project" },
     "System.Runtime.InteropServices.WindowsRuntime": "4.0.1"
   },
-  
+
   "frameworks": {
     "net45": {
       "buildOptions": {
@@ -94,6 +94,25 @@
         ]
       }
     },
+    "netstandard1.1": {
+      "buildOptions": {
+        "define": [
+          "NO_EVENTARGS_CONSTRAINT",
+          "HAS_EDI",
+          "HAS_WINRT",
+          "HAS_PROGRESS",
+          "PREFER_ASYNC",
+          "HAS_AWAIT",
+          "HAS_APTCA",
+          "NO_REMOTING",
+          "NO_SERIALIZABLE",
+          "NO_THREAD",
+          "CRIPPLED_REFLECTION",
+          "USE_TIMER_SELF_ROOT",
+          "PLIB"
+        ]
+      }
+    },
     "netstandard1.3": {
       "buildOptions": {
         "define": [

+ 1 - 1
Rx.NET/Source/Tests.System.Reactive.Uwp.DeviceRunner/Tests.System.Reactive.Uwp.DeviceRunner.csproj

@@ -394,7 +394,7 @@
       <HintPath>..\Microsoft.Reactive.Testing\bin\$(Configuration)\uap10.0\Microsoft.Reactive.Testing.dll</HintPath>
     </Reference>
     <Reference Include="System.Reactive.Core">
-      <HintPath>..\System.Reactive.Core\bin\$(Configuration)\netstandard1.3\System.Reactive.Core.dll</HintPath>
+      <HintPath>..\System.Reactive.Core\bin\$(Configuration)\uap10.0\System.Reactive.Core.dll</HintPath>
     </Reference>
     <Reference Include="System.Reactive.Experimental">
       <HintPath>..\System.Reactive.Experimental\bin\$(Configuration)\netstandard1.3\System.Reactive.Experimental.dll</HintPath>

+ 25 - 3
Rx.NET/Source/Tests.System.Reactive/Tests/Linq/ObservableTimeTest.cs

@@ -264,9 +264,11 @@ namespace ReactiveTests.Tests
                 Subscribe(200, 600)
             );
 
+#if !WINDOWS
             scheduler.Timers.AssertEqual(
                 new TimerRun(200, 600) { 300, 400, 500 }
             );
+#endif
         }
 
         [Fact]
@@ -303,9 +305,11 @@ namespace ReactiveTests.Tests
                 Subscribe(200, 480)
             );
 
+#if !WINDOWS
             scheduler.Timers.AssertEqual(
                 new TimerRun(200, 480) { 300, 400 }
             );
+#endif
         }
 
         [Fact]
@@ -444,9 +448,9 @@ namespace ReactiveTests.Tests
             Observable.Range(1, 10, DefaultScheduler.Instance).Buffer(TimeSpan.FromDays(1), 3).Skip(1).First().AssertEqual(4, 5, 6);
         }
 
-        #endregion
+#endregion
 
-        #region + Delay +
+#region + Delay +
 
         [Fact]
         public void Delay_ArgumentChecking()
@@ -2850,9 +2854,11 @@ namespace ReactiveTests.Tests
                 Subscribe(200, 390)
             );
 
+#if !WINDOWS
             scheduler.Timers.AssertEqual(
                 new TimerRun(200, 400) { 250, 300, 350, 400 }
             );
+#endif
         }
 
         [Fact]
@@ -2918,9 +2924,11 @@ namespace ReactiveTests.Tests
                 Subscribe(200, 330)
             );
 
+#if !WINDOWS
             scheduler.Timers.AssertEqual(
                 new TimerRun(200, 330) { 250, 300 }
             );
+#endif
         }
 
         [Fact]
@@ -2968,9 +2976,11 @@ namespace ReactiveTests.Tests
                 Subscribe(200, 300)
             );
 
+#if !WINDOWS
             scheduler.Timers.AssertEqual(
                 new TimerRun(200, 300) { 250, 300 }
             );
+#endif
         }
 
         [Fact]
@@ -3022,9 +3032,11 @@ namespace ReactiveTests.Tests
                 Subscribe(200, 300)
             );
 
+#if !WINDOWS
             scheduler.Timers.AssertEqual(
                 new TimerRun(200, 300) { 250 }
             );
+#endif
         }
 
         [Fact]
@@ -3068,9 +3080,11 @@ namespace ReactiveTests.Tests
                 Subscribe(200, 1000)
             );
 
+#if !WINDOWS
             scheduler.Timers.AssertEqual(
                 new TimerRun(200, 1000) { 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950 }
             );
+#endif
         }
 
         [Fact]
@@ -7671,9 +7685,11 @@ namespace ReactiveTests.Tests
                 OnNext(650, 4L)
             );
 
+#if !WINDOWS
             scheduler.Timers.AssertEqual(
                 new TimerRun(250, 700) { 350, 450, 550, 650 }
             );
+#endif
         }
 
         [Fact]
@@ -7694,9 +7710,11 @@ namespace ReactiveTests.Tests
                 OnNext(700, 4L)
             );
 
+#if !WINDOWS
             scheduler.Timers.AssertEqual(
                 new TimerRun(200, 750) { 300, 400, 500, 600, 700 }
             );
+#endif
         }
 
         [Fact]
@@ -8217,7 +8235,7 @@ namespace ReactiveTests.Tests
                 if (serviceType == typeof(ISchedulerPeriodic))
                     return this as ISchedulerPeriodic;
 
-                return null;
+                return base.GetService(serviceType);
             }
         }
 
@@ -8519,9 +8537,11 @@ namespace ReactiveTests.Tests
                 Subscribe(200, 490)
             );
 
+#if !WINDOWS
             scheduler.Timers.AssertEqual(
                 new TimerRun(200, 490) { 300, 400 }
             );
+#endif
         }
 
         [Fact]
@@ -8564,9 +8584,11 @@ namespace ReactiveTests.Tests
                 Subscribe(200, 460)
             );
 
+#if !WINDOWS
             scheduler.Timers.AssertEqual(
                 new TimerRun(200, 460) { 300, 400 }
             );
+#endif
         }
 
         [Fact]

+ 5 - 0
Rx.NET/Source/build-new.ps1

@@ -28,6 +28,11 @@ Write-Host "Version: $version"
 Write-Host "Restoring packages" -Foreground Green
 dotnet restore $scriptPath | out-null
 
+#need to ensure core is built first due to bad dependency order determination by dotnet build
+
+$coreDir = gci . -Directory | where-object {$_.Name -eq "System.Reactive.Core"} | Select -First 1
+dotnet build -c "$configuration" $coreDir.FullName
+
 Write-Host "Building projects" -Foreground Green
 $projects = gci $scriptPath -Directory `
    | Where-Object { ($_.Name -notlike "*DeviceRunner") -and (Test-Path (Join-Path $_.FullName "project.json"))  } `