I recently had a WinRT class definition with methods like this:
public void Foo(string x){}
public void Foo(CustomClass x){}
The compiler threw an error though that
The 1-parameter overloads of Earlz.FooBar must have exactly one method specified as the default overload by decorating it with Windows.Foundation.Metadata.DefaultOverloadAttribute.
What kind of implications does this attribtue have? I’m unfamiliar with how WinRT projections work, but what I’m writing will eventually be a publicly usable API. So, I want to make sure that I’m not doing something that will cause pain to people who use the API. Should I rename my Foo method to FooCustom or some such, or is using DefaultOverload on the more commonly used function the way to go?
Also, I tried looking up what this attribute does and why it’s required, but MSDN was short on details as usual and just gave single sentence description “Indicates that a method is the default overload method”
I assume the primary reason for this attribute is because Javascript only supports overloading on parameter count, not parameter type. However, how would a Javascript app access the non-default WinRT methods with type overloads?
As Jesse Jiang described in this thread: