Earlz
Earlz

Reputation: 63905

What is the ComposableAttribute in WinRT?

I'm trying to understand how some of the more lower-level portions of WinRT work. I came across the ComposableAttribute which may be the key to what I need. However, the documentation on it is very thin.

Indicates how a programming element is composed.

As you can tell, that doesn't actually tell me anything. Does anyone know what this attribute is used for and what it is suppose to do?

Upvotes: 2

Views: 535

Answers (1)

James McNellis
James McNellis

Reputation: 355267

The ComposableAttribute marks a type as being instantiable for use as a base class across the Windows Runtime ABI boundary. It is similar to the ActivatableAttribute, which marks a type as being instantiable for "activation" (i.e. for direct use, not for use not as a base class) across the ABI boundary. The Windows Runtime is based on COM and does not really support real inheritance. Instead, inheritance is faked through metadata trickery and aggregation.

You can define your own composable types, but if you do, they must derive from a composable type in the platform (this is one of the metadata rules in the Windows 8 app certification requirements). For Windows 8, this means that your composable types must "derive" directly or indirectly from Windows.UI.Xaml.DependencyObject. Finally, composable types may only be authored using IDL and WRL; neither C++/CX nor .NET can be used to define a composable type.

Upvotes: 4

Related Questions