Skip to content

Generated C++/WinRT constructors should be marked explicit #413

@jevansaks

Description

@jevansaks

One of our devs just ran into a bug where we have a WinRT type with a constructor that takes Object:

unsealed runtimeclass ItemsSourceView: Windows.UI.Xaml.Interop.INotifyCollectionChanged
{
    ItemsSourceView(Object source);

And then we had a function with parameter typed as winrt::ItemsSourceView but the caller passed winrt::IInspectable. This compiled but did unexpected things at runtime because the ItemsSourceView constructor was being run.

I think that the generated constructors should be marked explicit to help avoid this problem.

Metadata

Metadata

Assignees

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