From b47aebb934aa2cb67437b12c0bcfa6b32e20ec44 Mon Sep 17 00:00:00 2001 From: Brandon Thetford Date: Fri, 19 Apr 2024 16:46:41 -0700 Subject: [PATCH] Definitions of enum types for use in tests --- .../EnumDefinitions/EnumMemberValues.cs | 48 +++++++++++++++++ .../WithGenerator/BetterEnum.cs | 49 ++++++++++++++++++ .../WithGenerator/BetterEnum_ExplicitInt.cs | 49 ++++++++++++++++++ .../BetterEnum_ExplicitInt_NoFastIsDefined.cs | 50 ++++++++++++++++++ .../WithGenerator/BetterEnum_ExplicitUInt.cs | 49 ++++++++++++++++++ ...BetterEnum_ExplicitUInt_NoFastIsDefined.cs | 49 ++++++++++++++++++ .../BetterEnum_NoFastIsDefined.cs | 49 ++++++++++++++++++ .../WithGenerator/BetterFlagsEnum.cs | 50 ++++++++++++++++++ .../BetterFlagsEnum_ExplicitInt.cs | 51 +++++++++++++++++++ .../BetterFlagsEnum_ExplicitUInt.cs | 50 ++++++++++++++++++ .../WithoutGenerator/BasicEnum.cs | 46 +++++++++++++++++ .../WithoutGenerator/BasicEnum_ExplicitInt.cs | 48 +++++++++++++++++ .../BasicEnum_ExplicitUint.cs | 46 +++++++++++++++++ .../WithoutGenerator/FlagsEnum.cs | 43 ++++++++++++++++ .../WithoutGenerator/FlagsEnum_ExplicitInt.cs | 43 ++++++++++++++++ .../FlagsEnum_ExplicitUInt.cs | 43 ++++++++++++++++ 16 files changed, 763 insertions(+) create mode 100644 Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/EnumMemberValues.cs create mode 100644 Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithGenerator/BetterEnum.cs create mode 100644 Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithGenerator/BetterEnum_ExplicitInt.cs create mode 100644 Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithGenerator/BetterEnum_ExplicitInt_NoFastIsDefined.cs create mode 100644 Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithGenerator/BetterEnum_ExplicitUInt.cs create mode 100644 Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithGenerator/BetterEnum_ExplicitUInt_NoFastIsDefined.cs create mode 100644 Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithGenerator/BetterEnum_NoFastIsDefined.cs create mode 100644 Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithGenerator/BetterFlagsEnum.cs create mode 100644 Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithGenerator/BetterFlagsEnum_ExplicitInt.cs create mode 100644 Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithGenerator/BetterFlagsEnum_ExplicitUInt.cs create mode 100644 Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithoutGenerator/BasicEnum.cs create mode 100644 Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithoutGenerator/BasicEnum_ExplicitInt.cs create mode 100644 Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithoutGenerator/BasicEnum_ExplicitUint.cs create mode 100644 Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithoutGenerator/FlagsEnum.cs create mode 100644 Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithoutGenerator/FlagsEnum_ExplicitInt.cs create mode 100644 Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithoutGenerator/FlagsEnum_ExplicitUInt.cs diff --git a/Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/EnumMemberValues.cs b/Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/EnumMemberValues.cs new file mode 100644 index 000000000..6f7ac613f --- /dev/null +++ b/Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/EnumMemberValues.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Terminal.Gui.Analyzers.Internal.Tests.Generators.EnumExtensions.EnumDefinitions; +internal class SignedEnumMemberValues +{ + internal const int Bit31 = ~0b_01111111_11111111_11111111_11111111; + internal const int Bit30 = 0b_01000000_00000000_00000000_00000000; + internal const int Bit29 = 0b_00100000_00000000_00000000_00000000; + internal const int Bit28 = 0b_00010000_00000000_00000000_00000000; + internal const int Bit27 = 0b_00001000_00000000_00000000_00000000; + internal const int Bit26 = 0b_00000100_00000000_00000000_00000000; + internal const int Bit25 = 0b_00000010_00000000_00000000_00000000; + internal const int Bit24 = 0b_00000001_00000000_00000000_00000000; + internal const int Bit23 = 0b_00000000_10000000_00000000_00000000; + internal const int Bit22 = 0b_00000000_01000000_00000000_00000000; + internal const int Bit21 = 0b_00000000_00100000_00000000_00000000; + internal const int Bit20 = 0b_00000000_00010000_00000000_00000000; + internal const int Bit19 = 0b_00000000_00001000_00000000_00000000; + internal const int Bit18 = 0b_00000000_00000100_00000000_00000000; + internal const int Bit17 = 0b_00000000_00000010_00000000_00000000; + internal const int Bit16 = 0b_00000000_00000001_00000000_00000000; + internal const int Bit15 = 0b_00000000_00000000_10000000_00000000; + internal const int Bit14 = 0b_00000000_00000000_01000000_00000000; + internal const int Bit13 = 0b_00000000_00000000_00100000_00000000; + internal const int Bit12 = 0b_00000000_00000000_00010000_00000000; + internal const int Bit11 = 0b_00000000_00000000_00001000_00000000; + internal const int Bit10 = 0b_00000000_00000000_00000100_00000000; + internal const int Bit09 = 0b_00000000_00000000_00000010_00000000; + internal const int Bit08 = 0b_00000000_00000000_00000001_00000000; + internal const int Bit07 = 0b_00000000_00000000_00000000_10000000; + internal const int Bit06 = 0b_00000000_00000000_00000000_01000000; + internal const int Bit05 = 0b_00000000_00000000_00000000_00100000; + internal const int Bit04 = 0b_00000000_00000000_00000000_00010000; + internal const int Bit03 = 0b_00000000_00000000_00000000_00001000; + internal const int Bit02 = 0b_00000000_00000000_00000000_00000100; + internal const int Bit01 = 0b_00000000_00000000_00000000_00000010; + internal const int Bit00 = 0b_00000000_00000000_00000000_00000001; + internal const int All_0 = 0; + internal const int All_1 = ~All_0; + internal const int Alternating_01 = 0b_01010101_01010101_01010101_01010101; + internal const int Alternating_10 = ~Alternating_01; + internal const int EvenBytesHigh = 0b_00000000_11111111_00000000_11111111; + internal const int OddBytesHigh = ~EvenBytesHigh; +} diff --git a/Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithGenerator/BetterEnum.cs b/Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithGenerator/BetterEnum.cs new file mode 100644 index 000000000..0a57e7dc3 --- /dev/null +++ b/Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithGenerator/BetterEnum.cs @@ -0,0 +1,49 @@ +using Terminal.Gui.Analyzers.Internal.Attributes; + +namespace Terminal.Gui.Analyzers.Internal.Tests.Generators.EnumExtensions.EnumDefinitions; + +/// +/// Same as , but with applied. +/// +[GenerateEnumExtensionMethods] +public enum BetterEnum +{ + Bit31 = -0b_10000000_00000000_00000000_00000000, + Bit30 = 0b_01000000_00000000_00000000_00000000, + Bit29 = 0b_00100000_00000000_00000000_00000000, + Bit28 = 0b_00010000_00000000_00000000_00000000, + Bit27 = 0b_00001000_00000000_00000000_00000000, + Bit26 = 0b_00000100_00000000_00000000_00000000, + Bit25 = 0b_00000010_00000000_00000000_00000000, + Bit24 = 0b_00000001_00000000_00000000_00000000, + Bit23 = 0b_00000000_10000000_00000000_00000000, + Bit22 = 0b_00000000_01000000_00000000_00000000, + Bit21 = 0b_00000000_00100000_00000000_00000000, + Bit20 = 0b_00000000_00010000_00000000_00000000, + Bit19 = 0b_00000000_00001000_00000000_00000000, + Bit18 = 0b_00000000_00000100_00000000_00000000, + Bit17 = 0b_00000000_00000010_00000000_00000000, + Bit16 = 0b_00000000_00000001_00000000_00000000, + Bit15 = 0b_00000000_00000000_10000000_00000000, + Bit14 = 0b_00000000_00000000_01000000_00000000, + Bit13 = 0b_00000000_00000000_00100000_00000000, + Bit12 = 0b_00000000_00000000_00010000_00000000, + Bit11 = 0b_00000000_00000000_00001000_00000000, + Bit10 = 0b_00000000_00000000_00000100_00000000, + Bit09 = 0b_00000000_00000000_00000010_00000000, + Bit08 = 0b_00000000_00000000_00000001_00000000, + Bit07 = 0b_00000000_00000000_00000000_10000000, + Bit06 = 0b_00000000_00000000_00000000_01000000, + Bit05 = 0b_00000000_00000000_00000000_00100000, + Bit04 = 0b_00000000_00000000_00000000_00010000, + Bit03 = 0b_00000000_00000000_00000000_00001000, + Bit02 = 0b_00000000_00000000_00000000_00000100, + Bit01 = 0b_00000000_00000000_00000000_00000010, + Bit00 = 0b_00000000_00000000_00000000_00000001, + All_0 = 0, + All_1 = ~All_0, + Alternating_01 = 0b_01010101_01010101_01010101_01010101, + Alternating_10 = ~Alternating_01, + EvenBytesHigh = 0b_00000000_11111111_00000000_11111111, + OddBytesHigh = ~EvenBytesHigh, +} \ No newline at end of file diff --git a/Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithGenerator/BetterEnum_ExplicitInt.cs b/Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithGenerator/BetterEnum_ExplicitInt.cs new file mode 100644 index 000000000..7514e1b66 --- /dev/null +++ b/Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithGenerator/BetterEnum_ExplicitInt.cs @@ -0,0 +1,49 @@ +using Terminal.Gui.Analyzers.Internal.Attributes; + +namespace Terminal.Gui.Analyzers.Internal.Tests.Generators.EnumExtensions.EnumDefinitions; + +/// +/// Same as , but with applied. +/// +[GenerateEnumExtensionMethods] +public enum BetterEnum_ExplicitInt +{ + Bit31 = BasicEnum_ExplicitInt.Bit31, + Bit30 = BasicEnum_ExplicitInt.Bit30, + Bit29 = BasicEnum_ExplicitInt.Bit29, + Bit28 = BasicEnum_ExplicitInt.Bit28, + Bit27 = BasicEnum_ExplicitInt.Bit27, + Bit26 = BasicEnum_ExplicitInt.Bit26, + Bit25 = BasicEnum_ExplicitInt.Bit25, + Bit24 = BasicEnum_ExplicitInt.Bit24, + Bit23 = BasicEnum_ExplicitInt.Bit23, + Bit22 = BasicEnum_ExplicitInt.Bit22, + Bit21 = BasicEnum_ExplicitInt.Bit21, + Bit20 = BasicEnum_ExplicitInt.Bit20, + Bit19 = BasicEnum_ExplicitInt.Bit19, + Bit18 = BasicEnum_ExplicitInt.Bit18, + Bit17 = BasicEnum_ExplicitInt.Bit17, + Bit16 = BasicEnum_ExplicitInt.Bit16, + Bit15 = BasicEnum_ExplicitInt.Bit15, + Bit14 = BasicEnum_ExplicitInt.Bit14, + Bit13 = BasicEnum_ExplicitInt.Bit13, + Bit12 = BasicEnum_ExplicitInt.Bit12, + Bit11 = BasicEnum_ExplicitInt.Bit11, + Bit10 = BasicEnum_ExplicitInt.Bit10, + Bit09 = BasicEnum_ExplicitInt.Bit09, + Bit08 = BasicEnum_ExplicitInt.Bit08, + Bit07 = BasicEnum_ExplicitInt.Bit07, + Bit06 = BasicEnum_ExplicitInt.Bit06, + Bit05 = BasicEnum_ExplicitInt.Bit05, + Bit04 = BasicEnum_ExplicitInt.Bit04, + Bit03 = BasicEnum_ExplicitInt.Bit03, + Bit02 = BasicEnum_ExplicitInt.Bit02, + Bit01 = BasicEnum_ExplicitInt.Bit01, + Bit00 = BasicEnum_ExplicitInt.Bit00, + All_0 = BasicEnum_ExplicitInt.All_0, + All_1 = BasicEnum_ExplicitInt.All_1, + Alternating_01 = BasicEnum_ExplicitInt.Alternating_01, + Alternating_10 = BasicEnum_ExplicitInt.Alternating_10, + EvenBytesHigh = BasicEnum_ExplicitInt.EvenBytesHigh, + OddBytesHigh = BasicEnum_ExplicitInt.OddBytesHigh +} diff --git a/Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithGenerator/BetterEnum_ExplicitInt_NoFastIsDefined.cs b/Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithGenerator/BetterEnum_ExplicitInt_NoFastIsDefined.cs new file mode 100644 index 000000000..0309c174e --- /dev/null +++ b/Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithGenerator/BetterEnum_ExplicitInt_NoFastIsDefined.cs @@ -0,0 +1,50 @@ +// ReSharper disable EnumUnderlyingTypeIsInt +using Terminal.Gui.Analyzers.Internal.Attributes; + +namespace Terminal.Gui.Analyzers.Internal.Tests.Generators.EnumExtensions.EnumDefinitions; + +/// +/// Same as , but with = . +/// +[GenerateEnumExtensionMethods (FastIsDefined = false)] +public enum BetterEnum_ExplicitInt_NoFastIsDefined : int +{ + Bit31 = -0b_10000000_00000000_00000000_00000000, + Bit30 = 0b_01000000_00000000_00000000_00000000, + Bit29 = 0b_00100000_00000000_00000000_00000000, + Bit28 = 0b_00010000_00000000_00000000_00000000, + Bit27 = 0b_00001000_00000000_00000000_00000000, + Bit26 = 0b_00000100_00000000_00000000_00000000, + Bit25 = 0b_00000010_00000000_00000000_00000000, + Bit24 = 0b_00000001_00000000_00000000_00000000, + Bit23 = 0b_00000000_10000000_00000000_00000000, + Bit22 = 0b_00000000_01000000_00000000_00000000, + Bit21 = 0b_00000000_00100000_00000000_00000000, + Bit20 = 0b_00000000_00010000_00000000_00000000, + Bit19 = 0b_00000000_00001000_00000000_00000000, + Bit18 = 0b_00000000_00000100_00000000_00000000, + Bit17 = 0b_00000000_00000010_00000000_00000000, + Bit16 = 0b_00000000_00000001_00000000_00000000, + Bit15 = 0b_00000000_00000000_10000000_00000000, + Bit14 = 0b_00000000_00000000_01000000_00000000, + Bit13 = 0b_00000000_00000000_00100000_00000000, + Bit12 = 0b_00000000_00000000_00010000_00000000, + Bit11 = 0b_00000000_00000000_00001000_00000000, + Bit10 = 0b_00000000_00000000_00000100_00000000, + Bit09 = 0b_00000000_00000000_00000010_00000000, + Bit08 = 0b_00000000_00000000_00000001_00000000, + Bit07 = 0b_00000000_00000000_00000000_10000000, + Bit06 = 0b_00000000_00000000_00000000_01000000, + Bit05 = 0b_00000000_00000000_00000000_00100000, + Bit04 = 0b_00000000_00000000_00000000_00010000, + Bit03 = 0b_00000000_00000000_00000000_00001000, + Bit02 = 0b_00000000_00000000_00000000_00000100, + Bit01 = 0b_00000000_00000000_00000000_00000010, + Bit00 = 0b_00000000_00000000_00000000_00000001, + All_0 = 0, + All_1 = ~All_0, + Alternating_01 = 0b_01010101_01010101_01010101_01010101, + Alternating_10 = ~Alternating_01, + EvenBytesHigh = 0b_00000000_11111111_00000000_11111111, + OddBytesHigh = ~EvenBytesHigh, +} diff --git a/Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithGenerator/BetterEnum_ExplicitUInt.cs b/Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithGenerator/BetterEnum_ExplicitUInt.cs new file mode 100644 index 000000000..175a8e440 --- /dev/null +++ b/Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithGenerator/BetterEnum_ExplicitUInt.cs @@ -0,0 +1,49 @@ +using Terminal.Gui.Analyzers.Internal.Attributes; + +namespace Terminal.Gui.Analyzers.Internal.Tests.Generators.EnumExtensions.EnumDefinitions; + +/// +/// Same as , but with applied. +/// +[GenerateEnumExtensionMethods] +public enum BetterEnum_ExplicitUInt : uint +{ + Bit31 = 0b_10000000_00000000_00000000_00000000u, + Bit30 = 0b_01000000_00000000_00000000_00000000u, + Bit29 = 0b_00100000_00000000_00000000_00000000u, + Bit28 = 0b_00010000_00000000_00000000_00000000u, + Bit27 = 0b_00001000_00000000_00000000_00000000u, + Bit26 = 0b_00000100_00000000_00000000_00000000u, + Bit25 = 0b_00000010_00000000_00000000_00000000u, + Bit24 = 0b_00000001_00000000_00000000_00000000u, + Bit23 = 0b_00000000_10000000_00000000_00000000u, + Bit22 = 0b_00000000_01000000_00000000_00000000u, + Bit21 = 0b_00000000_00100000_00000000_00000000u, + Bit20 = 0b_00000000_00010000_00000000_00000000u, + Bit19 = 0b_00000000_00001000_00000000_00000000u, + Bit18 = 0b_00000000_00000100_00000000_00000000u, + Bit17 = 0b_00000000_00000010_00000000_00000000u, + Bit16 = 0b_00000000_00000001_00000000_00000000u, + Bit15 = 0b_00000000_00000000_10000000_00000000u, + Bit14 = 0b_00000000_00000000_01000000_00000000u, + Bit13 = 0b_00000000_00000000_00100000_00000000u, + Bit12 = 0b_00000000_00000000_00010000_00000000u, + Bit11 = 0b_00000000_00000000_00001000_00000000u, + Bit10 = 0b_00000000_00000000_00000100_00000000u, + Bit09 = 0b_00000000_00000000_00000010_00000000u, + Bit08 = 0b_00000000_00000000_00000001_00000000u, + Bit07 = 0b_00000000_00000000_00000000_10000000u, + Bit06 = 0b_00000000_00000000_00000000_01000000u, + Bit05 = 0b_00000000_00000000_00000000_00100000u, + Bit04 = 0b_00000000_00000000_00000000_00010000u, + Bit03 = 0b_00000000_00000000_00000000_00001000u, + Bit02 = 0b_00000000_00000000_00000000_00000100u, + Bit01 = 0b_00000000_00000000_00000000_00000010u, + Bit00 = 0b_00000000_00000000_00000000_00000001u, + All_0 = 0, + All_1 = ~All_0, + Alternating_01 = 0b_01010101_01010101_01010101_01010101, + Alternating_10 = ~Alternating_01, + EvenBytesHigh = 0b_00000000_11111111_00000000_11111111, + OddBytesHigh = ~EvenBytesHigh, +} \ No newline at end of file diff --git a/Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithGenerator/BetterEnum_ExplicitUInt_NoFastIsDefined.cs b/Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithGenerator/BetterEnum_ExplicitUInt_NoFastIsDefined.cs new file mode 100644 index 000000000..bec88097b --- /dev/null +++ b/Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithGenerator/BetterEnum_ExplicitUInt_NoFastIsDefined.cs @@ -0,0 +1,49 @@ +using Terminal.Gui.Analyzers.Internal.Attributes; + +namespace Terminal.Gui.Analyzers.Internal.Tests.Generators.EnumExtensions.EnumDefinitions; + +/// +/// Same as , but with = . +/// +[GenerateEnumExtensionMethods (FastIsDefined = false)] +public enum BetterEnum_ExplicitUInt_NoFastIsDefined : uint +{ + Bit31 = 0b_10000000_00000000_00000000_00000000u, + Bit30 = 0b_01000000_00000000_00000000_00000000u, + Bit29 = 0b_00100000_00000000_00000000_00000000u, + Bit28 = 0b_00010000_00000000_00000000_00000000u, + Bit27 = 0b_00001000_00000000_00000000_00000000u, + Bit26 = 0b_00000100_00000000_00000000_00000000u, + Bit25 = 0b_00000010_00000000_00000000_00000000u, + Bit24 = 0b_00000001_00000000_00000000_00000000u, + Bit23 = 0b_00000000_10000000_00000000_00000000u, + Bit22 = 0b_00000000_01000000_00000000_00000000u, + Bit21 = 0b_00000000_00100000_00000000_00000000u, + Bit20 = 0b_00000000_00010000_00000000_00000000u, + Bit19 = 0b_00000000_00001000_00000000_00000000u, + Bit18 = 0b_00000000_00000100_00000000_00000000u, + Bit17 = 0b_00000000_00000010_00000000_00000000u, + Bit16 = 0b_00000000_00000001_00000000_00000000u, + Bit15 = 0b_00000000_00000000_10000000_00000000u, + Bit14 = 0b_00000000_00000000_01000000_00000000u, + Bit13 = 0b_00000000_00000000_00100000_00000000u, + Bit12 = 0b_00000000_00000000_00010000_00000000u, + Bit11 = 0b_00000000_00000000_00001000_00000000u, + Bit10 = 0b_00000000_00000000_00000100_00000000u, + Bit09 = 0b_00000000_00000000_00000010_00000000u, + Bit08 = 0b_00000000_00000000_00000001_00000000u, + Bit07 = 0b_00000000_00000000_00000000_10000000u, + Bit06 = 0b_00000000_00000000_00000000_01000000u, + Bit05 = 0b_00000000_00000000_00000000_00100000u, + Bit04 = 0b_00000000_00000000_00000000_00010000u, + Bit03 = 0b_00000000_00000000_00000000_00001000u, + Bit02 = 0b_00000000_00000000_00000000_00000100u, + Bit01 = 0b_00000000_00000000_00000000_00000010u, + Bit00 = 0b_00000000_00000000_00000000_00000001u, + All_0 = 0, + All_1 = ~All_0, + Alternating_01 = 0b_01010101_01010101_01010101_01010101, + Alternating_10 = ~Alternating_01, + EvenBytesHigh = 0b_00000000_11111111_00000000_11111111, + OddBytesHigh = ~EvenBytesHigh, +} \ No newline at end of file diff --git a/Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithGenerator/BetterEnum_NoFastIsDefined.cs b/Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithGenerator/BetterEnum_NoFastIsDefined.cs new file mode 100644 index 000000000..2258d8a99 --- /dev/null +++ b/Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithGenerator/BetterEnum_NoFastIsDefined.cs @@ -0,0 +1,49 @@ +using Terminal.Gui.Analyzers.Internal.Attributes; + +namespace Terminal.Gui.Analyzers.Internal.Tests.Generators.EnumExtensions.EnumDefinitions; + +/// +/// Same as , but with = . +/// +[GenerateEnumExtensionMethods (FastIsDefined = false)] +public enum BetterEnum_NoFastIsDefined +{ + Bit31 = -0b_10000000_00000000_00000000_00000000, + Bit30 = 0b_01000000_00000000_00000000_00000000, + Bit29 = 0b_00100000_00000000_00000000_00000000, + Bit28 = 0b_00010000_00000000_00000000_00000000, + Bit27 = 0b_00001000_00000000_00000000_00000000, + Bit26 = 0b_00000100_00000000_00000000_00000000, + Bit25 = 0b_00000010_00000000_00000000_00000000, + Bit24 = 0b_00000001_00000000_00000000_00000000, + Bit23 = 0b_00000000_10000000_00000000_00000000, + Bit22 = 0b_00000000_01000000_00000000_00000000, + Bit21 = 0b_00000000_00100000_00000000_00000000, + Bit20 = 0b_00000000_00010000_00000000_00000000, + Bit19 = 0b_00000000_00001000_00000000_00000000, + Bit18 = 0b_00000000_00000100_00000000_00000000, + Bit17 = 0b_00000000_00000010_00000000_00000000, + Bit16 = 0b_00000000_00000001_00000000_00000000, + Bit15 = 0b_00000000_00000000_10000000_00000000, + Bit14 = 0b_00000000_00000000_01000000_00000000, + Bit13 = 0b_00000000_00000000_00100000_00000000, + Bit12 = 0b_00000000_00000000_00010000_00000000, + Bit11 = 0b_00000000_00000000_00001000_00000000, + Bit10 = 0b_00000000_00000000_00000100_00000000, + Bit09 = 0b_00000000_00000000_00000010_00000000, + Bit08 = 0b_00000000_00000000_00000001_00000000, + Bit07 = 0b_00000000_00000000_00000000_10000000, + Bit06 = 0b_00000000_00000000_00000000_01000000, + Bit05 = 0b_00000000_00000000_00000000_00100000, + Bit04 = 0b_00000000_00000000_00000000_00010000, + Bit03 = 0b_00000000_00000000_00000000_00001000, + Bit02 = 0b_00000000_00000000_00000000_00000100, + Bit01 = 0b_00000000_00000000_00000000_00000010, + Bit00 = 0b_00000000_00000000_00000000_00000001, + All_0 = 0, + All_1 = ~All_0, + Alternating_01 = 0b_01010101_01010101_01010101_01010101, + Alternating_10 = ~Alternating_01, + EvenBytesHigh = 0b_00000000_11111111_00000000_11111111, + OddBytesHigh = ~EvenBytesHigh, +} \ No newline at end of file diff --git a/Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithGenerator/BetterFlagsEnum.cs b/Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithGenerator/BetterFlagsEnum.cs new file mode 100644 index 000000000..ffb50b098 --- /dev/null +++ b/Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithGenerator/BetterFlagsEnum.cs @@ -0,0 +1,50 @@ +using Terminal.Gui.Analyzers.Internal.Attributes; + +namespace Terminal.Gui.Analyzers.Internal.Tests.Generators.EnumExtensions.EnumDefinitions; + +/// +/// Same as , but with applied. +/// +[Flags] +[GenerateEnumExtensionMethods] +public enum BetterFlagsEnum +{ + Bit31 = -0b_10000000_00000000_00000000_00000000, + Bit30 = 0b_01000000_00000000_00000000_00000000, + Bit29 = 0b_00100000_00000000_00000000_00000000, + Bit28 = 0b_00010000_00000000_00000000_00000000, + Bit27 = 0b_00001000_00000000_00000000_00000000, + Bit26 = 0b_00000100_00000000_00000000_00000000, + Bit25 = 0b_00000010_00000000_00000000_00000000, + Bit24 = 0b_00000001_00000000_00000000_00000000, + Bit23 = -0b_00000000_10000000_00000000_00000000, + Bit22 = 0b_00000000_01000000_00000000_00000000, + Bit21 = 0b_00000000_00100000_00000000_00000000, + Bit20 = 0b_00000000_00010000_00000000_00000000, + Bit19 = 0b_00000000_00001000_00000000_00000000, + Bit18 = 0b_00000000_00000100_00000000_00000000, + Bit17 = 0b_00000000_00000010_00000000_00000000, + Bit16 = 0b_00000000_00000001_00000000_00000000, + Bit15 = -0b_00000000_00000000_10000000_00000000, + Bit14 = 0b_00000000_00000000_01000000_00000000, + Bit13 = 0b_00000000_00000000_00100000_00000000, + Bit12 = 0b_00000000_00000000_00010000_00000000, + Bit11 = 0b_00000000_00000000_00001000_00000000, + Bit10 = 0b_00000000_00000000_00000100_00000000, + Bit09 = 0b_00000000_00000000_00000010_00000000, + Bit08 = 0b_00000000_00000000_00000001_00000000, + Bit07 = -0b_00000000_00000000_00000000_10000000, + Bit06 = 0b_00000000_00000000_00000000_01000000, + Bit05 = 0b_00000000_00000000_00000000_00100000, + Bit04 = 0b_00000000_00000000_00000000_00010000, + Bit03 = 0b_00000000_00000000_00000000_00001000, + Bit02 = 0b_00000000_00000000_00000000_00000100, + Bit01 = 0b_00000000_00000000_00000000_00000010, + Bit00 = 0b_00000000_00000000_00000000_00000001, + All_0 = 0, + All_1 = ~All_0, + Alternating_01 = 0b_01010101_01010101_01010101_01010101, + Alternating_10 = ~Alternating_01, + EvenBytesHigh = 0b_00000000_11111111_00000000_11111111, + OddBytesHigh = ~EvenBytesHigh, +} \ No newline at end of file diff --git a/Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithGenerator/BetterFlagsEnum_ExplicitInt.cs b/Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithGenerator/BetterFlagsEnum_ExplicitInt.cs new file mode 100644 index 000000000..e244a3aa5 --- /dev/null +++ b/Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithGenerator/BetterFlagsEnum_ExplicitInt.cs @@ -0,0 +1,51 @@ +using Terminal.Gui.Analyzers.Internal.Attributes; + +namespace Terminal.Gui.Analyzers.Internal.Tests.Generators.EnumExtensions.EnumDefinitions; + +/// +/// +/// Same as , but with applied. +/// +[Flags] +[GenerateEnumExtensionMethods] +public enum BetterFlagsEnum_ExplicitInt : int +{ + Bit31 = -0b_10000000_00000000_00000000_00000000, + Bit30 = 0b_01000000_00000000_00000000_00000000, + Bit29 = 0b_00100000_00000000_00000000_00000000, + Bit28 = 0b_00010000_00000000_00000000_00000000, + Bit27 = 0b_00001000_00000000_00000000_00000000, + Bit26 = 0b_00000100_00000000_00000000_00000000, + Bit25 = 0b_00000010_00000000_00000000_00000000, + Bit24 = 0b_00000001_00000000_00000000_00000000, + Bit23 = -0b_00000000_10000000_00000000_00000000, + Bit22 = 0b_00000000_01000000_00000000_00000000, + Bit21 = 0b_00000000_00100000_00000000_00000000, + Bit20 = 0b_00000000_00010000_00000000_00000000, + Bit19 = 0b_00000000_00001000_00000000_00000000, + Bit18 = 0b_00000000_00000100_00000000_00000000, + Bit17 = 0b_00000000_00000010_00000000_00000000, + Bit16 = 0b_00000000_00000001_00000000_00000000, + Bit15 = -0b_00000000_00000000_10000000_00000000, + Bit14 = 0b_00000000_00000000_01000000_00000000, + Bit13 = 0b_00000000_00000000_00100000_00000000, + Bit12 = 0b_00000000_00000000_00010000_00000000, + Bit11 = 0b_00000000_00000000_00001000_00000000, + Bit10 = 0b_00000000_00000000_00000100_00000000, + Bit09 = 0b_00000000_00000000_00000010_00000000, + Bit08 = 0b_00000000_00000000_00000001_00000000, + Bit07 = -0b_00000000_00000000_00000000_10000000, + Bit06 = 0b_00000000_00000000_00000000_01000000, + Bit05 = 0b_00000000_00000000_00000000_00100000, + Bit04 = 0b_00000000_00000000_00000000_00010000, + Bit03 = 0b_00000000_00000000_00000000_00001000, + Bit02 = 0b_00000000_00000000_00000000_00000100, + Bit01 = 0b_00000000_00000000_00000000_00000010, + Bit00 = 0b_00000000_00000000_00000000_00000001, + All_0 = 0, + All_1 = ~All_0, + Alternating_01 = 0b_01010101_01010101_01010101_01010101, + Alternating_10 = ~Alternating_01, + EvenBytesHigh = 0b_00000000_11111111_00000000_11111111, + OddBytesHigh = ~EvenBytesHigh, +} \ No newline at end of file diff --git a/Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithGenerator/BetterFlagsEnum_ExplicitUInt.cs b/Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithGenerator/BetterFlagsEnum_ExplicitUInt.cs new file mode 100644 index 000000000..89229a522 --- /dev/null +++ b/Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithGenerator/BetterFlagsEnum_ExplicitUInt.cs @@ -0,0 +1,50 @@ +using Terminal.Gui.Analyzers.Internal.Attributes; + +namespace Terminal.Gui.Analyzers.Internal.Tests.Generators.EnumExtensions.EnumDefinitions; + +/// +/// Same as , but with applied. +/// +[Flags] +[GenerateEnumExtensionMethods] +public enum BetterFlagsEnum_ExplicitUInt : uint +{ + Bit31 = 0b_10000000_00000000_00000000_00000000u, + Bit30 = 0b_01000000_00000000_00000000_00000000u, + Bit29 = 0b_00100000_00000000_00000000_00000000u, + Bit28 = 0b_00010000_00000000_00000000_00000000u, + Bit27 = 0b_00001000_00000000_00000000_00000000u, + Bit26 = 0b_00000100_00000000_00000000_00000000u, + Bit25 = 0b_00000010_00000000_00000000_00000000u, + Bit24 = 0b_00000001_00000000_00000000_00000000u, + Bit23 = 0b_00000000_10000000_00000000_00000000u, + Bit22 = 0b_00000000_01000000_00000000_00000000u, + Bit21 = 0b_00000000_00100000_00000000_00000000u, + Bit20 = 0b_00000000_00010000_00000000_00000000u, + Bit19 = 0b_00000000_00001000_00000000_00000000u, + Bit18 = 0b_00000000_00000100_00000000_00000000u, + Bit17 = 0b_00000000_00000010_00000000_00000000u, + Bit16 = 0b_00000000_00000001_00000000_00000000u, + Bit15 = 0b_00000000_00000000_10000000_00000000u, + Bit14 = 0b_00000000_00000000_01000000_00000000u, + Bit13 = 0b_00000000_00000000_00100000_00000000u, + Bit12 = 0b_00000000_00000000_00010000_00000000u, + Bit11 = 0b_00000000_00000000_00001000_00000000u, + Bit10 = 0b_00000000_00000000_00000100_00000000u, + Bit09 = 0b_00000000_00000000_00000010_00000000u, + Bit08 = 0b_00000000_00000000_00000001_00000000u, + Bit07 = 0b_00000000_00000000_00000000_10000000u, + Bit06 = 0b_00000000_00000000_00000000_01000000u, + Bit05 = 0b_00000000_00000000_00000000_00100000u, + Bit04 = 0b_00000000_00000000_00000000_00010000u, + Bit03 = 0b_00000000_00000000_00000000_00001000u, + Bit02 = 0b_00000000_00000000_00000000_00000100u, + Bit01 = 0b_00000000_00000000_00000000_00000010u, + Bit00 = 0b_00000000_00000000_00000000_00000001u, + All_0 = 0, + All_1 = ~All_0, + Alternating_01 = 0b_01010101_01010101_01010101_01010101, + Alternating_10 = ~Alternating_01, + EvenBytesHigh = 0b_00000000_11111111_00000000_11111111, + OddBytesHigh = ~EvenBytesHigh, +} \ No newline at end of file diff --git a/Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithoutGenerator/BasicEnum.cs b/Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithoutGenerator/BasicEnum.cs new file mode 100644 index 000000000..b49efcd78 --- /dev/null +++ b/Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithoutGenerator/BasicEnum.cs @@ -0,0 +1,46 @@ +namespace Terminal.Gui.Analyzers.Internal.Tests.Generators.EnumExtensions.EnumDefinitions; + +/// +/// Basic enum without explicitly-defined backing type and no attributes on the enum or any of its members. +/// +public enum BasicEnum +{ + Bit31 = -0b_10000000_00000000_00000000_00000000, + Bit30 = 0b_01000000_00000000_00000000_00000000, + Bit29 = 0b_00100000_00000000_00000000_00000000, + Bit28 = 0b_00010000_00000000_00000000_00000000, + Bit27 = 0b_00001000_00000000_00000000_00000000, + Bit26 = 0b_00000100_00000000_00000000_00000000, + Bit25 = 0b_00000010_00000000_00000000_00000000, + Bit24 = 0b_00000001_00000000_00000000_00000000, + Bit23 = 0b_00000000_10000000_00000000_00000000, + Bit22 = 0b_00000000_01000000_00000000_00000000, + Bit21 = 0b_00000000_00100000_00000000_00000000, + Bit20 = 0b_00000000_00010000_00000000_00000000, + Bit19 = 0b_00000000_00001000_00000000_00000000, + Bit18 = 0b_00000000_00000100_00000000_00000000, + Bit17 = 0b_00000000_00000010_00000000_00000000, + Bit16 = 0b_00000000_00000001_00000000_00000000, + Bit15 = 0b_00000000_00000000_10000000_00000000, + Bit14 = 0b_00000000_00000000_01000000_00000000, + Bit13 = 0b_00000000_00000000_00100000_00000000, + Bit12 = 0b_00000000_00000000_00010000_00000000, + Bit11 = 0b_00000000_00000000_00001000_00000000, + Bit10 = 0b_00000000_00000000_00000100_00000000, + Bit09 = 0b_00000000_00000000_00000010_00000000, + Bit08 = 0b_00000000_00000000_00000001_00000000, + Bit07 = 0b_00000000_00000000_00000000_10000000, + Bit06 = 0b_00000000_00000000_00000000_01000000, + Bit05 = 0b_00000000_00000000_00000000_00100000, + Bit04 = 0b_00000000_00000000_00000000_00010000, + Bit03 = 0b_00000000_00000000_00000000_00001000, + Bit02 = 0b_00000000_00000000_00000000_00000100, + Bit01 = 0b_00000000_00000000_00000000_00000010, + Bit00 = 0b_00000000_00000000_00000000_00000001, + All_0 = 0, + All_1 = -1, + Alternating_01 = 0b_01010101_01010101_01010101_01010101, + Alternating_10 = unchecked((int)0b_10101010_10101010_10101010_10101010), + OddBytesHigh = unchecked((int)0b_11111111_00000000_11111111_00000000), + EvenBytesHigh = 0b_00000000_11111111_00000000_11111111, +} \ No newline at end of file diff --git a/Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithoutGenerator/BasicEnum_ExplicitInt.cs b/Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithoutGenerator/BasicEnum_ExplicitInt.cs new file mode 100644 index 000000000..ee059cfac --- /dev/null +++ b/Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithoutGenerator/BasicEnum_ExplicitInt.cs @@ -0,0 +1,48 @@ +using Terminal.Gui.Analyzers.Internal.Attributes; + +namespace Terminal.Gui.Analyzers.Internal.Tests.Generators.EnumExtensions.EnumDefinitions; + +/// +/// Basic enum with explicitly-defined backing type of int and no attributes on the enum or any of its members. +/// +public enum BasicEnum_ExplicitInt : int +{ + Bit31 = -0b_10000000_00000000_00000000_00000000, + Bit30 = 0b_01000000_00000000_00000000_00000000, + Bit29 = 0b_00100000_00000000_00000000_00000000, + Bit28 = 0b_00010000_00000000_00000000_00000000, + Bit27 = 0b_00001000_00000000_00000000_00000000, + Bit26 = 0b_00000100_00000000_00000000_00000000, + Bit25 = 0b_00000010_00000000_00000000_00000000, + Bit24 = 0b_00000001_00000000_00000000_00000000, + Bit23 = 0b_00000000_10000000_00000000_00000000, + Bit22 = 0b_00000000_01000000_00000000_00000000, + Bit21 = 0b_00000000_00100000_00000000_00000000, + Bit20 = 0b_00000000_00010000_00000000_00000000, + Bit19 = 0b_00000000_00001000_00000000_00000000, + Bit18 = 0b_00000000_00000100_00000000_00000000, + Bit17 = 0b_00000000_00000010_00000000_00000000, + Bit16 = 0b_00000000_00000001_00000000_00000000, + Bit15 = 0b_00000000_00000000_10000000_00000000, + Bit14 = 0b_00000000_00000000_01000000_00000000, + Bit13 = 0b_00000000_00000000_00100000_00000000, + Bit12 = 0b_00000000_00000000_00010000_00000000, + Bit11 = 0b_00000000_00000000_00001000_00000000, + Bit10 = 0b_00000000_00000000_00000100_00000000, + Bit09 = 0b_00000000_00000000_00000010_00000000, + Bit08 = 0b_00000000_00000000_00000001_00000000, + Bit07 = 0b_00000000_00000000_00000000_10000000, + Bit06 = 0b_00000000_00000000_00000000_01000000, + Bit05 = 0b_00000000_00000000_00000000_00100000, + Bit04 = 0b_00000000_00000000_00000000_00010000, + Bit03 = 0b_00000000_00000000_00000000_00001000, + Bit02 = 0b_00000000_00000000_00000000_00000100, + Bit01 = 0b_00000000_00000000_00000000_00000010, + Bit00 = 0b_00000000_00000000_00000000_00000001, + All_0 = 0, + All_1 = -1, + Alternating_01 = 0b_01010101_01010101_01010101_01010101, + Alternating_10 = unchecked((int)0b_10101010_10101010_10101010_10101010), + OddBytesHigh = unchecked((int)0b_11111111_00000000_11111111_00000000), + EvenBytesHigh = unchecked((int)0b_00000000_11111111_00000000_11111111), +} \ No newline at end of file diff --git a/Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithoutGenerator/BasicEnum_ExplicitUint.cs b/Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithoutGenerator/BasicEnum_ExplicitUint.cs new file mode 100644 index 000000000..5a0ecd6c7 --- /dev/null +++ b/Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithoutGenerator/BasicEnum_ExplicitUint.cs @@ -0,0 +1,46 @@ +namespace Terminal.Gui.Analyzers.Internal.Tests.Generators.EnumExtensions.EnumDefinitions; + +/// +/// Basic enum with explicitly-defined backing type of uint and no attributes on the enum or any of its members. +/// +public enum BasicEnum_ExplicitUInt : uint +{ + Bit31 = 0b_10000000_00000000_00000000_00000000u, + Bit30 = 0b_01000000_00000000_00000000_00000000u, + Bit29 = 0b_00100000_00000000_00000000_00000000u, + Bit28 = 0b_00010000_00000000_00000000_00000000u, + Bit27 = 0b_00001000_00000000_00000000_00000000u, + Bit26 = 0b_00000100_00000000_00000000_00000000u, + Bit25 = 0b_00000010_00000000_00000000_00000000u, + Bit24 = 0b_00000001_00000000_00000000_00000000u, + Bit23 = 0b_00000000_10000000_00000000_00000000u, + Bit22 = 0b_00000000_01000000_00000000_00000000u, + Bit21 = 0b_00000000_00100000_00000000_00000000u, + Bit20 = 0b_00000000_00010000_00000000_00000000u, + Bit19 = 0b_00000000_00001000_00000000_00000000u, + Bit18 = 0b_00000000_00000100_00000000_00000000u, + Bit17 = 0b_00000000_00000010_00000000_00000000u, + Bit16 = 0b_00000000_00000001_00000000_00000000u, + Bit15 = 0b_00000000_00000000_10000000_00000000u, + Bit14 = 0b_00000000_00000000_01000000_00000000u, + Bit13 = 0b_00000000_00000000_00100000_00000000u, + Bit12 = 0b_00000000_00000000_00010000_00000000u, + Bit11 = 0b_00000000_00000000_00001000_00000000u, + Bit10 = 0b_00000000_00000000_00000100_00000000u, + Bit09 = 0b_00000000_00000000_00000010_00000000u, + Bit08 = 0b_00000000_00000000_00000001_00000000u, + Bit07 = 0b_00000000_00000000_00000000_10000000u, + Bit06 = 0b_00000000_00000000_00000000_01000000u, + Bit05 = 0b_00000000_00000000_00000000_00100000u, + Bit04 = 0b_00000000_00000000_00000000_00010000u, + Bit03 = 0b_00000000_00000000_00000000_00001000u, + Bit02 = 0b_00000000_00000000_00000000_00000100u, + Bit01 = 0b_00000000_00000000_00000000_00000010u, + Bit00 = 0b_00000000_00000000_00000000_00000001u, + All_0 = 0b_00000000_00000000_00000000_00000000u, + All_1 = 0b_11111111_11111111_11111111_11111111u, + Alternating_01 = 0b_01010101_01010101_01010101_01010101u, + Alternating_10 = 0b_10101010_10101010_10101010_10101010u, + OddBytesHigh = 0b_11111111_00000000_11111111_00000000u, + EvenBytesHigh = 0b_00000000_11111111_00000000_11111111u, +} \ No newline at end of file diff --git a/Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithoutGenerator/FlagsEnum.cs b/Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithoutGenerator/FlagsEnum.cs new file mode 100644 index 000000000..595175400 --- /dev/null +++ b/Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithoutGenerator/FlagsEnum.cs @@ -0,0 +1,43 @@ +namespace Terminal.Gui.Analyzers.Internal.Tests.Generators.EnumExtensions.EnumDefinitions; + +/// +/// Flags enum without explicitly-defined backing type and only a on the enum declaration No other attributes on the enum or its members.. +/// +[Flags] +public enum FlagsEnum +{ + Bit31 = -0b_10000000_00000000_00000000_00000000, + Bit30 = 0b_01000000_00000000_00000000_00000000, + Bit29 = 0b_00100000_00000000_00000000_00000000, + Bit28 = 0b_00010000_00000000_00000000_00000000, + Bit27 = 0b_00001000_00000000_00000000_00000000, + Bit26 = 0b_00000100_00000000_00000000_00000000, + Bit25 = 0b_00000010_00000000_00000000_00000000, + Bit24 = 0b_00000001_00000000_00000000_00000000, + Bit23 = -0b_00000000_10000000_00000000_00000000, + Bit22 = 0b_00000000_01000000_00000000_00000000, + Bit21 = 0b_00000000_00100000_00000000_00000000, + Bit20 = 0b_00000000_00010000_00000000_00000000, + Bit19 = 0b_00000000_00001000_00000000_00000000, + Bit18 = 0b_00000000_00000100_00000000_00000000, + Bit17 = 0b_00000000_00000010_00000000_00000000, + Bit16 = 0b_00000000_00000001_00000000_00000000, + Bit15 = -0b_00000000_00000000_10000000_00000000, + Bit14 = 0b_00000000_00000000_01000000_00000000, + Bit13 = 0b_00000000_00000000_00100000_00000000, + Bit12 = 0b_00000000_00000000_00010000_00000000, + Bit11 = 0b_00000000_00000000_00001000_00000000, + Bit10 = 0b_00000000_00000000_00000100_00000000, + Bit09 = 0b_00000000_00000000_00000010_00000000, + Bit08 = 0b_00000000_00000000_00000001_00000000, + Bit07 = -0b_00000000_00000000_00000000_10000000, + Bit06 = 0b_00000000_00000000_00000000_01000000, + Bit05 = 0b_00000000_00000000_00000000_00100000, + Bit04 = 0b_00000000_00000000_00000000_00010000, + Bit03 = 0b_00000000_00000000_00000000_00001000, + Bit02 = 0b_00000000_00000000_00000000_00000100, + Bit01 = 0b_00000000_00000000_00000000_00000010, + Bit00 = 0b_00000000_00000000_00000000_00000001, + All_0 = 0, + All_1 = -1 +} \ No newline at end of file diff --git a/Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithoutGenerator/FlagsEnum_ExplicitInt.cs b/Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithoutGenerator/FlagsEnum_ExplicitInt.cs new file mode 100644 index 000000000..cdd121606 --- /dev/null +++ b/Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithoutGenerator/FlagsEnum_ExplicitInt.cs @@ -0,0 +1,43 @@ +namespace Terminal.Gui.Analyzers.Internal.Tests.Generators.EnumExtensions.EnumDefinitions; + +/// +/// Flags enum with explicitly-defined backing type of int and only a on the enum declaration No other attributes on the enum or its members.. +/// +[Flags] +public enum FlagsEnum_ExplicitInt : int +{ + Bit31 = -0b_10000000_00000000_00000000_00000000, + Bit30 = 0b_01000000_00000000_00000000_00000000, + Bit29 = 0b_00100000_00000000_00000000_00000000, + Bit28 = 0b_00010000_00000000_00000000_00000000, + Bit27 = 0b_00001000_00000000_00000000_00000000, + Bit26 = 0b_00000100_00000000_00000000_00000000, + Bit25 = 0b_00000010_00000000_00000000_00000000, + Bit24 = 0b_00000001_00000000_00000000_00000000, + Bit23 = -0b_00000000_10000000_00000000_00000000, + Bit22 = 0b_00000000_01000000_00000000_00000000, + Bit21 = 0b_00000000_00100000_00000000_00000000, + Bit20 = 0b_00000000_00010000_00000000_00000000, + Bit19 = 0b_00000000_00001000_00000000_00000000, + Bit18 = 0b_00000000_00000100_00000000_00000000, + Bit17 = 0b_00000000_00000010_00000000_00000000, + Bit16 = 0b_00000000_00000001_00000000_00000000, + Bit15 = -0b_00000000_00000000_10000000_00000000, + Bit14 = 0b_00000000_00000000_01000000_00000000, + Bit13 = 0b_00000000_00000000_00100000_00000000, + Bit12 = 0b_00000000_00000000_00010000_00000000, + Bit11 = 0b_00000000_00000000_00001000_00000000, + Bit10 = 0b_00000000_00000000_00000100_00000000, + Bit09 = 0b_00000000_00000000_00000010_00000000, + Bit08 = 0b_00000000_00000000_00000001_00000000, + Bit07 = -0b_00000000_00000000_00000000_10000000, + Bit06 = 0b_00000000_00000000_00000000_01000000, + Bit05 = 0b_00000000_00000000_00000000_00100000, + Bit04 = 0b_00000000_00000000_00000000_00010000, + Bit03 = 0b_00000000_00000000_00000000_00001000, + Bit02 = 0b_00000000_00000000_00000000_00000100, + Bit01 = 0b_00000000_00000000_00000000_00000010, + Bit00 = 0b_00000000_00000000_00000000_00000001, + All_0 = 0, + All_1 = -1 +} \ No newline at end of file diff --git a/Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithoutGenerator/FlagsEnum_ExplicitUInt.cs b/Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithoutGenerator/FlagsEnum_ExplicitUInt.cs new file mode 100644 index 000000000..4f7d998a5 --- /dev/null +++ b/Analyzers/Terminal.Gui.Analyzers.Internal.Tests/Generators/EnumExtensions/EnumDefinitions/WithoutGenerator/FlagsEnum_ExplicitUInt.cs @@ -0,0 +1,43 @@ +namespace Terminal.Gui.Analyzers.Internal.Tests.Generators.EnumExtensions.EnumDefinitions; + +/// +/// Flags enum with explicitly-defined backing type of uint and only a on the enum declaration No other attributes on the enum or its members.. +/// +[Flags] +public enum FlagsEnum_ExplicitUInt : uint +{ + Bit31 = 0b_10000000_00000000_00000000_00000000u, + Bit30 = 0b_01000000_00000000_00000000_00000000u, + Bit29 = 0b_00100000_00000000_00000000_00000000u, + Bit28 = 0b_00010000_00000000_00000000_00000000u, + Bit27 = 0b_00001000_00000000_00000000_00000000u, + Bit26 = 0b_00000100_00000000_00000000_00000000u, + Bit25 = 0b_00000010_00000000_00000000_00000000u, + Bit24 = 0b_00000001_00000000_00000000_00000000u, + Bit23 = 0b_00000000_10000000_00000000_00000000u, + Bit22 = 0b_00000000_01000000_00000000_00000000u, + Bit21 = 0b_00000000_00100000_00000000_00000000u, + Bit20 = 0b_00000000_00010000_00000000_00000000u, + Bit19 = 0b_00000000_00001000_00000000_00000000u, + Bit18 = 0b_00000000_00000100_00000000_00000000u, + Bit17 = 0b_00000000_00000010_00000000_00000000u, + Bit16 = 0b_00000000_00000001_00000000_00000000u, + Bit15 = 0b_00000000_00000000_10000000_00000000u, + Bit14 = 0b_00000000_00000000_01000000_00000000u, + Bit13 = 0b_00000000_00000000_00100000_00000000u, + Bit12 = 0b_00000000_00000000_00010000_00000000u, + Bit11 = 0b_00000000_00000000_00001000_00000000u, + Bit10 = 0b_00000000_00000000_00000100_00000000u, + Bit09 = 0b_00000000_00000000_00000010_00000000u, + Bit08 = 0b_00000000_00000000_00000001_00000000u, + Bit07 = 0b_00000000_00000000_00000000_10000000u, + Bit06 = 0b_00000000_00000000_00000000_01000000u, + Bit05 = 0b_00000000_00000000_00000000_00100000u, + Bit04 = 0b_00000000_00000000_00000000_00010000u, + Bit03 = 0b_00000000_00000000_00000000_00001000u, + Bit02 = 0b_00000000_00000000_00000000_00000100u, + Bit01 = 0b_00000000_00000000_00000000_00000010u, + Bit00 = 0b_00000000_00000000_00000000_00000001u, + All_0 = 0b_00000000_00000000_00000000_00000000u, + All_1 = 0b_11111111_11111111_11111111_11111111u +}