Skip to content

Commit

Permalink
Fix emitting Windows.Foundation.Metadata.DeprecatedAttribute. (#152)
Browse files Browse the repository at this point in the history
Fixes #137
  • Loading branch information
jkoritzinsky authored Apr 16, 2020
1 parent 037e63f commit 9ebe644
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions cswinrt/code_writers.h
Original file line number Diff line number Diff line change
Expand Up @@ -3608,7 +3608,7 @@ AbiToProjectionVftablePtr = (IntPtr)nativeVftbl;
{
if (auto uint32_value = std::get_if<uint32_t>(&arg_value.value))
{
w.write(*uint32_value);
w.write("%u", *uint32_value);
}
else if (auto int32_value = std::get_if<int32_t>(&arg_value.value))
{
Expand Down Expand Up @@ -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<std::string> params;
Expand Down Expand Up @@ -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<write_custom_attributes>(type),
bind<write_type_name>(type, false, false), is_flags_enum(type) ? "uint" : "uint");
bind<write_type_name>(type, false, false), enum_underlying_type);
{
for (auto&& field : type.FieldList())
{
if (auto constant = field.Constant())
{
w.write("% = %,\n", field.Name(), bind<write_constant>(constant));
w.write("% = unchecked((%)%),\n", field.Name(), enum_underlying_type, bind<write_constant>(constant));
}
}
}
Expand Down

0 comments on commit 9ebe644

Please sign in to comment.