Prechádzať zdrojové kódy

Merge pull request #1319 from dotnet/dev/bartde/enable_cancellation_attr

Enable use of EnumeratorCancellation.
Bart J.F. De Smet 5 rokov pred
rodič
commit
23998a7d93

+ 3 - 0
Ix.NET/Source/Directory.build.targets

@@ -27,6 +27,9 @@
   <PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0' or '$(TargetFramework)' == 'netstandard2.1' or '$(TargetFramework)' == 'netstandard2.0'">
     <DefineConstants>$(DefineConstants);HAS_VALUETUPLE</DefineConstants>
   </PropertyGroup>
+  <PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0' or '$(TargetFramework)' == 'netstandard2.1'">
+    <DefineConstants>$(DefineConstants);HAS_ASYNC_ENUMERABLE_CANCELLATION</DefineConstants>
+  </PropertyGroup>
 
   <PropertyGroup>
     <Product>$(AssemblyName) ($(TargetFramework))</Product>

+ 3 - 3
Ix.NET/Source/System.Interactive.Async/System/Linq/Operators/DistinctUntilChanged.cs

@@ -210,7 +210,7 @@ namespace System.Linq
 #if HAS_ASYNC_ENUMERABLE_CANCELLATION
             return Core(source, keySelector, comparer);
 
-            static async IAsyncEnumerable<TSource> Core(IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey> comparer, [System.Runtime.CompilerServices.EnumeratorCancellation]CancellationToken cancellationToken = default)
+            static async IAsyncEnumerable<TSource> Core(IAsyncEnumerable<TSource> source, Func<TSource, TKey> keySelector, IEqualityComparer<TKey>? comparer, [System.Runtime.CompilerServices.EnumeratorCancellation]CancellationToken cancellationToken = default)
 #else
             return AsyncEnumerable.Create(Core);
 
@@ -255,7 +255,7 @@ namespace System.Linq
 #if HAS_ASYNC_ENUMERABLE_CANCELLATION
             return Core(source, keySelector, comparer);
 
-            static async IAsyncEnumerable<TSource> Core(IAsyncEnumerable<TSource> source, Func<TSource, ValueTask<TKey>> keySelector, IEqualityComparer<TSource> comparer, [System.Runtime.CompilerServices.EnumeratorCancellation]CancellationToken cancellationToken = default)
+            static async IAsyncEnumerable<TSource> Core(IAsyncEnumerable<TSource> source, Func<TSource, ValueTask<TKey>> keySelector, IEqualityComparer<TKey>? comparer, [System.Runtime.CompilerServices.EnumeratorCancellation]CancellationToken cancellationToken = default)
 #else
             return AsyncEnumerable.Create(Core);
 
@@ -301,7 +301,7 @@ namespace System.Linq
 #if HAS_ASYNC_ENUMERABLE_CANCELLATION
             return Core(source, keySelector, comparer);
 
-            static async IAsyncEnumerable<TSource> Core(IAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, ValueTask<TKey>> keySelector, IEqualityComparer<TSource> comparer, [System.Runtime.CompilerServices.EnumeratorCancellation]CancellationToken cancellationToken = default)
+            static async IAsyncEnumerable<TSource> Core(IAsyncEnumerable<TSource> source, Func<TSource, CancellationToken, ValueTask<TKey>> keySelector, IEqualityComparer<TKey>? comparer, [System.Runtime.CompilerServices.EnumeratorCancellation]CancellationToken cancellationToken = default)
 #else
             return AsyncEnumerable.Create(Core);
 

+ 0 - 15
Ix.NET/Source/System.Linq.Async/System/Runtime/CompilerServices/EnumeratorCancellationAttribute.cs

@@ -1,15 +0,0 @@
-#if !BCL_HAS_ENUMERATOR_CANCELLATION
-
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-namespace System.Runtime.CompilerServices
-{
-    [AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
-    public sealed class EnumeratorCancellationAttribute : Attribute
-    {
-    }
-}
-
-#endif