Skip to content

Bug: Protected members are exposed publiclyΒ #1317

@sylveon

Description

@sylveon

Version

2.0.230524.4

Summary

If you declare a protected member on a WinRT class, the projection type will directly expose this protected member to all consumers, meaning it is trivial to accidentally do things you shouldn't.

Reproducible example

[default_interface]
runtimeclass Class
{
    Class();
    protected Int32 MyProperty;
}
Class a;
int b = a.MyProperty();

Expected behavior

A build error saying MyProperty doesn't exist or is protected

Actual behavior

It correctly builds and will actually call implementation::Class::MyProperty.

Additional comments

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions