Use expression-bodied members in more places (dotnet/coreclr#26500)
authorStephen Toub <stoub@microsoft.com>
Wed, 4 Sep 2019 15:21:59 +0000 (11:21 -0400)
committerGitHub <noreply@github.com>
Wed, 4 Sep 2019 15:21:59 +0000 (11:21 -0400)
* Fix IDE0027 (use expression body for accessors)

* Fix IDE0023 / IDE0024 (use expression body for operators)

* Apply suggestions from code review

Co-Authored-By: Adam Sitnik <adam.sitnik@gmail.com>
Commit migrated from https://github.com/dotnet/coreclr/commit/7b9509e01b9e1f840b990c56f5b4dfce33002896

92 files changed:
src/coreclr/src/System.Private.CoreLib/src/System/Collections/ObjectModel/ReadOnlyDictionary.cs
src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/ConstructorBuilder.cs
src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/DynamicMethod.cs
src/coreclr/src/System.Private.CoreLib/src/System/Reflection/Emit/MethodBuilder.cs
src/coreclr/src/System.Private.CoreLib/src/System/Reflection/RtFieldInfo.cs
src/coreclr/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.cs
src/coreclr/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/CLRIReferenceImpl.cs
src/coreclr/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/EventRegistrationTokenTable.cs
src/coreclr/src/System.Private.CoreLib/src/System/RuntimeHandles.cs
src/coreclr/src/System.Private.CoreLib/src/System/Threading/Overlapped.cs
src/libraries/System.Private.CoreLib/src/Internal/Threading/Tasks/AsyncCausalitySupport.cs
src/libraries/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeFileHandle.Windows.cs
src/libraries/System.Private.CoreLib/src/System/AppDomain.cs
src/libraries/System.Private.CoreLib/src/System/Array.cs
src/libraries/System.Private.CoreLib/src/System/AttributeUsageAttribute.cs
src/libraries/System.Private.CoreLib/src/System/ByReference.cs
src/libraries/System.Private.CoreLib/src/System/Collections/ArrayList.cs
src/libraries/System.Private.CoreLib/src/System/Collections/DictionaryEntry.cs
src/libraries/System.Private.CoreLib/src/System/Collections/Generic/List.cs
src/libraries/System.Private.CoreLib/src/System/Collections/Hashtable.cs
src/libraries/System.Private.CoreLib/src/System/Collections/ObjectModel/Collection.cs
src/libraries/System.Private.CoreLib/src/System/Collections/ObjectModel/ReadOnlyCollection.cs
src/libraries/System.Private.CoreLib/src/System/DateTime.cs
src/libraries/System.Private.CoreLib/src/System/DateTimeOffset.cs
src/libraries/System.Private.CoreLib/src/System/Decimal.cs
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Debug.cs
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/DiagnosticCounter.cs
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventDescriptor.cs
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventProvider.cs
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/EventDataAttribute.cs
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/EventPayload.cs
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/EventSourceActivity.cs
src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/TraceLogging/EventSourceOptions.cs
src/libraries/System.Private.CoreLib/src/System/Double.cs
src/libraries/System.Private.CoreLib/src/System/Exception.cs
src/libraries/System.Private.CoreLib/src/System/Globalization/CultureInfo.cs
src/libraries/System.Private.CoreLib/src/System/Globalization/IdnMapping.cs
src/libraries/System.Private.CoreLib/src/System/Globalization/SortVersion.cs
src/libraries/System.Private.CoreLib/src/System/Guid.cs
src/libraries/System.Private.CoreLib/src/System/IO/Stream.cs
src/libraries/System.Private.CoreLib/src/System/IO/StreamWriter.cs
src/libraries/System.Private.CoreLib/src/System/IO/TextWriter.cs
src/libraries/System.Private.CoreLib/src/System/IO/UnmanagedMemoryStreamWrapper.cs
src/libraries/System.Private.CoreLib/src/System/IntPtr.cs
src/libraries/System.Private.CoreLib/src/System/LocalAppContextSwitches.cs
src/libraries/System.Private.CoreLib/src/System/Nullable.cs
src/libraries/System.Private.CoreLib/src/System/Numerics/Vector.cs
src/libraries/System.Private.CoreLib/src/System/Numerics/Vector_Operations.cs
src/libraries/System.Private.CoreLib/src/System/OperationCanceledException.cs
src/libraries/System.Private.CoreLib/src/System/ReadOnlySpan.Fast.cs
src/libraries/System.Private.CoreLib/src/System/ReadOnlySpan.cs
src/libraries/System.Private.CoreLib/src/System/Reflection/Assembly.cs
src/libraries/System.Private.CoreLib/src/System/Reflection/AssemblyName.cs
src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/Label.cs
src/libraries/System.Private.CoreLib/src/System/Reflection/Emit/Opcode.cs
src/libraries/System.Private.CoreLib/src/System/Reflection/ParameterModifier.cs
src/libraries/System.Private.CoreLib/src/System/Resources/ResourceManager.cs
src/libraries/System.Private.CoreLib/src/System/Resources/ResourceReader.cs
src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/StrongBox.cs
src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/ArrayWithOffset.cs
src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/HandleRef.cs
src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Arm64/Aes.PlatformNotSupported.cs
src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Arm64/Base.PlatformNotSupported.cs
src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Arm64/Sha1.PlatformNotSupported.cs
src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Arm64/Sha256.PlatformNotSupported.cs
src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Arm64/Simd.PlatformNotSupported.cs
src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector128_1.cs
src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector256_1.cs
src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector64_1.cs
src/libraries/System.Private.CoreLib/src/System/Runtime/MemoryFailPoint.cs
src/libraries/System.Private.CoreLib/src/System/Runtime/Serialization/OptionalFieldAttribute.cs
src/libraries/System.Private.CoreLib/src/System/Runtime/Serialization/SerializationInfo.cs
src/libraries/System.Private.CoreLib/src/System/Runtime/Versioning/TargetFrameworkAttribute.cs
src/libraries/System.Private.CoreLib/src/System/Security/SecurityElement.cs
src/libraries/System.Private.CoreLib/src/System/Single.cs
src/libraries/System.Private.CoreLib/src/System/Span.Fast.cs
src/libraries/System.Private.CoreLib/src/System/Span.cs
src/libraries/System.Private.CoreLib/src/System/String.Comparison.cs
src/libraries/System.Private.CoreLib/src/System/Text/Decoder.cs
src/libraries/System.Private.CoreLib/src/System/Text/Encoder.cs
src/libraries/System.Private.CoreLib/src/System/Text/Encoding.cs
src/libraries/System.Private.CoreLib/src/System/Text/StringBuilder.cs
src/libraries/System.Private.CoreLib/src/System/Threading/AsyncLocal.cs
src/libraries/System.Private.CoreLib/src/System/Threading/ExecutionContext.cs
src/libraries/System.Private.CoreLib/src/System/Threading/ManualResetEventSlim.cs
src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs
src/libraries/System.Private.CoreLib/src/System/Threading/Thread.cs
src/libraries/System.Private.CoreLib/src/System/Threading/WaitHandle.cs
src/libraries/System.Private.CoreLib/src/System/TimeSpan.cs
src/libraries/System.Private.CoreLib/src/System/UIntPtr.cs
src/libraries/System.Private.CoreLib/src/System/Version.cs

index c31dc91..f493578 100644 (file)
@@ -92,14 +92,8 @@ namespace System.Collections.ObjectModel
 
         TValue IDictionary<TKey, TValue>.this[TKey key]
         {
-            get
-            {
-                return m_dictionary[key];
-            }
-            set
-            {
-                ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
-            }
+            get => m_dictionary[key];
+            set => ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
         }
 
         #endregion
@@ -193,10 +187,7 @@ namespace System.Collections.ObjectModel
                 }
                 return null;
             }
-            set
-            {
-                ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
-            }
+            set => ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
         }
 
         void ICollection.CopyTo(Array array, int index)
index c46f556..75e0999 100644 (file)
@@ -189,8 +189,8 @@ namespace System.Reflection.Emit
 
         public bool InitLocals
         {
-            get { return m_methodBuilder.InitLocals; }
-            set { m_methodBuilder.InitLocals = value; }
+            get => m_methodBuilder.InitLocals;
+            set => m_methodBuilder.InitLocals = value;
         }
 
         #endregion
index a50d49c..f4ec345 100644 (file)
@@ -535,8 +535,8 @@ namespace System.Reflection.Emit
 
         public bool InitLocals
         {
-            get { return m_fInitLocals; }
-            set { m_fInitLocals = value; }
+            get => m_fInitLocals;
+            set => m_fInitLocals = value;
         }
 
         //
index db38f60..3a2d85a 100644 (file)
@@ -1094,15 +1094,9 @@ namespace System.Reflection.Emit
                 other.m_kind == m_kind;
         }
 
-        public static bool operator ==(ExceptionHandler left, ExceptionHandler right)
-        {
-            return left.Equals(right);
-        }
+        public static bool operator ==(ExceptionHandler left, ExceptionHandler right) => left.Equals(right);
 
-        public static bool operator !=(ExceptionHandler left, ExceptionHandler right)
-        {
-            return !left.Equals(right);
-        }
+        public static bool operator !=(ExceptionHandler left, ExceptionHandler right) => !left.Equals(right);
 
         #endregion
     }
index 0e4cc8a..cad61f8 100644 (file)
@@ -23,11 +23,8 @@ namespace System.Reflection
         internal INVOCATION_FLAGS InvocationFlags
         {
             [MethodImpl(MethodImplOptions.AggressiveInlining)]
-            get
-            {
-                return (m_invocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_INITIALIZED) != 0 ?
+            get => (m_invocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_INITIALIZED) != 0 ?
                     m_invocationFlags : InitializeInvocationFlags();
-            }
         }
 
         [MethodImpl(MethodImplOptions.NoInlining)]
@@ -241,10 +238,7 @@ namespace System.Reflection
         public override Type FieldType
         {
             [MethodImpl(MethodImplOptions.AggressiveInlining)]
-            get
-            {
-                return m_fieldType ?? InitializeFieldType();
-            }
+            get => m_fieldType ?? InitializeFieldType();
         }
 
         [MethodImpl(MethodImplOptions.NoInlining)]
index f170f60..78f37f0 100644 (file)
@@ -106,8 +106,7 @@ namespace System.Runtime.CompilerServices
             // This offset is baked in by string indexer intrinsic, so there is no harm
             // in getting it baked in here as well.
             [System.Runtime.Versioning.NonVersionable]
-            get
-            {
+            get =>
                 // Number of bytes from the address pointed to by a reference to
                 // a String to the first 16-bit character in the String.  Skip
                 // over the MethodTable pointer, & String
@@ -116,11 +115,11 @@ namespace System.Runtime.CompilerServices
                 // This property allows C#'s fixed statement to work on Strings.
                 // On 64 bit platforms, this should be 12 (8+4) and on 32 bit 8 (4+4).
 #if BIT64
-                return 12;
+                12;
 #else // 32
-                return 8;
+                8;
 #endif // BIT64
-            }
+
         }
 
         // This method ensures that there is sufficient stack to execute the average Framework function.
index cd89b86..3a3741c 100644 (file)
@@ -99,15 +99,8 @@ namespace System.Runtime.InteropServices.WindowsRuntime
         //
         object? IList.this[int index]
         {
-            get
-            {
-                return _list[index];
-            }
-
-            set
-            {
-                _list[index] = value;
-            }
+            get => _list[index];
+            set => _list[index] = value;
         }
 
         int IList.Add(object? value)
index 219aa8b..ce52f02 100644 (file)
@@ -34,10 +34,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime
         // in this table.  If the property is set, the new value will replace any existing token registrations.
         public T? InvocationList
         {
-            get
-            {
-                return m_invokeList;
-            }
+            get => m_invokeList;
             set
             {
                 lock (m_tokens)
index 9057cbf..8e21ad6 100644 (file)
@@ -68,13 +68,13 @@ namespace System
             return type;
         }
 
-        public static bool operator ==(RuntimeTypeHandle left, object? right) { return left.Equals(right); }
+        public static bool operator ==(RuntimeTypeHandle left, object? right) => left.Equals(right);
 
-        public static bool operator ==(object? left, RuntimeTypeHandle right) { return right.Equals(left); }
+        public static bool operator ==(object? left, RuntimeTypeHandle right) => right.Equals(left);
 
-        public static bool operator !=(RuntimeTypeHandle left, object? right) { return !left.Equals(right); }
+        public static bool operator !=(RuntimeTypeHandle left, object? right) => !left.Equals(right);
 
-        public static bool operator !=(object? left, RuntimeTypeHandle right) { return !right.Equals(left); }
+        public static bool operator !=(object? left, RuntimeTypeHandle right) => !right.Equals(left);
 
 
         // This is the RuntimeType for the type
@@ -751,15 +751,9 @@ namespace System
             return handle.Value == Value;
         }
 
-        public static bool operator ==(RuntimeMethodHandle left, RuntimeMethodHandle right)
-        {
-            return left.Equals(right);
-        }
+        public static bool operator ==(RuntimeMethodHandle left, RuntimeMethodHandle right) => left.Equals(right);
 
-        public static bool operator !=(RuntimeMethodHandle left, RuntimeMethodHandle right)
-        {
-            return !left.Equals(right);
-        }
+        public static bool operator !=(RuntimeMethodHandle left, RuntimeMethodHandle right) => !left.Equals(right);
 
         public bool Equals(RuntimeMethodHandle handle)
         {
@@ -1081,15 +1075,9 @@ namespace System
             return handle.Value == Value;
         }
 
-        public static bool operator ==(RuntimeFieldHandle left, RuntimeFieldHandle right)
-        {
-            return left.Equals(right);
-        }
+        public static bool operator ==(RuntimeFieldHandle left, RuntimeFieldHandle right) => left.Equals(right);
 
-        public static bool operator !=(RuntimeFieldHandle left, RuntimeFieldHandle right)
-        {
-            return !left.Equals(right);
-        }
+        public static bool operator !=(RuntimeFieldHandle left, RuntimeFieldHandle right) => !left.Equals(right);
 
         [MethodImplAttribute(MethodImplOptions.InternalCall)]
         internal static extern string GetName(RtFieldInfo field);
@@ -1193,15 +1181,9 @@ namespace System
             return handle.m_ptr == m_ptr;
         }
 
-        public static bool operator ==(ModuleHandle left, ModuleHandle right)
-        {
-            return left.Equals(right);
-        }
+        public static bool operator ==(ModuleHandle left, ModuleHandle right) => left.Equals(right);
 
-        public static bool operator !=(ModuleHandle left, ModuleHandle right)
-        {
-            return !left.Equals(right);
-        }
+        public static bool operator !=(ModuleHandle left, ModuleHandle right) => !left.Equals(right);
 
         [MethodImplAttribute(MethodImplOptions.InternalCall)]
         internal static extern IRuntimeMethodInfo GetDynamicMethod(System.Reflection.Emit.DynamicMethod method, RuntimeModule module, string name, byte[] sig, Resolver resolver);
