From f7315fd2d2b749afdf1eb58df4860e15d11c9647 Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Fri, 6 Sep 2019 09:08:45 -0400 Subject: [PATCH] Remove stale SuppressMessage attributes (dotnet/coreclr#26501) Commit migrated from https://github.com/dotnet/coreclr/commit/94f6badbea1eb09104041bba01273b4a39a2d4a2 --- .../src/System/Collections/ArrayList.cs | 49 ---------------------- .../System/ComponentModel/DefaultValueAttribute.cs | 2 - .../System/Diagnostics/Tracing/EventProvider.cs | 6 --- .../src/System/Diagnostics/Tracing/EventSource.cs | 26 ------------ .../src/System/Diagnostics/Tracing/Winmeta.cs | 1 - .../src/System/IO/StreamReader.cs | 1 - .../src/System/LocalDataStoreSlot.cs | 3 +- .../System.Private.CoreLib/src/System/Object.cs | 3 +- .../System/Runtime/CompilerServices/StrongBox.cs | 1 - .../CriticalFinalizerObject.cs | 4 +- .../System/Runtime/InteropServices/SafeHandle.cs | 1 - .../Tasks/ConcurrentExclusiveSchedulerPair.cs | 8 ---- .../src/System/Threading/ThreadPool.cs | 2 - 13 files changed, 7 insertions(+), 100 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Collections/ArrayList.cs b/src/libraries/System.Private.CoreLib/src/System/Collections/ArrayList.cs index 53c7d79..71965b3 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Collections/ArrayList.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Collections/ArrayList.cs @@ -904,7 +904,6 @@ namespace System.Collections return _list.IndexOf(value); } - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override int IndexOf(object? value, int startIndex) { return IndexOf(value, startIndex, _list.Count - startIndex); @@ -970,13 +969,11 @@ namespace System.Collections return LastIndexOf(value, _list.Count - 1, _list.Count); } - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override int LastIndexOf(object? value, int startIndex) { return LastIndexOf(value, startIndex, startIndex + 1); } - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override int LastIndexOf(object? value, int startIndex, int count) { if (_list.Count == 0) @@ -1216,7 +1213,6 @@ namespace System.Collections return _list.Capacity; } } - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. set { lock (_root) @@ -1290,7 +1286,6 @@ namespace System.Collections } } - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override int BinarySearch(int index, int count, object? value, IComparer? comparer) { lock (_root) @@ -1339,7 +1334,6 @@ namespace System.Collections } } - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override void CopyTo(int index, Array array, int arrayIndex, int count) { lock (_root) @@ -1356,7 +1350,6 @@ namespace System.Collections } } - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override IEnumerator GetEnumerator(int index, int count) { lock (_root) @@ -1373,7 +1366,6 @@ namespace System.Collections } } - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override int IndexOf(object? value, int startIndex) { lock (_root) @@ -1382,7 +1374,6 @@ namespace System.Collections } } - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override int IndexOf(object? value, int startIndex, int count) { lock (_root) @@ -1399,7 +1390,6 @@ namespace System.Collections } } - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override void InsertRange(int index, ICollection c) { lock (_root) @@ -1416,7 +1406,6 @@ namespace System.Collections } } - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override int LastIndexOf(object? value, int startIndex) { lock (_root) @@ -1425,7 +1414,6 @@ namespace System.Collections } } - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override int LastIndexOf(object? value, int startIndex, int count) { lock (_root) @@ -1450,7 +1438,6 @@ namespace System.Collections } } - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override void RemoveRange(int index, int count) { lock (_root) @@ -1459,7 +1446,6 @@ namespace System.Collections } } - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override void Reverse(int index, int count) { lock (_root) @@ -1468,7 +1454,6 @@ namespace System.Collections } } - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override void SetRange(int index, ICollection c) { lock (_root) @@ -1477,7 +1462,6 @@ namespace System.Collections } } - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override ArrayList GetRange(int index, int count) { lock (_root) @@ -1502,7 +1486,6 @@ namespace System.Collections } } - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override void Sort(int index, int count, IComparer? comparer) { lock (_root) @@ -1519,7 +1502,6 @@ namespace System.Collections } } - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override Array ToArray(Type type) { lock (_root) @@ -1766,7 +1748,6 @@ namespace System.Collections throw new NotSupportedException(SR.NotSupported_FixedSizeCollection); } - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override int BinarySearch(int index, int count, object? value, IComparer? comparer) { return _list.BinarySearch(index, count, value, comparer); @@ -1775,7 +1756,6 @@ namespace System.Collections public override int Capacity { get => _list.Capacity; - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. set => throw new NotSupportedException(SR.NotSupported_FixedSizeCollection); } @@ -1801,7 +1781,6 @@ namespace System.Collections _list.CopyTo(array, index); } - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override void CopyTo(int index, Array array, int arrayIndex, int count) { _list.CopyTo(index, array, arrayIndex, count); @@ -1812,7 +1791,6 @@ namespace System.Collections return _list.GetEnumerator(); } - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override IEnumerator GetEnumerator(int index, int count) { return _list.GetEnumerator(index, count); @@ -1823,13 +1801,11 @@ namespace System.Collections return _list.IndexOf(value); } - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override int IndexOf(object? value, int startIndex) { return _list.IndexOf(value, startIndex); } - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override int IndexOf(object? value, int startIndex, int count) { return _list.IndexOf(value, startIndex, count); @@ -1840,7 +1816,6 @@ namespace System.Collections throw new NotSupportedException(SR.NotSupported_FixedSizeCollection); } - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override void InsertRange(int index, ICollection c) { throw new NotSupportedException(SR.NotSupported_FixedSizeCollection); @@ -1851,13 +1826,11 @@ namespace System.Collections return _list.LastIndexOf(value); } - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override int LastIndexOf(object? value, int startIndex) { return _list.LastIndexOf(value, startIndex); } - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override int LastIndexOf(object? value, int startIndex, int count) { return _list.LastIndexOf(value, startIndex, count); @@ -1873,13 +1846,11 @@ namespace System.Collections throw new NotSupportedException(SR.NotSupported_FixedSizeCollection); } - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override void RemoveRange(int index, int count) { throw new NotSupportedException(SR.NotSupported_FixedSizeCollection); } - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override void SetRange(int index, ICollection c) { _list.SetRange(index, c); @@ -1896,14 +1867,12 @@ namespace System.Collections return new Range(this, index, count); } - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override void Reverse(int index, int count) { _list.Reverse(index, count); _version = _list._version; } - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override void Sort(int index, int count, IComparer? comparer) { _list.Sort(index, count, comparer); @@ -1915,7 +1884,6 @@ namespace System.Collections return _list.ToArray(); } - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override Array ToArray(Type type) { return _list.ToArray(type); @@ -2033,7 +2001,6 @@ namespace System.Collections throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection); } - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override int BinarySearch(int index, int count, object? value, IComparer? comparer) { return _list.BinarySearch(index, count, value, comparer); @@ -2043,7 +2010,6 @@ namespace System.Collections public override int Capacity { get => _list.Capacity; - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. set => throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection); } @@ -2069,7 +2035,6 @@ namespace System.Collections _list.CopyTo(array, index); } - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override void CopyTo(int index, Array array, int arrayIndex, int count) { _list.CopyTo(index, array, arrayIndex, count); @@ -2080,7 +2045,6 @@ namespace System.Collections return _list.GetEnumerator(); } - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override IEnumerator GetEnumerator(int index, int count) { return _list.GetEnumerator(index, count); @@ -2091,13 +2055,11 @@ namespace System.Collections return _list.IndexOf(value); } - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override int IndexOf(object? value, int startIndex) { return _list.IndexOf(value, startIndex); } - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override int IndexOf(object? value, int startIndex, int count) { return _list.IndexOf(value, startIndex, count); @@ -2108,7 +2070,6 @@ namespace System.Collections throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection); } - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override void InsertRange(int index, ICollection c) { throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection); @@ -2119,13 +2080,11 @@ namespace System.Collections return _list.LastIndexOf(value); } - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override int LastIndexOf(object? value, int startIndex) { return _list.LastIndexOf(value, startIndex); } - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override int LastIndexOf(object? value, int startIndex, int count) { return _list.LastIndexOf(value, startIndex, count); @@ -2141,13 +2100,11 @@ namespace System.Collections throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection); } - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override void RemoveRange(int index, int count) { throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection); } - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override void SetRange(int index, ICollection c) { throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection); @@ -2163,13 +2120,11 @@ namespace System.Collections return new Range(this, index, count); } - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override void Reverse(int index, int count) { throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection); } - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override void Sort(int index, int count, IComparer? comparer) { throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection); @@ -2180,7 +2135,6 @@ namespace System.Collections return _list.ToArray(); } - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override Array ToArray(Type type) { return _list.ToArray(type); @@ -2521,13 +2475,11 @@ namespace System.Collections return -1; } - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override int LastIndexOf(object? value, int startIndex) { return LastIndexOf(value, startIndex, startIndex + 1); } - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override int LastIndexOf(object? value, int startIndex, int count) { InternalUpdateRange(); @@ -2586,7 +2538,6 @@ namespace System.Collections InternalUpdateVersion(); } - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override void SetRange(int index, ICollection c) { InternalUpdateRange(); diff --git a/src/libraries/System.Private.CoreLib/src/System/ComponentModel/DefaultValueAttribute.cs b/src/libraries/System.Private.CoreLib/src/System/ComponentModel/DefaultValueAttribute.cs index 428464c..66e8c75 100644 --- a/src/libraries/System.Private.CoreLib/src/System/ComponentModel/DefaultValueAttribute.cs +++ b/src/libraries/System.Private.CoreLib/src/System/ComponentModel/DefaultValueAttribute.cs @@ -12,8 +12,6 @@ namespace System.ComponentModel /// /// Specifies the default value for a property. /// - [SuppressMessage("Microsoft.Design", "CA1019:DefineAccessorsForAttributeArguments")] - [SuppressMessage("Microsoft.Performance", "CA1813:AvoidUnsealedAttributes")] [AttributeUsage(AttributeTargets.All)] public class DefaultValueAttribute : Attribute { diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventProvider.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventProvider.cs index 6a3d373..41d6198 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventProvider.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventProvider.cs @@ -100,7 +100,6 @@ namespace System.Diagnostics.Tracing private const int s_etwAPIMaxRefObjCount = 8; private const int s_traceEventMaximumSize = 65482; - [SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")] public enum WriteEventErrorCode : int { // check mapping to runtime codes @@ -684,7 +683,6 @@ namespace System.Diagnostics.Tracing return false; } - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] public static WriteEventErrorCode GetLastWriteEventError() { return s_returnCode; @@ -957,8 +955,6 @@ namespace System.Diagnostics.Tracing // // // - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity", Justification = "Performance-critical code")] - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1045:DoNotPassTypesByReference")] internal unsafe bool WriteEvent(ref EventDescriptor eventDescriptor, IntPtr eventHandle, Guid* activityID, Guid* childActivityID, params object?[] eventPayload) { WriteEventErrorCode status = WriteEventErrorCode.NoError; @@ -1155,7 +1151,6 @@ namespace System.Diagnostics.Tracing // // // - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1045:DoNotPassTypesByReference")] protected internal unsafe bool WriteEvent(ref EventDescriptor eventDescriptor, IntPtr eventHandle, Guid* activityID, Guid* childActivityID, int dataCount, IntPtr data) { if (childActivityID != null) @@ -1177,7 +1172,6 @@ namespace System.Diagnostics.Tracing return true; } - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1045:DoNotPassTypesByReference")] internal unsafe bool WriteEventRaw( ref EventDescriptor eventDescriptor, IntPtr eventHandle, diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs index 4783935..cfd2173 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs @@ -248,7 +248,6 @@ namespace System.Diagnostics.Tracing /// Returns true if the eventSource has been enabled at all. This is the preferred test /// to be performed before a relatively expensive EventSource operation. /// - [SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "This does not need to be correct when racing with other threads")] public bool IsEnabled() { return m_eventSourceEnabled; @@ -263,7 +262,6 @@ namespace System.Diagnostics.Tracing /// positives (but is always accurate when returning false). EventSources are free to /// have additional filtering. /// - [SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "This does not need to be correct when racing with other threads")] public bool IsEnabled(EventLevel level, EventKeywords keywords) { return IsEnabled(level, keywords, EventChannel.None); @@ -279,7 +277,6 @@ namespace System.Diagnostics.Tracing /// positives (but is always accurate when returning false). EventSources are free to /// have additional filtering. /// - [SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "This does not need to be correct when racing with other threads")] public bool IsEnabled(EventLevel level, EventKeywords keywords, EventChannel channel) { if (!m_eventSourceEnabled) @@ -743,14 +740,12 @@ namespace System.Diagnostics.Tracing #pragma warning disable 1591 // optimized for common signatures (no args) - [SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "This does not need to be correct when racing with other threads")] protected unsafe void WriteEvent(int eventId) { WriteEventCore(eventId, 0, null); } // optimized for common signatures (ints) - [SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "This does not need to be correct when racing with other threads")] protected unsafe void WriteEvent(int eventId, int arg1) { if (m_eventSourceEnabled) @@ -763,7 +758,6 @@ namespace System.Diagnostics.Tracing } } - [SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "This does not need to be correct when racing with other threads")] protected unsafe void WriteEvent(int eventId, int arg1, int arg2) { if (m_eventSourceEnabled) @@ -779,7 +773,6 @@ namespace System.Diagnostics.Tracing } } - [SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "This does not need to be correct when racing with other threads")] protected unsafe void WriteEvent(int eventId, int arg1, int arg2, int arg3) { if (m_eventSourceEnabled) @@ -799,7 +792,6 @@ namespace System.Diagnostics.Tracing } // optimized for common signatures (longs) - [SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "This does not need to be correct when racing with other threads")] protected unsafe void WriteEvent(int eventId, long arg1) { if (m_eventSourceEnabled) @@ -812,7 +804,6 @@ namespace System.Diagnostics.Tracing } } - [SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "This does not need to be correct when racing with other threads")] protected unsafe void WriteEvent(int eventId, long arg1, long arg2) { if (m_eventSourceEnabled) @@ -828,7 +819,6 @@ namespace System.Diagnostics.Tracing } } - [SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "This does not need to be correct when racing with other threads")] protected unsafe void WriteEvent(int eventId, long arg1, long arg2, long arg3) { if (m_eventSourceEnabled) @@ -848,7 +838,6 @@ namespace System.Diagnostics.Tracing } // optimized for common signatures (strings) - [SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "This does not need to be correct when racing with other threads")] protected unsafe void WriteEvent(int eventId, string? arg1) { if (m_eventSourceEnabled) @@ -865,7 +854,6 @@ namespace System.Diagnostics.Tracing } } - [SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "This does not need to be correct when racing with other threads")] protected unsafe void WriteEvent(int eventId, string? arg1, string? arg2) { if (m_eventSourceEnabled) @@ -887,7 +875,6 @@ namespace System.Diagnostics.Tracing } } - [SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "This does not need to be correct when racing with other threads")] protected unsafe void WriteEvent(int eventId, string? arg1, string? arg2, string? arg3) { if (m_eventSourceEnabled) @@ -915,7 +902,6 @@ namespace System.Diagnostics.Tracing } // optimized for common signatures (string and ints) - [SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "This does not need to be correct when racing with other threads")] protected unsafe void WriteEvent(int eventId, string? arg1, int arg2) { if (m_eventSourceEnabled) @@ -935,7 +921,6 @@ namespace System.Diagnostics.Tracing } } - [SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "This does not need to be correct when racing with other threads")] protected unsafe void WriteEvent(int eventId, string? arg1, int arg2, int arg3) { if (m_eventSourceEnabled) @@ -959,7 +944,6 @@ namespace System.Diagnostics.Tracing } // optimized for common signatures (string and longs) - [SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "This does not need to be correct when racing with other threads")] protected unsafe void WriteEvent(int eventId, string? arg1, long arg2) { if (m_eventSourceEnabled) @@ -980,7 +964,6 @@ namespace System.Diagnostics.Tracing } // optimized for common signatures (long and string) - [SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "This does not need to be correct when racing with other threads")] protected unsafe void WriteEvent(int eventId, long arg1, string? arg2) { if (m_eventSourceEnabled) @@ -1001,7 +984,6 @@ namespace System.Diagnostics.Tracing } // optimized for common signatures (int and string) - [SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "This does not need to be correct when racing with other threads")] protected unsafe void WriteEvent(int eventId, int arg1, string? arg2) { if (m_eventSourceEnabled) @@ -1021,7 +1003,6 @@ namespace System.Diagnostics.Tracing } } - [SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "This does not need to be correct when racing with other threads")] protected unsafe void WriteEvent(int eventId, byte[]? arg1) { if (m_eventSourceEnabled) @@ -1055,7 +1036,6 @@ namespace System.Diagnostics.Tracing } } - [SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "This does not need to be correct when racing with other threads")] protected unsafe void WriteEvent(int eventId, long arg1, byte[]? arg2) { if (m_eventSourceEnabled) @@ -1305,7 +1285,6 @@ namespace System.Diagnostics.Tracing /// method signature. Even if you use this for rare events, this call should be guarded by an /// check so that the varargs call is not made when the EventSource is not active. /// - [SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "This does not need to be correct when racing with other threads")] protected unsafe void WriteEvent(int eventId, params object?[] args) { WriteEventVarargs(eventId, null, args); @@ -1442,7 +1421,6 @@ namespace System.Diagnostics.Tracing /// "Log", such an exception would become a cached exception for the initialization of the static /// member, and any future access to the "Log" would throw the cached exception). /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "guid")] private unsafe void Initialize(Guid eventSourceGuid, string eventSourceName, string[]? traits) { try @@ -2178,7 +2156,6 @@ namespace System.Diagnostics.Tracing } } - [SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "This does not need to be correct when racing with other threads")] private unsafe void WriteEventString(EventLevel level, long keywords, string msgString) { #if FEATURE_MANAGED_ETW @@ -3706,7 +3683,6 @@ namespace System.Diagnostics.Tracing /// /// The method to probe. /// The literal value or -1 if the value could not be determined. - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity", Justification = "Switch statement is clearer than alternatives")] private static int GetHelperCallFirstArg(MethodInfo method) { #if (!ES_BUILD_PCL && !ES_BUILD_PN) @@ -3835,7 +3811,6 @@ namespace System.Diagnostics.Tracing /// It will do this even if the EventSource is not enabled. /// TODO remove flush parameter it is not used. /// - [SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "This does not need to be correct when racing with other threads")] internal void ReportOutOfBandMessage(string msg, bool flush) { try @@ -4083,7 +4058,6 @@ namespace System.Diagnostics.Tracing /// call Dispose when they are done with their logging. /// #if ES_BUILD_STANDALONE - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly")] #endif public virtual void Dispose() { diff --git a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/Winmeta.cs b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/Winmeta.cs index a230f54..03d86f8 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/Winmeta.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/Winmeta.cs @@ -117,7 +117,6 @@ namespace System.Diagnostics.Tracing /// /// EventChannel. Custom values must be in the range from 16 through 255. Currently only predefined values allowed. /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32", Justification = "Backwards compatibility")] public enum EventChannel : byte { /// diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/StreamReader.cs b/src/libraries/System.Private.CoreLib/src/System/IO/StreamReader.cs index 9db4769..393d224 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/StreamReader.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/StreamReader.cs @@ -1330,7 +1330,6 @@ namespace System.IO return -1; } - [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override int Read(char[] buffer, int index, int count) { return 0; diff --git a/src/libraries/System.Private.CoreLib/src/System/LocalDataStoreSlot.cs b/src/libraries/System.Private.CoreLib/src/System/LocalDataStoreSlot.cs index 6464878..592b817 100644 --- a/src/libraries/System.Private.CoreLib/src/System/LocalDataStoreSlot.cs +++ b/src/libraries/System.Private.CoreLib/src/System/LocalDataStoreSlot.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System.Diagnostics.CodeAnalysis; using System.Threading; namespace System @@ -16,7 +17,7 @@ namespace System internal ThreadLocal Data { get; private set; } - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA1821", Justification = "Finalizer preserved for compat, it is suppressed by the constructor.")] + [SuppressMessage("Microsoft.Security", "CA1821", Justification = "Finalizer preserved for compat, it is suppressed by the constructor.")] ~LocalDataStoreSlot() { } diff --git a/src/libraries/System.Private.CoreLib/src/System/Object.cs b/src/libraries/System.Private.CoreLib/src/System/Object.cs index 376bb55..a8e12bc 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Object.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Object.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; @@ -28,7 +29,7 @@ namespace System // Allow an object to free resources before the object is reclaimed by the GC. // This method's virtual slot number is hardcoded in runtimes. Do not add any virtual methods ahead of this. [NonVersionable] - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1821:RemoveEmptyFinalizers")] + [SuppressMessage("Microsoft.Performance", "CA1821:RemoveEmptyFinalizers")] ~Object() { } diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/StrongBox.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/StrongBox.cs index 02a21c3..bdee518 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/StrongBox.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/StrongBox.cs @@ -16,7 +16,6 @@ namespace System.Runtime.CompilerServices /// Gets the strongly typed value associated with the /// This is explicitly exposed as a field instead of a property to enable loading the address of the field. /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields")] [MaybeNull] public T Value = default!; /// diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/ConstrainedExecution/CriticalFinalizerObject.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/ConstrainedExecution/CriticalFinalizerObject.cs index 0f22b03..a6e07b8 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/ConstrainedExecution/CriticalFinalizerObject.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/ConstrainedExecution/CriticalFinalizerObject.cs @@ -12,6 +12,8 @@ ** ===========================================================*/ +using System.Diagnostics.CodeAnalysis; + namespace System.Runtime.ConstrainedExecution { public abstract class CriticalFinalizerObject @@ -20,7 +22,7 @@ namespace System.Runtime.ConstrainedExecution { } - [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1821:RemoveEmptyFinalizers")] + [SuppressMessage("Microsoft.Performance", "CA1821:RemoveEmptyFinalizers")] ~CriticalFinalizerObject() { } diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/SafeHandle.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/SafeHandle.cs index 234446c..c9f8766 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/SafeHandle.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/SafeHandle.cs @@ -23,7 +23,6 @@ namespace System.Runtime.InteropServices // manipulating _state. /// Specifies the handle to be wrapped. - [SuppressMessage("Microsoft.Security", "CA2111:PointersShouldNotBeVisible")] protected IntPtr handle; /// Combined ref count and closed/disposed flags (so we can atomically modify them). private volatile int _state; diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/ConcurrentExclusiveSchedulerPair.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/ConcurrentExclusiveSchedulerPair.cs index dd8a36e..1389949 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/ConcurrentExclusiveSchedulerPair.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/ConcurrentExclusiveSchedulerPair.cs @@ -246,20 +246,15 @@ namespace System.Threading.Tasks /// Gets the number of tasks waiting to run concurrently. /// This does not take the necessary lock, as it's only called from under the debugger. - [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] private int ConcurrentTaskCountForDebugger => m_concurrentTaskScheduler.m_tasks.Count; /// Gets the number of tasks waiting to run exclusively. /// This does not take the necessary lock, as it's only called from under the debugger. - [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] private int ExclusiveTaskCountForDebugger => m_exclusiveTaskScheduler.m_tasks.Count; /// Notifies the pair that new work has arrived to be processed. /// Whether tasks should be scheduled fairly with regards to other tasks. /// Must only be called while holding the lock. - [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] - [SuppressMessage("Microsoft.Performance", "CA1804:RemoveUnusedLocals")] - [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")] private void ProcessAsyncIfNecessary(bool fairly = false) { ContractAssertMonitorStatus(ValueLock, held: true); @@ -467,7 +462,6 @@ namespace System.Threading.Tasks /// state in one of those conditions or if the user explicitly asks for /// the Completion. /// - [SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses")] private sealed class CompletionState : Task { /// Whether the scheduler has had completion requested. @@ -622,7 +616,6 @@ namespace System.Threading.Tasks /// /// The task to execute inline if possible. /// true if the task was inlined successfully; otherwise, false. - [SuppressMessage("Microsoft.Performance", "CA1804:RemoveUnusedLocals", MessageId = "ignored")] private bool TryExecuteTaskInlineOnTargetScheduler(Task task) { // We'd like to simply call TryExecuteTaskInline here, but we can't. @@ -669,7 +662,6 @@ namespace System.Threading.Tasks protected override IEnumerable GetScheduledTasks() { return m_tasks; } /// Gets the number of tasks queued to this scheduler. - [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] private int CountForDebugger => m_tasks.Count; /// Provides a debug view for ConcurrentExclusiveTaskScheduler. diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.cs index 8ab07b7..8f99a52 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.cs @@ -212,7 +212,6 @@ namespace System.Threading } } - [SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "Reviewed for thread safety")] public bool LocalFindAndPop(object obj) { // Fast path: check the tail. If equal, we can skip the lock. @@ -271,7 +270,6 @@ namespace System.Threading public object? LocalPop() => m_headIndex < m_tailIndex ? LocalPopCore() : null; - [SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "Reviewed for thread safety")] private object? LocalPopCore() { while (true) -- 2.7.4