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

Mark some structs as readonly.

Bart De Smet 7 лет назад
Родитель
Сommit
8d11e5c8f4

+ 3 - 3
Ix.NET/Source/System.Linq.Async/System/Linq/AsyncEnumerable.cs

@@ -19,7 +19,7 @@ namespace System.Linq
             return new AnonymousAsyncEnumerable<T>(getEnumerator);
             return new AnonymousAsyncEnumerable<T>(getEnumerator);
         }
         }
 
 
-        public static IAsyncEnumerable<T> WithCancellation<T>(this IAsyncEnumerable<T> source, CancellationToken cancellationToken)
+        public static WithCancellationAsyncEnumerable<T> WithCancellation<T>(this IAsyncEnumerable<T> source, CancellationToken cancellationToken)
         {
         {
             if (source == null)
             if (source == null)
                 throw Error.ArgumentNull(nameof(source));
                 throw Error.ArgumentNull(nameof(source));
@@ -44,7 +44,7 @@ namespace System.Linq
         // REVIEW: Explicit implementation of the interfaces allows for composition with other "modifier operators" such as ConfigureAwait.
         // REVIEW: Explicit implementation of the interfaces allows for composition with other "modifier operators" such as ConfigureAwait.
         //         We expect that the "await foreach" statement will bind to the public struct methods, thus avoiding boxing.
         //         We expect that the "await foreach" statement will bind to the public struct methods, thus avoiding boxing.
 
 
-        public struct WithCancellationAsyncEnumerable<T> : IAsyncEnumerable<T>
+        public readonly struct WithCancellationAsyncEnumerable<T> : IAsyncEnumerable<T>
         {
         {
             private readonly IAsyncEnumerable<T> _source;
             private readonly IAsyncEnumerable<T> _source;
             private readonly CancellationToken _cancellationToken;
             private readonly CancellationToken _cancellationToken;
@@ -63,7 +63,7 @@ namespace System.Linq
             IAsyncEnumerator<T> IAsyncEnumerable<T>.GetAsyncEnumerator(CancellationToken cancellationToken)
             IAsyncEnumerator<T> IAsyncEnumerable<T>.GetAsyncEnumerator(CancellationToken cancellationToken)
                 => GetAsyncEnumerator(cancellationToken);
                 => GetAsyncEnumerator(cancellationToken);
 
 
-            public struct WithCancellationAsyncEnumerator : IAsyncEnumerator<T>
+            public readonly struct WithCancellationAsyncEnumerator : IAsyncEnumerator<T>
             {
             {
                 private readonly IAsyncEnumerator<T> _enumerator;
                 private readonly IAsyncEnumerator<T> _enumerator;
 
 

+ 1 - 1
Ix.NET/Source/System.Linq.Async/System/Linq/Maybe.cs

@@ -6,7 +6,7 @@ using System.Collections.Generic;
 
 
 namespace System.Linq
 namespace System.Linq
 {
 {
-    internal struct Maybe<T> : IEquatable<Maybe<T>>
+    internal readonly struct Maybe<T> : IEquatable<Maybe<T>>
     {
     {
         public Maybe(T value)
         public Maybe(T value)
         {
         {

+ 2 - 2
Ix.NET/Source/System.Linq.Async/System/Threading/Tasks/AsyncEnumerableExtensions.cs

@@ -22,7 +22,7 @@ namespace System.Threading.Tasks
             // REVIEW: Explicit implementation of the interfaces allows for composition with other "modifier operators" such as WithCancellation.
             // REVIEW: Explicit implementation of the interfaces allows for composition with other "modifier operators" such as WithCancellation.
             //         We expect that the "await foreach" statement will bind to the public struct methods, thus avoiding boxing.
             //         We expect that the "await foreach" statement will bind to the public struct methods, thus avoiding boxing.
 
 
-            public struct ConfiguredAsyncEnumerable<T> : IAsyncEnumerable<T>
+            public readonly struct ConfiguredAsyncEnumerable<T> : IAsyncEnumerable<T>
             {
             {
                 private readonly IAsyncEnumerable<T> _enumerable;
                 private readonly IAsyncEnumerable<T> _enumerable;
                 private readonly bool _continueOnCapturedContext;
                 private readonly bool _continueOnCapturedContext;
@@ -39,7 +39,7 @@ namespace System.Threading.Tasks
                 IAsyncEnumerator<T> IAsyncEnumerable<T>.GetAsyncEnumerator(CancellationToken cancellationToken) =>
                 IAsyncEnumerator<T> IAsyncEnumerable<T>.GetAsyncEnumerator(CancellationToken cancellationToken) =>
                     GetAsyncEnumerator(cancellationToken);
                     GetAsyncEnumerator(cancellationToken);
 
 
-                public struct ConfiguredAsyncEnumerator : IAsyncEnumerator<T>
+                public readonly struct ConfiguredAsyncEnumerator : IAsyncEnumerator<T>
                 {
                 {
                     private readonly IAsyncEnumerator<T> _enumerator;
                     private readonly IAsyncEnumerator<T> _enumerator;
                     private readonly bool _continueOnCapturedContext;
                     private readonly bool _continueOnCapturedContext;