Skip to content

Commit 4266ea2

Browse files
committed
Update xaml-designer-extensibility-migration.md
1 parent f2e2da7 commit 4266ea2

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

docs/extensibility/xaml-designer-extensibility-migration.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ monikerRange: vs-2019
1212
---
1313
# XAML designer extensibility migration
1414

15-
Starting in Visual Studio 2019 version 16.1 as a public preview, the XAML designer supports two different architectures: the designer isolation architecture and the more recent surface isolation architecture. This architecture transition is required to support target runtimes that can't be hosted in a .NET Framework process. Moving to the surface isolation architecture introduces breaking changes to the third-party extensibility model. This article outlines the changes.
15+
In Visual Studio 2019, the XAML designer supports two different architectures: the designer isolation architecture and the more recent surface isolation architecture. This architecture transition is required to support target runtimes that can't be hosted in a .NET Framework process. Moving to the surface isolation architecture introduces breaking changes to the third-party extensibility model. This article outlines these changes which are available in the Visual Studio 2019 16.2 preview channel.
1616

1717
**Designer isolation** is used by the WPF designer for projects that target the .NET Framework and supports *.design.dll* extensions. User code, control libraries, and third-party extensions are loaded in an external process (*XDesProc.exe*) along with the actual designer code and designer panels.
1818

@@ -41,7 +41,7 @@ While third-party control libraries are compiled for the actual target runtime (
4141

4242
The surface isolation extensibility model doesn't allow for extensions to depend on actual control libraries, and therefore, extensions can't reference types from the control library. For example, *MyLibrary.designtools.dll* should not have a dependency on *MyLibrary.dll*.
4343

44-
Such dependencies were most common when registering metadata for types via attribute tables. Extension code that references control library types directly via [typeof](/dotnet/csharp/language-reference/keywords/typeof) ([GetType](/dotnet/visual-basic/language-reference/operators/gettype-operator) in Visual Basic) is substituted in the new APIs by using string-based type names:
44+
Such dependencies were most common when registering metadata for types via attribute tables. Extension code that references control library types directly via [typeof](/dotnet/csharp/language-reference/keywords/typeof) or [GetType](/dotnet/visual-basic/language-reference/operators/gettype-operator) is substituted in the new APIs by using string-based type names:
4545

4646
```csharp
4747
using Microsoft.VisualStudio.DesignTools.Extensibility.Metadata;
@@ -56,7 +56,7 @@ public class AttributeTableProvider : IProvideAttributeTable
5656
{
5757
get
5858
{
59-
AttributeTableBuilder builder = new AttributeTableBuilder();
59+
var builder = new AttributeTableBuilder();
6060
builder.AddCustomAttributes("MyLibrary.MyControl", new DescriptionAttribute(Strings.MyControlDescription);
6161
builder.AddCustomAttributes("MyLibrary.MyControl", new FeatureAttribute(typeof(MyControlDefaultInitializer));
6262
return builder.CreateTable();
@@ -90,6 +90,14 @@ End Class
9090

9191
Feature providers are implemented in extension assemblies and loaded in the Visual Studio process. `FeatureAttribute` will continue to reference feature provider types directly using [typeof](/dotnet/csharp/language-reference/keywords/typeof).
9292

93+
Currently, the following feature providers are supported:
94+
95+
* `DefaultInitializer`
96+
* `AdornerProvider`
97+
* `ContextMenuProvider`
98+
* `ParentAdapter`
99+
* `PlacementAdapter`
100+
93101
Because feature providers are now loaded in a process different from the actual runtime code and control libraries, they are no longer able to access runtime objects directly. Instead, all such interactions must be converted to use the corresponding Model-based APIs. The Model API has been updated, and access to <xref:System.Type> or <xref:System.Object> is either no longer available or has been replaced with `TypeIdentifier` and `TypeDefinition`.
94102

95103
`TypeIdentifier` represents a string without an assembly name identifying a type. A `TypeIdenfifier` can be resolved to a `TypeDefinition` to query additional information about the type. `TypeDefinition` instances can't be cached in extension code.
@@ -99,7 +107,7 @@ TypeDefinition type = ModelFactory.ResolveType(
99107
item.Context, new TypeIdentifier("MyLibrary.MyControl"));
100108
TypeDefinition buttonType = ModelFactory.ResolveType(
101109
item.Context, new TypeIdentifier("System.Windows.Controls.Button"));
102-
if (type != null && buttonType != type.IsSubclassOf(buttonType))
110+
if (type?.IsSubclassOf(buttonType) == true)
103111
{
104112
}
105113
```
@@ -198,6 +206,8 @@ Public Class MyControlDefaultInitializer
198206
End Class
199207
```
200208

209+
More code samples are available in the [xaml-designer-extensibility-samples](https://github.com/microsoft/xaml-designer-extensibility-samples) repository.
210+
201211
## Limited support for .design.dll extensions
202212

203213
If any *.designtools.dll* extension is discovered for a control library, it is loaded first and discovery for *.design.dll* extensions is skipped.

0 commit comments

Comments
 (0)