index 77caf8d..c7d2bd7 100644 (file)
@@ -180,33 +180,33 @@ namespace System.Threading
 
         public IAsyncResult? AsyncResult
         {
-            get { return _overlappedData!._asyncResult; }
-            set { _overlappedData!._asyncResult = value; }
+            get => _overlappedData!._asyncResult;
+            set => _overlappedData!._asyncResult = value;
         }
 
         public int OffsetLow
         {
-            get { return _overlappedData!.OffsetLow; }
-            set { _overlappedData!.OffsetLow = value; }
+            get => _overlappedData!.OffsetLow;
+            set => _overlappedData!.OffsetLow = value;
         }
 
         public int OffsetHigh
         {
-            get { return _overlappedData!.OffsetHigh; }
-            set { _overlappedData!.OffsetHigh = value; }
+            get => _overlappedData!.OffsetHigh;
+            set => _overlappedData!.OffsetHigh = value;
         }
 
         [Obsolete("This property is not 64-bit compatible.  Use EventHandleIntPtr instead.  http://go.microsoft.com/fwlink/?linkid=14202")]
         public int EventHandle
         {
-            get { return EventHandleIntPtr.ToInt32(); }
-            set { EventHandleIntPtr = new IntPtr(value); }
+            get => EventHandleIntPtr.ToInt32();
+            set => EventHandleIntPtr = new IntPtr(value);
         }
 
         public IntPtr EventHandleIntPtr
         {
-            get { return _overlappedData!.EventHandle; }
-            set { _overlappedData!.EventHandle = value; }
+            get => _overlappedData!.EventHandle;
+            set => _overlappedData!.EventHandle = value;
         }
 
         /*====================================================================
index 5fdeb43..f05a201 100644 (file)
@@ -7,9 +7,7 @@ using System.Runtime.CompilerServices;
 
 namespace Internal.Threading.Tasks
 {
-    //
-    // An internal contract that exposes just enough async debugger support needed by the AsTask() extension methods in the WindowsRuntimeSystemExtensions class.
-    //
+    /// <summary>Internal contract exposing just enough async debugger support needed by the AsTask() extension methods in the WindowsRuntimeSystemExtensions class.</summary>
     public static class AsyncCausalitySupport
     {
         [MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -29,28 +27,19 @@ namespace Internal.Threading.Tasks
         public static bool LoggingOn
         {
             [MethodImpl(MethodImplOptions.AggressiveInlining)]
-            get
-            {
-                return AsyncCausalityTracer.LoggingOn;
-            }
+            get => AsyncCausalityTracer.LoggingOn;
         }
 
         [MethodImpl(MethodImplOptions.AggressiveInlining)]
-        public static void TraceOperationCreation(Task task, string operationName)
-        {
+        public static void TraceOperationCreation(Task task, string operationName) =>
             AsyncCausalityTracer.TraceOperationCreation(task, operationName);
-        }
 
         [MethodImpl(MethodImplOptions.AggressiveInlining)]
-        public static void TraceOperationCompletedSuccess(Task task)
-        {
+        public static void TraceOperationCompletedSuccess(Task task) =>
             AsyncCausalityTracer.TraceOperationCompletion(task, AsyncCausalityStatus.Completed);
-        }
 
         [MethodImpl(MethodImplOptions.AggressiveInlining)]
-        public static void TraceOperationCompletedError(Task task)
-        {
+        public static void TraceOperationCompletedError(Task task) =>
             AsyncCausalityTracer.TraceOperationCompletion(task, AsyncCausalityStatus.Error);
-        }
     }
 }
index 500f0f5..c54218e 100644 (file)
@@ -25,22 +25,13 @@ namespace Microsoft.Win32.SafeHandles
 
         internal bool? IsAsync
         {
-            get
-            {
-                return _isAsync;
-            }
-
-            set
-            {
-                _isAsync = value;
-            }
+            get => _isAsync;
+            set => _isAsync = value;
         }
 
         internal ThreadPoolBoundHandle? ThreadPoolBinding { get; set; }
 
-        protected override bool ReleaseHandle()
-        {
-            return Interop.Kernel32.CloseHandle(handle);
-        }
+        protected override bool ReleaseHandle() =>
+            Interop.Kernel32.CloseHandle(handle);
     }
 }
index 64ed058..f5013dc 100644 (file)
@@ -181,7 +181,7 @@ namespace System
 
         public static bool MonitoringIsEnabled
         {
-            get { return true; }
+            get => true;
             set
             {
                 if (!value)
index 0ceeec3..260e414 100644 (file)
@@ -260,8 +260,8 @@ namespace System
 
         object? IList.this[int index]
         {
-            get { return GetValue(index); }
-            set { SetValue(value, index); }
+            get => GetValue(index);
+            set => SetValue(value, index);
         }
 
         int IList.Add(object? value)
index 7a0fa3e..6f67366 100644 (file)
@@ -27,6 +27,7 @@ namespace System
         {
             _attributeTarget = validOn;
         }
+
         internal AttributeUsageAttribute(AttributeTargets validOn, bool allowMultiple, bool inherited)
         {
             _attributeTarget = validOn;
@@ -38,14 +39,14 @@ namespace System
 
         public bool AllowMultiple
         {
-            get { return _allowMultiple; }
-            set { _allowMultiple = value; }
+            get => _allowMultiple;
+            set => _allowMultiple = value;
         }
 
         public bool Inherited
         {
-            get { return _inherited; }
-            set { _inherited = value; }
+            get => _inherited;
+            set => _inherited = value;
         }
     }
 }
index ab51cb6..980aedc 100644 (file)
@@ -31,14 +31,11 @@ namespace System
 
         public ref T Value
         {
+            // Implemented as a JIT intrinsic - This default implementation is for
+            // completeness and to provide a concrete error if called via reflection
+            // or if the intrinsic is missed.
             [Intrinsic]
-            get
-            {
-                // Implemented as a JIT intrinsic - This default implementation is for
-                // completeness and to provide a concrete error if called via reflection
-                // or if the intrinsic is missed.
-                throw new PlatformNotSupportedException();
-            }
+            get => throw new PlatformNotSupportedException();
         }
     }
 }
index 70f21d6..53c7d79 100644 (file)
@@ -90,10 +90,7 @@ namespace System.Collections
         //
         public virtual int Capacity
         {
-            get
-            {
-                return _items.Length;
-            }
+            get => _items.Length;
             set
             {
                 if (value < _size)
@@ -766,7 +763,7 @@ namespace System.Collections
 
             public override int Capacity
             {
-                get { return _list.Count; }
+                get => _list.Count;
                 set
                 {
                     if (value < Count) throw new ArgumentOutOfRangeException(nameof(value), SR.ArgumentOutOfRange_SmallCapacity);
@@ -784,10 +781,7 @@ namespace System.Collections
 
             public override object? this[int index]
             {
-                get
-                {
-                    return _list[index];
-                }
+                get => _list[index];
                 set
                 {
                     _list[index] = value;
@@ -1680,14 +1674,8 @@ namespace System.Collections
 
             public virtual object? this[int index]
             {
-                get
-                {
-                    return _list[index];
-                }
-                set
-                {
-                    _list[index] = value;
-                }
+                get => _list[index];
+                set => _list[index] = value;
             }
 
             public virtual object SyncRoot => _list.SyncRoot;
@@ -1758,10 +1746,7 @@ namespace System.Collections
 
             public override object? this[int index]
             {
-                get
-                {
-                    return _list[index];
-                }
+                get => _list[index];
                 set
                 {
                     _list[index] = value;
@@ -1789,10 +1774,9 @@ namespace System.Collections
 
             public override int Capacity
             {
-                get { return _list.Capacity; }
+                get => _list.Capacity;
                 [SuppressMessage("Microsoft.Contracts", "CC1055")]  // Skip extra error checking to avoid *potential* AppCompat problems.
-                set
-                { throw new NotSupportedException(SR.NotSupported_FixedSizeCollection); }
+                set => throw new NotSupportedException(SR.NotSupported_FixedSizeCollection);
             }
 
             public override void Clear()
@@ -1962,14 +1946,8 @@ namespace System.Collections
 
             public virtual object? this[int index]
             {
-                get
-                {
-                    return _list[index];
-                }
-                set
-                {
-                    throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection);
-                }
+                get => _list[index];
+                set => throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection);
             }
 
             public virtual object SyncRoot => _list.SyncRoot;
@@ -2039,14 +2017,8 @@ namespace System.Collections
 
             public override object? this[int index]
             {
-                get
-                {
-                    return _list[index];
-                }
-                set
-                {
-                    throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection);
-                }
+                get => _list[index];
+                set => throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection);
             }
 
             public override object SyncRoot => _list.SyncRoot;
@@ -2070,10 +2042,9 @@ namespace System.Collections
 
             public override int Capacity
             {
-                get { return _list.Capacity; }
+                get => _list.Capacity;
                 [SuppressMessage("Microsoft.Contracts", "CC1055")]  // Skip extra error checking to avoid *potential* AppCompat problems.
-                set
-                { throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection); }
+                set => throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection);
             }
 
             public override void Clear()
@@ -2355,10 +2326,7 @@ namespace System.Collections
 
             public override int Capacity
             {
-                get
-                {
-                    return _baseList.Capacity;
-                }
+                get => _baseList.Capacity;
 
                 set
                 {
index 7e86f38..d328692 100644 (file)
@@ -25,28 +25,14 @@ namespace System.Collections
 
         public object Key
         {
-            get
-            {
-                return _key;
-            }
-
-            set
-            {
-                _key = value;
-            }
+            get => _key;
+            set => _key = value;
         }
 
         public object? Value
         {
-            get
-            {
-                return _value;
-            }
-
-            set
-            {
-                _value = value;
-            }
+            get => _value;
+            set => _value = value;
         }
 
         [EditorBrowsable(EditorBrowsableState.Never)]
index d72f6f4..62993e7 100644 (file)
@@ -98,10 +98,7 @@ namespace System.Collections.Generic
         //
         public int Capacity
         {
-            get
-            {
-                return _items.Length;
-            }
+            get => _items.Length;
             set
             {
                 if (value < _size)
@@ -177,10 +174,7 @@ namespace System.Collections.Generic
 
         object? IList.this[int index]
         {
-            get
-            {
-                return this[index];
-            }
+            get => this[index];
             set
             {
                 ThrowHelper.IfNullAndNullsAreIllegalThenThrow<T>(value, ExceptionArgument.value);
index b9b6e86..119d768 100644 (file)
@@ -699,10 +699,7 @@ namespace System.Collections
                 return null;
             }
 
-            set
-            {
-                Insert(key, value, false);
-            }
+            set => Insert(key, value, false);
         }
 
         // Increases the bucket count of this hashtable. This method is called from
@@ -1328,10 +1325,7 @@ namespace System.Collections
 
             public override object? this[object key]
             {
-                get
-                {
-                    return _table[key];
-                }
+                get => _table[key];
                 set
                 {
                     lock (_table.SyncRoot)
index e8e9b19..6b032ed 100644 (file)
@@ -35,7 +35,7 @@ namespace System.Collections.ObjectModel
 
         public T this[int index]
         {
-            get { return items[index]; }
+            get => items[index];
             set
             {
                 if (items.IsReadOnly)
@@ -240,7 +240,7 @@ namespace System.Collections.ObjectModel
 
         object? IList.this[int index]
         {
-            get { return items[index]; }
+            get => items[index];
             set
             {
                 ThrowHelper.IfNullAndNullsAreIllegalThenThrow<T>(value, ExceptionArgument.value);
index 9a9a142..4791ae7 100644 (file)
@@ -57,11 +57,8 @@ namespace System.Collections.ObjectModel
 
         T IList<T>.this[int index]
         {
-            get { return list[index]; }
-            set
-            {
-                ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
-            }
+            get => list[index];
+            set => ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
         }
 
         void ICollection<T>.Add(T value)
@@ -176,11 +173,8 @@ namespace System.Collections.ObjectModel
 
         object? IList.this[int index]
         {
-            get { return list[index]; }
-            set
-            {
-                ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
-            }
+            get => list[index];
+            set => ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection);
         }
 
         int IList.Add(object? value)
index 08b5187..afe5488 100644 (file)
@@ -1418,40 +1418,19 @@ namespace System
             return new DateTime((ulong)(ticks - valueTicks) | d.InternalKind);
         }
 
-        public static TimeSpan operator -(DateTime d1, DateTime d2)
-        {
-            return new TimeSpan(d1.InternalTicks - d2.InternalTicks);
-        }
+        public static TimeSpan operator -(DateTime d1, DateTime d2) => new TimeSpan(d1.InternalTicks - d2.InternalTicks);
 
-        public static bool operator ==(DateTime d1, DateTime d2)
-        {
-            return d1.InternalTicks == d2.InternalTicks;
-        }
+        public static bool operator ==(DateTime d1, DateTime d2) => d1.InternalTicks == d2.InternalTicks;
 
-        public static bool operator !=(DateTime d1, DateTime d2)
-        {
-            return d1.InternalTicks != d2.InternalTicks;
-        }
+        public static bool operator !=(DateTime d1, DateTime d2) => d1.InternalTicks != d2.InternalTicks;
 
-        public static bool operator <(DateTime t1, DateTime t2)
-        {
-            return t1.InternalTicks < t2.InternalTicks;
-        }
+        public static bool operator <(DateTime t1, DateTime t2) => t1.InternalTicks < t2.InternalTicks;
 
-        public static bool operator <=(DateTime t1, DateTime t2)
-        {
-            return t1.InternalTicks <= t2.InternalTicks;
-        }
+        public static bool operator <=(DateTime t1, DateTime t2) => t1.InternalTicks <= t2.InternalTicks;
 
-        public static bool operator >(DateTime t1, DateTime t2)
-        {
-            return t1.InternalTicks > t2.InternalTicks;
-        }
+        public static bool operator >(DateTime t1, DateTime t2) => t1.InternalTicks > t2.InternalTicks;
 
-        public static bool operator >=(DateTime t1, DateTime t2)
-        {
-            return t1.InternalTicks >= t2.InternalTicks;
-        }
+        public static bool operator >=(DateTime t1, DateTime t2) => t1.InternalTicks >= t2.InternalTicks;
 
 
         // Returns a string array containing all of the known date and time options for the
index 091513a..42fd917 100644 (file)
@@ -828,55 +828,35 @@ namespace System
 
         // Operators
 
-        public static implicit operator DateTimeOffset(DateTime dateTime)
-        {
-            return new DateTimeOffset(dateTime);
-        }
+        public static implicit operator DateTimeOffset(DateTime dateTime) =>
+            new DateTimeOffset(dateTime);
 
-        public static DateTimeOffset operator +(DateTimeOffset dateTimeOffset, TimeSpan timeSpan)
-        {
-            return new DateTimeOffset(dateTimeOffset.ClockDateTime + timeSpan, dateTimeOffset.Offset);
-        }
+        public static DateTimeOffset operator +(DateTimeOffset dateTimeOffset, TimeSpan timeSpan) =>
+            new DateTimeOffset(dateTimeOffset.ClockDateTime + timeSpan, dateTimeOffset.Offset);
 
 
-        public static DateTimeOffset operator -(DateTimeOffset dateTimeOffset, TimeSpan timeSpan)
-        {
-            return new DateTimeOffset(dateTimeOffset.ClockDateTime - timeSpan, dateTimeOffset.Offset);
-        }
+        public static DateTimeOffset operator -(DateTimeOffset dateTimeOffset, TimeSpan timeSpan) =>
+            new DateTimeOffset(dateTimeOffset.ClockDateTime - timeSpan, dateTimeOffset.Offset);
 
-        public static TimeSpan operator -(DateTimeOffset left, DateTimeOffset right)
-        {
-            return left.UtcDateTime - right.UtcDateTime;
-        }
+        public static TimeSpan operator -(DateTimeOffset left, DateTimeOffset right) =>
+            left.UtcDateTime - right.UtcDateTime;
 
-        public static bool operator ==(DateTimeOffset left, DateTimeOffset right)
-        {
-            return left.UtcDateTime == right.UtcDateTime;
-        }
+        public static bool operator ==(DateTimeOffset left, DateTimeOffset right) =>
+            left.UtcDateTime == right.UtcDateTime;
 
-        public static bool operator !=(DateTimeOffset left, DateTimeOffset right)
-        {
-            return left.UtcDateTime != right.UtcDateTime;
-        }
+        public static bool operator !=(DateTimeOffset left, DateTimeOffset right) =>
+            left.UtcDateTime != right.UtcDateTime;
 
-        public static bool operator <(DateTimeOffset left, DateTimeOffset right)
-        {
-            return left.UtcDateTime < right.UtcDateTime;
-        }
+        public static bool operator <(DateTimeOffset left, DateTimeOffset right) =>
+            left.UtcDateTime < right.UtcDateTime;
 
-        public static bool operator <=(DateTimeOffset left, DateTimeOffset right)
-        {
-            return left.UtcDateTime <= right.UtcDateTime;
-        }
+        public static bool operator <=(DateTimeOffset left, DateTimeOffset right) =>
+            left.UtcDateTime <= right.UtcDateTime;
 
-        public static bool operator >(DateTimeOffset left, DateTimeOffset right)
-        {
-            return left.UtcDateTime > right.UtcDateTime;
-        }
+        public static bool operator >(DateTimeOffset left, DateTimeOffset right) =>
+            left.UtcDateTime > right.UtcDateTime;
 
-        public static bool operator >=(DateTimeOffset left, DateTimeOffset right)
-        {
-            return left.UtcDateTime >= right.UtcDateTime;
-        }
+        public static bool operator >=(DateTimeOffset left, DateTimeOffset right) =>
+            left.UtcDateTime >= right.UtcDateTime;
     }
 }
index d607739..9240c6f 100644 (file)
@@ -824,75 +824,36 @@ namespace System
                 DecCalc.InternalRound(ref AsMutable(ref d), (byte)(flags >> ScaleShift), MidpointRounding.ToZero);
         }
 
-        public static implicit operator decimal(byte value)
-        {
-            return new decimal((uint)value);
-        }
+        public static implicit operator decimal(byte value) => new decimal((uint)value);
 
         [CLSCompliant(false)]
-        public static implicit operator decimal(sbyte value)
-        {
-            return new decimal(value);
-        }
+        public static implicit operator decimal(sbyte value) => new decimal(value);
 
-        public static implicit operator decimal(short value)
-        {
-            return new decimal(value);
-        }
+        public static implicit operator decimal(short value) => new decimal(value);
 
         [CLSCompliant(false)]
-        public static implicit operator decimal(ushort value)
-        {
-            return new decimal((uint)value);
-        }
+        public static implicit operator decimal(ushort value) => new decimal((uint)value);
 
-        public static implicit operator decimal(char value)
-        {
-            return new decimal((uint)value);
-        }
+        public static implicit operator decimal(char value) => new decimal((uint)value);
 
-        public static implicit operator decimal(int value)
-        {
-            return new decimal(value);
-        }
+        public static implicit operator decimal(int value) => new decimal(value);
 
         [CLSCompliant(false)]
-        public static implicit operator decimal(uint value)
-        {
-            return new decimal(value);
-        }
+        public static implicit operator decimal(uint value) => new decimal(value);
 
-        public static implicit operator decimal(long value)
-        {
-            return new decimal(value);
-        }
+        public static implicit operator decimal(long value) => new decimal(value);
 
         [CLSCompliant(false)]
-        public static implicit operator decimal(ulong value)
-        {
-            return new decimal(value);
-        }
+        public static implicit operator decimal(ulong value) => new decimal(value);
 
-        public static explicit operator decimal(float value)
-        {
-            return new decimal(value);
-        }
+        public static explicit operator decimal(float value) => new decimal(value);
 
-        public static explicit operator decimal(double value)
-        {
-            return new decimal(value);
-        }
+        public static explicit operator decimal(double value) => new decimal(value);
 
-        public static explicit operator byte(decimal value)
-        {
-            return ToByte(value);
-        }
+        public static explicit operator byte(decimal value) => ToByte(value);
 
         [CLSCompliant(false)]
-        public static explicit operator sbyte(decimal value)
-        {
-            return ToSByte(value);
-        }
+        public static explicit operator sbyte(decimal value) => ToSByte(value);
 
         public static explicit operator char(decimal value)
         {
@@ -908,68 +869,32 @@ namespace System
             return (char)temp;
         }
 
-        public static explicit operator short(decimal value)
-        {
-            return ToInt16(value);
-        }
+        public static explicit operator short(decimal value) => ToInt16(value);
 
         [CLSCompliant(false)]
-        public static explicit operator ushort(decimal value)
-        {
-            return ToUInt16(value);
-        }
+        public static explicit operator ushort(decimal value) => ToUInt16(value);
 
-        public static explicit operator int(decimal value)
-        {
-            return ToInt32(value);
-        }
+        public static explicit operator int(decimal value) => ToInt32(value);
 
         [CLSCompliant(false)]
-        public static explicit operator uint(decimal value)
-        {
-            return ToUInt32(value);
-        }
+        public static explicit operator uint(decimal value) => ToUInt32(value);
 
-        public static explicit operator long(decimal value)
-        {
-            return ToInt64(value);
-        }
+        public static explicit operator long(decimal value) => ToInt64(value);
 
         [CLSCompliant(false)]
-        public static explicit operator ulong(decimal value)
-        {
-            return ToUInt64(value);
-        }
+        public static explicit operator ulong(decimal value) => ToUInt64(value);
 
-        public static explicit operator float(decimal value)
-        {
-            return ToSingle(value);
-        }
+        public static explicit operator float(decimal value) => ToSingle(value);
 
-        public static explicit operator double(decimal value)
-        {
-            return ToDouble(value);
-        }
+        public static explicit operator double(decimal value) => ToDouble(value);
 
-        public static decimal operator +(decimal d)
-        {
-            return d;
-        }
+        public static decimal operator +(decimal d) => d;
 
-        public static decimal operator -(decimal d)
-        {
-            return new decimal(in d, d.flags ^ SignMask);
-        }
+        public static decimal operator -(decimal d) => new decimal(in d, d.flags ^ SignMask);
 
-        public static decimal operator ++(decimal d)
-        {
-            return Add(d, One);
-        }
+        public static decimal operator ++(decimal d) => Add(d, One);
 
-        public static decimal operator --(decimal d)
-        {
-            return Subtract(d, One);
-        }
+        public static decimal operator --(decimal d) => Subtract(d, One);
 
         public static decimal operator +(decimal d1, decimal d2)
         {
@@ -1001,35 +926,17 @@ namespace System
             return d1;
         }
 
-        public static bool operator ==(decimal d1, decimal d2)
-        {
-            return DecCalc.VarDecCmp(in d1, in d2) == 0;
-        }
+        public static bool operator ==(decimal d1, decimal d2) => DecCalc.VarDecCmp(in d1, in d2) == 0;
 
-        public static bool operator !=(decimal d1, decimal d2)
-        {
-            return DecCalc.VarDecCmp(in d1, in d2) != 0;
-        }
+        public static bool operator !=(decimal d1, decimal d2) => DecCalc.VarDecCmp(in d1, in d2) != 0;
 
-        public static bool operator <(decimal d1, decimal d2)
-        {
-            return DecCalc.VarDecCmp(in d1, in d2) < 0;
-        }
+        public static bool operator <(decimal d1, decimal d2) => DecCalc.VarDecCmp(in d1, in d2) < 0;
 
-        public static bool operator <=(decimal d1, decimal d2)
-        {
-            return DecCalc.VarDecCmp(in d1, in d2) <= 0;
-        }
+        public static bool operator <=(decimal d1, decimal d2) => DecCalc.VarDecCmp(in d1, in d2) <= 0;
 
-        public static bool operator >(decimal d1, decimal d2)
-        {
-            return DecCalc.VarDecCmp(in d1, in d2) > 0;
-        }
+        public static bool operator >(decimal d1, decimal d2) => DecCalc.VarDecCmp(in d1, in d2) > 0;
 
-        public static bool operator >=(decimal d1, decimal d2)
-        {
-            return DecCalc.VarDecCmp(in d1, in d2) >= 0;
-        }
+        public static bool operator >=(decimal d1, decimal d2) => DecCalc.VarDecCmp(in d1, in d2) >= 0;
 
         //
         // IConvertible implementation
index 8e98288..ea1c0a8 100644 (file)
@@ -25,16 +25,17 @@ namespace System.Diagnostics
             return Interlocked.Exchange(ref s_provider, provider);
         }
 
-        public static bool AutoFlush { get { return true; } set { } }
+        public static bool AutoFlush
+        {
+            get => true;
+            set { }
+        }
 
         [ThreadStatic]
         private static int t_indentLevel;
         public static int IndentLevel
         {
-            get
-            {
-                return t_indentLevel;
-            }
+            get => t_indentLevel;
             set
             {
                 t_indentLevel = value < 0 ? 0 : value;
@@ -45,10 +46,7 @@ namespace System.Diagnostics
         private static volatile int s_indentSize = 4;
         public static int IndentSize
         {
-            get
-            {
-                return s_indentSize;
-            }
+            get => s_indentSize;
             set
             {
                 s_indentSize = value < 0 ? 0 : value;
@@ -63,40 +61,28 @@ namespace System.Diagnostics
         public static void Flush() { }
 
         [System.Diagnostics.Conditional("DEBUG")]
-        public static void Indent()
-        {
+        public static void Indent() =>
             IndentLevel++;
-        }
 
         [System.Diagnostics.Conditional("DEBUG")]
-        public static void Unindent()
-        {
+        public static void Unindent() =>
             IndentLevel--;
-        }
 
         [System.Diagnostics.Conditional("DEBUG")]
-        public static void Print(string? message)
-        {
+        public static void Print(string? message) =>
             WriteLine(message);
-        }
 
         [System.Diagnostics.Conditional("DEBUG")]
-        public static void Print(string format, params object?[] args)
-        {
+        public static void Print(string format, params object?[] args) =>
             WriteLine(string.Format(null, format, args));
-        }
 
         [System.Diagnostics.Conditional("DEBUG")]
-        public static void Assert([DoesNotReturnIf(false)] bool condition)
-        {
+        public static void Assert([DoesNotReturnIf(false)] bool condition) =>
             Assert(condition, string.Empty, string.Empty);
-        }
 
         [System.Diagnostics.Conditional("DEBUG")]
-        public static void Assert([DoesNotReturnIf(false)] bool condition, string? message)
-        {
+        public static void Assert([DoesNotReturnIf(false)] bool condition, string? message) =>
             Assert(condition, message, string.Empty);
-        }
 
         [System.Diagnostics.Conditional("DEBUG")]
         public static void Assert([DoesNotReturnIf(false)] bool condition, string? message, string? detailMessage)
@@ -124,53 +110,37 @@ namespace System.Diagnostics
 
         [System.Diagnostics.Conditional("DEBUG")]
         [DoesNotReturn]
-        public static void Fail(string? message)
-        {
+        public static void Fail(string? message) =>
             Fail(message, string.Empty);
-        }
 
         [System.Diagnostics.Conditional("DEBUG")]
         [DoesNotReturn]
-        public static void Fail(string? message, string? detailMessage)
-        {
+        public static void Fail(string? message, string? detailMessage) =>
             s_provider.Fail(message, detailMessage);
-        }
 
         [System.Diagnostics.Conditional("DEBUG")]
-        public static void Assert([DoesNotReturnIf(false)] bool condition, string? message, string detailMessageFormat, params object?[] args)
-        {
+        public static void Assert([DoesNotReturnIf(false)] bool condition, string? message, string detailMessageFormat, params object?[] args) =>
             Assert(condition, message, string.Format(detailMessageFormat, args));
-        }
 
         [System.Diagnostics.Conditional("DEBUG")]
-        public static void WriteLine(string? message)
-        {
+        public static void WriteLine(string? message) =>
             s_provider.WriteLine(message);
-        }
 
         [System.Diagnostics.Conditional("DEBUG")]
-        public static void Write(string? message)
-        {
+        public static void Write(string? message) =>
             s_provider.Write(message);
-        }
 
         [System.Diagnostics.Conditional("DEBUG")]
-        public static void WriteLine(object? value)
-        {
+        public static void WriteLine(object? value) =>
             WriteLine(value?.ToString());
-        }
 
         [System.Diagnostics.Conditional("DEBUG")]
-        public static void WriteLine(object? value, string? category)
-        {
+        public static void WriteLine(object? value, string? category) =>
             WriteLine(value?.ToString(), category);
-        }
 
         [System.Diagnostics.Conditional("DEBUG")]
-        public static void WriteLine(string format, params object?[] args)
-        {
+        public static void WriteLine(string format, params object?[] args) =>
             WriteLine(string.Format(null, format, args));
-        }
 
         [System.Diagnostics.Conditional("DEBUG")]
         public static void WriteLine(string? message, string? category)
@@ -186,10 +156,8 @@ namespace System.Diagnostics
         }
 
         [System.Diagnostics.Conditional("DEBUG")]
-        public static void Write(object? value)
-        {
+        public static void Write(object? value) =>
             Write(value?.ToString());
-        }
 
         [System.Diagnostics.Conditional("DEBUG")]
         public static void Write(string? message, string? category)
@@ -205,10 +173,8 @@ namespace System.Diagnostics
         }
 
         [System.Diagnostics.Conditional("DEBUG")]
-        public static void Write(object? value, string? category)
-        {
+        public static void Write(object? value, string? category) =>
             Write(value?.ToString(), category);
-        }
 
         [System.Diagnostics.Conditional("DEBUG")]
         public static void WriteIf(bool condition, string? message)
index c903686..9a01f20 100644 (file)
@@ -89,7 +89,7 @@ namespace System.Diagnostics.Tracing
         private string _displayName = "";
         public string DisplayName
         {
-            get { return _displayName; }
+            get => _displayName;
             set
             {
                 if (value == null)
@@ -101,7 +101,7 @@ namespace System.Diagnostics.Tracing
         private string _displayUnits = "";
         public string DisplayUnits
         {
-            get { return _displayUnits; }
+            get => _displayUnits;
             set
             {
                 if (value == null)
index 19ea483..02ba4d7 100644 (file)
@@ -121,42 +121,25 @@ namespace System.Diagnostics.Tracing
 
         internal int TraceLoggingId => m_traceloggingId;
 
-        public override bool Equals(object? obj)
-        {
-            if (!(obj is EventDescriptor))
-                return false;
-
-            return Equals((EventDescriptor)obj);
-        }
-
-        public override int GetHashCode()
-        {
-            return m_id ^ m_version ^ m_channel ^ m_level ^ m_opcode ^ m_task ^ (int)m_keywords;
-        }
-
-        public bool Equals(EventDescriptor other)
-        {
-            if ((m_id != other.m_id) ||
-                (m_version != other.m_version) ||
-                (m_channel != other.m_channel) ||
-                (m_level != other.m_level) ||
-                (m_opcode != other.m_opcode) ||
-                (m_task != other.m_task) ||
-                (m_keywords != other.m_keywords))
-            {
-                return false;
-            }
-            return true;
-        }
-
-        public static bool operator ==(EventDescriptor event1, EventDescriptor event2)
-        {
-            return event1.Equals(event2);
-        }
-
-        public static bool operator !=(EventDescriptor event1, EventDescriptor event2)
-        {
-            return !event1.Equals(event2);
-        }
+        public override bool Equals(object? obj) =>
+            obj is EventDescriptor ed && Equals(ed);
+
+        public override int GetHashCode() =>
+            m_id ^ m_version ^ m_channel ^ m_level ^ m_opcode ^ m_task ^ (int)m_keywords;
+
+        public bool Equals(EventDescriptor other) =>
+            m_id == other.m_id &&
+            m_version == other.m_version &&
+            m_channel == other.m_channel &&
+            m_level == other.m_level &&
+            m_opcode == other.m_opcode &&
+            m_task == other.m_task &&
+            m_keywords == other.m_keywords;
+
+        public static bool operator ==(EventDescriptor event1, EventDescriptor event2) =>
+            event1.Equals(event2);
+
+        public static bool operator !=(EventDescriptor event1, EventDescriptor event2) =>
+            !event1.Equals(event2);
     }
 }
index 1af6b10..6a3d373 100644 (file)
@@ -34,7 +34,6 @@ namespace System.Diagnostics.Tracing
         EventPipe
     }
 
-    // New in CLR4.0
     internal enum ControllerCommand
     {
         // Strictly Positive numbers are for provider-specific commands, negative number are for 'shared' commands. 256
@@ -343,11 +342,25 @@ namespace System.Diagnostics.Tracing
             }
         }
 
-        // New in CLR4.0
         protected virtual void OnControllerCommand(ControllerCommand command, IDictionary<string, string?>? arguments, int sessionId, int etwSessionId) { }
-        protected EventLevel Level { get { return (EventLevel)m_level; } set { m_level = (byte)value; } }
-        protected EventKeywords MatchAnyKeyword { get { return (EventKeywords)m_anyKeywordMask; } set { m_anyKeywordMask = unchecked((long)value); } }
-        protected EventKeywords MatchAllKeyword { get { return (EventKeywords)m_allKeywordMask; } set { m_allKeywordMask = unchecked((long)value); } }
+
+        protected EventLevel Level
+        {
+            get => (EventLevel)m_level;
+            set => m_level = (byte)value;
+        }
+
+        protected EventKeywords MatchAnyKeyword
+        {
+            get => (EventKeywords)m_anyKeywordMask;
+            set => m_anyKeywordMask = unchecked((long)value);
+        }
+
+        protected EventKeywords MatchAllKeyword
+        {
+            get => (EventKeywords)m_allKeywordMask;
+            set => m_allKeywordMask = unchecked((long)value);
+        }
 
         private static int FindNull(byte[] buffer, int idx)
         {
index 08a04b6..4783935 100644 (file)
@@ -1103,18 +1103,30 @@ namespace System.Diagnostics.Tracing
             /// Address where the one argument lives (if this points to managed memory you must ensure the
             /// managed object is pinned.
             /// </summary>
-            public unsafe IntPtr DataPointer { get { return (IntPtr)(void*)m_Ptr; } set { m_Ptr = unchecked((ulong)(void*)value); } }
+            public unsafe IntPtr DataPointer
+            {
+                get => (IntPtr)(void*)m_Ptr;
+                set => m_Ptr = unchecked((ulong)(void*)value);
+            }
 
             /// <summary>
             /// Size of the argument referenced by DataPointer
             /// </summary>
-            public int Size { get { return m_Size; } set { m_Size = value; } }
+            public int Size
+            {
+                get => m_Size;
+                set => m_Size = value;
+            }
 
             /// <summary>
             /// Reserved by ETW.  This property is present to ensure that we can zero it
             /// since System.Private.CoreLib uses are not zero'd.
             /// </summary>
-            internal int Reserved { get { return m_Reserved; } set { m_Reserved = value; } }
+            internal int Reserved
+            {
+                get => m_Reserved;
+                set => m_Reserved = value;
+            }
 
 #region private
             /// <summary>
@@ -4676,10 +4688,7 @@ namespace System.Diagnostics.Tracing
                     return m_eventSource.m_eventData[EventId].Name;
                 }
             }
-            internal set
-            {
-                m_eventName = value;
-            }
+            internal set => m_eventName = value;
         }
 
         /// <summary>
@@ -4702,10 +4711,7 @@ namespace System.Diagnostics.Tracing
 
                 return activityId;
             }
-            internal set
-            {
-                m_activityId = value;
-            }
+            internal set => m_activityId = value;
         }
 
         /// <summary>
@@ -4748,10 +4754,7 @@ namespace System.Diagnostics.Tracing
                 return m_payloadNames;
             }
 
-            internal set
-            {
-                m_payloadNames = value;
-            }
+            internal set => m_payloadNames = value;
         }
 
         /// <summary>
@@ -4836,10 +4839,7 @@ namespace System.Diagnostics.Tracing
                     return m_eventSource.m_eventData[EventId].Message;
                 }
             }
-            internal set
-            {
-                m_message = value;
-            }
+            internal set => m_message = value;
         }
 
 
@@ -4908,10 +4908,7 @@ namespace System.Diagnostics.Tracing
 
                 return m_osThreadId.Value;
             }
-            internal set
-            {
-                m_osThreadId = value;
-            }
+            internal set => m_osThreadId = value;
         }
 
         /// <summary>
@@ -5005,10 +5002,7 @@ namespace System.Diagnostics.Tracing
         /// <summary>Event's operation code: allows defining operations, generally used with Tasks</summary>
         public EventOpcode Opcode
         {
-            get
-            {
-                return m_opcode;
-            }
+            get => m_opcode;
             set
             {
                 this.m_opcode = value;
@@ -5247,31 +5241,21 @@ namespace System.Diagnostics.Tracing
             }
         }
 
-        public static SessionMask operator |(SessionMask m1, SessionMask m2)
-        {
-            return new SessionMask(m1.m_mask | m2.m_mask);
-        }
+        public static SessionMask operator |(SessionMask m1, SessionMask m2) =>
+            new SessionMask(m1.m_mask | m2.m_mask);
 
-        public static SessionMask operator &(SessionMask m1, SessionMask m2)
-        {
-            return new SessionMask(m1.m_mask & m2.m_mask);
-        }
+        public static SessionMask operator &(SessionMask m1, SessionMask m2) =>
+            new SessionMask(m1.m_mask & m2.m_mask);
 
-        public static SessionMask operator ^(SessionMask m1, SessionMask m2)
-        {
-            return new SessionMask(m1.m_mask ^ m2.m_mask);
-        }
+        public static SessionMask operator ^(SessionMask m1, SessionMask m2) =>
+            new SessionMask(m1.m_mask ^ m2.m_mask);
 
-        public static SessionMask operator ~(SessionMask m)
-        {
-            return new SessionMask(MASK & ~(m.m_mask));
-        }
+        public static SessionMask operator ~(SessionMask m) =>
+            new SessionMask(MASK & ~(m.m_mask));
 
-        public static explicit operator ulong(SessionMask m)
-        { return m.m_mask; }
+        public static explicit operator ulong(SessionMask m) => m.m_mask;
 
-        public static explicit operator uint(SessionMask m)
-        { return m.m_mask; }
+        public static explicit operator uint(SessionMask m) => m.m_mask;
 
         private uint m_mask;
 
index 1dff406..cd88c81 100644 (file)
@@ -83,8 +83,8 @@ namespace System.Diagnostics.Tracing
         /// </summary>
         internal EventLevel Level
         {
-            get { return this.level; }
-            set { this.level = value; }
+            get => this.level;
+            set => this.level = value;
         }
 
         /// <summary>
@@ -109,8 +109,8 @@ namespace System.Diagnostics.Tracing
         /// </summary>
         internal EventOpcode Opcode
         {
-            get { return this.opcode; }
-            set { this.opcode = value; }
+            get => this.opcode;
+            set => this.opcode = value;
         }
 
         /// <summary>
index de71538..b177a75 100644 (file)
@@ -53,10 +53,7 @@ namespace System.Diagnostics.Tracing
 
                 throw new System.Collections.Generic.KeyNotFoundException(SR.Format(SR.Arg_KeyNotFoundWithKey, key));
             }
-            set
-            {
-                throw new System.NotSupportedException();
-            }
+            set => throw new System.NotSupportedException();
         }
 
         public void Add(string key, object? value)
index 8d2835f..62952a7 100644 (file)
@@ -40,7 +40,8 @@ namespace System.Diagnostics.Tracing
         /// <summary>
         /// You can make an activity out of just an EventSource.
         /// </summary>
-        public static implicit operator EventSourceActivity(EventSource eventSource) { return new EventSourceActivity(eventSource); }
+        public static implicit operator EventSourceActivity(EventSource eventSource) =>
+            new EventSourceActivity(eventSource);
 
         /* Properties */
         /// <summary>
index 1e52a19..c6b675a 100644 (file)
@@ -38,11 +38,7 @@ namespace System.Diagnostics.Tracing
         /// </summary>
         public EventLevel Level
         {
-            get
-            {
-                return (EventLevel)this.level;
-            }
-
+            get => (EventLevel)this.level;
             set
             {
                 this.level = checked((byte)value);
@@ -56,11 +52,7 @@ namespace System.Diagnostics.Tracing
         /// </summary>
         public EventOpcode Opcode
         {
-            get
-            {
-                return (EventOpcode)this.opcode;
-            }
-
+            get => (EventOpcode)this.opcode;
             set
             {
                 this.opcode = checked((byte)value);
@@ -76,11 +68,7 @@ namespace System.Diagnostics.Tracing
         /// </summary>
         public EventKeywords Keywords
         {
-            get
-            {
-                return this.keywords;
-            }
-
+            get => this.keywords;
             set
             {
                 this.keywords = value;
@@ -94,11 +82,7 @@ namespace System.Diagnostics.Tracing
         /// </summary>
         public EventTags Tags
         {
-            get
-            {
-                return this.tags;
-            }
-
+            get => this.tags;
             set
             {
                 this.tags = value;
@@ -112,10 +96,7 @@ namespace System.Diagnostics.Tracing
         /// </summary>
         public EventActivityOptions ActivityOptions
         {
-            get
-            {
-                return this.activityOptions;
-            }
+            get => this.activityOptions;
             set
             {
                 this.activityOptions = value;
index 82e6cd7..8b7bf9f 100644 (file)
@@ -209,40 +209,22 @@ namespace System
         }
 
         [NonVersionable]
-        public static bool operator ==(double left, double right)
-        {
-            return left == right;
-        }
+        public static bool operator ==(double left, double right) => left == right;
 
         [NonVersionable]
-        public static bool operator !=(double left, double right)
-        {
-            return left != right;
-        }
+        public static bool operator !=(double left, double right) => left != right;
 
         [NonVersionable]
-        public static bool operator <(double left, double right)
-        {
-            return left < right;
-        }
+        public static bool operator <(double left, double right) => left < right;
 
         [NonVersionable]
-        public static bool operator >(double left, double right)
-        {
-            return left > right;
-        }
+        public static bool operator >(double left, double right) => left > right;
 
         [NonVersionable]
-        public static bool operator <=(double left, double right)
-        {
-            return left <= right;
-        }
+        public static bool operator <=(double left, double right) => left <= right;
 
         [NonVersionable]
-        public static bool operator >=(double left, double right)
-        {
-            return left >= right;
-        }
+        public static bool operator >=(double left, double right) => left >= right;
 
         public bool Equals(double obj)
         {
index bd0e80c..0fe895c 100644 (file)
@@ -81,26 +81,14 @@ namespace System
         // "file:///C:/Applications/Bazzal/help.html#ErrorNum42"
         public virtual string? HelpLink
         {
-            get
-            {
-                return _helpURL;
-            }
-            set
-            {
-                _helpURL = value;
-            }
+            get => _helpURL;
+            set => _helpURL = value;
         }
 
         public virtual string? Source
         {
-            get
-            {
-                return _source ?? (_source = CreateSourceName());
-            }
-            set
-            {
-                _source = value;
-            }
+            get => _source ?? (_source = CreateSourceName());
+            set => _source = value;
         }
 
         public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
@@ -162,14 +150,8 @@ namespace System
 
         public int HResult
         {
-            get
-            {
-                return _HResult;
-            }
-            set
-            {
-                _HResult = value;
-            }
+            get => _HResult;
+            set => _HResult = value;
         }
 
         // this method is required so Object.GetType is not made virtual by the compiler
index 46bea6a..fe4e3aa 100644 (file)
@@ -520,12 +520,10 @@ namespace System.Globalization
         public static CultureInfo? DefaultThreadCurrentCulture
         {
             get => s_DefaultThreadCurrentCulture;
-            set
-            {
+            set =>
                 // If you add pre-conditions to this method, check to see if you also need to
                 // add them to Thread.CurrentCulture.set.
                 s_DefaultThreadCurrentCulture = value;
-            }
         }
 
         public static CultureInfo? DefaultThreadCurrentUICulture
index 0cab20b..09d2e82 100644 (file)
@@ -42,21 +42,19 @@ namespace System.Globalization
 
         public bool AllowUnassigned
         {
-            get { return _allowUnassigned; }
-            set { _allowUnassigned = value; }
+            get => _allowUnassigned;
+            set => _allowUnassigned = value;
         }
 
         public bool UseStd3AsciiRules
         {
-            get { return _useStd3AsciiRules; }
-            set { _useStd3AsciiRules = value; }
+            get => _useStd3AsciiRules;
+            set => _useStd3AsciiRules = value;
         }
 
         // Gets ASCII (Punycode) version of the string
-        public string GetAscii(string unicode)
-        {
-            return GetAscii(unicode, 0);
-        }
+        public string GetAscii(string unicode) =>
+            GetAscii(unicode, 0);
 
         public string GetAscii(string unicode, int index)
         {
@@ -100,10 +98,8 @@ namespace System.Globalization
         }
 
         // Gets Unicode version of the string.  Normalized and limited to IDNA characters.
-        public string GetUnicode(string ascii)
-        {
-            return GetUnicode(ascii, 0);
-        }
+        public string GetUnicode(string ascii) =>
+            GetUnicode(ascii, 0);
 
         public string GetUnicode(string ascii, int index)
         {
@@ -143,26 +139,19 @@ namespace System.Globalization
             }
         }
 
-        public override bool Equals(object? obj)
-        {
-            return
-                obj is IdnMapping that &&
-                _allowUnassigned == that._allowUnassigned &&
-                _useStd3AsciiRules == that._useStd3AsciiRules;
-        }
+        public override bool Equals(object? obj) =>
+            obj is IdnMapping that &&
+            _allowUnassigned == that._allowUnassigned &&
+            _useStd3AsciiRules == that._useStd3AsciiRules;
 
-        public override int GetHashCode()
-        {
-            return (_allowUnassigned ? 100 : 200) + (_useStd3AsciiRules ? 1000 : 2000);
-        }
+        public override int GetHashCode() =>
+            (_allowUnassigned ? 100 : 200) + (_useStd3AsciiRules ? 1000 : 2000);
 
         [MethodImpl(MethodImplOptions.AggressiveInlining)]
-        private static unsafe string GetStringForOutput(string originalString, char* input, int inputLength, char* output, int outputLength)
-        {
-            return originalString.Length == inputLength && new ReadOnlySpan<char>(input, inputLength).SequenceEqual(new ReadOnlySpan<char>(output, outputLength)) ?
+        private static unsafe string GetStringForOutput(string originalString, char* input, int inputLength, char* output, int outputLength) =>
+            originalString.Length == inputLength && new ReadOnlySpan<char>(input, inputLength).SequenceEqual(new ReadOnlySpan<char>(output, outputLength)) ?
                 originalString :
                 new string(output, 0, outputLength);
-        }
 
         //
         // Invariant implementation
@@ -183,7 +172,7 @@ namespace System.Globalization
 
 
         // Legal "dot" separators (i.e: . in www.microsoft.com)
-        private static readonly char[] c_Dots = { '.', '\u3002', '\uFF0E', '\uFF61' };
+        private static readonly char[] s_dotSeparators = { '.', '\u3002', '\uFF0E', '\uFF61' };
 
         private string GetAsciiInvariant(string unicode, int index, int count)
         {
@@ -321,7 +310,7 @@ namespace System.Globalization
             while (iNextDot < unicode.Length)
             {
                 // Find end of this segment
-                iNextDot = unicode.IndexOfAny(c_Dots, iAfterLastDot);
+                iNextDot = unicode.IndexOfAny(s_dotSeparators, iAfterLastDot);
                 Debug.Assert(iNextDot <= unicode.Length, "[IdnMapping.punycode_encode]IndexOfAny is broken");
                 if (iNextDot < 0)
                     iNextDot = unicode.Length;
@@ -521,21 +510,15 @@ namespace System.Globalization
         // are we U+002E (., full stop), U+3002 (ideographic full stop), U+FF0E (fullwidth full stop), or
         // U+FF61 (halfwidth ideographic full stop).
         // Note: IDNA Normalization gets rid of dots now, but testing for last dot is before normalization
-        private static bool IsDot(char c)
-        {
-            return c == '.' || c == '\u3002' || c == '\uFF0E' || c == '\uFF61';
-        }
+        private static bool IsDot(char c) =>
+            c == '.' || c == '\u3002' || c == '\uFF0E' || c == '\uFF61';
 
-        private static bool IsSupplementary(int cTest)
-        {
-            return cTest >= 0x10000;
-        }
+        private static bool IsSupplementary(int cTest) =>
+            cTest >= 0x10000;
 
-        private static bool Basic(uint cp)
-        {
+        private static bool Basic(uint cp) =>
             // Is it in ASCII range?
-            return cp < 0x80;
-        }
+            cp < 0x80;
 
         // Validate Std3 rules for a character
         private static void ValidateStd3(char c, bool bNextToDot)
@@ -868,10 +851,8 @@ namespace System.Globalization
         }
 
         // Return whether a punycode code point is flagged as being upper case.
-        private static bool HasUpperCaseFlag(char punychar)
-        {
-            return (punychar >= 'A' && punychar <= 'Z');
-        }
+        private static bool HasUpperCaseFlag(char punychar) =>
+            punychar >= 'A' && punychar <= 'Z';
 
         /* EncodeDigit(d,flag) returns the basic code point whose value      */
         /* (when used for representing integers) is d, which needs to be in   */
index f2b8e56..2cac238 100644 (file)
@@ -77,9 +77,7 @@ namespace System.Globalization
             return right.Equals(left);
         }
 
-        public static bool operator !=(SortVersion? left, SortVersion? right)
-        {
-            return !(left == right);
-        }
+        public static bool operator !=(SortVersion? left, SortVersion? right) =>
+            !(left == right);
     }
 }
index 97de756..6a2f850 100644 (file)
@@ -939,23 +939,18 @@ namespace System
             return 0;
         }
 
-        public static bool operator ==(Guid a, Guid b)
-        {
-            // Now compare each of the elements
-            return a._a == b._a &&
+        public static bool operator ==(Guid a, Guid b) =>
+            a._a == b._a &&
                 Unsafe.Add(ref a._a, 1) == Unsafe.Add(ref b._a, 1) &&
                 Unsafe.Add(ref a._a, 2) == Unsafe.Add(ref b._a, 2) &&
                 Unsafe.Add(ref a._a, 3) == Unsafe.Add(ref b._a, 3);
-        }
 
-        public static bool operator !=(Guid a, Guid b)
-        {
+        public static bool operator !=(Guid a, Guid b) =>
             // Now compare each of the elements
-            return a._a != b._a ||
+            a._a != b._a ||
                 Unsafe.Add(ref a._a, 1) != Unsafe.Add(ref b._a, 1) ||
                 Unsafe.Add(ref a._a, 2) != Unsafe.Add(ref b._a, 2) ||
                 Unsafe.Add(ref a._a, 3) != Unsafe.Add(ref b._a, 3);
-        }
 
         public string ToString(string? format)
         {
index dc6e884..e53fc9f 100644 (file)
@@ -76,26 +76,14 @@ namespace System.IO
 
         public virtual int ReadTimeout
         {
-            get
-            {
-                throw new InvalidOperationException(SR.InvalidOperation_TimeoutsNotSupported);
-            }
-            set
-            {
-                throw new InvalidOperationException(SR.InvalidOperation_TimeoutsNotSupported);
-            }
+            get => throw new InvalidOperationException(SR.InvalidOperation_TimeoutsNotSupported);
+            set => throw new InvalidOperationException(SR.InvalidOperation_TimeoutsNotSupported);
         }
 
         public virtual int WriteTimeout
         {
-            get
-            {
-                throw new InvalidOperationException(SR.InvalidOperation_TimeoutsNotSupported);
-            }
-            set
-            {
-                throw new InvalidOperationException(SR.InvalidOperation_TimeoutsNotSupported);
-            }
+            get => throw new InvalidOperationException(SR.InvalidOperation_TimeoutsNotSupported);
+            set => throw new InvalidOperationException(SR.InvalidOperation_TimeoutsNotSupported);
         }
 
         public Task CopyToAsync(Stream destination)
@@ -878,7 +866,7 @@ namespace System.IO
 
             public override long Position
             {
-                get { return 0; }
+                get => 0;
                 set { }
             }
 
@@ -1134,26 +1122,14 @@ namespace System.IO
 
             public override int ReadTimeout
             {
-                get
-                {
-                    return _stream.ReadTimeout;
-                }
-                set
-                {
-                    _stream.ReadTimeout = value;
-                }
+                get => _stream.ReadTimeout;
+                set => _stream.ReadTimeout = value;
             }
 
             public override int WriteTimeout
             {
-                get
-                {
-                    return _stream.WriteTimeout;
-                }
-                set
-                {
-                    _stream.WriteTimeout = value;
-                }
+                get => _stream.WriteTimeout;
+                set => _stream.WriteTimeout = value;
             }
 
             // In the off chance that some wrapped stream has different
index 4950d28..3987457 100644 (file)
@@ -293,7 +293,7 @@ namespace System.IO
 
         public virtual bool AutoFlush
         {
-            get { return _autoFlush; }
+            get => _autoFlush;
 
             set
             {
index 3b7d2db..256f3d0 100644 (file)
@@ -121,7 +121,7 @@ namespace System.IO
         [AllowNull]
         public virtual string NewLine
         {
-            get { return CoreNewLineStr; }
+            get => CoreNewLineStr;
             set
             {
                 if (value == null)
@@ -766,9 +766,9 @@ namespace System.IO
             public override string NewLine
             {
                 [MethodImpl(MethodImplOptions.Synchronized)]
-                get { return _out.NewLine; }
+                get => _out.NewLine;
                 [MethodImpl(MethodImplOptions.Synchronized)]
-                set { _out.NewLine = value; }
+                set => _out.NewLine = value;
             }
 
             [MethodImpl(MethodImplOptions.Synchronized)]
index 88915cc..e90c094 100644 (file)
@@ -65,28 +65,16 @@ namespace System.IO
 
         public override int Capacity
         {
-            get
-            {
-                return (int)_unmanagedStream.Capacity;
-            }
-            set
-            {
-                throw new IOException(SR.IO_FixedCapacity);
-            }
+            get => (int)_unmanagedStream.Capacity;
+            set => throw new IOException(SR.IO_FixedCapacity);
         }
 
         public override long Length => _unmanagedStream.Length;
 
         public override long Position
         {
-            get
-            {
-                return _unmanagedStream.Position;
-            }
-            set
-            {
-                _unmanagedStream.Position = value;
-            }
+            get => _unmanagedStream.Position;
+            set => _unmanagedStream.Position = value;
         }
 
         public override int Read(byte[] buffer, int offset, int count)
index d3c2c9b..4c63510 100644 (file)
@@ -73,19 +73,12 @@ namespace System
             info.AddValue("value", ToInt64());
         }
 
-        public override unsafe bool Equals(object? obj)
-        {
-            if (obj is IntPtr)
-            {
-                return (_value == ((IntPtr)obj)._value);
-            }
-            return false;
-        }
+        public override unsafe bool Equals(object? obj) =>
+            obj is IntPtr other &&
+            _value == other._value;
 
-        unsafe bool IEquatable<IntPtr>.Equals(IntPtr other)
-        {
-            return _value == other._value;
-        }
+        unsafe bool IEquatable<IntPtr>.Equals(IntPtr other) =>
+            _value == other._value;
 
         public override unsafe int GetHashCode()
         {
@@ -111,40 +104,30 @@ namespace System
 
         [Intrinsic]
         [NonVersionable]
-        public unsafe long ToInt64()
-        {
-            return (nint)_value;
-        }
+        public unsafe long ToInt64() =>
+            (nint)_value;
 
         [Intrinsic]
         [NonVersionable]
-        public static unsafe explicit operator IntPtr(int value)
-        {
-            return new IntPtr(value);
-        }
+        public static unsafe explicit operator IntPtr(int value) =>
+            new IntPtr(value);
 
         [Intrinsic]
         [NonVersionable]
-        public static unsafe explicit operator IntPtr(long value)
-        {
-            return new IntPtr(value);
-        }
+        public static unsafe explicit operator IntPtr(long value) =>
+            new IntPtr(value);
 
         [CLSCompliant(false)]
         [Intrinsic]
         [NonVersionable]
-        public static unsafe explicit operator IntPtr(void* value)
-        {
-            return new IntPtr(value);
-        }
+        public static unsafe explicit operator IntPtr(void* value) =>
+            new IntPtr(value);
 
         [CLSCompliant(false)]
         [Intrinsic]
         [NonVersionable]
-        public static unsafe explicit operator void*(IntPtr value)
-        {
-            return value._value;
-        }
+        public static unsafe explicit operator void*(IntPtr value) =>
+            value._value;
 
         [Intrinsic]
         [NonVersionable]
@@ -160,77 +143,53 @@ namespace System
 
         [Intrinsic]
         [NonVersionable]
-        public static unsafe explicit operator long(IntPtr value)
-        {
-            return (nint)value._value;
-        }
+        public static unsafe explicit operator long(IntPtr value) =>
+            (nint)value._value;
 
         [Intrinsic]
         [NonVersionable]
-        public static unsafe bool operator ==(IntPtr value1, IntPtr value2)
-        {
-            return value1._value == value2._value;
-        }
+        public static unsafe bool operator ==(IntPtr value1, IntPtr value2) =>
+            value1._value == value2._value;
 
         [Intrinsic]
         [NonVersionable]
-        public static unsafe bool operator !=(IntPtr value1, IntPtr value2)
-        {
-            return value1._value != value2._value;
-        }
+        public static unsafe bool operator !=(IntPtr value1, IntPtr value2) =>
+            value1._value != value2._value;
 
         [NonVersionable]
-        public static IntPtr Add(IntPtr pointer, int offset)
-        {
-            return pointer + offset;
-        }
+        public static IntPtr Add(IntPtr pointer, int offset) =>
+            pointer + offset;
 
         [Intrinsic]
         [NonVersionable]
-        public static unsafe IntPtr operator +(IntPtr pointer, int offset)
-        {
-            return new IntPtr((nint)pointer._value + offset);
-        }
+        public static unsafe IntPtr operator +(IntPtr pointer, int offset) =>
+            new IntPtr((nint)pointer._value + offset);
 
         [NonVersionable]
-        public static IntPtr Subtract(IntPtr pointer, int offset)
-        {
-            return pointer - offset;
-        }
+        public static IntPtr Subtract(IntPtr pointer, int offset) =>
+            pointer - offset;
 
         [Intrinsic]
         [NonVersionable]
-        public static unsafe IntPtr operator -(IntPtr pointer, int offset)
-        {
-            return new IntPtr((nint)pointer._value - offset);
-        }
+        public static unsafe IntPtr operator -(IntPtr pointer, int offset) =>
+            new IntPtr((nint)pointer._value - offset);
 
         public static int Size
         {
             [Intrinsic]
             [NonVersionable]
-            get
-            {
-                return sizeof(nint);
-            }
+            get => sizeof(nint);
         }
 
         [CLSCompliant(false)]
         [Intrinsic]
         [NonVersionable]
-        public unsafe void* ToPointer()
-        {
-            return _value;
-        }
+        public unsafe void* ToPointer() => _value;
 
-        public override unsafe string ToString()
-        {
-            return ((nint)_value).ToString(CultureInfo.InvariantCulture);
-        }
+        public override unsafe string ToString() =>
+            ((nint)_value).ToString(CultureInfo.InvariantCulture);
 
-        public unsafe string ToString(string format)
-        {
-            return ((nint)_value).ToString(format, CultureInfo.InvariantCulture);
-        }
+        public unsafe string ToString(string format) =>
+            ((nint)_value).ToString(format, CultureInfo.InvariantCulture);
     }
 }
index a285359..a8c2b18 100644 (file)
@@ -12,49 +12,34 @@ namespace System
         public static bool EnforceJapaneseEraYearRanges
         {
             [MethodImpl(MethodImplOptions.AggressiveInlining)]
-            get
-            {
-                return GetCachedSwitchValue("Switch.System.Globalization.EnforceJapaneseEraYearRanges", ref s_enforceJapaneseEraYearRanges);
-            }
+            get => GetCachedSwitchValue("Switch.System.Globalization.EnforceJapaneseEraYearRanges", ref s_enforceJapaneseEraYearRanges);
         }
 
         private static int s_formatJapaneseFirstYearAsANumber;
         public static bool FormatJapaneseFirstYearAsANumber
         {
             [MethodImpl(MethodImplOptions.AggressiveInlining)]
-            get
-            {
-                return GetCachedSwitchValue("Switch.System.Globalization.FormatJapaneseFirstYearAsANumber", ref s_formatJapaneseFirstYearAsANumber);
-            }
+            get => GetCachedSwitchValue("Switch.System.Globalization.FormatJapaneseFirstYearAsANumber", ref s_formatJapaneseFirstYearAsANumber);
         }
         private static int s_enforceLegacyJapaneseDateParsing;
         public static bool EnforceLegacyJapaneseDateParsing
         {
             [MethodImpl(MethodImplOptions.AggressiveInlining)]
-            get
-            {
-                return GetCachedSwitchValue("Switch.System.Globalization.EnforceLegacyJapaneseDateParsing", ref s_enforceLegacyJapaneseDateParsing);
-            }
+            get => GetCachedSwitchValue("Switch.System.Globalization.EnforceLegacyJapaneseDateParsing", ref s_enforceLegacyJapaneseDateParsing);
         }
 
         private static int s_preserveEventListnerObjectIdentity;
         public static bool PreserveEventListnerObjectIdentity
         {
             [MethodImpl(MethodImplOptions.AggressiveInlining)]
-            get
-            {
-                return GetCachedSwitchValue("Switch.System.Diagnostics.EventSource.PreserveEventListnerObjectIdentity", ref s_preserveEventListnerObjectIdentity);
-            }
+            get => GetCachedSwitchValue("Switch.System.Diagnostics.EventSource.PreserveEventListnerObjectIdentity", ref s_preserveEventListnerObjectIdentity);
         }
 
         private static int s_serializationGuard;
         public static bool SerializationGuard
         {
             [MethodImpl(MethodImplOptions.AggressiveInlining)]
-            get
-            {
-                return GetCachedSwitchValue("Switch.System.Runtime.Serialization.SerializationGuard", ref s_serializationGuard);
-            }
+            get => GetCachedSwitchValue("Switch.System.Runtime.Serialization.SerializationGuard", ref s_serializationGuard);
         }
     }
 }
index 77bb353..b3ecf62 100644 (file)
@@ -29,10 +29,7 @@ namespace System
         public bool HasValue
         {
             [NonVersionable]
-            get
-            {
-                return hasValue;
-            }
+            get => hasValue;
         }
 
         public T Value
@@ -48,16 +45,11 @@ namespace System
         }
 
         [NonVersionable]
-        public T GetValueOrDefault()
-        {
-            return value;
-        }
+        public T GetValueOrDefault() => value;
 
         [NonVersionable]
-        public T GetValueOrDefault(T defaultValue)
-        {
-            return hasValue ? value : defaultValue;
-        }
+        public T GetValueOrDefault(T defaultValue) =>
+            hasValue ? value : defaultValue;
 
         public override bool Equals(object? other)
         {
@@ -66,27 +58,16 @@ namespace System
             return value.Equals(other);
         }
 
-        public override int GetHashCode()
-        {
-            return hasValue ? value.GetHashCode() : 0;
-        }
+        public override int GetHashCode() => hasValue ? value.GetHashCode() : 0;
 
-        public override string? ToString()
-        {
-            return hasValue ? value.ToString() : "";
-        }
+        public override string? ToString() => hasValue ? value.ToString() : "";
 
         [NonVersionable]
-        public static implicit operator Nullable<T>(T value)
-        {
-            return new Nullable<T>(value);
-        }
+        public static implicit operator Nullable<T>(T value) =>
+            new Nullable<T>(value);
 
         [NonVersionable]
-        public static explicit operator T(Nullable<T> value)
-        {
-            return value!.Value;
-        }
+        public static explicit operator T(Nullable<T> value) => value!.Value;
     }
 
     public static class Nullable
index 13c7186..b4332d1 100644 (file)
@@ -71,10 +71,7 @@ namespace System.Numerics
         public static Vector<T> Zero
         {
             [Intrinsic]
-            get
-            {
-                return s_zero;
-            }
+            get => s_zero;
         }
         private static readonly Vector<T> s_zero = new Vector<T>();
 
@@ -84,20 +81,14 @@ namespace System.Numerics
         public static Vector<T> One
         {
             [Intrinsic]
-            get
-            {
-                return s_one;
-            }
+            get => s_one;
         }
         private static readonly Vector<T> s_one = new Vector<T>(GetOneValue());
 
         internal static Vector<T> AllOnes
         {
             [Intrinsic]
-            get
-            {
-                return s_allOnes;
-            }
+            get => s_allOnes;
         }
         private static readonly Vector<T> s_allOnes = new Vector<T>(GetAllBitsSetValue());
         #endregion Static Members
@@ -2253,10 +2244,8 @@ namespace System.Numerics
         /// <param name="factor">The scalar value.</param>
         /// <returns>The scaled vector.</returns>
         [MethodImplAttribute(MethodImplOptions.AggressiveInlining)]
-        public static Vector<T> operator *(Vector<T> value, T factor)
-        {
-            return new Vector<T>(factor) * value;
-        }
+        public static Vector<T> operator *(Vector<T> value, T factor) =>
+            new Vector<T>(factor) * value;
 
         /// <summary>
         /// Multiplies a vector by the given scalar.
@@ -2265,10 +2254,8 @@ namespace System.Numerics
         /// <param name="value">The source vector.</param>
         /// <returns>The scaled vector.</returns>
         [MethodImplAttribute(MethodImplOptions.AggressiveInlining)]
-        public static Vector<T> operator *(T factor, Vector<T> value)
-        {
-            return new Vector<T>(factor) * value;
-        }
+        public static Vector<T> operator *(T factor, Vector<T> value) =>
+            new Vector<T>(factor) * value;
 
         // This method is intrinsic only for certain types. It cannot access fields directly unless we are sure the context is unaccelerated.
         /// <summary>
@@ -2488,10 +2475,7 @@ namespace System.Numerics
         /// </summary>
         /// <param name="value">The source vector.</param>
         /// <returns>The negated vector.</returns>
-        public static Vector<T> operator -(Vector<T> value)
-        {
-            return Zero - value;
-        }
+        public static Vector<T> operator -(Vector<T> value) => Zero - value;
         #endregion Arithmetic Operators
 
         #region Bitwise Operators
@@ -2594,10 +2578,8 @@ namespace System.Numerics
         /// <param name="value">The source vector.</param>
         /// <returns>The one's complement vector.</returns>
         [MethodImplAttribute(MethodImplOptions.AggressiveInlining)]
-        public static Vector<T> operator ~(Vector<T> value)
-        {
-            return s_allOnes ^ value;
-        }
+        public static Vector<T> operator ~(Vector<T> value) =>
+            s_allOnes ^ value;
         #endregion Bitwise Operators
 
         #region Logical Operators
@@ -2609,10 +2591,8 @@ namespace System.Numerics
         /// <returns>True if all elements are equal; False otherwise.</returns>
         [Intrinsic]
         [MethodImplAttribute(MethodImplOptions.AggressiveInlining)]
-        public static bool operator ==(Vector<T> left, Vector<T> right)
-        {
-            return left.Equals(right);
-        }
+        public static bool operator ==(Vector<T> left, Vector<T> right) =>
+            left.Equals(right);
 
         /// <summary>
         /// Returns a boolean indicating whether any single pair of elements in the given vectors are not equal.
@@ -2622,10 +2602,7 @@ namespace System.Numerics
         /// <returns>True if left and right are not equal; False otherwise.</returns>
         [Intrinsic]
         [MethodImplAttribute(MethodImplOptions.AggressiveInlining)]
-        public static bool operator !=(Vector<T> left, Vector<T> right)
-        {
-            return !(left == right);
-        }
+        public static bool operator !=(Vector<T> left, Vector<T> right) => !(left == right);
         #endregion Logical Operators
 
         #region Conversions
@@ -2635,10 +2612,8 @@ namespace System.Numerics
         /// <param name="value">The source vector</param>
         /// <returns>The reinterpreted vector.</returns>
         [Intrinsic]
-        public static explicit operator Vector<byte>(Vector<T> value)
-        {
-            return new Vector<byte>(ref value.register);
-        }
+        public static explicit operator Vector<byte>(Vector<T> value) =>
+            new Vector<byte>(ref value.register);
 
         /// <summary>
         /// Reinterprets the bits of the given vector into those of another type.
@@ -2647,10 +2622,8 @@ namespace System.Numerics
         /// <returns>The reinterpreted vector.</returns>
         [CLSCompliant(false)]
         [Intrinsic]
-        public static explicit operator Vector<sbyte>(Vector<T> value)
-        {
-            return new Vector<sbyte>(ref value.register);
-        }
+        public static explicit operator Vector<sbyte>(Vector<T> value) =>
+            new Vector<sbyte>(ref value.register);
 
         /// <summary>
         /// Reinterprets the bits of the given vector into those of another type.
@@ -2659,10 +2632,8 @@ namespace System.Numerics
         /// <returns>The reinterpreted vector.</returns>
         [CLSCompliant(false)]
         [Intrinsic]
-        public static explicit operator Vector<ushort>(Vector<T> value)
-        {
-            return new Vector<ushort>(ref value.register);
-        }
+        public static explicit operator Vector<ushort>(Vector<T> value) =>
+            new Vector<ushort>(ref value.register);
 
         /// <summary>
         /// Reinterprets the bits of the given vector into those of another type.
@@ -2670,10 +2641,8 @@ namespace System.Numerics
         /// <param name="value">The source vector</param>
         /// <returns>The reinterpreted vector.</returns>
         [Intrinsic]
-        public static explicit operator Vector<short>(Vector<T> value)
-        {
-            return new Vector<short>(ref value.register);
-        }
+        public static explicit operator Vector<short>(Vector<T> value) =>
+            new Vector<short>(ref value.register);
 
         /// <summary>
         /// Reinterprets the bits of the given vector into those of another type.
@@ -2682,10 +2651,8 @@ namespace System.Numerics
         /// <returns>The reinterpreted vector.</returns>
         [CLSCompliant(false)]
         [Intrinsic]
-        public static explicit operator Vector<uint>(Vector<T> value)
-        {
-            return new Vector<uint>(ref value.register);
-        }
+        public static explicit operator Vector<uint>(Vector<T> value) =>
+            new Vector<uint>(ref value.register);
 
         /// <summary>
         /// Reinterprets the bits of the given vector into those of another type.
@@ -2693,10 +2660,8 @@ namespace System.Numerics
         /// <param name="value">The source vector</param>
         /// <returns>The reinterpreted vector.</returns>
         [Intrinsic]
-        public static explicit operator Vector<int>(Vector<T> value)
-        {
-            return new Vector<int>(ref value.register);
-        }
+        public static explicit operator Vector<int>(Vector<T> value) =>
+            new Vector<int>(ref value.register);
 
         /// <summary>
         /// Reinterprets the bits of the given vector into those of another type.
@@ -2705,10 +2670,8 @@ namespace System.Numerics
         /// <returns>The reinterpreted vector.</returns>
         [CLSCompliant(false)]
         [Intrinsic]
-        public static explicit operator Vector<ulong>(Vector<T> value)
-        {
-            return new Vector<ulong>(ref value.register);
-        }
+        public static explicit operator Vector<ulong>(Vector<T> value) =>
+            new Vector<ulong>(ref value.register);
 
         /// <summary>
         /// Reinterprets the bits of the given vector into those of another type.
@@ -2716,10 +2679,8 @@ namespace System.Numerics
         /// <param name="value">The source vector</param>
         /// <returns>The reinterpreted vector.</returns>
         [Intrinsic]
-        public static explicit operator Vector<long>(Vector<T> value)
-        {
-            return new Vector<long>(ref value.register);
-        }
+        public static explicit operator Vector<long>(Vector<T> value) =>
+            new Vector<long>(ref value.register);
 
         /// <summary>
         /// Reinterprets the bits of the given vector into those of another type.
@@ -2727,10 +2688,8 @@ namespace System.Numerics
         /// <param name="value">The source vector</param>
         /// <returns>The reinterpreted vector.</returns>
         [Intrinsic]
-        public static explicit operator Vector<float>(Vector<T> value)
-        {
-            return new Vector<float>(ref value.register);
-        }
+        public static explicit operator Vector<float>(Vector<T> value) =>
+            new Vector<float>(ref value.register);
 
         /// <summary>
         /// Reinterprets the bits of the given vector into those of another type.
@@ -2738,10 +2697,8 @@ namespace System.Numerics
         /// <param name="value">The source vector</param>
         /// <returns>The reinterpreted vector.</returns>
         [Intrinsic]
-        public static explicit operator Vector<double>(Vector<T> value)
-        {
-            return new Vector<double>(ref value.register);
-        }
+        public static explicit operator Vector<double>(Vector<T> value) =>
+            new Vector<double>(ref value.register);
 
         #endregion Conversions
 
index 6d09caf..529aca3 100644 (file)
@@ -555,10 +555,7 @@ namespace System.Numerics
         public static bool IsHardwareAccelerated
         {
             [Intrinsic]
-            get
-            {
-                return false;
-            }
+            get => false;
         }
 
         // Vector<T>
index 31896e1..6eb8510 100644 (file)
@@ -25,8 +25,8 @@ namespace System
 
         public CancellationToken CancellationToken
         {
-            get { return _cancellationToken; }
-            private set { _cancellationToken = value; }
+            get => _cancellationToken;
+            private set => _cancellationToken = value;
         }
 
         public OperationCanceledException()
index 187d89c..e4514ef 100644 (file)
@@ -206,10 +206,9 @@ namespace System
         /// Returns true if left and right point at the same memory and have the same length.  Note that
         /// this does *not* check to see if the *contents* are equal.
         /// </summary>
-        public static bool operator ==(ReadOnlySpan<T> left, ReadOnlySpan<T> right)
-        {
-            return left._length == right._length && Unsafe.AreSame<T>(ref left._pointer.Value, ref right._pointer.Value);
-        }
+        public static bool operator ==(ReadOnlySpan<T> left, ReadOnlySpan<T> right) =>
+            left._length == right._length &&
+            Unsafe.AreSame<T>(ref left._pointer.Value, ref right._pointer.Value);
 
         /// <summary>
         /// For <see cref="ReadOnlySpan{Char}"/>, returns a new instance of string that represents the characters pointed to by the span.
index e91ff7e..9a3f49f 100644 (file)
@@ -26,10 +26,7 @@ namespace System
         public int Length
         {
             [NonVersionable]
-            get
-            {
-                return _length;
-            }
+            get => _length;
         }
 
         /// <summary>
@@ -38,12 +35,9 @@ namespace System
         public bool IsEmpty
         {
             [NonVersionable]
-            get
-            {
-                // Workaround for https://github.com/dotnet/coreclr/issues/19620
-                return 0 >= (uint)_length;
-            }
+            get => 0 >= (uint)_length; // Workaround for https://github.com/dotnet/coreclr/issues/19620
         }
+
         /// <summary>
         /// Returns false if left and right point at the same memory and have the same length.  Note that
         /// this does *not* check to see if the *contents* are equal.
@@ -58,10 +52,8 @@ namespace System
         /// </summary>
         [Obsolete("Equals() on ReadOnlySpan will always throw an exception. Use == instead.")]
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public override bool Equals(object? obj)
-        {
+        public override bool Equals(object? obj) =>
             throw new NotSupportedException(SR.NotSupported_CannotCallEqualsOnSpan);
-        }
 
         /// <summary>
         /// This method is not supported as spans cannot be boxed.
@@ -71,10 +63,8 @@ namespace System
         /// </summary>
         [Obsolete("GetHashCode() on ReadOnlySpan will always throw an exception.")]
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public override int GetHashCode()
-        {
+        public override int GetHashCode() =>
             throw new NotSupportedException(SR.NotSupported_CannotCallGetHashCodeOnSpan);
-        }
 
         /// <summary>
         /// Defines an implicit conversion of an array to a <see cref="ReadOnlySpan{T}"/>
index de0c8a5..9cd971e 100644 (file)
@@ -174,10 +174,7 @@ namespace System.Reflection
             return (left is null) ? false : left.Equals(right);
         }
 
-        public static bool operator !=(Assembly? left, Assembly? right)
-        {
-            return !(left == right);
-        }
+        public static bool operator !=(Assembly? left, Assembly? right) => !(left == right);
 
         public static string CreateQualifiedName(string? assemblyName, string? typeName) => typeName + ", " + assemblyName;
 
index 87b3942..690c3b0 100644 (file)
@@ -37,39 +37,33 @@ namespace System.Reflection
         // the name partitions up the strong name's namespace
         public string? Name
         {
-            get { return _name; }
-            set { _name = value; }
+            get => _name;
+            set => _name = value;
         }
 
         public Version? Version
         {
-            get { return _version; }
-            set { _version = value; }
+            get => _version;
+            set => _version = value;
         }
 
         // Locales, internally the LCID is used for the match.
         public CultureInfo? CultureInfo
         {
-            get { return _cultureInfo; }
-            set { _cultureInfo = value; }
+            get => _cultureInfo;
+            set => _cultureInfo = value;
         }
 
         public string? CultureName
         {
-            get
-            {
-                return _cultureInfo?.Name;
-            }
-            set
-            {
-                _cultureInfo = (value == null) ? null : new CultureInfo(value);
-            }
+            get => _cultureInfo?.Name;
+            set => _cultureInfo = (value == null) ? null : new CultureInfo(value);
         }
 
         public string? CodeBase
         {
-            get { return _codeBase; }
-            set { _codeBase = value; }
+            get => _codeBase;
+            set => _codeBase = value;
         }
 
         public string? EscapedCodeBase
@@ -192,7 +186,7 @@ namespace System.Reflection
         // set or retrieved directly
         public AssemblyNameFlags Flags
         {
-            get { return (AssemblyNameFlags)((uint)_flags & 0xFFFFF10F); }
+            get => (AssemblyNameFlags)((uint)_flags & 0xFFFFF10F);
             set
             {
                 _flags &= unchecked((AssemblyNameFlags)0x00000EF0);
@@ -202,20 +196,20 @@ namespace System.Reflection
 
         public AssemblyHashAlgorithm HashAlgorithm
         {
-            get { return _hashAlgorithm; }
-            set { _hashAlgorithm = value; }
+            get => _hashAlgorithm;
+            set => _hashAlgorithm = value;
         }
 
         public AssemblyVersionCompatibility VersionCompatibility
         {
-            get { return _versionCompatibility; }
-            set { _versionCompatibility = value; }
+            get => _versionCompatibility;
+            set => _versionCompatibility = value;
         }
 
         public StrongNameKeyPair? KeyPair
         {
-            get { return _strongNameKeyPair; }
-            set { _strongNameKeyPair = value; }
+            get => _strongNameKeyPair;
+            set => _strongNameKeyPair = value;
         }
 
         public string FullName
index ab971ca..5f47910 100644 (file)
@@ -26,42 +26,20 @@ namespace System.Reflection.Emit
     {
         internal readonly int m_label;
 
-        internal Label(int label)
-        {
-            m_label = label;
-        }
+        internal Label(int label) => m_label = label;
 
-        internal int GetLabelValue()
-        {
-            return m_label;
-        }
+        internal int GetLabelValue() => m_label;
 
-        public override int GetHashCode()
-        {
-            return m_label;
-        }
+        public override int GetHashCode() => m_label;
 
-        public override bool Equals(object? obj)
-        {
-            if (obj is Label)
-                return Equals((Label)obj);
-            else
-                return false;
-        }
+        public override bool Equals(object? obj) =>
+            obj is Label other && Equals(other);
 
-        public bool Equals(Label obj)
-        {
-            return obj.m_label == m_label;
-        }
+        public bool Equals(Label obj) =>
+            obj.m_label == m_label;
 
-        public static bool operator ==(Label a, Label b)
-        {
-            return a.Equals(b);
-        }
+        public static bool operator ==(Label a, Label b) => a.Equals(b);
 
-        public static bool operator !=(Label a, Label b)
-        {
-            return !(a == b);
-        }
+        public static bool operator !=(Label a, Label b) => !(a == b);
     }
 }
index 8f2a3c5..0c6933e 100644 (file)
@@ -42,15 +42,11 @@ namespace System.Reflection.Emit
             m_flags = flags;
         }
 
-        internal bool EndsUncondJmpBlk()
-        {
-            return (m_flags & EndsUncondJmpBlkFlag) != 0;
-        }
+        internal bool EndsUncondJmpBlk() =>
+            (m_flags & EndsUncondJmpBlkFlag) != 0;
 
-        internal int StackChange()
-        {
-            return (m_flags >> StackChangeShift);
-        }
+        internal int StackChange() =>
+            m_flags >> StackChangeShift;
 
         public OperandType OperandType => (OperandType)(m_flags & OperandTypeMask);
 
@@ -113,37 +109,17 @@ namespace System.Reflection.Emit
             }
         }
 
-        public override bool Equals(object? obj)
-        {
-            if (obj is OpCode)
-                return Equals((OpCode)obj);
-            else
-                return false;
-        }
+        public override bool Equals(object? obj) =>
+            obj is OpCode other && Equals(other);
 
-        public bool Equals(OpCode obj)
-        {
-            return obj.Value == Value;
-        }
+        public bool Equals(OpCode obj) => obj.Value == Value;
 
-        public static bool operator ==(OpCode a, OpCode b)
-        {
-            return a.Equals(b);
-        }
+        public static bool operator ==(OpCode a, OpCode b) => a.Equals(b);
 
-        public static bool operator !=(OpCode a, OpCode b)
-        {
-            return !(a == b);
-        }
+        public static bool operator !=(OpCode a, OpCode b) => !(a == b);
 
-        public override int GetHashCode()
-        {
-            return Value;
-        }
+        public override int GetHashCode() => Value;
 
-        public override string? ToString()
-        {
-            return Name;
-        }
+        public override string? ToString() => Name;
     }
 }
