Skip to content

Commit

Permalink
Enable SA1136: Enum values should be on separate lines #94098 (#94100)
Browse files Browse the repository at this point in the history
  • Loading branch information
artl93 committed Oct 31, 2023
1 parent 920cd6e commit 9c579f9
Show file tree
Hide file tree
Showing 23 changed files with 126 additions and 26 deletions.
2 changes: 1 addition & 1 deletion eng/CodeAnalysis.src.globalconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ internal static partial class @cgroups
// For disambiguation, see https://systemd.io/CGROUP_DELEGATION/#three-different-tree-setups-

/// <summary>The supported versions of cgroup.</summary>
internal enum CGroupVersion { None, CGroup1, CGroup2 };
internal enum CGroupVersion
{
None,
CGroup1,
CGroup2
};

/// <summary>Path to cgroup filesystem that tells us which version of cgroup is in use.</summary>
private const string SysFsCgroupFileSystemPath = "/sys/fs/cgroup";
Expand Down
8 changes: 7 additions & 1 deletion src/libraries/Common/src/System/IO/Compression/ZLibNative.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,13 @@ public enum CompressionMethod : int
/// </summary>
public sealed class ZLibStreamHandle : SafeHandle
{
public enum State { NotInitialized, InitializedForDeflate, InitializedForInflate, Disposed }
public enum State
{
NotInitialized,
InitializedForDeflate,
InitializedForInflate,
Disposed
}

private ZStream _zStream;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ private static bool IsBusyboxPing(string? pingBinary)
return false;
}

public enum PingFragmentOptions { Default, Do, Dont };
public enum PingFragmentOptions
{
Default,
Do,
Dont
};

/// <summary>
/// The location of the IPv4 ping utility on the current machine.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<TChar>(TimeSpan value, StandardFormat format, ReadOnlySpan<TChar> decimalSeparator, Span<TChar> destination, out int written) where TChar : unmanaged, IUtfChar<TChar>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ internal enum ItemLocation
/// True--Branch if boolean expression evaluates to true
/// False--Branch if boolean expression evaluates to false
/// </summary>
internal enum BranchingContext { None, OnTrue, OnFalse };
internal enum BranchingContext
{
None,
OnTrue,
OnFalse
};

/// <summary>
/// Describes the Clr type and location of items returned by an iterator.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1299,7 +1299,12 @@ public int GetByteCount(bool isUnsigned = false)
}

/// <summary>Mode used to enable sharing <see cref="TryGetBytes(GetBytesMode, Span{byte}, bool, bool, ref int)"/> for multiple purposes.</summary>
private enum GetBytesMode { AllocateArray, Count, Span }
private enum GetBytesMode
{
AllocateArray,
Count,
Span
}

/// <summary>Shared logic for <see cref="ToByteArray(bool, bool)"/>, <see cref="TryWriteBytes(Span{byte}, out int, bool, bool)"/>, and <see cref="GetByteCount"/>.</summary>
/// <param name="mode">Which entry point is being used.</param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ namespace System.Speech.Internal
{
internal enum AlphabetType
{
Sapi, Ipa, Ups
Sapi,
Ipa,
Ups
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ private static void CreateAssembly(Backend backend, CustomGrammar cg)

internal enum RuleScope
{
PublicRule, PrivateRule
PublicRule,
PrivateRule
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ internal interface IGrammar : IElement

internal enum GrammarType
{
VoiceGrammar, DtmfGrammar
VoiceGrammar,
DtmfGrammar
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ namespace System.Text.Json.SourceGeneration
{
public enum JsonPrimitiveTypeKind
{
String, Boolean, ByteArray, Char, Number
String,
Boolean,
ByteArray,
Char,
Number
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 5 additions & 1 deletion src/tools/illink/src/linker/Linker/Driver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 9c579f9

Please sign in to comment.