Skip to content

Commit

Permalink
fix(codegen): BindableMetadata properly globalizing generic type pare…
Browse files Browse the repository at this point in the history
…meters
  • Loading branch information
Xiaoy312 committed Mar 18, 2020
1 parent dff5de8 commit d0f62c5
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/SamplesApp/UITests.Shared/UITests.Shared.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -3057,6 +3057,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Xaml_CodeGen\BindableMetadataGlobalizationTest.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)Helpers\BindableBase.cs" />
Expand Down Expand Up @@ -5382,6 +5386,9 @@
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml\Enability\BasicEnability.xaml.cs">
<DependentUpon>BasicEnability.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Xaml_CodeGen\BindableMetadataGlobalizationTest.xaml.cs">
<DependentUpon>BindableMetadataGlobalizationTest.xaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<Content Include="$(MSBuildThisFileDirectory)Assets\AcrylicBrush.png" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Page x:Class="UITests.Xaml_CodeGen.BindableMetadataGlobalizationTest"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UITests.Xaml_CodeGen"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<Grid />
</Page>
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238

namespace UITests.Xaml_CodeGen
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class BindableMetadataGlobalizationTest : Page
{
// #2815: generic type parameter are not prefixed with `global::` during BindableTypeProvidersSourceGenerator
// which causes CS0234, "type or namespace name X not found in Y", in some case like here.
// the BindableMetadata are generated with a RootNamespace `SamplesApp.${platform}`, and
// `UITests.Xaml_CodeGen.TestAsd` is then resolved to `SamplesApp.UITests.Xaml_CodeGen.TestAsd`
// since `SamplesApp.UITests` has a higher precedence than `global::UITests`, even if `Xaml_CodeGen` is not declared there.
public IEnumerable<TestAsd> MyProperty { get; set; }

public BindableMetadataGlobalizationTest()
{
this.InitializeComponent();
}
}

public class TestAsd { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ where field.IsStatic

foreach (var property in properties)
{
var propertyTypeName = GetGlobalQualifier(property.Type) + SanitizeTypeName(property.Type.ToString());
var propertyTypeName = property.Type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat);
var propertyName = property.Name;

if (IsStringIndexer(property))
Expand Down

0 comments on commit d0f62c5

Please sign in to comment.