Skip to content

Commit

Permalink
Add DefaultOverload attribute to projected interface methods (#672)
Browse files Browse the repository at this point in the history
* Add DefaultOverload attribute to projected interface methods as they are checked in authoring scenarios.

* Add other overload attribute.
  • Loading branch information
manodasanW authored Jan 18, 2021
1 parent 0f83d07 commit 3a4dd0d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
20 changes: 20 additions & 0 deletions src/Tests/AuthoringTest/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Markup;
using System;
using System.Collections;
using System.Collections.Generic;
Expand Down Expand Up @@ -958,4 +959,23 @@ public IEnumerator GetEnumerator()
return _enumerable.GetEnumerator();
}
}

public sealed class CustomXamlMetadataProvider : IXamlMetadataProvider
{
// Tests DefaultOverload attribute specified in projected interface.
public IXamlType GetXamlType(Type type)
{
throw new NotImplementedException();
}

public IXamlType GetXamlType(string fullName)
{
throw new NotImplementedException();
}

public XmlnsDefinition[] GetXmlnsDefinitions()
{
throw new NotImplementedException();
}
}
}
5 changes: 3 additions & 2 deletions src/cswinrt/code_writers.h
Original file line number Diff line number Diff line change
Expand Up @@ -1303,7 +1303,7 @@ remove => %.% -= value;
}
}
// Skip metadata attributes
if (attribute_namespace == "Windows.Foundation.Metadata") continue;
if (attribute_namespace == "Windows.Foundation.Metadata" && attribute_name != "DefaultOverload" && attribute_name != "Overload") continue;
attributes[attribute_full] = std::move(params);
}
if (auto&& usage = attributes.find("AttributeUsage"); usage != attributes.end())
Expand Down Expand Up @@ -2330,7 +2330,8 @@ private static global::System.Runtime.CompilerServices.ConditionalWeakTable<IWin

method_signature signature{ method };
w.write(R"(
% %(%);)",
%% %(%);)",
bind<write_custom_attributes>(method.CustomAttribute(), false),
bind<write_projection_return_type>(signature),
method.Name(),
bind_list<write_projection_parameter>(", ", signature.params())
Expand Down

0 comments on commit 3a4dd0d

Please sign in to comment.