index 0fb75ff..d280c94 100644 (file)
@@ -18,14 +18,8 @@ namespace System.Reflection
 
         public bool this[int index]
         {
-            get
-            {
-                return _byRef[index];
-            }
-            set
-            {
-                _byRef[index] = value;
-            }
+            get => _byRef[index];
+            set => _byRef[index] = value;
         }
 
 #if CORECLR
index b34cfd3..7f486b3 100644 (file)
@@ -260,8 +260,8 @@ namespace System.Resources
         // GetString or GetObject.
         public virtual bool IgnoreCase
         {
-            get { return _ignoreCase; }
-            set { _ignoreCase = value; }
+            get => _ignoreCase;
+            set => _ignoreCase = value;
         }
 
         // Returns the Type of the ResourceSet the ResourceManager uses
@@ -270,8 +270,8 @@ namespace System.Resources
 
         protected UltimateResourceFallbackLocation FallbackLocation
         {
-            get { return _fallbackLoc; }
-            set { _fallbackLoc = value; }
+            get => _fallbackLoc;
+            set => _fallbackLoc = value;
         }
 
         // Tells the ResourceManager to call Close on all ResourceSets and
@@ -775,37 +775,33 @@ namespace System.Resources
 
             internal CultureInfo? NeutralResourcesCulture
             {
-                get { return _rm._neutralResourcesCulture; }
-                set { _rm._neutralResourcesCulture = value; }
+                get => _rm._neutralResourcesCulture;
+                set => _rm._neutralResourcesCulture = value;
             }
 
