Exemple #1
0
        /// <summary>Writes an enum to a <see cref="CsWriter"/>.</summary>
        /// <param name="csWriter">The <see cref="CsWriter"/> to write the handle to.</param>
        /// <param name="enumInfo">The enum to write to <paramref name="csWriter"/>.</param>
        private static void WriteEnum(CsWriter csWriter, EnumInfo enumInfo)
        {
            if (enumInfo.Type == EnumType.Bitmask)
            {
                csWriter.WriteLine($"[Flags]");
            }

            csWriter.WriteLine($"public enum {enumInfo.Name}{((enumInfo.BitWidth == 64) ? " : long" : "")}");
            csWriter.WriteScope(() =>
            {
                foreach (var enumValue in enumInfo.Values.Distinct(new EnumFieldInfoDisplayNameEqualityComparer()))
                {
                    csWriter.WriteLine(enumValue.ToString());
                }
            });
        }