Skip to content

Commit

Permalink
Enable IDE0065 (Misplaced using directive) (#70919)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephentoub committed Jun 19, 2022
1 parent 8442a62 commit 246d9bb
Show file tree
Hide file tree
Showing 240 changed files with 1,251 additions and 1,295 deletions.
2 changes: 1 addition & 1 deletion eng/CodeAnalysis.src.globalconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1492,7 +1492,7 @@ dotnet_diagnostic.IDE0063.severity = silent
dotnet_diagnostic.IDE0064.severity = silent

# IDE0065: Misplaced using directive
dotnet_diagnostic.IDE0065.severity = suggestion
dotnet_diagnostic.IDE0065.severity = warning

# IDE0066: Convert switch statement to expression
dotnet_diagnostic.IDE0066.severity = suggestion
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/nativeaot/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<NoWarn>$(NoWarn);CS8602;CS8603;CS8604;CS8618;CS8625;CS8632;CS8765</NoWarn>

<!-- we should just fix -->
<NoWarn>$(NoWarn);CA1810;CA1823;CA1825;CA1852;CA2208;SA1129;SA1205;SA1400;SA1517</NoWarn>
<NoWarn>$(NoWarn);CA1810;CA1823;CA1825;CA1852;CA2208;SA1129;SA1205;SA1400;SA1517;IDE0065</NoWarn>

<!-- Arrays as attribute arguments is not CLS-compliant -->
<NoWarn>$(NoWarn);CS3016</NoWarn>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Diagnostics.CodeAnalysis;

namespace System.ComponentModel
{
using System;
using System.Diagnostics.CodeAnalysis;

/// <summary>
/// DesignTimeVisibileAttribute marks a component's visibility. If
/// DesignTimeVisibileAttribute.Yes is present, a visual designer can show
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Collections;

namespace System.Configuration
{
using Collections;

// Contains all the updates to section definitions across all location sections.
internal sealed class ConfigDefinitionUpdates
{
Expand Down
3 changes: 1 addition & 2 deletions src/libraries/System.Data.OleDb/src/OleDbConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@
using System.Globalization;
using System.Runtime.InteropServices;
using System.Text;
using SysTx = System.Transactions;

namespace System.Data.OleDb
{
using SysTx = Transactions;

// wraps the OLEDB IDBInitialize interface which represents a connection
// Notes about connection pooling
// 1. Only happens if we use the IDataInitialize or IDBPromptInitialize interfaces
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
using System.Globalization;
using System.Runtime.InteropServices;
using System.Threading;
using SysTx = System.Transactions;

namespace System.Data.OleDb
{
using SysTx = Transactions;

internal sealed class OleDbConnectionInternal : DbConnectionInternal, IDisposable
{
private static volatile OleDbServicesWrapper? idataInitialize;
Expand Down
9 changes: 4 additions & 5 deletions src/libraries/System.Data.OleDb/src/OleDbStruct.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.Runtime.InteropServices;

namespace System.Data.OleDb
{
#if DEBUG
using Globalization;
using Text;
using System.Globalization;
using System.Text;
#endif

namespace System.Data.OleDb
{
internal enum DBBindStatus
{
OK = 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
using System.Data.ProviderBase;
using System.Diagnostics;
using System.Threading;
using SysTx = System.Transactions;

namespace System.Data.OleDb
{
using SysTx = Transactions;

public sealed partial class OleDbConnection : DbConnection
{
private static readonly DbConnectionFactory _connectionFactory = OleDbConnectionFactory.SingletonInstance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@
using System.Runtime.Versioning;
using System.Threading;
using System.Threading.Tasks;
using SysTx = System.Transactions;

namespace System.Data.ProviderBase
{
using SysTx = Transactions;

internal sealed class DbConnectionPool
{
private enum State
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Collections.Generic;
using System.Collections;
using System.DirectoryServices;

namespace System.DirectoryServices.AccountManagement
{
using System;
using System.Collections.Generic;
using System.Collections;
using System.DirectoryServices;

internal sealed class ExtensionCacheValue
{
internal ExtensionCacheValue(object[] value)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

//
using System;
using System.Runtime.InteropServices;

// This file defines many COM dual interfaces which are legacy and,
// cannot be changed. Tolerate possible obsoletion.
//
#pragma warning disable CS0618 // Type or member is obsolete

namespace System.DirectoryServices.AccountManagement
{
using System.Runtime.InteropServices;
using System;

internal static class Constants
{
internal static byte[] GUID_FOREIGNSECURITYPRINCIPALS_CONTAINER_BYTE = new byte[] { 0x22, 0xb7, 0x0c, 0x67, 0xd5, 0x6e, 0x4e, 0xfb, 0x91, 0xe9, 0x30, 0x0f, 0xca, 0x3d, 0xc1, 0xaa };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Drawing.Imaging;
using System.Threading;

namespace System.Drawing
{
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing.Imaging;
using System.Threading;

/// <summary>
/// Animates one or more images that have time-based frames.
/// See the ImageInfo.cs file for the helper nested ImageInfo class.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Runtime.InteropServices;

namespace System.Drawing.Imaging
{
using System.Runtime.InteropServices;

// sdkinc\imaging.h
[StructLayout(LayoutKind.Sequential, Pack = 8)]
internal struct ImageCodecInfoPrivate
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace System.Drawing.Imaging
{
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
#if NET7_0_OR_GREATER
using System.Runtime.InteropServices.Marshalling;
using System.Runtime.InteropServices.Marshalling;
#endif

namespace System.Drawing.Imaging
{
#if NET7_0_OR_GREATER
[NativeMarshalling(typeof(PinningMarshaller))]
#endif
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

namespace System.Drawing.Imaging
{
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
#if NET7_0_OR_GREATER
using System.Runtime.InteropServices.Marshalling;
#endif

namespace System.Drawing.Imaging
{
[StructLayout(LayoutKind.Sequential, Pack = 8)]
internal sealed class MetafileHeaderWmf
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ namespace System.Resources
.Extensions
#endif
{
#pragma warning disable IDE0065
#if RESOURCES_EXTENSIONS
using ResourceReader = DeserializingResourceReader;
#endif
#pragma warning restore IDE0065

// Provides the default implementation of IResourceReader, reading
// .resources file from the system default binary format. This class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ namespace System.Resources
.Extensions
#endif
{
#pragma warning disable IDE0065
#if RESOURCES_EXTENSIONS
using ResourceReader = DeserializingResourceReader;
#endif
#pragma warning restore IDE0065

// A RuntimeResourceSet stores all the resources defined in one
// particular CultureInfo, with some loading optimizations.
//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Threading;
using System.Xml;
using DataContractDictionary = System.Collections.Generic.Dictionary<System.Xml.XmlQualifiedName, System.Runtime.Serialization.DataContract>;

namespace System.Runtime.Serialization
{
using System;
using System.Collections;
using System.Diagnostics;
using System.Collections.Generic;
using System.IO;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Xml;
using DataContractDictionary = System.Collections.Generic.Dictionary<System.Xml.XmlQualifiedName, DataContract>;
using System.Linq;
using System.Diagnostics.CodeAnalysis;

internal sealed class ClassDataContract : DataContract
{
public XmlDictionaryString[]? ContractNamespaces;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Threading;
using System.Xml;
using DataContractDictionary = System.Collections.Generic.Dictionary<System.Xml.XmlQualifiedName, System.Runtime.Serialization.DataContract>;

namespace System.Runtime.Serialization
{
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Xml;
using System.Linq;
using DataContractDictionary = System.Collections.Generic.Dictionary<System.Xml.XmlQualifiedName, DataContract>;
using System.Security;
using System.Diagnostics.CodeAnalysis;

// The interface is a perf optimization.
// Only KeyValuePairAdapter should implement the interface.
internal interface IKeyValuePairAdapter { }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Buffers.Binary;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Xml;
using System.Xml.Schema;
using DataContractDictionary = System.Collections.Generic.Dictionary<System.Xml.XmlQualifiedName, System.Runtime.Serialization.DataContract>;

namespace System.Runtime.Serialization
{
using System;
using System.Buffers.Binary;
using System.Collections.Generic;
using System.Globalization;
using System.Reflection;
using System.Text;
using System.Xml;
using DataContractDictionary = System.Collections.Generic.Dictionary<System.Xml.XmlQualifiedName, DataContract>;
using System.Text.RegularExpressions;
using System.Runtime.CompilerServices;
using System.Linq;
using Xml.Schema;
using System.Collections.Concurrent;
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics;

internal abstract class DataContract
{
private XmlDictionaryString _name;
Expand Down

0 comments on commit 246d9bb

Please sign in to comment.