What is the use of an AmbientClassAttribute whose definition is as below (in C#):
using System;
namespace Metamodel
{
[AttributeUsage(AttributeTargets.Class, Inherited = true)]
public sealed class AmbientClassAttribute : System.Attribute
{
}
}
The
AmbientClassAttributeis, as the name implies an attribute class, which means it’s used as an attribute on a class definition, like this:All this does is add metadata – it marks the class as an AmbientClass – whatever that means. But the act of marking itself – the adding of the attribute – doesn’t have any logic behind it, which is why the class doesn’t have any members. It doesn’t do anything. It just marks the class as an Ambient Class.
What is it good for, then? It allows other pieces of code, code that goes over my class – in this case XAML processors – to know about this metadata and process accordingly:
“XAML processors [use this to] determine type owners of members”.