Skip to content

Enable properties, methods, events to be virtual based on flag #1901

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: user/chenss3/enableflag
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/cswinrt/code_writers.h
Original file line number Diff line number Diff line change
Expand Up @@ -1208,7 +1208,7 @@ namespace cswinrt

// If this interface is overridable but the type is sealed, don't mark the member as virtual.
// The C# compiler errors out about declaring a virtual member in a sealed class.
if (is_overridable && !class_type.Flags().Sealed())
if (is_overridable && !class_type.Flags().Sealed() || settings.abstract_class)
{
// All overridable methods in the WinRT type system have protected visibility.
access_spec = "protected ";
Expand Down Expand Up @@ -1537,7 +1537,7 @@ remove => %;
visibility = "protected ";
}

if (is_overridable)
if (is_overridable || settings.abstract_class)
{
visibility = "protected virtual ";
}
Expand Down Expand Up @@ -3458,8 +3458,8 @@ private % AsInternal(InterfaceTag<%> _) => % ?? Make_%();
{
auto& [prop_type, getter_target, getter_platform, setter_target, setter_platform, is_overridable, is_public, is_private, getter_prop, setter_prop] = prop_data;
if (is_private) continue;
std::string_view access_spec = is_public ? "public "sv : "protected "sv;
std::string_view method_spec = is_overridable ? "virtual "sv : ""sv;
std::string_view access_spec = (is_public && !settings.abstract_class) ? "public "sv : "protected "sv;
std::string_view method_spec = (is_overridable || settings.abstract_class)? "virtual "sv : ""sv;
write_property(w, prop_name, prop_name, prop_type,
getter_prop.has_value() ? w.write_temp("%", bind<write_objref_type_name>(getter_prop.value().first)) : getter_target,
setter_prop.has_value() ? w.write_temp("%", bind<write_objref_type_name>(setter_prop.value().first)) : setter_target,
Expand Down