diff --git a/cswinrt/code_writers.h b/cswinrt/code_writers.h index c962084e6..e2d2244a0 100644 --- a/cswinrt/code_writers.h +++ b/cswinrt/code_writers.h @@ -3608,7 +3608,7 @@ AbiToProjectionVftablePtr = (IntPtr)nativeVftbl; { if (auto uint32_value = std::get_if(&arg_value.value)) { - w.write(*uint32_value); + w.write("%u", *uint32_value); } else if (auto int32_value = std::get_if(&arg_value.value)) { @@ -3664,8 +3664,6 @@ AbiToProjectionVftablePtr = (IntPtr)nativeVftbl; attribute_name = attribute_name.substr(0, attribute_name.length() - "Attribute"sv.length()); // Guid and Flags are handled explicitly if (attribute_name == "Guid" || attribute_name == "Flags") continue; - // Deprecated is causing csc.exe to crash - if (attribute_name == "Deprecated") continue; auto attribute_full = (attribute_name == "AttributeUsage") ? "AttributeUsage" : w.write_temp("%.%", attribute_namespace, attribute_name); std::vector params; @@ -4329,18 +4327,20 @@ public static Guid PIID = GuidGenerator.CreateIID(typeof(%));)", w.write("[FlagsAttribute]\n"); } + auto enum_underlying_type = is_flags_enum(type) ? "uint" : "int"; + w.write(R"([global::WinRT.WindowsRuntimeType] %public enum % : % { )", bind(type), - bind(type, false, false), is_flags_enum(type) ? "uint" : "uint"); + bind(type, false, false), enum_underlying_type); { for (auto&& field : type.FieldList()) { if (auto constant = field.Constant()) { - w.write("% = %,\n", field.Name(), bind(constant)); + w.write("% = unchecked((%)%),\n", field.Name(), enum_underlying_type, bind(constant)); } } }