-            internal string GetResourceFileName(CultureInfo culture)
-            {
-                return _rm.GetResourceFileName(culture);
-            }
+            internal string GetResourceFileName(CultureInfo culture) =>
+                _rm.GetResourceFileName(culture);
 
             // NEEDED ONLY BY ASSEMBLY-BASED
             internal bool LookedForSatelliteContractVersion
             {
-                get { return _rm._lookedForSatelliteContractVersion; }
-                set { _rm._lookedForSatelliteContractVersion = value; }
+                get => _rm._lookedForSatelliteContractVersion;
+                set => _rm._lookedForSatelliteContractVersion = value;
             }
 
             internal Version? SatelliteContractVersion
             {
-                get { return _rm._satelliteContractVersion; }
-                set { _rm._satelliteContractVersion = value; }
+                get => _rm._satelliteContractVersion;
+                set => _rm._satelliteContractVersion = value;
             }
 
-            internal Version? ObtainSatelliteContractVersion(Assembly a)
-            {
-                return ResourceManager.GetSatelliteContractVersion(a);
-            }
+            internal Version? ObtainSatelliteContractVersion(Assembly a) =>
+                ResourceManager.GetSatelliteContractVersion(a);
 
             internal UltimateResourceFallbackLocation FallbackLoc
             {
-                get { return _rm.FallbackLocation; }
-                set { _rm._fallbackLoc = value; }
+                get => _rm.FallbackLocation;
+                set => _rm._fallbackLoc = value;
             }
 
             internal Assembly? MainAssembly => _rm.MainAssembly;
