Skip to content

Commit

Permalink
NET-1123 Repro FN S2183
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastien-marichal authored and sonartech committed Feb 11, 2025
1 parent 8df4d5c commit 7b52b1b
Showing 1 changed file with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,47 @@ private void ImproveShiftingBehavior()
}
}
}

// https://sonarsource.atlassian.net/browse/NET-1122
namespace Enums
{
enum Int8Enum : byte
{
One = 1,
Two = 1 << 1,
Three = 1 << 7,
Four = unchecked((byte)(1 << 9)), // FN
Five = (byte)(1 << 9), // Error [CS0221]
Six = unchecked((byte)(Three << 2)), // FN
Seven = Three << 2, // Error [CS0031]
}

enum Int16Enum : short
{
One = 1,
Two = 1 << 1,
Three = 1 << 13,
Four = unchecked((short)(1 << 17)), // FN
Five = (short)(1 << 17), // Error [CS0221]
Six = unchecked((short)(Three << 2)), // FN
Seven = Three << 2, // Error [CS0031]
}

enum Int32Enum : int
{
One = 1,
Two = 1 << 1,
Three = 1 << 31,
Four = 1 << 33, // FN
Five = Three << 2, // FN
}

enum Int64Enum : long
{
One = 1,
Two = 1 << 1,
Three = 1 << 63,
Four = 1 << 65, // FN
Five = Three << 2, // FN
}
}

0 comments on commit 7b52b1b

Please sign in to comment.