Skip to content

Commit

Permalink
Move typeof into Typedata files
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Nirmal4G committed Sep 12, 2020
1 parent 8ccc834 commit e708469
Show file tree
Hide file tree
Showing 56 changed files with 529 additions and 128 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ internal class DataGridMetadata : AttributeTableBuilder
{
public DataGridMetadata() : base()
{
AddCallback(typeof(DataGrid),
AddCallback(ControlTypes.DataGrid,
b =>
{
b.AddCustomAttributes(new FeatureAttribute(typeof(DataGridDefaults)));
Expand Down Expand Up @@ -75,7 +75,7 @@ public DataGridMetadata() : base()
b.AddCustomAttributes(new ToolboxCategoryAttribute(ToolboxCategoryPaths.Toolkit, false));
});

AddCallback(typeof(DataGridColumn),
AddCallback(ControlTypes.DataGridColumn,
b =>
{
b.AddCustomAttributes(nameof(DataGridColumn.CanUserResize), new CategoryAttribute(Resources.CategoryLayout));
Expand All @@ -89,13 +89,13 @@ public DataGridMetadata() : base()
b.AddCustomAttributes(nameof(DataGridColumn.Width), new CategoryAttribute(Resources.CategoryLayout));
});

AddCallback(typeof(DataGridBoundColumn),
AddCallback(ControlTypes.DataGridBoundColumn,
b =>
{
b.AddCustomAttributes(nameof(DataGridBoundColumn.Binding), new CategoryAttribute(Resources.CategoryCellBinding));
});

AddCallback(typeof(DataGridTextColumn),
AddCallback(ControlTypes.DataGridTextColumn,
b =>
{
b.AddCustomAttributes(nameof(DataGridTextColumn.FontFamily), new CategoryAttribute(Resources.CategoryText));
Expand All @@ -105,13 +105,13 @@ public DataGridMetadata() : base()
b.AddCustomAttributes(nameof(DataGridTextColumn.Foreground), new CategoryAttribute(Resources.CategoryText));
});

AddCallback(typeof(DataGridCheckBoxColumn),
AddCallback(ControlTypes.DataGridCheckBoxColumn,
b =>
{
b.AddCustomAttributes(nameof(DataGridCheckBoxColumn.IsThreeState), new CategoryAttribute(Resources.CategoryCommon));
});

AddCallback(typeof(DataGridTemplateColumn),
AddCallback(ControlTypes.DataGridTemplateColumn,
b =>
{
b.AddCustomAttributes(nameof(DataGridTemplateColumn.CellEditingTemplate), new CategoryAttribute(Resources.CategoryCellTemplate));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;

namespace Microsoft.Toolkit.Uwp.UI.Controls.Design
{
#if VS_DESIGNER_PROCESS_ISOLATION
internal static partial class ControlTypes
{
internal static readonly Type DataGrid = typeof(DataGrid);
internal static readonly Type DataGridColumn = typeof(DataGridColumn);
internal static readonly Type DataGridBoundColumn = typeof(DataGridBoundColumn);
internal static readonly Type DataGridTextColumn = typeof(DataGridTextColumn);
internal static readonly Type DataGridCheckBoxColumn = typeof(DataGridCheckBoxColumn);
internal static readonly Type DataGridTemplateColumn = typeof(DataGridTemplateColumn);
}
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProjectGuid>{6BD0BA4A-DE6D-3E87-8F83-63518C31ECD1}</ProjectGuid>
<ProjectGuid>{618C1EA2-CAA6-4ED8-A53B-E8F4B63AEDB8}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Microsoft.Toolkit.Uwp.UI.Controls.Design</RootNamespace>
Expand Down Expand Up @@ -82,10 +82,11 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="..\Microsoft.Toolkit.Uwp.UI.Controls.Design\Common\Constants.cs" Link="Common\Constants.cs" />
<Compile Include="..\Microsoft.Toolkit.Uwp.UI.Controls.Design\Common\MetadataRegistrationBase.cs" Link="Common\MetadataRegistrationBase.cs" />
<Compile Include="..\Microsoft.Toolkit.Uwp.UI.Controls.Design\Common\PlatformTypes.cs" Link="Common\PlatformTypes.cs" />
<Compile Include="..\Microsoft.Toolkit.Uwp.UI.Controls.Design\Common\ToolboxCategoryPaths.cs" Link="Common\ToolboxCategoryPaths.cs" />
<Compile Include="Controls\DataGrid.Metadata.cs" />
<Compile Include="Controls\DataGrid.Typedata.cs" />
<Compile Include="MetadataRegistration.cs" />
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ private void AddDescriptions(AttributeTableBuilder builder)
}

var type = Type.GetType(typeName + ", " + AssemblyFullName);

#if VS_DESIGNER_PROCESS_ISOLATION
var typeID = type;
#endif
if (type != null && type.IsPublic && type.IsClass && type.IsSubclassOf(PlatformTypes.DependencyObject))
{
string desc = ParseDescription(member);
Expand All @@ -152,11 +154,11 @@ private void AddDescriptions(AttributeTableBuilder builder)
{
if (IsBrowsable(type))
{
builder.AddCustomAttributes(type, new DescriptionAttribute(desc));
builder.AddCustomAttributes(typeID, new DescriptionAttribute(desc));
}
else //Hide from intellisense
{
builder.AddCustomAttributes(type,
builder.AddCustomAttributes(typeID,
new BrowsableAttribute(false),
new ToolboxBrowsableAttribute(false),
new ToolboxItemAttribute(false));
Expand All @@ -170,11 +172,11 @@ private void AddDescriptions(AttributeTableBuilder builder)
{
if (IsBrowsable(type))
{
builder.AddCustomAttributes(type, propertyName, new DescriptionAttribute(desc));
builder.AddCustomAttributes(typeID, propertyName, new DescriptionAttribute(desc));
}
else //Hide from intellisense
{
builder.AddCustomAttributes(type, new BrowsableAttribute(false));
builder.AddCustomAttributes(typeID, new BrowsableAttribute(false));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal class CustomDialogMetadata : AttributeTableBuilder
public CustomDialogMetadata()
: base()
{
AddCallback(typeof(AdaptiveGridView),
AddCallback(ControlTypes.AdaptiveGridView,
b =>
{
b.AddCustomAttributes(nameof(AdaptiveGridView.DesiredWidth),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;

namespace Microsoft.Toolkit.Uwp.UI.Controls.Design
{
#if VS_DESIGNER_PROCESS_ISOLATION
internal static partial class ControlTypes
{
internal static readonly Type AdaptiveGridView = typeof(AdaptiveGridView);
}
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ internal class BladeItemMetadata : AttributeTableBuilder
public BladeItemMetadata()
: base()
{
AddCallback(typeof(BladeItem),
AddCallback(ControlTypes.BladeItem,
b =>
{
b.AddCustomAttributes(nameof(BladeItem.TitleBarVisibility),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;

namespace Microsoft.Toolkit.Uwp.UI.Controls.Design
{
#if VS_DESIGNER_PROCESS_ISOLATION
internal static partial class ControlTypes
{
internal static readonly Type BladeItem = typeof(BladeItem);
}
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ internal class BladeViewMetadata : AttributeTableBuilder
public BladeViewMetadata()
: base()
{
AddCallback(typeof(BladeView),
AddCallback(ControlTypes.BladeView,
b =>
{
b.AddCustomAttributes(nameof(BladeView.ActiveBlades),
Expand All @@ -37,9 +37,7 @@ public BladeViewMetadata()
new CategoryAttribute(Resources.CategoryCommon),
//The following is necessary because this is a collection of an abstract type, so we help
//the designer with populating supported types that can be added to the collection
new NewItemTypesAttribute(new System.Type[] {
typeof(BladeItem),
}),
new NewItemTypesAttribute(ControlTypes.BladeItem),
new AlternateContentPropertyAttribute()
);
b.AddCustomAttributes(new ToolboxCategoryAttribute(ToolboxCategoryPaths.Toolkit, false));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;

namespace Microsoft.Toolkit.Uwp.UI.Controls.Design
{
#if VS_DESIGNER_PROCESS_ISOLATION
internal static partial class ControlTypes
{
internal static readonly Type BladeView = typeof(BladeView);
}
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal class CarouselMetadata : AttributeTableBuilder
public CarouselMetadata()
: base()
{
AddCallback(typeof(Carousel),
AddCallback(ControlTypes.Carousel,
b =>
{
b.AddCustomAttributes(nameof(Carousel.SelectedItem), new CategoryAttribute(Resources.CategoryCommon));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;

namespace Microsoft.Toolkit.Uwp.UI.Controls.Design
{
#if VS_DESIGNER_PROCESS_ISOLATION
internal static partial class ControlTypes
{
internal static readonly Type Carousel = typeof(Carousel);
}
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ internal class DropShadowPanelMetadata : AttributeTableBuilder
public DropShadowPanelMetadata()
: base()
{
AddCallback(typeof(DropShadowPanel),
AddCallback(ControlTypes.DropShadowPanel,
b =>
{
b.AddCustomAttributes(new FeatureAttribute(typeof(DropShadowPanelDefaults)));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;

namespace Microsoft.Toolkit.Uwp.UI.Controls.Design
{
#if VS_DESIGNER_PROCESS_ISOLATION
internal static partial class ControlTypes
{
internal static readonly Type DropShadowPanel = typeof(DropShadowPanel);
}
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal class ExpanderMetadata : AttributeTableBuilder
public ExpanderMetadata()
: base()
{
AddCallback(typeof(Expander),
AddCallback(ControlTypes.Expander,
b =>
{
b.AddCustomAttributes(nameof(Expander.Header), new CategoryAttribute(Resources.CategoryCommon));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;

namespace Microsoft.Toolkit.Uwp.UI.Controls.Design
{
#if VS_DESIGNER_PROCESS_ISOLATION
internal static partial class ControlTypes
{
internal static readonly Type Expander = typeof(Expander);
}
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal class GridSplitterMetadata : AttributeTableBuilder
public GridSplitterMetadata()
: base()
{
AddCallback(typeof(GridSplitter),
AddCallback(ControlTypes.GridSplitter,
b =>
{
b.AddCustomAttributes(nameof(GridSplitter.Element), new CategoryAttribute(Resources.CategoryCommon));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;

namespace Microsoft.Toolkit.Uwp.UI.Controls.Design
{
#if VS_DESIGNER_PROCESS_ISOLATION
internal static partial class ControlTypes
{
internal static readonly Type GridSplitter = typeof(GridSplitter);
}
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal class ImageExMetadata : AttributeTableBuilder
public ImageExMetadata()
: base()
{
AddCallback(typeof(ImageEx),
AddCallback(ControlTypes.ImageEx,
b =>
{
b.AddCustomAttributes(nameof(ImageEx.NineGrid), new CategoryAttribute(Resources.CategoryAppearance));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;

namespace Microsoft.Toolkit.Uwp.UI.Controls.Design
{
#if VS_DESIGNER_PROCESS_ISOLATION
internal static partial class ControlTypes
{
internal static readonly Type ImageEx = typeof(ImageEx);
}
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal class InAppNotificationMetadata : AttributeTableBuilder
public InAppNotificationMetadata()
: base()
{
AddCallback(typeof(InAppNotification),
AddCallback(ControlTypes.InAppNotification,
b =>
{
b.AddCustomAttributes(nameof(InAppNotification.ShowDismissButton), new CategoryAttribute(Resources.CategoryAppearance));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;

namespace Microsoft.Toolkit.Uwp.UI.Controls.Design
{
#if VS_DESIGNER_PROCESS_ISOLATION
internal static partial class ControlTypes
{
internal static readonly Type InAppNotification = typeof(InAppNotification);
}
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal class LayoutTransformControlMetadata : AttributeTableBuilder
public LayoutTransformControlMetadata()
: base()
{
AddCallback(typeof(LayoutTransformControl),
AddCallback(ControlTypes.LayoutTransformControl,
b =>
{
b.AddCustomAttributes(nameof(LayoutTransformControl.Child), new CategoryAttribute(Resources.CategoryCommon));
Expand Down
Loading

0 comments on commit e708469

Please sign in to comment.