index 77053d5..e5bb706 100644 (file)
@@ -43,8 +43,8 @@ namespace System.Resources
         // resource profiling build.  We could also use WeakReference.
         internal object? Value
         {
-            get { return _value; }
-            set { _value = value; }
+            get => _value;
+            set => _value = value;
         }
 
         internal static bool CanCache(ResourceTypeCode value)
index 7b59222..02a21c3 100644 (file)
@@ -37,14 +37,8 @@ namespace System.Runtime.CompilerServices
 
         object? IStrongBox.Value
         {
-            get
-            {
-                return Value;
-            }
-            set
-            {
-                Value = (T)value!;
-            }
+            get => Value;
+            set => Value = (T)value!;
         }
     }
 
index 5d7396b..0d5f197 100644 (file)
@@ -65,14 +65,8 @@ namespace System.Runtime.InteropServices
             return obj.m_array == m_array && obj.m_offset == m_offset && obj.m_count == m_count;
         }
 
-        public static bool operator ==(ArrayWithOffset a, ArrayWithOffset b)
-        {
-            return a.Equals(b);
-        }
+        public static bool operator ==(ArrayWithOffset a, ArrayWithOffset b) => a.Equals(b);
 
-        public static bool operator !=(ArrayWithOffset a, ArrayWithOffset b)
-        {
-            return !(a == b);
-        }
+        public static bool operator !=(ArrayWithOffset a, ArrayWithOffset b) => !(a == b);
     }
 }
