From bc8c340c7f68042117b61c7b296a1304d0cc5582 Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Fri, 1 Feb 2019 17:26:36 -0500 Subject: [PATCH] Remove stale warning 420 pragmas (dotnet/coreclr#22352) It used to be that the CS0420 warning ("a reference to a volatile field will not be treated as volatile") would fire when a volatile was used with an Interlocked.* operation. That warning was unnecessary, as Interlocked.* would itself provide the relevant barriers, and these functions were special cased in Roslyn a long time ago. But there are still lots of places where pragmas disabling the warning have stuck around. I'm deleting them all. Commit migrated from https://github.com/dotnet/coreclr/commit/7ca73bcfa0ce072617b068393b7ed66919097bc1 --- src/libraries/System.Private.CoreLib/src/System/Lazy.cs | 2 -- .../System.Private.CoreLib/src/System/Threading/Tasks/Future.cs | 3 --- .../System.Private.CoreLib/src/System/Threading/Tasks/Task.cs | 3 --- .../src/System/Threading/Tasks/TaskCompletionSource.cs | 3 --- .../src/System/Threading/Tasks/TaskExceptionHolder.cs | 3 --- .../System.Private.CoreLib/src/System/Threading/Tasks/TaskScheduler.cs | 2 -- src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Win32.cs | 2 -- src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.cs | 2 -- 8 files changed, 20 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Lazy.cs b/src/libraries/System.Private.CoreLib/src/System/Lazy.cs index 78d5c40..ca445fc 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Lazy.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Lazy.cs @@ -10,8 +10,6 @@ // // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -#pragma warning disable 0420 - using System.Diagnostics; using System.Runtime.ExceptionServices; using System.Runtime.InteropServices; diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Future.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Future.cs index 7a1711b..0b93ee8 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Future.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Future.cs @@ -15,9 +15,6 @@ using System.Diagnostics; using System.Runtime.CompilerServices; using System.Runtime.ExceptionServices; -// Disable the "reference to volatile field not treated as volatile" error. -#pragma warning disable 0420 - namespace System.Threading.Tasks { /// diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs index 2e2c6d6..61b8308 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs @@ -23,9 +23,6 @@ using Internal.Runtime.CompilerServices; using Thread = Internal.Runtime.Augments.RuntimeThread; #endif -// Disable the "reference to volatile field not treated as volatile" error. -#pragma warning disable 0420 - namespace System.Threading.Tasks { /// diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskCompletionSource.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskCompletionSource.cs index 11ba26d..c85a44f 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskCompletionSource.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskCompletionSource.cs @@ -18,9 +18,6 @@ using System.Runtime.CompilerServices; using System.Runtime.ExceptionServices; using System.Threading; -// Disable the "reference to volatile field not treated as volatile" error. -#pragma warning disable 0420 - namespace System.Threading.Tasks { /// diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskExceptionHolder.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskExceptionHolder.cs index cdf5c78..67b4220 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskExceptionHolder.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskExceptionHolder.cs @@ -10,9 +10,6 @@ // // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -// Disable the "reference to volatile field not treated as volatile" error. -#pragma warning disable 0420 - using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskScheduler.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskScheduler.cs index 7de42a7..f274f20 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskScheduler.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskScheduler.cs @@ -9,8 +9,6 @@ // This file contains the primary interface and management of tasks and queues. // // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -// Disable the "reference to volatile field not treated as volatile" error. -#pragma warning disable 0420 using System.Collections.Generic; using System.Diagnostics; diff --git a/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Win32.cs b/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Win32.cs index a7095de..4de4ea5 100644 --- a/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Win32.cs +++ b/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Win32.cs @@ -38,7 +38,6 @@ namespace System private const int MaxKeyLength = 255; -#pragma warning disable 0420 private sealed partial class CachedData { private static TimeZoneInfo GetCurrentOneYearLocal() @@ -66,7 +65,6 @@ namespace System return oneYearLocFromUtc; } } -#pragma warning restore 0420 private sealed class OffsetAndRule { diff --git a/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.cs b/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.cs index 698fa21..c7090d5 100644 --- a/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.cs +++ b/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.cs @@ -61,7 +61,6 @@ namespace System // For example, TimeZoneInfo.Local can be cleared by another thread calling TimeZoneInfo.ClearCachedData. Without the consistent snapshot, // there is a chance that the internal ConvertTime calls will throw since 'source' won't be reference equal to the new TimeZoneInfo.Local. // -#pragma warning disable 0420 private sealed partial class CachedData { private volatile TimeZoneInfo _localTimeZone; @@ -139,7 +138,6 @@ namespace System public ReadOnlyCollection _readOnlySystemTimeZones; public bool _allSystemTimeZonesRead; }; -#pragma warning restore 0420 // used by GetUtcOffsetFromUtc (DateTime.Now, DateTime.ToLocalTime) for max/min whole-day range checks private static readonly DateTime s_maxDateOnly = new DateTime(9999, 12, 31); -- 2.7.4