public static void WriteEnum(CsCodeWriter cw, EnumDefinition enumDef, TypeNameMappings tnm) { if (enumDef.Name.EndsWith("FlagBits")) { } if (enumDef.Type == EnumType.Bitmask) { cw.WriteLine("[Flags]"); } string mappedName = tnm.GetMappedName(enumDef.Name); using (cw.PushBlock("public enum " + mappedName)) { string enumNamePrefix = GetEnumNamePrefix(mappedName); if (enumDef.Type == EnumType.Bitmask && !enumDef.Values.Any(ev => GetPrettyEnumName(ev.Name, enumNamePrefix) == "None")) { cw.WriteLine($"None = 0,"); } foreach (var value in enumDef.Values) { if (!string.IsNullOrEmpty(value.Comment)) { cw.WriteLine($"///<summary>{value.Comment}</summary>"); } string prettyName = GetPrettyEnumName(value.Name, enumNamePrefix); cw.WriteLine($"{prettyName} = {value.ValueOrBitPosition},"); } } }
public TypeSpec MapTypeSpec(TypeNameMappings tnm) { return(new TypeSpec(tnm.GetMappedName(Name), PointerIndirection, ArrayDimensions)); }