diff --git a/src/libraries/Common/src/Interop/FreeBSD/Interop.Process.cs b/src/libraries/Common/src/Interop/FreeBSD/Interop.Process.cs index 79892b65114ec..e0f0f5a29fadf 100644 --- a/src/libraries/Common/src/Interop/FreeBSD/Interop.Process.cs +++ b/src/libraries/Common/src/Interop/FreeBSD/Interop.Process.cs @@ -8,7 +8,7 @@ using System.Diagnostics; using System.Runtime.InteropServices; -#pragma warning disable CA1823 // analyzer incorrectly flags fixed buffer length const (https://github.com/dotnet/roslyn-analyzers/issues/2724) +#pragma warning disable CA1823 // analyzer incorrectly flags fixed buffer length const (https://github.com/dotnet/roslyn/issues/37593) internal static partial class Interop { diff --git a/src/libraries/Common/src/Interop/OSX/Interop.libproc.cs b/src/libraries/Common/src/Interop/OSX/Interop.libproc.cs index 1d39b2a3000fc..0a9b2c53b5d2d 100644 --- a/src/libraries/Common/src/Interop/OSX/Interop.libproc.cs +++ b/src/libraries/Common/src/Interop/OSX/Interop.libproc.cs @@ -10,7 +10,7 @@ using System.Diagnostics; using System.Runtime.InteropServices; -#pragma warning disable CA1823 // analyzer incorrectly flags fixed buffer length const (https://github.com/dotnet/roslyn-analyzers/issues/2724) +#pragma warning disable CA1823 // analyzer incorrectly flags fixed buffer length const (https://github.com/dotnet/roslyn/issues/37593) internal static partial class Interop { diff --git a/src/libraries/Common/tests/Extensions/CommandLineApplicationTests.cs b/src/libraries/Common/tests/Extensions/CommandLineApplicationTests.cs index 191f5d5642817..edbb1abbc36a1 100644 --- a/src/libraries/Common/tests/Extensions/CommandLineApplicationTests.cs +++ b/src/libraries/Common/tests/Extensions/CommandLineApplicationTests.cs @@ -1101,15 +1101,10 @@ public void HelpAndVersionOptionStopProcessing(string[] input, string expectedOu Assert.False(optFlag.HasValue()); } - // disable inaccurate analyzer error https://github.com/xunit/xunit/issues/1274 -#pragma warning disable xUnit1010 -#pragma warning disable xUnit1011 [Theory] [InlineData("-f:File1", "-f:File2")] [InlineData("--file:File1", "--file:File2")] [InlineData("--file", "File1", "--file", "File2")] -#pragma warning restore xUnit1010 -#pragma warning restore xUnit1011 public void ThrowsExceptionOnSingleValueOptionHavingTwoValues(params string[] inputOptions) { var app = new CommandLineApplication(); diff --git a/src/libraries/System.Drawing.Common/src/System/Drawing/ImageAnimator.Windows.cs b/src/libraries/System.Drawing.Common/src/System/Drawing/ImageAnimator.Windows.cs index fb5b72a94c9f3..e292bc29f512e 100644 --- a/src/libraries/System.Drawing.Common/src/System/Drawing/ImageAnimator.Windows.cs +++ b/src/libraries/System.Drawing.Common/src/System/Drawing/ImageAnimator.Windows.cs @@ -124,10 +124,8 @@ public static void UpdateFrames(Image image) if (imageInfo.FrameDirty) { // See comment in the class header about locking the image ref. -#pragma warning disable CA2002 lock (imageInfo.Image) { -#pragma warning restore CA2002 imageInfo.UpdateFrame(); } } @@ -175,10 +173,8 @@ public static void UpdateFrames() foreach (ImageInfo imageInfo in s_imageInfoList) { // See comment in the class header about locking the image ref. -#pragma warning disable CA2002 lock (imageInfo.Image) { -#pragma warning restore CA2002 imageInfo.UpdateFrame(); } } @@ -204,10 +200,8 @@ public static void Animate(Image image, EventHandler onFrameChangedHandler) ImageInfo? imageInfo = null; // See comment in the class header about locking the image ref. -#pragma warning disable CA2002 lock (image) { -#pragma warning restore CA2002 // could we avoid creating an ImageInfo object if FrameCount == 1 ? imageInfo = new ImageInfo(image); } @@ -293,10 +287,8 @@ public static bool CanAnimate(Image? image) } // See comment in the class header about locking the image ref. -#pragma warning disable CA2002 lock (image) { -#pragma warning restore CA2002 Guid[] dimensions = image.FrameDimensionsList; foreach (Guid guid in dimensions) diff --git a/src/libraries/System.IO.FileSystem.Watcher/src/System/IO/FileSystemWatcher.cs b/src/libraries/System.IO.FileSystem.Watcher/src/System/IO/FileSystemWatcher.cs index b3f2ed317d30f..27cd0bca2dbfb 100644 --- a/src/libraries/System.IO.FileSystem.Watcher/src/System/IO/FileSystemWatcher.cs +++ b/src/libraries/System.IO.FileSystem.Watcher/src/System/IO/FileSystemWatcher.cs @@ -65,10 +65,8 @@ public partial class FileSystemWatcher : Component, ISupportInitialize static FileSystemWatcher() { int s_notifyFiltersValidMask = 0; -#pragma warning disable CS8605 // Unboxing a possibly null value foreach (int enumValue in Enum.GetValues(typeof(NotifyFilters))) s_notifyFiltersValidMask |= enumValue; -#pragma warning restore CS8605 Debug.Assert(c_notifyFiltersValidMask == s_notifyFiltersValidMask, "The NotifyFilters enum has changed. The c_notifyFiltersValidMask must be updated to reflect the values of the NotifyFilters enum."); } #endif diff --git a/src/libraries/System.Management/src/System/Management/ManagementEventWatcher.cs b/src/libraries/System.Management/src/System/Management/ManagementEventWatcher.cs index 793f1b6fef09a..63106795230cb 100644 --- a/src/libraries/System.Management/src/System/Management/ManagementEventWatcher.cs +++ b/src/libraries/System.Management/src/System/Management/ManagementEventWatcher.cs @@ -394,9 +394,7 @@ public ManagementBaseObject WaitForNextEvent() Initialize(); -#pragma warning disable CA2002 lock (this) -#pragma warning restore CA2002 { SecurityHandler securityHandler = Scope.GetSecurityHandler(); @@ -561,9 +559,7 @@ private void Initialize() Options = new EventWatcherOptions(); //If we're not connected yet, this is the time to do it... -#pragma warning disable CA2002 lock (this) -#pragma warning restore CA2002 { if (null == scope) Scope = new ManagementScope(); @@ -721,9 +717,7 @@ internal void Cancel() { if (null != stub) { -#pragma warning disable CA2002 lock (this) -#pragma warning restore CA2002 { if (null != stub) { @@ -749,9 +743,7 @@ internal void ReleaseStub() { if (null != stub) { -#pragma warning disable CA2002 lock (this) -#pragma warning restore CA2002 { /* * We force a release of the stub here so as to allow diff --git a/src/libraries/System.Management/src/System/Management/ManagementObject.cs b/src/libraries/System.Management/src/System/Management/ManagementObject.cs index 6b4db0291c9cd..5d8538263dae7 100644 --- a/src/libraries/System.Management/src/System/Management/ManagementObject.cs +++ b/src/libraries/System.Management/src/System/Management/ManagementObject.cs @@ -2567,9 +2567,7 @@ internal override void Initialize(bool getObject) //If we're not connected yet, this is the time to do it... We lock //the state to prevent 2 threads simultaneously doing the same //connection -#pragma warning disable CA2002 lock (this) -#pragma warning restore CA2002 { // Make sure we have some kind of path if we get here. Note that // we don't use a set to the Path property since that would trigger diff --git a/src/libraries/System.Management/src/System/Management/ManagementScope.cs b/src/libraries/System.Management/src/System/Management/ManagementScope.cs index 6fc957b580577..97dcd75f5509b 100644 --- a/src/libraries/System.Management/src/System/Management/ManagementScope.cs +++ b/src/libraries/System.Management/src/System/Management/ManagementScope.cs @@ -945,9 +945,7 @@ internal void Initialize() */ if (!IsConnected) { -#pragma warning disable CA2002 lock (this) -#pragma warning restore CA2002 { if (!IsConnected) { diff --git a/src/libraries/System.Management/src/System/Management/MethodSet.cs b/src/libraries/System.Management/src/System/Management/MethodSet.cs index 34cbc1594fe87..88dd5925eb208 100644 --- a/src/libraries/System.Management/src/System/Management/MethodSet.cs +++ b/src/libraries/System.Management/src/System/Management/MethodSet.cs @@ -78,9 +78,7 @@ public int Count string methodName; int status = (int)ManagementStatus.Failed; -#pragma warning disable CA2002 lock (typeof(enumLock)) -#pragma warning restore CA2002 { try { @@ -258,9 +256,7 @@ internal MethodDataEnumerator(ManagementObject parent) string tempMethodName; int status = (int)ManagementStatus.Failed; -#pragma warning disable CA2002 lock (typeof(enumLock)) -#pragma warning restore CA2002 { try { diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/JsonEncodingStreamWrapper.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/JsonEncodingStreamWrapper.cs index a7e52e2c2113f..615912680e371 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/JsonEncodingStreamWrapper.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/Json/JsonEncodingStreamWrapper.cs @@ -2,8 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#pragma warning disable 1634 // Stops compiler from warning about unknown warnings (for Presharp) - using System.IO; using System.Text; using System.Xml; diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlTextReader.cs b/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlTextReader.cs index 53acf677ab535..572699871ad6c 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlTextReader.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Core/XmlTextReader.cs @@ -353,15 +353,12 @@ IDictionary IXmlNamespaceResolver.GetNamespacesInScope(XmlNamesp return _impl.LookupPrefix(namespaceName); } - // This pragma disables a warning that the return type is not CLS-compliant, but generics are part of CLS in Whidbey. -#pragma warning disable 3002 // FXCOP: ExplicitMethodImplementationsInUnsealedClassesHaveVisibleAlternates // public versions of IXmlNamespaceResolver methods, so that XmlTextReader subclasses can access them public IDictionary GetNamespacesInScope(XmlNamespaceScope scope) { return _impl.GetNamespacesInScope(scope); } -#pragma warning restore 3002 // // XmlTextReader diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Schema/SchemaCollectionpreProcessor.cs b/src/libraries/System.Private.Xml/src/System/Xml/Schema/SchemaCollectionpreProcessor.cs index d195a38369169..6cc71a1569416 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Schema/SchemaCollectionpreProcessor.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Schema/SchemaCollectionpreProcessor.cs @@ -706,7 +706,6 @@ private void PreprocessRedefine(XmlSchemaRedefine redefine) } } -#pragma warning disable CS8605 // TODO-NULLABLE: https://github.com/dotnet/csharplang/issues/3214 foreach (DictionaryEntry entry in redefine.Groups) { redefine.Schema!.Groups.Insert((XmlQualifiedName)entry.Key!, (XmlSchemaObject)entry.Value!); @@ -721,7 +720,6 @@ private void PreprocessRedefine(XmlSchemaRedefine redefine) { redefine.Schema!.SchemaTypes.Insert((XmlQualifiedName)entry.Key!, (XmlSchemaObject)entry.Value!); } -#pragma warning restore CS8605 } private int CountGroupSelfReference(XmlSchemaObjectCollection items, XmlQualifiedName name) diff --git a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/Rss20FeedFormatter.cs b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/Rss20FeedFormatter.cs index 3ff0f52f33dd7..dc27f6ccd4dd6 100644 --- a/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/Rss20FeedFormatter.cs +++ b/src/libraries/System.ServiceModel.Syndication/src/System/ServiceModel/Syndication/Rss20FeedFormatter.cs @@ -875,9 +875,7 @@ private void WriteFeed(XmlWriter writer) // if there's a single author with an email address, then serialize as the managingEditor // else serialize the authors as Atom extensions -#pragma warning disable 56506 // tvish: this.Feed.Authors is never null if ((Feed.Authors.Count == 1) && (Feed.Authors[0].Email != null)) -#pragma warning restore 56506 { WritePerson(writer, Rss20Constants.ManagingEditorTag, Feed.Authors[0]); } @@ -896,9 +894,7 @@ private void WriteFeed(XmlWriter writer) writer.WriteEndElement(); } -#pragma warning disable 56506 // tvish: this.Feed.Categories is never null for (int i = 0; i < Feed.Categories.Count; ++i) -#pragma warning restore 56506 { WriteCategory(writer, Feed.Categories[i]); } @@ -908,9 +904,7 @@ private void WriteFeed(XmlWriter writer) writer.WriteElementString(Rss20Constants.GeneratorTag, Feed.Generator); } -#pragma warning disable 56506 // tvish: this.Feed.Contributors is never null if (Feed.Contributors.Count > 0) -#pragma warning restore 56506 { if (SerializeExtensionsAsAtom) { @@ -1042,9 +1036,7 @@ private void WriteItemContents(XmlWriter writer, SyndicationItem item, Uri feedB WriteAlternateLink(writer, firstAlternateLink, (item.BaseUri ?? feedBaseUri)); } -#pragma warning disable 56506 // tvish, item.Authors is never null if (item.Authors.Count == 1 && !string.IsNullOrEmpty(item.Authors[0].Email)) -#pragma warning restore 56506 { WritePerson(writer, Rss20Constants.AuthorTag, item.Authors[0]); } @@ -1056,9 +1048,7 @@ private void WriteItemContents(XmlWriter writer, SyndicationItem item, Uri feedB } } -#pragma warning disable 56506 // tvish, item.Categories is never null for (int i = 0; i < item.Categories.Count; ++i) -#pragma warning restore 56506 { WriteCategory(writer, item.Categories[i]); } @@ -1163,9 +1153,7 @@ private void WriteItemContents(XmlWriter writer, SyndicationItem item, Uri feedB } } -#pragma warning disable 56506 // tvish, item.COntributors is never null if (item.Contributors.Count > 0) -#pragma warning restore 56506 { if (SerializeExtensionsAsAtom) { diff --git a/src/libraries/System.Text.RegularExpressions/ref/System.Text.RegularExpressions.cs b/src/libraries/System.Text.RegularExpressions/ref/System.Text.RegularExpressions.cs index c063564dd4244..a392155295605 100644 --- a/src/libraries/System.Text.RegularExpressions/ref/System.Text.RegularExpressions.cs +++ b/src/libraries/System.Text.RegularExpressions/ref/System.Text.RegularExpressions.cs @@ -87,9 +87,7 @@ void System.Collections.IList.Clear() { } void System.Collections.IList.Insert(int index, object? value) { } void System.Collections.IList.Remove(object? value) { } void System.Collections.IList.RemoveAt(int index) { } -#pragma warning disable CS8614 // Nullability of reference types in type of parameter doesn't match implicitly implemented member. public bool TryGetValue(string key, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out System.Text.RegularExpressions.Group? value) { throw null; } -#pragma warning restore CS8614 } public partial class Match : System.Text.RegularExpressions.Group { diff --git a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/GroupCollection.cs b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/GroupCollection.cs index 71f797ca3acbd..dc30260baff30 100644 --- a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/GroupCollection.cs +++ b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/GroupCollection.cs @@ -195,9 +195,7 @@ void IList.RemoveAt(int index) => IEnumerator> IEnumerable>.GetEnumerator() => new Enumerator(this); -#pragma warning disable CS8614 // Nullability of reference types in type of parameter doesn't match implicitly implemented member. public bool TryGetValue(string key, [NotNullWhen(true)] out Group? value) -#pragma warning restore CS8614 { Group group = this[key]; if (group == Group.s_emptyGroup)