Skip to content

Commit e708469

Browse files
committed
Move typeof into Typedata files
Since the new designer APIs require type as FQN (_fully qualified name_) instead of `Type` objects, we move those definitions into it's own class `ControlTypes`, so that we can add FQNs for the new designer APIs. Refactoring like this will help us maintain logic for both designers for the foreseeable future.
1 parent 8ccc834 commit e708469

File tree

56 files changed

+529
-128
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+529
-128
lines changed

Microsoft.Toolkit.Uwp.UI.Controls.DataGrid.Design/Controls/DataGrid.Metadata.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ internal class DataGridMetadata : AttributeTableBuilder
2727
{
2828
public DataGridMetadata() : base()
2929
{
30-
AddCallback(typeof(DataGrid),
30+
AddCallback(ControlTypes.DataGrid,
3131
b =>
3232
{
3333
b.AddCustomAttributes(new FeatureAttribute(typeof(DataGridDefaults)));
@@ -75,7 +75,7 @@ public DataGridMetadata() : base()
7575
b.AddCustomAttributes(new ToolboxCategoryAttribute(ToolboxCategoryPaths.Toolkit, false));
7676
});
7777

78-
AddCallback(typeof(DataGridColumn),
78+
AddCallback(ControlTypes.DataGridColumn,
7979
b =>
8080
{
8181
b.AddCustomAttributes(nameof(DataGridColumn.CanUserResize), new CategoryAttribute(Resources.CategoryLayout));
@@ -89,13 +89,13 @@ public DataGridMetadata() : base()
8989
b.AddCustomAttributes(nameof(DataGridColumn.Width), new CategoryAttribute(Resources.CategoryLayout));
9090
});
9191

92-
AddCallback(typeof(DataGridBoundColumn),
92+
AddCallback(ControlTypes.DataGridBoundColumn,
9393
b =>
9494
{
9595
b.AddCustomAttributes(nameof(DataGridBoundColumn.Binding), new CategoryAttribute(Resources.CategoryCellBinding));
9696
});
9797

98-
AddCallback(typeof(DataGridTextColumn),
98+
AddCallback(ControlTypes.DataGridTextColumn,
9999
b =>
100100
{
101101
b.AddCustomAttributes(nameof(DataGridTextColumn.FontFamily), new CategoryAttribute(Resources.CategoryText));
@@ -105,13 +105,13 @@ public DataGridMetadata() : base()
105105
b.AddCustomAttributes(nameof(DataGridTextColumn.Foreground), new CategoryAttribute(Resources.CategoryText));
106106
});
107107

108-
AddCallback(typeof(DataGridCheckBoxColumn),
108+
AddCallback(ControlTypes.DataGridCheckBoxColumn,
109109
b =>
110110
{
111111
b.AddCustomAttributes(nameof(DataGridCheckBoxColumn.IsThreeState), new CategoryAttribute(Resources.CategoryCommon));
112112
});
113113

114-
AddCallback(typeof(DataGridTemplateColumn),
114+
AddCallback(ControlTypes.DataGridTemplateColumn,
115115
b =>
116116
{
117117
b.AddCustomAttributes(nameof(DataGridTemplateColumn.CellEditingTemplate), new CategoryAttribute(Resources.CategoryCellTemplate));
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System;
6+
7+
namespace Microsoft.Toolkit.Uwp.UI.Controls.Design
8+
{
9+
#if VS_DESIGNER_PROCESS_ISOLATION
10+
internal static partial class ControlTypes
11+
{
12+
internal static readonly Type DataGrid = typeof(DataGrid);
13+
internal static readonly Type DataGridColumn = typeof(DataGridColumn);
14+
internal static readonly Type DataGridBoundColumn = typeof(DataGridBoundColumn);
15+
internal static readonly Type DataGridTextColumn = typeof(DataGridTextColumn);
16+
internal static readonly Type DataGridCheckBoxColumn = typeof(DataGridCheckBoxColumn);
17+
internal static readonly Type DataGridTemplateColumn = typeof(DataGridTemplateColumn);
18+
}
19+
#endif
20+
}

Microsoft.Toolkit.Uwp.UI.Controls.DataGrid.Design/Microsoft.Toolkit.Uwp.UI.Controls.DataGrid.Design.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<PropertyGroup>
55
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
66
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
7-
<ProjectGuid>{6BD0BA4A-DE6D-3E87-8F83-63518C31ECD1}</ProjectGuid>
7+
<ProjectGuid>{618C1EA2-CAA6-4ED8-A53B-E8F4B63AEDB8}</ProjectGuid>
88
<OutputType>Library</OutputType>
99
<AppDesignerFolder>Properties</AppDesignerFolder>
1010
<RootNamespace>Microsoft.Toolkit.Uwp.UI.Controls.Design</RootNamespace>
@@ -82,10 +82,11 @@
8282
</Reference>
8383
</ItemGroup>
8484
<ItemGroup>
85+
<Compile Include="..\Microsoft.Toolkit.Uwp.UI.Controls.Design\Common\Constants.cs" Link="Common\Constants.cs" />
8586
<Compile Include="..\Microsoft.Toolkit.Uwp.UI.Controls.Design\Common\MetadataRegistrationBase.cs" Link="Common\MetadataRegistrationBase.cs" />
8687
<Compile Include="..\Microsoft.Toolkit.Uwp.UI.Controls.Design\Common\PlatformTypes.cs" Link="Common\PlatformTypes.cs" />
87-
<Compile Include="..\Microsoft.Toolkit.Uwp.UI.Controls.Design\Common\ToolboxCategoryPaths.cs" Link="Common\ToolboxCategoryPaths.cs" />
8888
<Compile Include="Controls\DataGrid.Metadata.cs" />
89+
<Compile Include="Controls\DataGrid.Typedata.cs" />
8990
<Compile Include="MetadataRegistration.cs" />
9091
<Compile Include="Properties\AssemblyInfo.cs">
9192
<SubType>Code</SubType>

Microsoft.Toolkit.Uwp.UI.Controls.Design/Common/MetadataRegistrationBase.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,9 @@ private void AddDescriptions(AttributeTableBuilder builder)
139139
}
140140

141141
var type = Type.GetType(typeName + ", " + AssemblyFullName);
142-
142+
#if VS_DESIGNER_PROCESS_ISOLATION
143+
var typeID = type;
144+
#endif
143145
if (type != null && type.IsPublic && type.IsClass && type.IsSubclassOf(PlatformTypes.DependencyObject))
144146
{
145147
string desc = ParseDescription(member);
@@ -152,11 +154,11 @@ private void AddDescriptions(AttributeTableBuilder builder)
152154
{
153155
if (IsBrowsable(type))
154156
{
155-
builder.AddCustomAttributes(type, new DescriptionAttribute(desc));
157+
builder.AddCustomAttributes(typeID, new DescriptionAttribute(desc));
156158
}
157159
else //Hide from intellisense
158160
{
159-
builder.AddCustomAttributes(type,
161+
builder.AddCustomAttributes(typeID,
160162
new BrowsableAttribute(false),
161163
new ToolboxBrowsableAttribute(false),
162164
new ToolboxItemAttribute(false));
@@ -170,11 +172,11 @@ private void AddDescriptions(AttributeTableBuilder builder)
170172
{
171173
if (IsBrowsable(type))
172174
{
173-
builder.AddCustomAttributes(type, propertyName, new DescriptionAttribute(desc));
175+
builder.AddCustomAttributes(typeID, propertyName, new DescriptionAttribute(desc));
174176
}
175177
else //Hide from intellisense
176178
{
177-
builder.AddCustomAttributes(type, new BrowsableAttribute(false));
179+
builder.AddCustomAttributes(typeID, new BrowsableAttribute(false));
178180
}
179181
}
180182
}

Microsoft.Toolkit.Uwp.UI.Controls.Design/Controls/AdaptiveGridView.Metadata.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ internal class CustomDialogMetadata : AttributeTableBuilder
1818
public CustomDialogMetadata()
1919
: base()
2020
{
21-
AddCallback(typeof(AdaptiveGridView),
21+
AddCallback(ControlTypes.AdaptiveGridView,
2222
b =>
2323
{
2424
b.AddCustomAttributes(nameof(AdaptiveGridView.DesiredWidth),
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System;
6+
7+
namespace Microsoft.Toolkit.Uwp.UI.Controls.Design
8+
{
9+
#if VS_DESIGNER_PROCESS_ISOLATION
10+
internal static partial class ControlTypes
11+
{
12+
internal static readonly Type AdaptiveGridView = typeof(AdaptiveGridView);
13+
}
14+
#endif
15+
}

Microsoft.Toolkit.Uwp.UI.Controls.Design/Controls/BladeItem.Metadata.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ internal class BladeItemMetadata : AttributeTableBuilder
1919
public BladeItemMetadata()
2020
: base()
2121
{
22-
AddCallback(typeof(BladeItem),
22+
AddCallback(ControlTypes.BladeItem,
2323
b =>
2424
{
2525
b.AddCustomAttributes(nameof(BladeItem.TitleBarVisibility),
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System;
6+
7+
namespace Microsoft.Toolkit.Uwp.UI.Controls.Design
8+
{
9+
#if VS_DESIGNER_PROCESS_ISOLATION
10+
internal static partial class ControlTypes
11+
{
12+
internal static readonly Type BladeItem = typeof(BladeItem);
13+
}
14+
#endif
15+
}

Microsoft.Toolkit.Uwp.UI.Controls.Design/Controls/BladeView.Metadata.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ internal class BladeViewMetadata : AttributeTableBuilder
2020
public BladeViewMetadata()
2121
: base()
2222
{
23-
AddCallback(typeof(BladeView),
23+
AddCallback(ControlTypes.BladeView,
2424
b =>
2525
{
2626
b.AddCustomAttributes(nameof(BladeView.ActiveBlades),
@@ -37,9 +37,7 @@ public BladeViewMetadata()
3737
new CategoryAttribute(Resources.CategoryCommon),
3838
//The following is necessary because this is a collection of an abstract type, so we help
3939
//the designer with populating supported types that can be added to the collection
40-
new NewItemTypesAttribute(new System.Type[] {
41-
typeof(BladeItem),
42-
}),
40+
new NewItemTypesAttribute(ControlTypes.BladeItem),
4341
new AlternateContentPropertyAttribute()
4442
);
4543
b.AddCustomAttributes(new ToolboxCategoryAttribute(ToolboxCategoryPaths.Toolkit, false));

0 commit comments

Comments
 (0)