index 895db21..075d78f 100644 (file)
@@ -22,14 +22,8 @@ namespace System.Runtime.InteropServices
 
         public IntPtr Handle => _handle;
 
-        public static explicit operator IntPtr(HandleRef value)
-        {
-            return value._handle;
-        }
+        public static explicit operator IntPtr(HandleRef value) => value._handle;
 
-        public static IntPtr ToIntPtr(HandleRef value)
-        {
-            return value._handle;
-        }
+        public static IntPtr ToIntPtr(HandleRef value) => value._handle;
     }
 }
index 1e90703..bfacc5b 100644 (file)
@@ -16,7 +16,7 @@ namespace System.Runtime.Intrinsics.Arm.Arm64
     [CLSCompliant(false)]
     public static class Aes
     {
-        public static bool IsSupported { [Intrinsic] get { return false; } }
+        public static bool IsSupported { [Intrinsic] get => false; }
 
         /// <summary>
         /// Performs AES single round decryption
index ab1e596..bc97958 100644 (file)
@@ -15,7 +15,7 @@ namespace System.Runtime.Intrinsics.Arm.Arm64
     [CLSCompliant(false)]
     public static class Base
     {
-        public static bool IsSupported { [Intrinsic] get { return false; } }
+        public static bool IsSupported { [Intrinsic] get => false; }
 
         /// <summary>
         /// Vector LeadingSignCount
index 7f6e092..2c73389 100644 (file)
@@ -16,7 +16,7 @@ namespace System.Runtime.Intrinsics.Arm.Arm64
     [CLSCompliant(false)]
     public static class Sha1
     {
-        public static bool IsSupported { [Intrinsic] get { return false; } }
+        public static bool IsSupported { [Intrinsic] get => false; }
 
         /// <summary>
         /// Performs SHA1 hash update choose form.
index adbbbcc..3141eb0 100644 (file)
@@ -16,7 +16,7 @@ namespace System.Runtime.Intrinsics.Arm.Arm64
     [CLSCompliant(false)]
     public static class Sha256
     {
-        public static bool IsSupported { [Intrinsic] get { return false; } }
+        public static bool IsSupported { [Intrinsic] get => false; }
 
         /// <summary>
         /// Performs SHA256 hash update (part 1).
index b45e07f..f86a236 100644 (file)
@@ -20,7 +20,7 @@ namespace System.Runtime.Intrinsics.Arm.Arm64
         /// IsSupported property indicates whether any method provided
         /// by this class is supported by the current runtime.
         /// </summary>
-        public static bool IsSupported { [Intrinsic] get { return false; } }
+        public static bool IsSupported { [Intrinsic] get => false; }
 
         /// <summary>
         /// Vector abs
index 4fda50c..8729965 100644 (file)
@@ -77,19 +77,16 @@ namespace System.Runtime.Intrinsics
         internal static bool IsSupported
         {
             [MethodImpl(MethodImplOptions.AggressiveInlining)]
-            get
-            {
-                return (typeof(T) == typeof(byte)) ||
-                       (typeof(T) == typeof(sbyte)) ||
-                       (typeof(T) == typeof(short)) ||
-                       (typeof(T) == typeof(ushort)) ||
-                       (typeof(T) == typeof(int)) ||
-                       (typeof(T) == typeof(uint)) ||
-                       (typeof(T) == typeof(long)) ||
-                       (typeof(T) == typeof(ulong)) ||
-                       (typeof(T) == typeof(float)) ||
-                       (typeof(T) == typeof(double));
-            }
+            get => (typeof(T) == typeof(byte)) ||
+                   (typeof(T) == typeof(sbyte)) ||
+                   (typeof(T) == typeof(short)) ||
+                   (typeof(T) == typeof(ushort)) ||
+                   (typeof(T) == typeof(int)) ||
+                   (typeof(T) == typeof(uint)) ||
+                   (typeof(T) == typeof(long)) ||
+                   (typeof(T) == typeof(ulong)) ||
+                   (typeof(T) == typeof(float)) ||
+                   (typeof(T) == typeof(double));
         }
 
         /// <summary>Determines whether the specified <see cref="Vector128{T}" /> is equal to the current instance.</summary>
index 59f8102..0f5a0a6 100644 (file)
@@ -79,19 +79,16 @@ namespace System.Runtime.Intrinsics
         internal static bool IsSupported
         {
             [MethodImpl(MethodImplOptions.AggressiveInlining)]
-            get
-            {
-                return (typeof(T) == typeof(byte)) ||
-                       (typeof(T) == typeof(sbyte)) ||
-                       (typeof(T) == typeof(short)) ||
-                       (typeof(T) == typeof(ushort)) ||
-                       (typeof(T) == typeof(int)) ||
-                       (typeof(T) == typeof(uint)) ||
-                       (typeof(T) == typeof(long)) ||
-                       (typeof(T) == typeof(ulong)) ||
-                       (typeof(T) == typeof(float)) ||
-                       (typeof(T) == typeof(double));
-            }
+            get => (typeof(T) == typeof(byte)) ||
+                   (typeof(T) == typeof(sbyte)) ||
+                   (typeof(T) == typeof(short)) ||
+                   (typeof(T) == typeof(ushort)) ||
+                   (typeof(T) == typeof(int)) ||
+                   (typeof(T) == typeof(uint)) ||
+                   (typeof(T) == typeof(long)) ||
+                   (typeof(T) == typeof(ulong)) ||
+                   (typeof(T) == typeof(float)) ||
+                   (typeof(T) == typeof(double));
         }
 
         /// <summary>Determines whether the specified <see cref="Vector256{T}" /> is equal to the current instance.</summary>
index af66c55..c1fdcf8 100644 (file)
@@ -62,19 +62,16 @@ namespace System.Runtime.Intrinsics
         internal static bool IsSupported
         {
             [MethodImpl(MethodImplOptions.AggressiveInlining)]
-            get
-            {
-                return (typeof(T) == typeof(byte)) ||
-                       (typeof(T) == typeof(sbyte)) ||
-                       (typeof(T) == typeof(short)) ||
-                       (typeof(T) == typeof(ushort)) ||
-                       (typeof(T) == typeof(int)) ||
-                       (typeof(T) == typeof(uint)) ||
-                       (typeof(T) == typeof(long)) ||
-                       (typeof(T) == typeof(ulong)) ||
-                       (typeof(T) == typeof(float)) ||
-                       (typeof(T) == typeof(double));
-            }
+            get => (typeof(T) == typeof(byte)) ||
+                   (typeof(T) == typeof(sbyte)) ||
+                   (typeof(T) == typeof(short)) ||
+                   (typeof(T) == typeof(ushort)) ||
+                   (typeof(T) == typeof(int)) ||
+                   (typeof(T) == typeof(uint)) ||
+                   (typeof(T) == typeof(long)) ||
+                   (typeof(T) == typeof(ulong)) ||
+                   (typeof(T) == typeof(float)) ||
+                   (typeof(T) == typeof(double));
         }
 
         /// <summary>Determines whether the specified <see cref="Vector64{T}" /> is equal to the current instance.</summary>
index 08cf89e..f63b0e0 100644 (file)
@@ -91,19 +91,17 @@ namespace System.Runtime
 
         private static long LastKnownFreeAddressSpace
         {
-            get { return Volatile.Read(ref s_hiddenLastKnownFreeAddressSpace); }
-            set { Volatile.Write(ref s_hiddenLastKnownFreeAddressSpace, value); }
+            get => Volatile.Read(ref s_hiddenLastKnownFreeAddressSpace);
+            set => Volatile.Write(ref s_hiddenLastKnownFreeAddressSpace, value);
         }
 
-        private static long AddToLastKnownFreeAddressSpace(long addend)
-        {
-            return Interlocked.Add(ref s_hiddenLastKnownFreeAddressSpace, addend);
-        }
+        private static long AddToLastKnownFreeAddressSpace(long addend) =>
+            Interlocked.Add(ref s_hiddenLastKnownFreeAddressSpace, addend);
 
         private static long LastTimeCheckingAddressSpace
         {
-            get { return Volatile.Read(ref s_hiddenLastTimeCheckingAddressSpace); }
-            set { Volatile.Write(ref s_hiddenLastTimeCheckingAddressSpace, value); }
+            get => Volatile.Read(ref s_hiddenLastTimeCheckingAddressSpace);
+            set => Volatile.Write(ref s_hiddenLastTimeCheckingAddressSpace, value);
         }
 
         // When allocating memory segment by segment, we've hit some cases
@@ -339,11 +337,9 @@ namespace System.Runtime
             */
         }
 
-        internal static long AddMemoryFailPointReservation(long size)
-        {
+        internal static long AddMemoryFailPointReservation(long size) =>
             // Size can legitimately be negative - see Dispose.
-            return Interlocked.Add(ref s_failPointReservedMemory, (long)size);
-        }
+            Interlocked.Add(ref s_failPointReservedMemory, (long)size);
 
         internal static ulong MemoryFailPointReservedMemory
         {
index 84daa53..3d6a523 100644 (file)
@@ -11,7 +11,7 @@ namespace System.Runtime.Serialization
 
         public int VersionAdded
         {
-            get { return _versionAdded; }
+            get => _versionAdded;
             set
             {
                 if (value < 1)
index c1922d6..83c27fb 100644 (file)
@@ -196,7 +196,7 @@ namespace System.Runtime.Serialization
 
         public string FullTypeName
         {
-            get { return _rootTypeName; }
+            get => _rootTypeName;
             set
             {
                 if (null == value)
@@ -211,7 +211,7 @@ namespace System.Runtime.Serialization
 
         public string AssemblyName
         {
-            get { return _rootTypeAssemblyName; }
+            get => _rootTypeAssemblyName;
             set
             {
                 if (null == value)
index 00de1bb..c06c5ae 100644 (file)
@@ -34,8 +34,8 @@ namespace System.Runtime.Versioning
 
         public string? FrameworkDisplayName
         {
-            get { return _frameworkDisplayName; }
-            set { _frameworkDisplayName = value; }
+            get => _frameworkDisplayName;
+            set => _frameworkDisplayName = value;
         }
     }
 }
index bb25669..93d5056 100644 (file)
@@ -80,11 +80,7 @@ namespace System.Security
 
         public string Tag
         {
-            get
-            {
-                return _tag;
-            }
-
+            get => _tag;
             set
             {
                 if (value == null)
@@ -154,11 +150,7 @@ namespace System.Security
 
         public string? Text
         {
-            get
-            {
-                return Unescape(_text);
-            }
-
+            get => Unescape(_text);
             set
             {
                 if (value == null)
index cdb4f1a..f5e3a14 100644 (file)
@@ -188,40 +188,22 @@ namespace System
         }
 
         [NonVersionable]
-        public static bool operator ==(float left, float right)
-        {
-            return left == right;
-        }
+        public static bool operator ==(float left, float right) => left == right;
 
         [NonVersionable]
-        public static bool operator !=(float left, float right)
-        {
-            return left != right;
-        }
+        public static bool operator !=(float left, float right) => left != right;
 
         [NonVersionable]
-        public static bool operator <(float left, float right)
-        {
-            return left < right;
-        }
+        public static bool operator <(float left, float right) => left < right;
 
         [NonVersionable]
-        public static bool operator >(float left, float right)
-        {
-            return left > right;
-        }
+        public static bool operator >(float left, float right) => left > right;
 
         [NonVersionable]
-        public static bool operator <=(float left, float right)
-        {
-            return left <= right;
-        }
+        public static bool operator <=(float left, float right) => left <= right;
 
         [NonVersionable]
-        public static bool operator >=(float left, float right)
-        {
-            return left >= right;
-        }
+        public static bool operator >=(float left, float right) => left >= right;
 
         public override bool Equals(object? obj)
         {
index 9e6aaf1..2ecc2a0 100644 (file)
@@ -280,15 +280,15 @@ namespace System
         /// Returns true if left and right point at the same memory and have the same length.  Note that
         /// this does *not* check to see if the *contents* are equal.
         /// </summary>
-        public static bool operator ==(Span<T> left, Span<T> right)
-        {
-            return left._length == right._length && Unsafe.AreSame<T>(ref left._pointer.Value, ref right._pointer.Value);
-        }
+        public static bool operator ==(Span<T> left, Span<T> right) =>
+            left._length == right._length &&
+            Unsafe.AreSame<T>(ref left._pointer.Value, ref right._pointer.Value);
 
         /// <summary>
         /// Defines an implicit conversion of a <see cref="Span{T}"/> to a <see cref="ReadOnlySpan{T}"/>
         /// </summary>
-        public static implicit operator ReadOnlySpan<T>(Span<T> span) => new ReadOnlySpan<T>(ref span._pointer.Value, span._length);
+        public static implicit operator ReadOnlySpan<T>(Span<T> span) =>
+            new ReadOnlySpan<T>(ref span._pointer.Value, span._length);
 
         /// <summary>
         /// For <see cref="Span{Char}"/>, returns a new instance of string that represents the characters pointed to by the span.
index afc6ba5..244d534 100644 (file)
@@ -26,10 +26,7 @@ namespace System
         public int Length
         {
             [NonVersionable]
-            get
-            {
-                return _length;
-            }
+            get => _length;
         }
 
         /// <summary>
@@ -38,11 +35,7 @@ namespace System
         public bool IsEmpty
         {
             [NonVersionable]
-            get
-            {
-                // Workaround for https://github.com/dotnet/coreclr/issues/19620
-                return 0 >= (uint)_length;
-            }
+            get => 0 >= (uint)_length; // Workaround for https://github.com/dotnet/coreclr/issues/19620
         }
 
         /// <summary>
@@ -59,10 +52,8 @@ namespace System
         /// </summary>
         [Obsolete("Equals() on Span will always throw an exception. Use == instead.")]
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public override bool Equals(object? obj)
-        {
+        public override bool Equals(object? obj) =>
             throw new NotSupportedException(SR.NotSupported_CannotCallEqualsOnSpan);
-        }
 
         /// <summary>
         /// This method is not supported as spans cannot be boxed.
@@ -72,10 +63,8 @@ namespace System
         /// </summary>
         [Obsolete("GetHashCode() on Span will always throw an exception.")]
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public override int GetHashCode()
-        {
+        public override int GetHashCode() =>
             throw new NotSupportedException(SR.NotSupported_CannotCallGetHashCodeOnSpan);
-        }
 
         /// <summary>
         /// Defines an implicit conversion of an array to a <see cref="Span{T}"/>
@@ -85,8 +74,8 @@ namespace System
         /// <summary>
         /// Defines an implicit conversion of a <see cref="ArraySegment{T}"/> to a <see cref="Span{T}"/>
         /// </summary>
-        public static implicit operator Span<T>(ArraySegment<T> segment)
-            => new Span<T>(segment.Array, segment.Offset, segment.Count);
+        public static implicit operator Span<T>(ArraySegment<T> segment) =>
+            new Span<T>(segment.Array, segment.Offset, segment.Count);
 
         /// <summary>
         /// Returns an empty <see cref="Span{T}"/>
index 3e90464..4340f60 100644 (file)
@@ -724,15 +724,9 @@ namespace System
             }
         }
 
-        public static bool operator ==(string? a, string? b)
-        {
-            return string.Equals(a, b);
-        }
+        public static bool operator ==(string? a, string? b) => string.Equals(a, b);
 
-        public static bool operator !=(string? a, string? b)
-        {
-            return !string.Equals(a, b);
-        }
+        public static bool operator !=(string? a, string? b) => !string.Equals(a, b);
 
         // Gets a hash code for this string.  If strings A and B are such that A.Equals(B), then
         // they will return the same hash code.
index cce80a8..fca6f53 100644 (file)
@@ -31,11 +31,7 @@ namespace System.Text
 
         public DecoderFallback? Fallback
         {
-            get
-            {
-                return _fallback;
-            }
-
+            get => _fallback;
             set
             {
                 if (value == null)
index aa03e7f..c300575 100644 (file)
@@ -31,11 +31,7 @@ namespace System.Text
 
         public EncoderFallback? Fallback
         {
-            get
-            {
-                return _fallback;
-            }
-
+            get => _fallback;
             set
             {
                 if (value == null)
index cbd7cba..cb1c102 100644 (file)
@@ -460,11 +460,7 @@ namespace System.Text
 
         public EncoderFallback EncoderFallback
         {
-            get
-            {
-                return encoderFallback;
-            }
-
+            get => encoderFallback;
             set
             {
                 if (this.IsReadOnly)
@@ -480,11 +476,7 @@ namespace System.Text
 
         public DecoderFallback DecoderFallback
         {
-            get
-            {
-                return decoderFallback;
-            }
-
+            get => decoderFallback;
             set
             {
                 if (this.IsReadOnly)
@@ -509,14 +501,8 @@ namespace System.Text
 
         public bool IsReadOnly
         {
-            get
-            {
-                return (_isReadOnly);
-            }
-            private protected set
-            {
-                _isReadOnly = value;
-            }
+            get => (_isReadOnly);
+            private protected set => _isReadOnly = value;
         }
 
         // Returns an encoding for the ASCII character set. The returned encoding
index 58bf658..1300f16 100644 (file)
@@ -295,7 +295,7 @@ namespace System.Text
 
         public int Capacity
         {
-            get { return m_ChunkChars.Length + m_ChunkOffset; }
+            get => m_ChunkChars.Length + m_ChunkOffset;
             set
             {
                 if (value < 0)
@@ -440,10 +440,7 @@ namespace System.Text
         /// </summary>
         public int Length
         {
-            get
-            {
-                return m_ChunkOffset + m_ChunkLength;
-            }
+            get => m_ChunkOffset + m_ChunkLength;
             set
             {
                 // If the new length is less than 0 or greater than our Maximum capacity, bail.
index e21e14e..e8f7713 100644 (file)
@@ -65,10 +65,7 @@ namespace System.Threading
                 object? obj = ExecutionContext.GetLocalValue(this);
                 return (obj == null) ? default : (T)obj;
             }
-            set
-            {
-                ExecutionContext.SetLocalValue(this, value, m_valueChangedHandler != null);
-            }
+            set => ExecutionContext.SetLocalValue(this, value, m_valueChangedHandler != null);
         }
 
         void IAsyncLocal.OnValueChanged(object? previousValueObj, object? currentValueObj, bool contextChanged)
index c62643c..dc7e8cd 100644 (file)
@@ -632,14 +632,8 @@ namespace System.Threading
             return _thread?.GetHashCode() ?? 0;
         }
 
-        public static bool operator ==(AsyncFlowControl a, AsyncFlowControl b)
-        {
-            return a.Equals(b);
-        }
+        public static bool operator ==(AsyncFlowControl a, AsyncFlowControl b) => a.Equals(b);
 
-        public static bool operator !=(AsyncFlowControl a, AsyncFlowControl b)
-        {
-            return !(a == b);
-        }
+        public static bool operator !=(AsyncFlowControl a, AsyncFlowControl b) => !(a == b);
     }
 }
index be2cd2b..ec2e1b9 100644 (file)
@@ -95,15 +95,8 @@ namespace System.Threading
         /// <value>true if the event has is set; otherwise, false.</value>
         public bool IsSet
         {
-            get
-            {
-                return 0 != ExtractStatePortion(m_combinedState, SignalledState_BitMask);
-            }
-
-            private set
-            {
-                UpdateStateAtomically(((value) ? 1 : 0) << SignalledState_ShiftCount, SignalledState_BitMask);
-            }
+            get => 0 != ExtractStatePortion(m_combinedState, SignalledState_BitMask);
+            private set => UpdateStateAtomically(((value) ? 1 : 0) << SignalledState_ShiftCount, SignalledState_BitMask);
         }
 
         /// <summary>
@@ -111,11 +104,7 @@ namespace System.Threading
         /// </summary>
         public int SpinCount
         {
-            get
-            {
-                return ExtractStatePortionAndShiftRight(m_combinedState, SpinCountState_BitMask, SpinCountState_ShiftCount);
-            }
-
+            get => ExtractStatePortionAndShiftRight(m_combinedState, SpinCountState_BitMask, SpinCountState_ShiftCount);
             private set
             {
                 Debug.Assert(value >= 0, "SpinCount is a restricted-width integer. The value supplied is outside the legal range.");
@@ -130,11 +119,7 @@ namespace System.Threading
         /// </summary>
         private int Waiters
         {
-            get
-            {
-                return ExtractStatePortionAndShiftRight(m_combinedState, NumWaitersState_BitMask, NumWaitersState_ShiftCount);
-            }
-
+            get => ExtractStatePortionAndShiftRight(m_combinedState, NumWaitersState_BitMask, NumWaitersState_ShiftCount);
             set
             {
                 // setting to <0 would indicate an internal flaw, hence Assert is appropriate.
index 218dc3e..8b6632c 100644 (file)
@@ -789,11 +789,8 @@ namespace System.Threading.Tasks
         internal bool IsWaitNotificationEnabledOrNotRanToCompletion
         {
             [MethodImpl(MethodImplOptions.AggressiveInlining)]
-            get
-            {
-                return (m_stateFlags & (Task.TASK_STATE_WAIT_COMPLETION_NOTIFICATION | Task.TASK_STATE_RAN_TO_COMPLETION))
+            get => (m_stateFlags & (Task.TASK_STATE_WAIT_COMPLETION_NOTIFICATION | Task.TASK_STATE_RAN_TO_COMPLETION))
                         != Task.TASK_STATE_RAN_TO_COMPLETION;
-            }
         }
 
         /// <summary>
index 9b7abbf..22fb45d 100644 (file)
@@ -220,14 +220,8 @@ namespace System.Threading
         [Obsolete("The ApartmentState property has been deprecated.  Use GetApartmentState, SetApartmentState or TrySetApartmentState instead.", false)]
         public ApartmentState ApartmentState
         {
-            get
-            {
-                return GetApartmentState();
-            }
-            set
-            {
-                TrySetApartmentState(value);
-            }
+            get => GetApartmentState();
+            set => TrySetApartmentState(value);
         }
 
         public void SetApartmentState(ApartmentState state)
index dba05d8..40d2b2f 100644 (file)
@@ -52,10 +52,7 @@ namespace System.Threading
         [Obsolete("Use the SafeWaitHandle property instead.")]
         public virtual IntPtr Handle
         {
-            get
-            {
-                return _waitHandle == null ? InvalidHandle : _waitHandle.DangerousGetHandle();
-            }
+            get => _waitHandle == null ? InvalidHandle : _waitHandle.DangerousGetHandle();
             set
             {
                 if (value == InvalidHandle)
@@ -82,18 +79,8 @@ namespace System.Threading
         [AllowNull]
         public SafeWaitHandle SafeWaitHandle
         {
-            get
-            {
-                if (_waitHandle == null)
-                {
-                    _waitHandle = new SafeWaitHandle(InvalidHandle, false);
-                }
-                return _waitHandle;
-            }
-            set
-            {
-                _waitHandle = value;
-            }
+            get => _waitHandle ??= new SafeWaitHandle(InvalidHandle, false);
+            set => _waitHandle = value;
         }
 
         internal static int ToTimeoutMilliseconds(TimeSpan timeout)
index b4a20cd..4b1fa7d 100644 (file)
@@ -436,20 +436,11 @@ namespace System
             return new TimeSpan(-t._ticks);
         }
 
-        public static TimeSpan operator -(TimeSpan t1, TimeSpan t2)
-        {
-            return t1.Subtract(t2);
-        }
+        public static TimeSpan operator -(TimeSpan t1, TimeSpan t2) => t1.Subtract(t2);
 
-        public static TimeSpan operator +(TimeSpan t)
-        {
-            return t;
-        }
+        public static TimeSpan operator +(TimeSpan t) => t;
 
-        public static TimeSpan operator +(TimeSpan t1, TimeSpan t2)
-        {
-            return t1.Add(t2);
-        }
+        public static TimeSpan operator +(TimeSpan t1, TimeSpan t2) => t1.Add(t2);
 
         public static TimeSpan operator *(TimeSpan timeSpan, double factor)
         {
@@ -493,34 +484,16 @@ namespace System
         // is perhaps less useful, but no less useful than an exception.
         public static double operator /(TimeSpan t1, TimeSpan t2) => t1.Ticks / (double)t2.Ticks;
 
-        public static bool operator ==(TimeSpan t1, TimeSpan t2)
-        {
-            return t1._ticks == t2._ticks;
-        }
+        public static bool operator ==(TimeSpan t1, TimeSpan t2) => t1._ticks == t2._ticks;
 
-        public static bool operator !=(TimeSpan t1, TimeSpan t2)
-        {
-            return t1._ticks != t2._ticks;
-        }
+        public static bool operator !=(TimeSpan t1, TimeSpan t2) => t1._ticks != t2._ticks;
 
-        public static bool operator <(TimeSpan t1, TimeSpan t2)
-        {
-            return t1._ticks < t2._ticks;
-        }
+        public static bool operator <(TimeSpan t1, TimeSpan t2) => t1._ticks < t2._ticks;
 
-        public static bool operator <=(TimeSpan t1, TimeSpan t2)
-        {
-            return t1._ticks <= t2._ticks;
-        }
+        public static bool operator <=(TimeSpan t1, TimeSpan t2) => t1._ticks <= t2._ticks;
 
-        public static bool operator >(TimeSpan t1, TimeSpan t2)
-        {
-            return t1._ticks > t2._ticks;
-        }
+        public static bool operator >(TimeSpan t1, TimeSpan t2) => t1._ticks > t2._ticks;
 
-        public static bool operator >=(TimeSpan t1, TimeSpan t2)
-        {
-            return t1._ticks >= t2._ticks;
-        }
+        public static bool operator >=(TimeSpan t1, TimeSpan t2) => t1._ticks >= t2._ticks;
     }
 }
index dff3da0..1749680 100644 (file)
@@ -78,10 +78,8 @@ namespace System
             return false;
         }
 
-        unsafe bool IEquatable<UIntPtr>.Equals(UIntPtr other)
-        {
-            return _value == other._value;
-        }
+        unsafe bool IEquatable<UIntPtr>.Equals(UIntPtr other) =>
+            _value == other._value;
 
         public override unsafe int GetHashCode()
         {
@@ -106,117 +104,83 @@ namespace System
 
         [Intrinsic]
         [NonVersionable]
-        public unsafe ulong ToUInt64()
-        {
-            return (ulong)_value;
-        }
+        public unsafe ulong ToUInt64() => (ulong)_value;
 
         [Intrinsic]
         [NonVersionable]
-        public static explicit operator UIntPtr(uint value)
-        {
-            return new UIntPtr(value);
-        }
+        public static explicit operator UIntPtr(uint value) =>
+            new UIntPtr(value);
 
         [Intrinsic]
         [NonVersionable]
-        public static explicit operator UIntPtr(ulong value)
-        {
-            return new UIntPtr(value);
-        }
+        public static explicit operator UIntPtr(ulong value) =>
+            new UIntPtr(value);
 
         [Intrinsic]
         [NonVersionable]
-        public static unsafe explicit operator UIntPtr(void* value)
-        {
-            return new UIntPtr(value);
-        }
+        public static unsafe explicit operator UIntPtr(void* value) =>
+            new UIntPtr(value);
 
         [Intrinsic]
         [NonVersionable]
-        public static unsafe explicit operator void*(UIntPtr value)
-        {
-            return value._value;
-        }
+        public static unsafe explicit operator void*(UIntPtr value) =>
+            value._value;
 
         [Intrinsic]
         [NonVersionable]
-        public static unsafe explicit operator uint(UIntPtr value)
-        {
+        public static unsafe explicit operator uint(UIntPtr value) =>
 #if BIT64
-            return checked((uint)value._value);
+            checked((uint)value._value);
 #else
-            return (uint)value._value;
+            (uint)value._value;
 #endif
-        }
+
 
         [Intrinsic]
         [NonVersionable]
-        public static unsafe explicit operator ulong(UIntPtr value)
-        {
-            return (ulong)value._value;
-        }
+        public static unsafe explicit operator ulong(UIntPtr value) =>
+            (ulong)value._value;
 
         [Intrinsic]
         [NonVersionable]
-        public static unsafe bool operator ==(UIntPtr value1, UIntPtr value2)
-        {
-            return value1._value == value2._value;
-        }
+        public static unsafe bool operator ==(UIntPtr value1, UIntPtr value2) =>
+            value1._value == value2._value;
 
         [Intrinsic]
         [NonVersionable]
-        public static unsafe bool operator !=(UIntPtr value1, UIntPtr value2)
-        {
-            return value1._value != value2._value;
-        }
+        public static unsafe bool operator !=(UIntPtr value1, UIntPtr value2) =>
+            value1._value != value2._value;
 
         [NonVersionable]
-        public static UIntPtr Add(UIntPtr pointer, int offset)
-        {
-            return pointer + offset;
-        }
+        public static UIntPtr Add(UIntPtr pointer, int offset) =>
+            pointer + offset;
 
         [Intrinsic]
         [NonVersionable]
-        public static unsafe UIntPtr operator +(UIntPtr pointer, int offset)
-        {
-            return new UIntPtr((nuint)pointer._value + (nuint)offset);
-        }
+        public static unsafe UIntPtr operator +(UIntPtr pointer, int offset) =>
+            new UIntPtr((nuint)pointer._value + (nuint)offset);
 
         [NonVersionable]
-        public static UIntPtr Subtract(UIntPtr pointer, int offset)
-        {
-            return pointer - offset;
-        }
+        public static UIntPtr Subtract(UIntPtr pointer, int offset) =>
+            pointer - offset;
 
         [Intrinsic]
         [NonVersionable]
-        public static unsafe UIntPtr operator -(UIntPtr pointer, int offset)
-        {
-            return new UIntPtr((nuint)pointer._value - (nuint)offset);
-        }
+        public static unsafe UIntPtr operator -(UIntPtr pointer, int offset) =>
+            new UIntPtr((nuint)pointer._value - (nuint)offset);
 
         public static int Size
         {
             [Intrinsic]
             [NonVersionable]
-            get
-            {
-                return sizeof(nuint);
-            }
+            get => sizeof(nuint);
         }
 
         [Intrinsic]
         [NonVersionable]
-        public unsafe void* ToPointer()
-        {
-            return _value;
-        }
+        public unsafe void* ToPointer() => _value;
 
-        public override unsafe string ToString()
-        {
-            return ((nuint)_value).ToString(CultureInfo.InvariantCulture);
-        }
+        public override unsafe string ToString() =>
+            ((nuint)_value).ToString(CultureInfo.InvariantCulture);
     }
 }
index 1778f64..7a9f411 100644 (file)
@@ -408,10 +408,7 @@ namespace System
             return ReferenceEquals(v2, v1) ? true : v2.Equals(v1);
         }
 
-        public static bool operator !=(Version? v1, Version? v2)
-        {
-            return !(v1 == v2);
-        }
+        public static bool operator !=(Version? v1, Version? v2) => !(v1 == v2);
 
         public static bool operator <(Version? v1, Version? v2)
         {
@@ -433,14 +430,8 @@ namespace System
             return (v1.CompareTo(v2) <= 0);
         }
 
-        public static bool operator >(Version? v1, Version? v2)
-        {
-            return (v2 < v1);
-        }
+        public static bool operator >(Version? v1, Version? v2) => (v2 < v1);
 
-        public static bool operator >=(Version? v1, Version? v2)
-        {
-            return (v2 <= v1);
-        }
+        public static bool operator >=(Version? v1, Version? v2) => (v2 <= v1);
     }
 }