From 9c579f9bc5c844257770e12beb667f5ffaa26a85 Mon Sep 17 00:00:00 2001 From: Art Leonard Date: Tue, 31 Oct 2023 03:59:38 -0700 Subject: [PATCH] Enable SA1136: Enum values should be on separate lines #94098 (#94100) --- eng/CodeAnalysis.src.globalconfig | 2 +- .../Internal/NativeFormat/NativeFormatWriter.cs | 7 ++++++- .../src/Interop/Linux/cgroups/Interop.cgroups.cs | 7 ++++++- .../src/System/IO/Compression/ZLibNative.cs | 8 +++++++- .../NetworkInformation/UnixCommandLinePing.cs | 7 ++++++- .../src/System/Data/Common/ObjectStorage.cs | 9 ++++++++- .../src/System/IO/Compression/ZipArchiveEntry.cs | 16 ++++++++++++++-- .../src/System/Net/Mail/MailMessage.cs | 6 +++++- .../Net/Sockets/SocketAsyncEventArgs.Windows.cs | 7 ++++++- .../src/System/Globalization/TimeSpanFormat.cs | 7 ++++++- .../src/System/Xml/EncodingStreamWrapper.cs | 8 +++++++- .../src/System/Xml/PrefixHandle.cs | 2 ++ .../System/Xml/Xsl/IlGen/IteratorDescriptor.cs | 7 ++++++- .../src/System/Xml/Xsl/Runtime/XsltLibrary.cs | 12 ++++++++---- .../src/System/Numerics/BigInteger.cs | 7 ++++++- .../src/Internal/AlphabetConverter.cs | 4 +++- .../src/Internal/SrgsCompiler/SRGSCompiler.cs | 3 ++- .../src/Internal/SrgsParser/IGrammar.cs | 3 ++- .../src/Internal/Synthesis/EngineSite.cs | 4 +++- .../src/Internal/Synthesis/PcmConverter.cs | 7 ++++++- .../gen/Model/JsonPrimitiveTypeKind.cs | 6 +++++- .../Json/Serialization/Metadata/JsonTypeInfo.cs | 7 ++++++- src/tools/illink/src/linker/Linker/Driver.cs | 6 +++++- 23 files changed, 126 insertions(+), 26 deletions(-) diff --git a/eng/CodeAnalysis.src.globalconfig b/eng/CodeAnalysis.src.globalconfig index d06bf337e234c..2677ac469e667 100644 --- a/eng/CodeAnalysis.src.globalconfig +++ b/eng/CodeAnalysis.src.globalconfig @@ -1269,7 +1269,7 @@ dotnet_diagnostic.SA1134.severity = none dotnet_diagnostic.SA1135.severity = none # SA1136: Enum values should be on separate lines -dotnet_diagnostic.SA1136.severity = none +dotnet_diagnostic.SA1136.severity = warning # SA1137: Elements should have the same indentation dotnet_diagnostic.SA1137.severity = none diff --git a/src/coreclr/tools/Common/Internal/NativeFormat/NativeFormatWriter.cs b/src/coreclr/tools/Common/Internal/NativeFormat/NativeFormatWriter.cs index 9c6f9a9401213..67b62fc84c508 100644 --- a/src/coreclr/tools/Common/Internal/NativeFormat/NativeFormatWriter.cs +++ b/src/coreclr/tools/Common/Internal/NativeFormat/NativeFormatWriter.cs @@ -627,7 +627,12 @@ public override bool Equals(object obj) #endif class VertexBag : Vertex { - private enum EntryType { Vertex, Unsigned, Signed } + private enum EntryType + { + Vertex, + Unsigned, + Signed + } private struct Entry { diff --git a/src/libraries/Common/src/Interop/Linux/cgroups/Interop.cgroups.cs b/src/libraries/Common/src/Interop/Linux/cgroups/Interop.cgroups.cs index b4dcedb1cc933..48ddfeebc8719 100644 --- a/src/libraries/Common/src/Interop/Linux/cgroups/Interop.cgroups.cs +++ b/src/libraries/Common/src/Interop/Linux/cgroups/Interop.cgroups.cs @@ -17,7 +17,12 @@ internal static partial class @cgroups // For disambiguation, see https://systemd.io/CGROUP_DELEGATION/#three-different-tree-setups- /// The supported versions of cgroup. - internal enum CGroupVersion { None, CGroup1, CGroup2 }; + internal enum CGroupVersion + { + None, + CGroup1, + CGroup2 + }; /// Path to cgroup filesystem that tells us which version of cgroup is in use. private const string SysFsCgroupFileSystemPath = "/sys/fs/cgroup"; diff --git a/src/libraries/Common/src/System/IO/Compression/ZLibNative.cs b/src/libraries/Common/src/System/IO/Compression/ZLibNative.cs index 00851ee1048d5..79f2ab1e0d458 100644 --- a/src/libraries/Common/src/System/IO/Compression/ZLibNative.cs +++ b/src/libraries/Common/src/System/IO/Compression/ZLibNative.cs @@ -187,7 +187,13 @@ public enum CompressionMethod : int /// public sealed class ZLibStreamHandle : SafeHandle { - public enum State { NotInitialized, InitializedForDeflate, InitializedForInflate, Disposed } + public enum State + { + NotInitialized, + InitializedForDeflate, + InitializedForInflate, + Disposed + } private ZStream _zStream; diff --git a/src/libraries/Common/src/System/Net/NetworkInformation/UnixCommandLinePing.cs b/src/libraries/Common/src/System/Net/NetworkInformation/UnixCommandLinePing.cs index b9961a39d8676..e098a3cf4487c 100644 --- a/src/libraries/Common/src/System/Net/NetworkInformation/UnixCommandLinePing.cs +++ b/src/libraries/Common/src/System/Net/NetworkInformation/UnixCommandLinePing.cs @@ -50,7 +50,12 @@ private static bool IsBusyboxPing(string? pingBinary) return false; } - public enum PingFragmentOptions { Default, Do, Dont }; + public enum PingFragmentOptions + { + Default, + Do, + Dont + }; /// /// The location of the IPv4 ping utility on the current machine. diff --git a/src/libraries/System.Data.Common/src/System/Data/Common/ObjectStorage.cs b/src/libraries/System.Data.Common/src/System/Data/Common/ObjectStorage.cs index c6f399c89fda9..58cae79e3d6ea 100644 --- a/src/libraries/System.Data.Common/src/System/Data/Common/ObjectStorage.cs +++ b/src/libraries/System.Data.Common/src/System/Data/Common/ObjectStorage.cs @@ -15,7 +15,14 @@ namespace System.Data.Common { internal sealed class ObjectStorage : DataStorage { - private enum Families { DATETIME, NUMBER, STRING, BOOLEAN, ARRAY }; + private enum Families + { + DATETIME, + NUMBER, + STRING, + BOOLEAN, + ARRAY + }; private object?[] _values = default!; // Late-initialized private readonly bool _implementsIXmlSerializable; diff --git a/src/libraries/System.IO.Compression/src/System/IO/Compression/ZipArchiveEntry.cs b/src/libraries/System.IO.Compression/src/System/IO/Compression/ZipArchiveEntry.cs index 3d415f8e3690f..14988fcab7281 100644 --- a/src/libraries/System.IO.Compression/src/System/IO/Compression/ZipArchiveEntry.cs +++ b/src/libraries/System.IO.Compression/src/System/IO/Compression/ZipArchiveEntry.cs @@ -1309,8 +1309,20 @@ protected override void Dispose(bool disposing) } [Flags] - internal enum BitFlagValues : ushort { IsEncrypted = 0x1, DataDescriptor = 0x8, UnicodeFileNameAndComment = 0x800 } + internal enum BitFlagValues : ushort + { + IsEncrypted = 0x1, + DataDescriptor = 0x8, + UnicodeFileNameAndComment = 0x800 + } - internal enum CompressionMethodValues : ushort { Stored = 0x0, Deflate = 0x8, Deflate64 = 0x9, BZip2 = 0xC, LZMA = 0xE } + internal enum CompressionMethodValues : ushort + { + Stored = 0x0, + Deflate = 0x8, + Deflate64 = 0x9, + BZip2 = 0xC, + LZMA = 0xE + } } } diff --git a/src/libraries/System.Net.Mail/src/System/Net/Mail/MailMessage.cs b/src/libraries/System.Net.Mail/src/System/Net/Mail/MailMessage.cs index c260999b2e15f..c414b047f1123 100644 --- a/src/libraries/System.Net.Mail/src/System/Net/Mail/MailMessage.cs +++ b/src/libraries/System.Net.Mail/src/System/Net/Mail/MailMessage.cs @@ -13,7 +13,11 @@ namespace System.Net.Mail [Flags] public enum DeliveryNotificationOptions { - None = 0, OnSuccess = 1, OnFailure = 2, Delay = 4, Never = (int)0x08000000 + None = 0, + OnSuccess = 1, + OnFailure = 2, + Delay = 4, + Never = (int)0x08000000 } public class MailMessage : IDisposable diff --git a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEventArgs.Windows.cs b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEventArgs.Windows.cs index bd193ee6565ab..19aa0fa8ab4d7 100644 --- a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEventArgs.Windows.cs +++ b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEventArgs.Windows.cs @@ -74,7 +74,12 @@ public partial class SocketAsyncEventArgs : EventArgs, IDisposable private unsafe NativeOverlapped* _pendingOverlappedForCancellation; private PinState _pinState; - private enum PinState : byte { None = 0, MultipleBuffer, SendPackets } + private enum PinState : byte + { + None = 0, + MultipleBuffer, + SendPackets + } [MemberNotNull(nameof(_preAllocatedOverlapped))] private void InitializeInternals() diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/TimeSpanFormat.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/TimeSpanFormat.cs index ad8340b0bc848..4e11f14c80903 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/TimeSpanFormat.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/TimeSpanFormat.cs @@ -99,7 +99,12 @@ private static string FormatG(TimeSpan value, DateTimeFormatInfo dtfi, StandardF return new string(destination.Slice(0, charsWritten)); } - internal enum StandardFormat { C, G, g } + internal enum StandardFormat + { + C, + G, + g + } internal static unsafe bool TryFormatStandard(TimeSpan value, StandardFormat format, ReadOnlySpan decimalSeparator, Span destination, out int written) where TChar : unmanaged, IUtfChar { diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Xml/EncodingStreamWrapper.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Xml/EncodingStreamWrapper.cs index 26bbdc388173b..e4a29aa7b6dbb 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Xml/EncodingStreamWrapper.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Xml/EncodingStreamWrapper.cs @@ -20,7 +20,13 @@ namespace System.Xml // during construction. internal sealed class EncodingStreamWrapper : Stream { - private enum SupportedEncoding { UTF8, UTF16LE, UTF16BE, None } + private enum SupportedEncoding + { + UTF8, + UTF16LE, + UTF16BE, + None + } private const int BufferLength = 128; // UTF-8 is fastpath, so that's how these are stored diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Xml/PrefixHandle.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Xml/PrefixHandle.cs index 297df4bae42d3..315e40de1dc39 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Xml/PrefixHandle.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Xml/PrefixHandle.cs @@ -11,7 +11,9 @@ namespace System.Xml internal enum PrefixHandleType { Empty, +#pragma warning disable SA1136 // Enum values should be on separate lines A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, +#pragma warning restore SA1136 Buffer, Max, } diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/IlGen/IteratorDescriptor.cs b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/IlGen/IteratorDescriptor.cs index ecc1c90e1bfa9..0491ad228a2e7 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/IlGen/IteratorDescriptor.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/IlGen/IteratorDescriptor.cs @@ -35,7 +35,12 @@ internal enum ItemLocation /// True--Branch if boolean expression evaluates to true /// False--Branch if boolean expression evaluates to false /// - internal enum BranchingContext { None, OnTrue, OnFalse }; + internal enum BranchingContext + { + None, + OnTrue, + OnFalse + }; /// /// Describes the Clr type and location of items returned by an iterator. diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Runtime/XsltLibrary.cs b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Runtime/XsltLibrary.cs index acedb054118c4..9cc3f5588a4c5 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Runtime/XsltLibrary.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Runtime/XsltLibrary.cs @@ -324,10 +324,14 @@ internal static string LangToNameInternal(string lang, bool forwardCompatibility #region Comparisons internal enum ComparisonOperator { - /*Equality */ - Eq, Ne, - /*Relational*/ - Lt, Le, Gt, Ge, + /* Equality */ + Eq, + Ne, + /* Relational */ + Lt, + Le, + Gt, + Ge, } // Returns TypeCode of the given atomic value diff --git a/src/libraries/System.Runtime.Numerics/src/System/Numerics/BigInteger.cs b/src/libraries/System.Runtime.Numerics/src/System/Numerics/BigInteger.cs index b306da5f3726f..68f24ae5733c6 100644 --- a/src/libraries/System.Runtime.Numerics/src/System/Numerics/BigInteger.cs +++ b/src/libraries/System.Runtime.Numerics/src/System/Numerics/BigInteger.cs @@ -1299,7 +1299,12 @@ public int GetByteCount(bool isUnsigned = false) } /// Mode used to enable sharing for multiple purposes. - private enum GetBytesMode { AllocateArray, Count, Span } + private enum GetBytesMode + { + AllocateArray, + Count, + Span + } /// Shared logic for , , and . /// Which entry point is being used. diff --git a/src/libraries/System.Speech/src/Internal/AlphabetConverter.cs b/src/libraries/System.Speech/src/Internal/AlphabetConverter.cs index 180daabdec2c7..754b0f2e1e415 100644 --- a/src/libraries/System.Speech/src/Internal/AlphabetConverter.cs +++ b/src/libraries/System.Speech/src/Internal/AlphabetConverter.cs @@ -12,7 +12,9 @@ namespace System.Speech.Internal { internal enum AlphabetType { - Sapi, Ipa, Ups + Sapi, + Ipa, + Ups } /// diff --git a/src/libraries/System.Speech/src/Internal/SrgsCompiler/SRGSCompiler.cs b/src/libraries/System.Speech/src/Internal/SrgsCompiler/SRGSCompiler.cs index c21bfeb74a4c2..e9367929f81f0 100644 --- a/src/libraries/System.Speech/src/Internal/SrgsCompiler/SRGSCompiler.cs +++ b/src/libraries/System.Speech/src/Internal/SrgsCompiler/SRGSCompiler.cs @@ -195,6 +195,7 @@ private static void CreateAssembly(Backend backend, CustomGrammar cg) internal enum RuleScope { - PublicRule, PrivateRule + PublicRule, + PrivateRule } } diff --git a/src/libraries/System.Speech/src/Internal/SrgsParser/IGrammar.cs b/src/libraries/System.Speech/src/Internal/SrgsParser/IGrammar.cs index 00decfc3dd2f5..89c557432c563 100644 --- a/src/libraries/System.Speech/src/Internal/SrgsParser/IGrammar.cs +++ b/src/libraries/System.Speech/src/Internal/SrgsParser/IGrammar.cs @@ -31,6 +31,7 @@ internal interface IGrammar : IElement internal enum GrammarType { - VoiceGrammar, DtmfGrammar + VoiceGrammar, + DtmfGrammar } } diff --git a/src/libraries/System.Speech/src/Internal/Synthesis/EngineSite.cs b/src/libraries/System.Speech/src/Internal/Synthesis/EngineSite.cs index fc88d65b50552..e37766fc656b9 100644 --- a/src/libraries/System.Speech/src/Internal/Synthesis/EngineSite.cs +++ b/src/libraries/System.Speech/src/Internal/Synthesis/EngineSite.cs @@ -364,7 +364,9 @@ internal class PhonemeEventMapper : TtsEventMapper { public enum PhonemeConversion { - IpaToSapi, SapiToIpa, NoConversion + IpaToSapi, + SapiToIpa, + NoConversion } internal PhonemeEventMapper(ITtsEventSink sink, PhonemeConversion conversion, AlphabetConverter alphabetConverter) : base(sink) diff --git a/src/libraries/System.Speech/src/Internal/Synthesis/PcmConverter.cs b/src/libraries/System.Speech/src/Internal/Synthesis/PcmConverter.cs index d86b8bc8cb767..2cdf053da5920 100644 --- a/src/libraries/System.Speech/src/Internal/Synthesis/PcmConverter.cs +++ b/src/libraries/System.Speech/src/Internal/Synthesis/PcmConverter.cs @@ -439,7 +439,12 @@ private static float[] Blackman(int iLength, bool bSymmetric) #region private Fields - private enum Block { First, Middle, Last }; + private enum Block + { + First, + Middle, + Last + }; private WAVEFORMATEX _inWavFormat; private WAVEFORMATEX _outWavFormat; diff --git a/src/libraries/System.Text.Json/gen/Model/JsonPrimitiveTypeKind.cs b/src/libraries/System.Text.Json/gen/Model/JsonPrimitiveTypeKind.cs index f0e54850234a4..d8f0ca1b50604 100644 --- a/src/libraries/System.Text.Json/gen/Model/JsonPrimitiveTypeKind.cs +++ b/src/libraries/System.Text.Json/gen/Model/JsonPrimitiveTypeKind.cs @@ -5,6 +5,10 @@ namespace System.Text.Json.SourceGeneration { public enum JsonPrimitiveTypeKind { - String, Boolean, ByteArray, Char, Number + String, + Boolean, + ByteArray, + Char, + Number } } diff --git a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonTypeInfo.cs b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonTypeInfo.cs index 668e0c7b15e1a..e915c5bf4879e 100644 --- a/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonTypeInfo.cs +++ b/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonTypeInfo.cs @@ -617,7 +617,12 @@ internal void VerifyMutable() internal bool IsConfigured => _configurationState == ConfigurationState.Configured; internal bool IsConfigurationStarted => _configurationState is not ConfigurationState.NotConfigured; private volatile ConfigurationState _configurationState; - private enum ConfigurationState : byte { NotConfigured = 0, Configuring = 1, Configured = 2 }; + private enum ConfigurationState : byte + { + NotConfigured = 0, + Configuring = 1, + Configured = 2 + }; private ExceptionDispatchInfo? _cachedConfigureError; diff --git a/src/tools/illink/src/linker/Linker/Driver.cs b/src/tools/illink/src/linker/Linker/Driver.cs index 7b4a78a690348..742ee2140b9ce 100644 --- a/src/tools/illink/src/linker/Linker/Driver.cs +++ b/src/tools/illink/src/linker/Linker/Driver.cs @@ -174,7 +174,11 @@ void ErrorMissingArgument (string optionName) Context.LogError (null, DiagnosticId.MissingArgumentForCommanLineOptionName, optionName); } - public enum DependenciesFileFormat { Xml, Dgml }; + public enum DependenciesFileFormat + { + Xml, + Dgml + }; // Perform setup of the LinkContext and parse the arguments. // Return values: