Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove some stale pragma warning disables #38551

Merged
merged 1 commit into from
Jun 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/Common/src/Interop/OSX/Interop.libproc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down Expand Up @@ -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();
}
}
Expand All @@ -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);
}
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,7 @@ public ManagementBaseObject WaitForNextEvent()

Initialize();

#pragma warning disable CA2002
lock (this)
#pragma warning restore CA2002
{
SecurityHandler securityHandler = Scope.GetSecurityHandler();

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -721,9 +717,7 @@ internal void Cancel()
{
if (null != stub)
{
#pragma warning disable CA2002
lock (this)
#pragma warning restore CA2002
{
if (null != stub)
{
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -945,9 +945,7 @@ internal void Initialize()
*/
if (!IsConnected)
{
#pragma warning disable CA2002
lock (this)
#pragma warning restore CA2002
{
if (!IsConnected)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,15 +353,12 @@ IDictionary<string, string> 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<string, string> GetNamespacesInScope(XmlNamespaceScope scope)
{
return _impl.GetNamespacesInScope(scope);
}
#pragma warning restore 3002

//
// XmlTextReader
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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!);
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
Expand All @@ -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]);
}
Expand All @@ -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)
{
Expand Down Expand Up @@ -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]);
}
Expand All @@ -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]);
}
Expand Down Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,7 @@ void IList.RemoveAt(int index) =>
IEnumerator<KeyValuePair<string, Group>> IEnumerable<KeyValuePair<string, Group>>.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)
Expand Down