Переглянути джерело

Merge pull request #1331 from dotnet/dev/bartde/readonly_structs

Mark some structs as readonly.
Bart J.F. De Smet 5 роки тому
батько
коміт
825f55bf24

+ 1 - 1
Rx.NET/Source/src/Microsoft.Reactive.Testing/Recorded.cs

@@ -17,7 +17,7 @@ namespace Microsoft.Reactive.Testing
 #if !NO_SERIALIZABLE
     [Serializable]
 #endif
-    public struct Recorded<T> : IEquatable<Recorded<T>>
+    public readonly struct Recorded<T> : IEquatable<Recorded<T>>
     {
         private readonly long _time;
         private readonly T _value;

+ 1 - 1
Rx.NET/Source/src/Microsoft.Reactive.Testing/Subscription.cs

@@ -15,7 +15,7 @@ namespace Microsoft.Reactive.Testing
 #if !NO_SERIALIZABLE
     [Serializable]
 #endif
-    public struct Subscription : IEquatable<Subscription>
+    public readonly struct Subscription : IEquatable<Subscription>
     {
         /// <summary>
         /// Infinite virtual time value, used to indicate an unsubscription never took place.

+ 1 - 1
Rx.NET/Source/src/System.Reactive/TimeInterval.cs

@@ -15,7 +15,7 @@ namespace System.Reactive
 #if !NO_SERIALIZABLE
     [Serializable]
 #endif
-    public struct TimeInterval<T> : IEquatable<TimeInterval<T>>
+    public readonly struct TimeInterval<T> : IEquatable<TimeInterval<T>>
     {
         /// <summary>
         /// Constructs a time interval value.

+ 1 - 1
Rx.NET/Source/src/System.Reactive/Timestamped.cs

@@ -16,7 +16,7 @@ namespace System.Reactive
     [Serializable]
 #endif
     [Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Timestamped", Justification = "Reviewed and agreed upon.")]
-    public struct Timestamped<T> : IEquatable<Timestamped<T>>
+    public readonly struct Timestamped<T> : IEquatable<Timestamped<T>>
     {
         /// <summary>
         /// Constructs a timestamped value.

+ 1 - 1
Rx.NET/Source/src/System.Reactive/Unit.cs

@@ -10,7 +10,7 @@ namespace System.Reactive
 #if !NO_SERIALIZABLE
     [Serializable]
 #endif
-    public struct Unit : IEquatable<Unit>
+    public readonly struct Unit : IEquatable<Unit>
     {
         /// <summary>
         /// Determines whether the specified <see cref="Unit"/> value is equal to the current <see cref="Unit"/>. Because <see cref="Unit"/> has a single value, this always returns <c>true</c>.

+ 3 - 3
Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/ApiApprovalTests.Core.verified.cs

@@ -184,7 +184,7 @@ namespace System.Reactive
         protected abstract void OnNextCore(T value);
     }
     [System.Serializable]
-    public struct TimeInterval<T> : System.IEquatable<System.Reactive.TimeInterval<T>>
+    public readonly struct TimeInterval<T> : System.IEquatable<System.Reactive.TimeInterval<T>>
     {
         public TimeInterval(T value, System.TimeSpan interval) { }
         public System.TimeSpan Interval { get; }
@@ -201,7 +201,7 @@ namespace System.Reactive
         public static System.Reactive.Timestamped<T> Create<T>(T value, System.DateTimeOffset timestamp) { }
     }
     [System.Serializable]
-    public struct Timestamped<T> : System.IEquatable<System.Reactive.Timestamped<T>>
+    public readonly struct Timestamped<T> : System.IEquatable<System.Reactive.Timestamped<T>>
     {
         public Timestamped(T value, System.DateTimeOffset timestamp) { }
         public System.DateTimeOffset Timestamp { get; }
@@ -214,7 +214,7 @@ namespace System.Reactive
         public static bool operator ==(System.Reactive.Timestamped<T> first, System.Reactive.Timestamped<T> second) { }
     }
     [System.Serializable]
-    public struct Unit : System.IEquatable<System.Reactive.Unit>
+    public readonly struct Unit : System.IEquatable<System.Reactive.Unit>
     {
         public static System.Reactive.Unit Default { get; }
         public override bool Equals(object obj) { }

+ 2 - 2
Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/ApiApprovalTests.Testing.verified.cs

@@ -55,7 +55,7 @@ namespace Microsoft.Reactive.Testing
     }
     [System.Diagnostics.DebuggerDisplay("{Value}@{Time}")]
     [System.Serializable]
-    public struct Recorded<T> : System.IEquatable<Microsoft.Reactive.Testing.Recorded<T>>
+    public readonly struct Recorded<T> : System.IEquatable<Microsoft.Reactive.Testing.Recorded<T>>
     {
         public Recorded(long time, T value) { }
         public long Time { get; }
@@ -69,7 +69,7 @@ namespace Microsoft.Reactive.Testing
     }
     [System.Diagnostics.DebuggerDisplay("({Subscribe}, {Unsubscribe})")]
     [System.Serializable]
-    public struct Subscription : System.IEquatable<Microsoft.Reactive.Testing.Subscription>
+    public readonly struct Subscription : System.IEquatable<Microsoft.Reactive.Testing.Subscription>
     {
         public const long Infinite = 9223372036854775807;
         public Subscription(long subscribe) { }