#XAML schema

    The package moonrockz/xaml/schema.

    The registered types, members, directives and namespaces that give a XAML document its meaning. The README of the module describes them. To read and write your own structs you usually need none of it: a codec registers them. This page is about what a codec cannot do: types registered by hand, and dependency objects, which are the controls that a document creates.

    In the examples @dependency is moonrockz/dependency-object, @events and @path are its packages events and path, @xaml is moonrockz/xaml, and @schema and @nodes are its packages schema and nodes.

    #Types registered by hand

    A XamlTypeDefinition has the name of a type in XAML, and the constructors, setters and getters to call. SchemaContextBuilder puts the definitions in a schema context, which parse, load and save take. You need them for:

    • Objects that refer to each other in a circle, such as a parent that its children have.
    • Filling an object that exists, and other objects that you change while a document is read.
    • Constructors with arguments and factory methods.
    • Dependency objects and events.
    • Attached members, such as Grid.Row.
    • Your own markup extensions, such as {Binding Path}.
    • Types with base types, generic types and name scopes of their own.

    The types in one document are all registered by hand or all described by codecs.

    The example does it for a Task, which has an id, a title, a task that comes before it, and smaller tasks:

    ///|
    priv struct Task {
    mut id : String
    mut title : String
    mut done : Bool
    mut after : @nodes.XamlValue
    tasks : Array[@nodes.XamlValue]
    }

    ///|
    let task_type : @nodes.XamlTypeName = @nodes.XamlTypeName::new(
    "urn:tasks", "Task",
    )

    ///|
    /// Puts a `Task` in a XAML value and takes it out again.
    let task_key : @nodes.ObjectKey[Task] = @nodes.ObjectKey::new()

    ///|
    fn task_of(target : @nodes.XamlObject) -> Task raise {
    guard task_key.unwrap(target) is Some(task) else {
    raise @schema.ValueError("not a Task")
    }
    task
    }

    ///|
    fn task_context() -> @schema.SchemaContext raise {
    let task = @schema.XamlTypeDefinition::new("urn:tasks", "Task")
    .object_key(task_key)
    .add_constructor([], (_, _) => {
    let task = { id: "", title: "", done: false, after: Null, tasks: [], }
    Object(task_key.wrap(task_type, task))
    })
    .add_member(
    "Id",
    value_type=@schema.string_type,
    getter=target => String(task_of(target).id),
    setter=(target, value) => {
    if value is String(id) {
    task_of(target).id = id
    }
    },
    default_value=String(""),
    )
    // `{x:Reference docs}` finds the task with the id `docs`.
    .aliased_member(Name, "Id")
    .add_member(
    "Title",
    value_type=@schema.string_type,
    getter=target => String(task_of(target).title),
    setter=(target, value) => {
    if value is String(title) {
    task_of(target).title = title
    }
    },
    )
    .add_member(
    "Done",
    value_type=@schema.boolean_type,
    getter=target => Bool(task_of(target).done),
    setter=(target, value) => {
    if value is Bool(done) {
    task_of(target).done = done
    }
    },
    default_value=Bool(false),
    )
    .add_member(
    "After",
    value_type=task_type,
    getter=target => task_of(target).after,
    setter=(target, value) => task_of(target).after = value,
    default_value=Null,
    )
    // The elements in a `Task` element are its smaller tasks.
    .collection(
    (target, item) => task_of(target).tasks.push(item),
    item_type=task_type,
    )
    .item_enumerator(target => ReadOnlyArray::from_array(task_of(target).tasks))
    @schema.SchemaContextBuilder::new().add_type(task).build()
    }

    ///|
    test "parse, change and save" {
    let context = task_context()
    let text =
    #|<Task xmlns="urn:tasks" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Release">
    #| <Task Id="docs" Title="Write the docs" />
    #| <Task Title="Publish" After="{x:Reference docs}" />
    #|</Task>
    let { root, .. } = @xaml.parse(text, context)
    guard root is Object(release) &&
    task_of(release).tasks is [docs, Object(publish)] else {
    fail("no tasks")
    }
    assert_eq(task_of(publish).title, "Publish")
    // `After` has the same object as the list.
    assert_true(task_of(publish).after == docs)
    task_of(publish).done = true
    inspect(
    @xaml.save(root, context),
    content=(
    #|<Task xmlns="urn:tasks" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Release">
    #| <Task Id="docs" Title="Write the docs"/>
    #| <Task After="{x:Reference docs}" Done="True" Title="Publish"/>
    #|</Task>
    ),
    )
    }

    Done and After have default values, so save writes them only when they differ. After has the object of another element, so save writes a reference to it. An object that is in several places and has no name gets one, such as __ReferenceID0.

    To copy objects without a text, load from an object reader:

    ///|
    test "copy objects" {
    let context = task_context()
    let { root, .. } = @xaml.parse(
    "<Task xmlns='urn:tasks' Title='Release' />", context,
    )
    let settings = @reader.ObjectReaderSettings::new(construction_first=true)
    let reader = @reader.XamlObjectReader::new(root, context, settings~)
    let copy = @xaml.load(reader, context).root
    guard copy is Object(task) else { fail("no task") }
    assert_eq(task_of(task).title, "Release")
    assert_true(copy != root)
    }

    #Fill an object that exists

    parse usually creates the root. With root_object in the settings it sets the members of your object, so a function that makes an object can fill it from a document:

    ///|
    /// A `Task` with the title and the smaller tasks of a release.
    fn new_release(text : String) -> Task raise {
    let release = {
    id: "release",
    title: "",
    done: false,
    after: Null,
    tasks: [],
    }
    let root_object = task_key.wrap(task_type, release)
    let settings = @xaml.LoadSettings::new(root_object~)
    ignore(@xaml.parse(text, task_context(), settings~))
    release
    }

    ///|
    test "fill an object" {
    let release = new_release(
    (
    #|<Task xmlns="urn:tasks" Title="Release">
    #| <Task Title="Write the docs" />
    #|</Task>
    ),
    )
    assert_eq(release.id, "release")
    assert_eq(release.title, "Release")
    assert_eq(release.tasks.length(), 1)
    }

    When the document has an error, parse raises it and the object keeps what was set before. So new_release gives no object then. The object writer says which types fit, what x:Class does, and why text alone, as in <Point>1,2</Point>, gives another object.

    #Controls

    The example has a panel, a card with one element in it, and a button. A Width is a dependency property of all three, and the button has a Click for the events below.

    First come the owner types, properties and events, which have nothing to do with XAML:

    ///|
    let element_owner : @dependency.OwnerType = try! @dependency.register_owner_type(
    "Element",
    element=true,
    )

    ///|
    let button_owner : @dependency.OwnerType = try! @dependency.register_owner_type(
    "Button",
    base=element_owner,
    )

    ///|
    let card_owner : @dependency.OwnerType = try! @dependency.register_owner_type(
    "Card",
    base=element_owner,
    )

    ///|
    let stack_owner : @dependency.OwnerType = try! @dependency.register_owner_type(
    "Stack",
    base=element_owner,
    )

    ///|
    let width : @dependency.DependencyProperty[Double] = try! @dependency.register(
    "Width",
    element_owner,
    @dependency.double_key,
    default_value=0,
    )

    ///|
    let click : @events.RoutedEvent[Unit] = try! @events.register_routed_event(
    "Click",
    Bubble,
    button_owner,
    @dependency.unit_key,
    )

    ///|
    let element_key : @dependency.ValueKey[@dependency.DependencyObject?] = @dependency.ValueKey::new(
    "Element",
    )

    ///|
    let content : @dependency.DependencyProperty[@dependency.DependencyObject?] = try! @dependency.register(
    "Content",
    card_owner,
    element_key,
    default_value=None,
    metadata=@dependency.PropertyMetadata::new(logical_content=value => value),
    )

    ///|
    priv struct Stack {
    object : @dependency.DependencyObject
    children : @dependency.ElementCollection
    }

    ///|
    let stack_key : @dependency.ValueKey[Stack] = @dependency.ValueKey::by_identity(
    "Stack",
    )

    ///|
    fn Stack::new() -> Stack raise {
    let object = @dependency.DependencyObject::new(stack_owner)
    let stack = { object, children: @dependency.ElementCollection::new(object), }
    object.set_host(stack_key.wrap(stack))
    stack
    }

    ///|
    /// The `Stack` of its XAML object.
    fn stack_of(value : @nodes.XamlValue) -> Stack raise {
    guard @schema.as_dependency_object(value) is Some(object) &&
    object.host() is Some(host) &&
    stack_key.unwrap(host) is Some(stack) else {
    raise @schema.ValueError("not a Stack")
    }
    stack
    }

    Then each control gets a XAML type. dependency_objects names its owner type and makes an object of it, and add_dependency_member maps a member to a property. The last argument converts the values of the property.

    ///|
    fn controls() -> @schema.SchemaContext raise {
    let type_name = name => @nodes.XamlTypeName::new("urn:controls", name)
    let control = (name, owner, create) => {
    @schema.XamlTypeDefinition::new(
    "urn:controls",
    name,
    base_type=type_name("Element"),
    ).dependency_objects(owner, create~)
    }
    let element = @schema.XamlTypeDefinition::new("urn:controls", "Element")
    .dependency_objects(element_owner)
    .add_dependency_member("Width", width, @schema.double_conversion)
    let button = control("Button", button_owner, () => {
    @dependency.DependencyObject::new(button_owner)
    }).add_routed_event_member("Click", click.info())
    let card = control("Card", card_owner, () => {
    @dependency.DependencyObject::new(card_owner)
    })
    .add_dependency_member(
    "Content",
    content,
    @schema.PropertyConversion::dependency_object(type_name("Element")).optional(),
    )
    .content_property("Content")
    let stack = control("Stack", stack_owner, () => Stack::new().object)
    .add_member(
    "Children",
    value_type=@schema.element_collection_type,
    visibility=Content,
    getter=target => {
    @schema.element_collection_value(stack_of(Object(target)).children)
    },
    )
    .content_property("Children")
    @schema.SchemaContextBuilder::new()
    .add_type(element)
    .add_type(button)
    .add_type(card)
    .add_type(stack)
    .build()
    }

    ///|
    test "parse, change and save controls" {
    let context = controls()
    let text =
    #|<Stack xmlns="urn:controls" Width="200">
    #| <Card>
    #| <Button Width="50"/>
    #| </Card>
    #|</Stack>
    let { root, .. } = @xaml.parse(text, context)
    let stack = stack_of(root)
    guard stack.object.logical_children() is [card] &&
    card.get_value(content) is Some(button) else {
    fail("no card with a button")
    }
    assert_eq(button.get_value(width), 50)
    button.set_value(width, 60)
    stack.children.add(@dependency.DependencyObject::new(button_owner))
    inspect(
    @xaml.save(root, context),
    content=(
    #|<Stack xmlns="urn:controls" Width="200">
    #| <Card>
    #| <Button Width="60"/>
    #| </Card>
    #| <Button/>
    #|</Stack>
    ),
    )
    // native and wasm do not free a tree by themselves.
    stack.children.clear()
    card.clear_value(content)
    stack.object.release_host()
    }

    Memory says what the last lines are for.

    #Members

    A PropertyConversion[T] has the XAML type of the values, and converts them to the type T of the property and back. Text in a document first converts to the XAML type, as for every member.

    ConversionType of the property
    bool_conversion, byte_conversion, int16_conversion, int_conversion, int64_conversion, float_conversion, double_conversion, char_conversion, string_conversionBool, Byte, Int16, Int, Int64, Float, Double, Char and String
    decimal_conversion, time_span_conversion, uri_conversionXamlDecimal, XamlTimeSpan and XamlUri
    PropertyConversion::dependency_object(type)DependencyObject, for types with dependency_objects
    PropertyConversion::object(type, key)the type of key, with which the objects of the XAML type are wrapped
    PropertyConversion::value(type)XamlValue, for values of several types and enumerations. xaml_value_key is the key for such a property
    PropertyConversion::new(type, from_xaml, to_xaml)any other
    conversion.optional()an option of the type of conversion. None is null in a document

    add_attached_dependency_member adds an attached member, such as Grid.Row. A document can set it on every object that has a dependency object, also when the object has nothing to do with Grid. The type that has the member names the owner type of the property itself, with dependency_objects or dependency_owner.

    • Loading sets the property. An error of its validation or its callbacks is an error at the value in the document.
    • A read-only property has no setter. When it has a collection or a dictionary, the document adds to the one that the object has, which is the effective value. Make it in create, because a default value is the same one for all objects.
    • All options of add_member for the text of values and for saving are there too, but for a default value. See Saving.

    An ElementCollection is the children of a panel. Give it with element_collection_value from the getter of a member of the type element_collection_type. Its items are elements of types with dependency_objects.

    A child is in its parent when its end callback runs, and before its members are set when its type has usable_during_initialization. Members of the parent that come later in the document are not set then.

    #Events

    A document adds handlers to the routed events of its controls by their names. In WPF the handlers are methods of the window that the document belongs to. MoonBit cannot find a method by its name, so the window lists them in a HandlerTable, with a line for each:

    ///|
    priv struct Counter {
    mut count : Int32
    }

    ///|
    fn Counter::handlers(self : Counter) -> @schema.HandlerTable raise {
    let handlers = @schema.HandlerTable::new()
    handlers.add("OnAdd", @dependency.unit_key, (_, _) => self.count += 1)
    handlers.add("OnReset", @dependency.unit_key, (_, args) => {
    self.count = 0
    args.set_handled(true)
    })
    handlers
    }

    ///|
    test "handlers of a document" {
    let counter = { count: 5, }
    let { root, .. } = @xaml.parse(
    (
    #|<Stack xmlns="urn:controls" Button.Click="OnAdd">
    #| <Button Click="OnReset"/>
    #| <Button/>
    #|</Stack>
    ),
    controls(),
    settings=@xaml.LoadSettings::new(
    event_handlers=counter.handlers().to_handle(),
    ),
    )
    let stack = stack_of(root)
    guard stack.object.logical_children() is [reset, add] else {
    fail("no buttons")
    }
    for button in [reset, add, add] {
    @events.raise_event(button, @events.RoutedEventArgs::new((), event=click))
    }
    assert_eq(counter.count, 2)
    stack.children.clear()
    stack.object.release_host()
    }

    add_routed_event_member gives an event to a type, as Click of the buttons. Button.Click is the same event on an element of another type, here a panel that hears of the clicks in it. A type can have an event that another owner type registered.

    • Click="OnAdd" and <Button.Click>OnAdd</Button.Click> are the same. The handler is added to the element that has the member, as add_handler does without handled_events_too.
    • The table finds a handler by its name and by the key of its data. So one name can have a handler for each type of data, as a method with overloads, and one handler serves all events with its key. add_routing adds a handler for events with any data, as a method that takes RoutedEventArgs in WPF.
    • A handler name is a name as in C#, which is the pattern of [MS-XAML-2017] 7.4.14. Upper and lower case differ.
    • A name that the table does not have, a handler for other data and an object that is no element are errors at the member. So is a load without a table, when the document has an event.
    • A value that is no handler name, such as a markup extension, is an error at the value. Nothing in it is created.
    • save writes no handlers, as in WPF. release_handlers of an element removes those that a document has added, which a program on native and wasm needs for a handler that uses its own element.

    #Property paths

    property_path_type is a type whose values are property paths, as the PropertyPath of WPF. Add it to your own namespace. Here a highlight has the path to what it shows:

    ///|
    let highlight_owner : @dependency.OwnerType = try! @dependency.register_owner_type(
    "Highlight",
    base=element_owner,
    )

    ///|
    let path_key : @dependency.ValueKey[@path.PropertyPath?] = @dependency.ValueKey::new(
    "PropertyPath",
    )

    ///|
    let target : @dependency.DependencyProperty[@path.PropertyPath?] = try! @dependency.register(
    "Target",
    highlight_owner,
    path_key,
    default_value=None,
    )

    ///|
    fn highlights() -> @schema.SchemaContext raise {
    let path_type = @schema.property_path_type("urn:controls", "PropertyPath")
    let element = @schema.XamlTypeDefinition::new("urn:controls", "Element").dependency_objects(
    element_owner,
    )
    let highlight = @schema.XamlTypeDefinition::new("urn:controls", "Highlight")
    .dependency_objects(highlight_owner, create=() => {
    @dependency.DependencyObject::new(highlight_owner)
    })
    .add_dependency_member(
    "Target",
    target,
    @schema.PropertyConversion::object(
    @nodes.XamlTypeName::new("urn:controls", "PropertyPath"),
    @schema.property_path_key,
    ).optional(),
    )
    @schema.SchemaContextBuilder::new()
    .add_type(path_type)
    .add_type(element)
    .add_type(highlight)
    .build()
    }

    ///|
    test "a path in a document" {
    let context = highlights()
    let { root, .. } = @xaml.parse(
    (
    #|<c:Highlight xmlns:c="urn:controls" Target="(c:Element.Width)"/>
    ),
    context,
    )
    guard @schema.as_dependency_object(root) is Some(highlight) &&
    highlight.get_value(target) is Some(path) else {
    fail("no path")
    }
    let button = @dependency.DependencyObject::new(button_owner)
    button.set_value(width, 50)
    assert_eq(
    path.get(@dependency.object_key.wrap(button)).read(@dependency.double_key),
    Some(50),
    )
    inspect(
    @xaml.save(root, context),
    content=(
    #|<Highlight xmlns="urn:controls" Target="(Element.Width)"/>
    ),
    )
    }

    • A type in a path has the prefix that it has in the rest of the document. The type of a member, such as c:Element, has a dependency_owner. It does not need a XAML member for the property.
    • A type of an argument, as in Items[(x:Int32)1], has a conversion from text, which gets no context, and an any_value_converter.
    • A wrong path is an error at the value, with the place in the path.
    • save writes the type on which the member was registered, with the prefix of the new document. A path that a program made can have types without a XAML type. These are errors.
    • The paths work with the registry of the process, or the one that you pass with registry~.

    #Saving

    save writes what XamlWriter.Save of WPF writes:

    • A property with a local value is written, also when that equals the default value. Default values and inherited values are not. The local value is written, and not the one that coercion makes of it.
    • A value of set_current_value is written too. It is a local value when the document is read again.
    • A read-only property is written only when it has a collection or a dictionary with contents, as the contents of its local value. visibility=Hidden prevents it.
    • An attached property is written on an object of any type, when a type that names the owner type of the property has an attached member for it. One that was added to a second owner type still has the name of the first one.
    • An attached property that is a member of the type of the object too, such as FontSize of a text box, is written as this member.
    • should_serialize of a member gets the dependency object, and prevents that the member is written when it gives false.

    A type can also register an attached_member_store for attached members that are no dependency properties. Entries for those that are dependency properties are ignored, because the dependency object has their values.

    A changed callback can undo what the document has set before. Members that are attributes are written in the order of their names, unless depends_on says otherwise.

    #Types of dependency objects

    dependency_objects says that the objects of a XAML type are dependency objects of an owner type, and how to make one:

    ///|
    let badge_owner : @dependency.OwnerType = try! @dependency.register_owner_type(
    "Badge",
    )

    ///|
    test "an object from a document" {
    let badge = @schema.XamlTypeDefinition::new("urn:badges", "Badge").dependency_objects(
    badge_owner,
    create=() => @dependency.DependencyObject::new(badge_owner),
    )
    let context = @schema.SchemaContextBuilder::new().add_type(badge).build()
    let { root, .. } = @xaml.parse("<Badge xmlns='urn:badges'/>", context)
    guard @schema.as_dependency_object(root) is Some(object) else {
    fail("no dependency object")
    }
    assert_eq(object.owner_type(), badge_owner)
    // `xaml_object` gives the XAML value of an object, also of one that no document made.
    assert_eq(root, Object(context.xaml_object(object)))
    }

    A document has no owner types, and a dependency object knows no XAML type. So give each XAML type an owner type of its own, as each class of WPF has one.

    FunctionWhat it gives
    as_dependency_object(value)the dependency object in the value of such a type
    SchemaContext::xaml_object(object)the XAML object of a dependency object
    SchemaContext::xaml_type_for_owner(owner)the XAML type that names owner itself. Of several it is the first one that was added
    XamlType::dependency_owner()the owner type of a XAML type, its own or that of its nearest base type with one
    XamlType::declared_dependency_owner()the owner type that the XAML type names itself
    XamlType::dependency_object(handle)the dependency object of an object of any type that has one

    Two more kinds of types use dependency_owner instead:

    • A type that only gives its name to attached properties, such as the static class TextOptions of WPF: dependency_owner(owner).
    • A type whose objects contain a dependency object and have an object key of their own: dependency_owner(owner, object=f), where f finds it. Derived types inherit the function, and one with another key needs a base view. xaml_object does not work for these objects.

    #Values of unknown type

    XamlType::any_value_converter converts a value of a XAML type to an AnyValue, for code that has no property with a type. The types of the XAML language have these:

    TypeKey of the result
    x:Boolean, x:Byte, x:Int16, x:Int32, x:Int64, x:Single, x:Double, x:Stringbool_key, byte_key, int16_key, int_key, int64_key, float_key, double_key and string_key of moonrockz/dependency-object
    x:Charchar_key there. Half of a surrogate pair is an error
    x:Decimal, x:TimeSpan, x:Uridecimal_value_key, time_span_value_key, uri_value_key
    x:Object, for a value with a type that has a converterthat of the converter
    x:Object, for another object with a dependency objectobject_key of moonrockz/dependency-object
    x:Object, for every other objectxaml_object_key
    x:Object, for nullnull_value_key

    Every other value is an error that names the type and the value. Give a type of your own a conversion with the any_value_converter of its definition. Derived types inherit it.

    ///|
    test "a value of unknown type" {
    let context = @schema.SchemaContextBuilder::new().build()
    guard context.get_type(@schema.int32_type) is Some(int32) &&
    int32.any_value_converter() is Some(convert) else {
    fail("no converter")
    }
    assert_eq(@dependency.int_key.unwrap(convert(Int(42))), Some(42))
    }

    #Differences from WPF

    MoonBit has no reflection and no inheritance between structs. So:

    1. Members and types are registered. An attached property without a registered member of its owner type is not saved, where WPF uses the name of its CLR type.
    2. The XAML object of an element is made from its dependency object each time. All of them are equal, and names and references find them. An object whose XAML type does not stand for its owner type cannot be in an ElementCollection or in a property with PropertyConversion::dependency_object, because its type would be lost.
    3. should_serialize can only prevent that a member is written. In WPF there are forms of ShouldSerializeX, and a virtual method, that decide alone.
    4. A Char is a whole character, so half of a surrogate pair in an x:Char is an error.
    5. Where WPF asks a CLR getter for a collection that is null, so that the getter can make it, create has to make it before.
    6. Handlers are in a HandlerTable. In WPF they are methods of the root object, whose types have to match the event.
    7. An event is registered as a member of one type or more. WPF finds every routed event by its name and owner type.

    A property path is saved with a ^ before each character that needs one, and without what means nothing, such as a space around a name. WPF writes the names and arguments as they are, and cannot always read them again.

    A markup extension cannot give a handler, as it can in WPF when it returns a delegate. Documents with events need no x:Class, as in System.Xaml. [MS-XAML-2017] 6.2.1.2 demands one.

    Bindings and resource references do not exist yet, so nothing of them is saved. Values themselves differ from WPF in one case: a current value over an inherited one stays, and is then saved.

    AnyValueConverter

    Converts a value of a XAML type to an AnyValue. It raises an error for a value that it does not take.

    AttachedMemberStore

    Lists the attached members set on an object with their values, as .NET IAttachedPropertyStore and AttachablePropertyServices do.

    ConstructorFunction

    Creates an object from the type arguments of the type being constructed, empty for a type that is not generic, and the arguments, one for each parameter in order. A factory method may return an object of another type, or null; the object writer checks the result.

    Gives the dependency object of a XAML object, or None when it has none.

    EntryAdder

    Adds a keyed entry to a dictionary object.

    EntryEnumerator

    The keyed entries of a dictionary object, in order, for saving.

    EventAdder

    Adds the handlers of an event member to an object: the target's XAML type and handle as a pair, never adapted to a base key, the member's top-level value nodes unchanged in document order, each with its own span (a nested object as its start object or get object node), the start member's span, and the erased event_handlers handle of the load settings, passed unchanged (design D3). It receives every value of the member in one call and diagnoses extra values itself.

    The object writer keeps the message and the span of an InvalidNode error, such as one at a value. To the message of any other error it adds the member and its span.

    InitializationCallback

    type InitializationCallback = (
    XamlObject
    ) -> Unit raise

    A begin or end initialization callback on an object, as .NET ISupportInitialize (design D25).

    InstanceDescriber

    Gives the instance descriptor of an object.

    ItemAdder

    Adds an item to a collection object.

    ItemEnumerator

    The items of a collection object, in order, for saving.

    MemberGetter

    Reads a member value from an object, as get object nodes need.

    MemberSetter

    Sets a member value on an object. It raises when the value is not acceptable.

    NameScopeLookup

    Looks up a name in the instance name scope of an object (.NET INameScope.FindName).

    NameScopeRegister

    Registers a value under a name in the instance name scope of an object (.NET INameScope.RegisterName). It raises when the scope does not accept the name.

    ParseFunction

    type ParseFunction = (String) ->
    XamlValue
    raise

    A function that a type registers to read its values from text, as Avalonia converts with a static Parse(string) method (design D19). For text it comes before the type converter.

    SaveReader

    Reads the value that saving compares with the default and writes, separately from the getter that loading uses; None means unset, so the member is not written (design D21).

    ShouldSerialize

    type ShouldSerialize = (
    XamlObject
    ) -> Bool raise

    Decides whether saving writes a member of an object, as a ShouldSerialize method does.

    ShouldSerializeProperty

    type ShouldSerializeProperty = (
    DependencyObject
    ) -> Bool raise

    Whether saving writes the value of a dependency property of an object. It has no say for a value that is not local.

    ValueProvider

    Evaluates a markup extension object to the value that it stands for, with the services of the load (design D14).

    ArgumentsError

    pub(all) suberror ArgumentsError {
    NoMatchingConstructor(type_name~ :
    XamlTypeName
    , factory_method~ : String?, argument_types~ : ReadOnlyArray[
    XamlTypeName
    ?])
    AmbiguousConstructor(type_name~ :
    XamlTypeName
    , factory_method~ : String?, candidates~ : ReadOnlyArray[ReadOnlyArray[
    XamlTypeName
    ]])
    InvalidDescriptor(type_name~ :
    XamlTypeName
    , factory_method~ : (
    XamlTypeName
    , String)?)
    WrongDescriptorArgumentCount(type_name~ :
    XamlTypeName
    , factory_method~ : (
    XamlTypeName
    , String)?, count~ : Int)
    WrongDescriptorArgumentType(type_name~ :
    XamlTypeName
    , factory_method~ : (
    XamlTypeName
    , String)?, argument_type~ :
    XamlTypeName
    ?, parameter_type~ :
    XamlTypeName
    )
    InvalidResult(type_name~ :
    XamlTypeName
    , factory_method~ : String?, result_type~ :
    XamlTypeName
    ?)
    } derive(Eq,
    Debug
    )

    Why x:Arguments selects no constructor or factory method.

    ArgumentsError::message

    fn ArgumentsError::message(self : ArgumentsError) -> String

    ConversionError

    pub(all) suberror ConversionError {
    ConversionFailed(subject~ : ConversionSubject, input~ : String, message~ : String)
    } derive(Eq,
    Debug
    )

    A conversion failed. It names the member or type, the input and the converter's message, as System.Xaml TypeConverterFailed does.

    ConversionError::message

    fn ConversionError::message(self : ConversionError) -> String

    NamespaceError

    pub(all) suberror NamespaceError {
    MalformedClrNamespace(namespace_uri~ : String)
    AmbiguousType(name~ : String, namespace_uri~ : String, scopes~ : ReadOnlyArray[String])
    } derive(Eq,
    Debug
    )

    Why a namespace URI cannot be used to look a type up.

    NamespaceError::message

    fn NamespaceError::message(self : NamespaceError) -> String

    SchemaError

    pub(all) suberror SchemaError {
    Conflicts(ReadOnlyArray[SchemaConflict])
    } derive(Eq,
    Debug
    )

    The registrations do not form a valid schema context.

    SchemaError::message

    fn SchemaError::message(self : SchemaError) -> String

    TypeResolutionError

    pub(all) suberror TypeResolutionError {
    UnknownType(
    XamlTypeName
    )
    ArityMismatch(name~ :
    XamlTypeName
    , expected~ : ReadOnlyArray[Int], given~ : Int)
    } derive(Eq,
    Debug
    )

    Why a type name does not resolve to a registered type.

    TypeResolutionError::message

    fn TypeResolutionError::message(self : TypeResolutionError) -> String

    ValueError

    pub(all) suberror ValueError {
    ValueError(String)
    } derive(Eq,
    Debug
    )

    A value that a converter, setter or markup extension of the built-in types cannot accept.

    AliasedDirective

    pub(all) enum AliasedDirective {
    Name
    Key
    Uid
    Lang
    } derive(Eq, Hash,
    Debug
    )

    A directive that a type can alias to one of its members, as System.Xaml RuntimeNamePropertyAttribute (x:Name), DictionaryKeyPropertyAttribute (x:Key), UidPropertyAttribute (x:Uid) and XmlLangPropertyAttribute (xml:lang) do.

    AliasedDirective::from_directive

    fn AliasedDirective::from_directive(namespace_uri : String, name : String) -> AliasedDirective?

    The aliased directive that the directive name of namespace_uri is, under either XAML language URI, or None for any other directive.

    AliasedDirective::member_name

    The member name of the directive, as start member nodes carry it.

    AllowedLocations

    pub(all) struct AllowedLocations {
    attribute : Bool
    element : Bool
    } derive(Eq, Hash,
    Debug
    )

    Where a member may be written in XAML text, as System.Xaml AllowedMemberLocations: as an attribute, as a property element, both or neither. Directives declare their locations; every other member allows both.

    ConstructorMatch

    pub struct ConstructorMatch {
    selected : XamlConstructor
    arguments : ReadOnlyArray[
    XamlValue
    ]
    }

    A selected constructor or factory method with the arguments to pass it, widened to the parameter types.

    ConversionDestination

    pub(all) enum ConversionDestination {
    Text
    MarkupExtension
    } derive(Eq, Hash,
    Debug
    )

    What a type converter converts a value to: text, or a markup extension object, as System.Xaml asks CanConvertTo(typeof(string)) and CanConvertTo(typeof(MarkupExtension)).

    ConversionSubject

    What a failed conversion was for.

    EnumBacking

    pub(all) enum EnumBacking {
    SByte
    Byte
    Int16
    UInt16
    Int32
    UInt32
    Int64
    UInt64
    } derive(Eq, Hash,
    Debug
    )

    The integer type behind an enumeration: its width and signedness (F50, 2F45).

    HandlerTable

    pub struct HandlerTable {
    // private fields
    }

    The handlers that the event members of documents name, which LoadSettings takes as event_handlers.

    It has the place of the root object in WPF, whose methods are the handlers. A handler is found by its name and by the key of the data that it takes, so one name can have handlers for data of different types.

    HandlerTable::add

    Add a handler for events with data of the key args_key, which is the unit_key of moonrockz/dependency-object for events without data. The handler gets what add_handler of moonrockz/dependency-object/events gives it.

    HandlerTable::add_routing

    Add a handler for events with any data, as a method in WPF that takes RoutedEventArgs. An event for whose data the name has a handler of its own does not use it.

    HandlerTable::from_handle

    The table that to_handle wrapped, or None for any other object.

    HandlerTable::new

    HandlerTable::to_handle

    The table as the event_handlers of LoadSettings.

    InstanceDescriptor

    pub(all) struct InstanceDescriptor {
    factory_method : (
    XamlTypeName
    , String)?
    arguments : ReadOnlyArray[
    XamlValue
    ]
    complete : Bool
    } derive(Eq,
    Debug
    )

    How to construct an object again, as .NET InstanceDescriptor gives it: a constructor, or a factory method by the type that registers it and its name, with its arguments, and whether the arguments describe the object completely, so that no member needs writing.

    NameResolver

    pub struct NameResolver {
    // private fields
    }

    The name services of a load, as System.Xaml IXamlNameResolver gives them (design D15): lookup with the initialization state, and fix-up tokens for names that are not available yet. It offers nothing else: no enumeration of names and no completion events.

    NameResolver::fixup_token

    fn NameResolver::fixup_token(self : NameResolver, names : ArrayView[String], can_assign_directly? : Bool) ->
    XamlObject
    ? raise

    A fix-up token that waits for every name in names, as GetFixupToken(names, canAssignDirectly). A markup extension or converter returns it as its value. A token that may be assigned directly takes exactly one name. None means token creation is disabled, as at the end of a load.

    NameResolver::new

    fn NameResolver::new(resolve~ : (String) -> ResolvedName? raise, fixup_token~ : (ReadOnlyArray[String], Bool) ->
    XamlObject
    ? raise) -> NameResolver

    A name resolver over resolve, which finds a registered value by name, and fixup_token, which gives a token for the names and whether the token may be assigned directly, or None once token creation is disabled. Both can raise, because the operations of a name scope can.

    NameResolver::resolve

    fn NameResolver::resolve(self : NameResolver, name : String) -> ResolvedName? raise

    The value registered as name in the first scope of the request's scope chain that has the name. Until the document ends, only a fully initialized one is given. After that fully_initialized tells.

    NameScope

    pub struct NameScope {
    // private fields
    }

    A name scope that holds its names itself, as System.Xaml NameScope: the scope of a document whose root has none of its own.

    NameScope::find

    The object or other value that has the name.

    NameScope::new

    fn NameScope::new() -> NameScope

    An empty name scope.

    NameScope::register

    fn NameScope::register(self : NameScope, name : String, value :
    XamlValue
    ) -> Unit raise ValueError

    Give value the name. The same object can be registered again under its name. Two values are never the same object, also when they are equal, as two boxes are not in .NET.

    NameScopeAccess

    pub(all) enum NameScopeAccess {
    Operations(lookup~ : (
    XamlObject
    , String) ->
    XamlValue
    ? raise, register~ : (
    XamlObject
    , String,
    XamlValue
    ) -> Unit raise)
    Property(XamlMember)
    }

    How a type gives access to its instance name scope (design D15).

    NamespaceDeclaration

    pub(all) struct NamespaceDeclaration {
    prefix : String
    namespace_uri : String
    } derive(Eq,
    Debug
    )

    A namespace declaration in scope: a prefix, "" for the default namespace, and its URI, as System.Xaml NamespaceDeclaration.

    PropertyConversion

    pub struct PropertyConversion[T] {
    value_type :
    XamlTypeName

    nullable : Bool
    // private fields
    }

    How a XamlValue becomes a value of a dependency property of type T, and back.

    There is one for each shared value key of moonrockz/dependency-object that has a XAML type: int_conversion for int_key, double_conversion for double_key, and so on.

    PropertyConversion::dependency_object

    The conversion for properties whose values are the dependency objects of the XAML type value_type. These register dependency_objects.

    PropertyConversion::new

    A conversion with values of the XAML type value_type. The functions raise an error for a value that they do not take.

    PropertyConversion::object

    The conversion of the values that key wraps as objects of the XAML type value_type. It does not keep the type of an object of a derived type, so use PropertyConversion::value for a property that takes those.

    PropertyConversion::optional

    fn[T] PropertyConversion::optional(self : PropertyConversion[T]) -> PropertyConversion[T?]

    The conversion for properties that can also be None, which is null in XAML.

    PropertyConversion::value

    The conversion for properties that keep the XamlValues of the XAML type value_type, with the key xaml_value_key.

    ResolvedName

    pub(all) struct ResolvedName {
    value :
    XamlValue

    fully_initialized : Bool
    } derive(Eq,
    Debug
    )

    An object or other value that a name resolver found, with whether its initialization has completed.

    SchemaConflict

    pub(all) enum SchemaConflict {
    DuplicateType(namespace_uri~ : String, name~ : String, arity~ : Int)
    DuplicateClrType(scope~ : String, clr_namespace~ : String, name~ : String, arity~ : Int)
    InvalidClrNamespace(name~ : String, scope~ : String, clr_namespace~ : String)
    EmptyNamespaceUri(name~ : String)
    InvalidPrefix(prefix~ : String, namespace_uri~ : String)
    InvalidSubsumption(newer~ : String, older~ : String)
    DuplicateSubsumption(older~ : String, newer~ : ReadOnlyArray[String])
    SubsumptionCycle(ReadOnlyArray[String])
    PreferredNamespaceConflict(name~ : String, preferred~ : String, mapped~ : String)
    UnknownTypeParameter(
    XamlTypeName
    , String)
    DuplicateMember(
    XamlTypeName
    , String)
    InvalidStaticMember(
    XamlTypeName
    , String)
    SaveReaderWithoutGetter(
    XamlTypeName
    , String)
    InvalidBracketPair(
    XamlTypeName
    , String, opening~ : Char, closing~ : Char)
    EnumeratorWithoutAdd(
    XamlTypeName
    )
    MissingBaseView(
    XamlTypeName
    , base~ :
    XamlTypeName
    , operation~ : String)
    DuplicateDependencyOwner(
    XamlTypeName
    )
    MemberWithoutDependencyObject(
    XamlTypeName
    , String)
    AttachedMemberWithoutOwner(
    XamlTypeName
    , String)
    PropertyRegistryMismatch(
    XamlTypeName
    , String, property~ :
    RegistryId
    , owner~ :
    RegistryId
    )
    InvalidDefaultValue(
    XamlTypeName
    , String, input~ : String, message~ : String)
    DuplicateDirective(namespace_uri~ : String, name~ : String)
    UnknownBaseType(
    XamlTypeName
    , base~ :
    XamlTypeName
    )
    BaseTypeCycle(
    XamlTypeName
    )
    UnknownMember(
    XamlTypeName
    , String)
    UnknownAttachedMember(
    XamlTypeName
    , String, owner~ :
    XamlTypeName
    )
    UsableDuringInitializationOnMarkupExtension(
    XamlTypeName
    )
    InvalidEnumValue(
    XamlTypeName
    , String)
    DuplicateConstructor(
    XamlTypeName
    , factory_method~ : String?, parameter_types~ : ReadOnlyArray[
    XamlTypeName
    ])
    DuplicatePositionalArity(
    XamlTypeName
    , Int)
    } derive(Eq,
    Debug
    )

    A registration problem that SchemaContextBuilder::build reports.

    SchemaConflict::message

    fn SchemaConflict::message(self : SchemaConflict) -> String

    SchemaContext

    pub struct SchemaContext {
    // private fields
    }

    An immutable set of registered XAML types and directives.

    Every context contains the XAML language namespace with its built-in types and directives, reachable under the 2006 and 2009 URIs. Each type has one identity, its name in its preferred namespace; every namespace that names it finds the same XamlType (design D11).

    SchemaContext::accepts

    Whether value as it is, without conversion and widening, is a value for a place of the type target, such as a member or a collection item: an instance of the type, or null when the type or the place takes null.

    SchemaContext::attached_member

    fn SchemaContext::attached_member(self : SchemaContext, owner :
    XamlTypeName
    , name : String) -> XamlMember?

    The attached member name that the type owner or one of its bases defines, nearest first.

    SchemaContext::can_convert_member_value

    fn SchemaContext::can_convert_member_value(self : SchemaContext, target : XamlMember, value :
    XamlValue
    , context? : ServiceContext) -> Bool

    Whether convert_member_value accepts values of the type of value for target.

    SchemaContext::check_result

    fn SchemaContext::check_result(self : SchemaContext, target : XamlType, selected : XamlConstructor, result :
    XamlValue
    ) -> Unit raise ArgumentsError

    Check what selected gave for target: null, or a value whose type is not assignable to target, is an error naming the type, the factory method and the result's type (design D16).

    SchemaContext::compatible_namespace

    fn SchemaContext::compatible_namespace(self : SchemaContext, namespace_uri : String, local_scope? : String, is_understood? : (String) -> Bool) -> String?

    The namespace that a document's namespace_uri is read as after subsumption, as System.Xaml XamlSchemaContext.TryGetCompatibleXamlNamespace gives it (design D17): itself when nothing subsumes it and it resolves; else its newer namespace, which must resolve, followed further while each replacement resolves. None means the namespace is not supported: an unresolved replacement is not retried with the original URI.

    clr-namespace:N and clr-namespace:N;assembly= are in the scope local_scope, in which every CLR-style namespace resolves, as each one of a loaded assembly does in System.Xaml. A namespace for which is_understood gives true is itself, whatever is registered.

    SchemaContext::convert_member_value

    Convert value for member: with the member's converter when it has one; otherwise as its value type converts it, text with the type's parse function first (design D19). It raises ConversionError naming the member.

    SchemaContext::descriptor_constructor

    fn SchemaContext::descriptor_constructor(self : SchemaContext, target : XamlType, descriptor : InstanceDescriptor) -> XamlConstructor raise ArgumentsError

    The constructor or factory method that descriptor gives for an object of target: the most specific one that takes the arguments as they are, without widening. The target of the descriptor, the number of its arguments and the type of each argument have their own errors, as in System.Xaml AddFactoryMethodAndValidateArguments (design D23).

    SchemaContext::directive

    fn SchemaContext::directive(self : SchemaContext, namespace_uri : String, name : String) -> XamlMember?

    The directive name of the XAML namespace namespace_uri.

    SchemaContext::get_type

    The type that name names, closed over its type arguments, or None when resolve_type fails.

    SchemaContext::is_assignable

    Whether a value of type type_name can be used where target is expected: the types are equal or target is a base type of type_name. Names in any of a type's namespaces are the same type.

    SchemaContext::is_instance_of

    Whether value is an instance of target: its runtime type, along its base chain, is target, or target is x:Object (F10).

    SchemaContext::is_known_namespace

    fn SchemaContext::is_known_namespace(self : SchemaContext, namespace_uri : String) -> Bool

    Whether the context resolves namespace_uri: a namespace of a registered type or directive, either XAML language URI, or using:N for a registered CLR-style namespace N.

    SchemaContext::lookup_type

    fn SchemaContext::lookup_type(self : SchemaContext, namespace_uri : String, name : String, arity? : Int) -> XamlType?

    The type registered as name with arity type parameters under the namespace URI namespace_uri, any of the type's namespaces. A generic type is returned open, with its type parameters. CLR-style URIs are matched as registered; lookup_type_in also resolves using: URIs and applies a local scope.

    SchemaContext::lookup_type_in

    fn SchemaContext::lookup_type_in(self : SchemaContext, namespace_uri : String, name : String, arity? : Int, local_scope? : String) -> XamlType? raise NamespaceError

    The type registered as name with arity type parameters in the namespace a document names with namespace_uri (design D11, 2F27, 2F28): clr-namespace:N;assembly=S in scope S, clr-namespace:N in local_scope when one is given, and using:N in every scope that registers N. It raises MalformedClrNamespace for a malformed CLR-style URI and AmbiguousType when several scopes register the type of a using: URI.

    SchemaContext::lookup_type_in_braces

    fn SchemaContext::lookup_type_in_braces(self : SchemaContext, namespace_uri : String, name : String, arity? : Int, local_scope? : String) -> XamlType? raise NamespaceError

    The type that a document names in braces as name with arity type arguments, such as NullExtension for {x:Null}: the type nameExtension, else the type name, each found as lookup_type_in finds it. The type is a markup extension or any other type, because System.Xaml MeScanner.ResolveTypeName does not filter by kind (design D13, 3F-OD5).

    SchemaContext::member_accepts_string

    fn SchemaContext::member_accepts_string(self : SchemaContext, target : XamlMember) -> Bool

    Whether text content goes to the content member target: its converter is the built-in x:String or x:Object one, or its value type is a collection of x:String or x:Object items, as System.Xaml XamlPullParser.CanAcceptString decides (design D17).

    SchemaContext::member_rule

    The rule that a schema-backed writer applies to a start member (design D8, 2F17): the resolved member's name as its identity, so one member named through two owners is one member, with the member's value cardinality; a name that resolves to nothing is its own identity and holds several values, because a document can have them there. An UnknownDirective never resolves.

    SchemaContext::member_type_converter

    fn SchemaContext::member_type_converter(self : SchemaContext, target : XamlMember) -> TypeConverter?

    The type converter of member: its own, attached members included, else the converter of its value type, as System.Xaml XamlMember.LookupTypeConverter finds it.

    SchemaContext::member_value_serializer

    fn SchemaContext::member_value_serializer(self : SchemaContext, target : XamlMember) -> ValueSerializer?

    The value serializer of member: its own, else its value type's (the type's own, its base types' nearest first, then the built-in one of the exact type), as System.Xaml LookupValueSerializer finds it. A nullable member uses its underlying type's.

    SchemaContext::preferred_prefix

    fn SchemaContext::preferred_prefix(self : SchemaContext, namespace_uri : String) -> String?

    The preferred prefix of namespace_uri: x for both XAML language URIs, else the shortest, then the ordinal least, of its registered preferred prefixes.

    SchemaContext::resolve_attached_member

    fn SchemaContext::resolve_attached_member(self : SchemaContext, namespace_uri : String, dotted_name : String) -> XamlMember?

    Resolve a dotted name such as Grid.Row, written in the XAML namespace namespace_uri, to the attached member Row of the type Grid of that namespace, the context-free attachable lookup (design D3, 2F15, 2F21): an attached property of Grid or its bases, nearest first, and only when there is none an attached event found the same way. It never returns an instance member or an instance event, and the name must have exactly one ..

    SchemaContext::resolve_member

    The member that name names, or None when it resolves to nothing.

    SchemaContext::resolve_type

    The type that name names, under any of its namespaces. For a generic type every type argument, at any depth, must resolve with its arity, and the result is the closed type with the arguments, named by their identities, substituted into its base and member types.

    SchemaContext::select_constructor

    fn SchemaContext::select_constructor(self : SchemaContext, target : XamlType, arguments : ArrayView[
    XamlValue
    ], factory_method? : String) -> ConstructorMatch raise ArgumentsError

    Select the constructor, or with factory_method the factory method of that name, of target for x:Arguments, by the CLR binder rules this release supports (design D16, 2F13): each argument of the exact parameter type, of a more specific assignable type or of a primitive type that widens to it, and null for a parameter that accepts null; among several matches the most specific, and a tie an ambiguity error. Parameter arrays are not supported.

    SchemaContext::types_in

    fn SchemaContext::types_in(self : SchemaContext, namespace_uri : String) -> Array[XamlType]

    The types registered under the namespace URI namespace_uri, any of their namespaces, in registration order.

    SchemaContext::xaml_object

    The XAML object of object, for example to save it. The XAML type that stands for the owner type of the object registers dependency_objects.

    SchemaContext::xaml_type_for_owner

    The type that stands for owner in a document: the first one in the order of registration that names it itself.

    SchemaContextBuilder

    pub struct SchemaContextBuilder {
    // private fields
    }

    Collects type, directive, preferred prefix and namespace subsumption registrations and builds an immutable SchemaContext (design D3, D11).

    SchemaContextBuilder::add_directive

    fn SchemaContextBuilder::add_directive(self : SchemaContextBuilder, namespace_uri : String, name : String, value_type? :
    XamlTypeName
    , item_type? :
    XamlTypeName
    , allowed_locations? : AllowedLocations) -> SchemaContextBuilder

    Add a custom directive of a namespace other than the XAML language namespaces and the XML namespace, whose directives are built in (design D8). With item_type it is a collection directive. build() fails with DuplicateDirective for a directive of those namespaces or a second directive of one namespace and name.

    SchemaContextBuilder::add_namespace_subsumption

    fn SchemaContextBuilder::add_namespace_subsumption(self : SchemaContextBuilder, newer~ : String, older~ : String) -> SchemaContextBuilder

    Register that the namespace newer subsumes the namespace older, as .NET XmlnsCompatibleWithAttribute(older, newer) does: a document that uses older is read as if it used newer (design D17).

    SchemaContextBuilder::add_preferred_prefix

    fn SchemaContextBuilder::add_preferred_prefix(self : SchemaContextBuilder, namespace_uri : String, prefix : String) -> SchemaContextBuilder

    Register prefix as a preferred prefix of namespace_uri, as .NET XmlnsPrefixAttribute does. Of several preferred prefixes of one URI the shortest, then the ordinal least, is chosen (F30).

    SchemaContextBuilder::add_type

    SchemaContextBuilder::build

    Build the context, or raise SchemaError with every conflict in registration order.

    SchemaContextBuilder::new

    SerializationVisibility

    pub(all) enum SerializationVisibility {
    Visible
    Hidden
    Content
    } derive(Eq, Hash,
    Debug
    )

    Whether saving writes a member, as .NET DesignerSerializationVisibilityAttribute decides.

    ServiceContext

    pub struct ServiceContext {
    schema_context : SchemaContext
    target_object :
    XamlObject
    ?
    target_member : XamlMember?
    root_object :
    XamlObject
    ?
    resolve_type : (String) ->
    XamlTypeName
    ??
    resolve_prefix : (String) -> String??
    prefixes : () -> ReadOnlyArray[NamespaceDeclaration]?
    name_resolver : NameResolver?
    parents :
    List
    [
    XamlObject
    ]
    base_uri : XamlUri?
    lookup_prefix : (String) -> String?
    name_provider : (
    XamlObject
    ) -> String?
    }

    The services that markup extensions, type converters and value serializers receive (design D14).

    Each field is the counterpart of one System.Xaml service. schema_context is always present. A load context has the load services: the target fields (IProvideValueTarget, absent when there is no destination), root_object (IRootObjectProvider), resolve_type (IXamlTypeResolver), resolve_prefix and prefixes (IXamlNamespaceResolver), name_resolver (IXamlNameResolver), parents, the objects of the enclosing elements and extensions from the nearest outward, and base_uri, the root xml:base (IUriContext). A save context has lookup_prefix (INamespacePrefixLookup) and name_provider (IXamlNameProvider). The services of the other direction are absent.

    A context that is kept after the call holds the objects in its fields, and after the load its name resolver finds no name.

    ServiceContext::for_load

    fn ServiceContext::for_load(schema_context : SchemaContext, resolve_prefix~ : (String) -> String?, prefixes~ : () -> ReadOnlyArray[NamespaceDeclaration], resolve_type? : (String) ->
    XamlTypeName
    ?, target_object? :
    XamlObject
    , target_member? : XamlMember, root_object? :
    XamlObject
    , name_resolver? : NameResolver, parents? :
    List
    [
    XamlObject
    ], base_uri? : XamlUri) -> ServiceContext

    A context for loading. Without resolve_type, a type name is parsed with resolve_prefix and resolves to the identity of the registered type that it names, type arguments included.

    ServiceContext::for_save

    fn ServiceContext::for_save(schema_context : SchemaContext, lookup_prefix~ : (String) -> String, name_provider~ : (
    XamlObject
    ) -> String) -> ServiceContext

    A context for saving, with the prefix lookup and the name provider of the save.

    ServiceContext::new

    fn ServiceContext::new(schema_context : SchemaContext) -> ServiceContext

    A context with the schema context only, as converters receive at build() and where no other service exists.

    StaticMemberKind

    pub(all) enum StaticMemberKind {
    Field
    Property
    } derive(Eq, Hash,
    Debug
    )

    Whether a static member is a field or a property, which decides the order in which x:Static searches them (2F12).

    TypeConverter

    pub struct TypeConverter {
    // private fields
    }

    Converts values of a type from other types, text above all, and back, in the style of System.ComponentModel TypeConverter (design D19).

    There is no culture argument: conversions are invariant by contract, as System.Xaml always passes CultureInfo.InvariantCulture. convert_from and the capability checks accept an absent context, as WPF's PropertyPath converts typed indexer arguments without one; a converter that needs a service raises without it. Loading and saving always pass a context.

    TypeConverter::can_convert_from

    fn TypeConverter::can_convert_from(self : TypeConverter, context? : ServiceContext, source :
    XamlTypeName
    ) -> Bool

    Whether the converter converts values of the type source.

    TypeConverter::can_convert_to

    fn TypeConverter::can_convert_to(self : TypeConverter, context? : ServiceContext, destination : ConversionDestination) -> Bool

    Whether the converter converts values of its type to destination.

    TypeConverter::convert_from

    Convert value to a value of the converter's type.

    TypeConverter::convert_to

    Convert value to destination: a String value for text, a markup extension object handle for a markup extension.

    TypeConverter::from_text

    A converter from text with parse, and to text with format when it is given.

    TypeConverter::new

    A converter from the four operations. can_convert_from defaults to accepting x:String only. Without convert_to the converter converts to nothing; with it, can_convert_to defaults to text only.

    ValueSerializer

    pub struct ValueSerializer {
    // private fields
    }

    Converts values of a type to text and back when saving, in the style of System.Xaml ValueSerializer (design D19). Loading never uses it, as XamlObjectWriter never calls ConvertFromString.

    ValueSerializer::can_convert_from_string

    fn ValueSerializer::can_convert_from_string(self : ValueSerializer, context : ServiceContext, text : String) -> Bool

    ValueSerializer::can_convert_to_string

    fn ValueSerializer::can_convert_to_string(self : ValueSerializer, context : ServiceContext, value :
    XamlValue
    ) -> Bool

    ValueSerializer::convert_from_string

    fn ValueSerializer::convert_from_string(self : ValueSerializer, context : ServiceContext, text : String) ->
    XamlValue
    raise

    ValueSerializer::convert_to_string

    fn ValueSerializer::convert_to_string(self : ValueSerializer, context : ServiceContext, value :
    XamlValue
    ) -> String raise

    ValueSerializer::new

    fn ValueSerializer::new(convert_to_string~ : (ServiceContext,
    XamlValue
    ) -> String raise, can_convert_to_string? : (ServiceContext,
    XamlValue
    ) -> Bool, convert_from_string? : (ServiceContext, String) ->
    XamlValue
    raise, can_convert_from_string? : (ServiceContext, String) -> Bool) -> ValueSerializer

    A value serializer. can_convert_to_string defaults to true. Without convert_from_string it converts no text back; with it, can_convert_from_string defaults to true.

    XamlArray

    What x:Array gives: the declared item type and the items (design D12, F7). The item type is kept as declared, so saving writes it unchanged even when the array is empty or holds items of derived types.
    impl Eq for XamlArray
    impl Hash for XamlArray

    XamlArray::new

    An array with a copy of items.

    XamlConstructor

    pub struct XamlConstructor {
    factory_method : String?
    parameters : ReadOnlyArray[XamlParameter]
    // private fields
    }

    A registered constructor or named factory method with its ordered parameters (design D13, D16). Constructors and factory methods are not inherited.

    XamlConstructor::arity

    fn XamlConstructor::arity(self : XamlConstructor) -> Int

    XamlConstructor::invoke

    Run the constructor with the type arguments of the closed type and the arguments.

    XamlConstructor::parameter_types

    The parameter types, in order.

    XamlDecimal

    pub struct XamlDecimal {
    // private fields
    }

    The value of x:Decimal: a coefficient whose absolute value is below 2^96 and a scale from 0 to 28, as System.Decimal holds (design D12, 2F66). The value is coefficient / 10^scale. Two decimals are equal by numeric value, so 1.5 equals 1.50, and the scale is kept for text.
    impl Eq for XamlDecimal
    impl Hash for XamlDecimal
    impl Show for XamlDecimal

    XamlDecimal::coefficient

    XamlDecimal::new

    fn XamlDecimal::new(coefficient :
    BigInt
    , scale : Int) -> XamlDecimal raise ValueError

    A decimal, or ValueError naming x:Decimal when the coefficient or scale is out of range.

    XamlDecimal::scale

    fn XamlDecimal::scale(self : XamlDecimal) -> Int

    XamlDecimal::to_string

    fn XamlDecimal::to_string(self : XamlDecimal) -> String

    Default implementation for Show::to_string, uses a StringBuilder

    XamlEnumValue

    pub(all) struct XamlEnumValue {
    type_name :
    XamlTypeName

    bits : UInt64
    } derive(Eq, Hash,
    Debug
    )

    An enumeration value: the type and the value as 64-bit two's complement bits, sign-extended for a signed backing type. Values of one type are equal when their bits are.

    XamlEnumeration

    pub struct XamlEnumeration {
    backing : EnumBacking
    flags : Bool
    values : ReadOnlyArray[(String, UInt64)]
    }

    The registration of an enumeration type: its backing type, its named values and whether it is a flags enumeration.

    XamlEnumeration::format

    fn XamlEnumeration::format(self : XamlEnumeration, label : String, bits : UInt64) -> String raise ValueError

    The text of bits, as .NET Enum.Format writes it: the name of a defined value, the names of a flags combination in ascending value order joined with ", ", and the number of an unnamed flags value. An unnamed value of a non-flags enumeration is an error (Owner, 2026-12-01).

    XamlEnumeration::parse

    fn XamlEnumeration::parse(self : XamlEnumeration, label : String, text : String) -> UInt64 raise ValueError

    The value that text stands for in the enumeration named label (F50, 2F45, Owner 2026-12-01): trimmed text that starts with a digit or a sign is one in-range decimal integer; otherwise it is a comma-separated list of case-sensitive names, each trimmed, combined with bitwise OR. A number inside a list is not a name, so it is an error.

    XamlEnumeration::value_of

    fn XamlEnumeration::value_of(self : XamlEnumeration, name : String) -> UInt64?

    The value of the name name, compared case-sensitively.

    XamlMember

    pub struct XamlMember {
    name : String
    kind : XamlMemberKind
    declaring_type :
    XamlTypeName
    ?
    namespace_uri : String
    value_type :
    XamlTypeName
    ?
    nullable : Bool
    bracket_pairs : ReadOnlyArray[(Char, Char)]
    default_value :
    XamlValue
    ?
    visibility : SerializationVisibility
    depends_on : ReadOnlyArray[String]
    constructor_argument : String?
    dependency_property :
    PropertyInfo
    ?
    routed_event :
    RoutedEventInfo
    ?
    allowed_locations : AllowedLocations
    item_type :
    XamlTypeName
    ?
    // private fields
    }

    A registered XAML member: a property, an attached property or a directive.

    XamlMember::is_attached

    fn XamlMember::is_attached(self : XamlMember) -> Bool

    Whether the member is an attached property or an attached event.

    XamlMember::is_collection_directive

    fn XamlMember::is_collection_directive(self : XamlMember) -> Bool

    Whether the member is a collection directive, such as x:Arguments or x:_Items, which holds several items of its item_type.

    XamlMember::is_directive

    fn XamlMember::is_directive(self : XamlMember) -> Bool

    XamlMember::is_event

    fn XamlMember::is_event(self : XamlMember) -> Bool

    Whether the member is an event or an attached event, which an event adder sets.

    XamlMember::member_name

    The member name that start member nodes carry for this member: Member for properties and events, Attached for attached properties and attached events, and Directive only for directives (design D3).

    XamlMember::paired_event

    fn XamlMember::paired_event(self : XamlMember) -> XamlMember?

    The other member of a pair that add_paired_event_member registered: the attached event for the event and the event for the attached event, as the type that the member was found on has them. None for every other member, and for one whose partner a derived type replaced.

    XamlMember::save_reader

    The save reader of the member, inherited with it (design D21).

    XamlMember::should_serialize

    fn XamlMember::should_serialize(self : XamlMember) -> (
    XamlObject
    ) -> Bool raise?

    The should-serialize check of the member.

    XamlMember::type_converter

    fn XamlMember::type_converter(self : XamlMember) -> TypeConverter?

    The type converter registered on the member itself. It takes precedence over the converter of the value type (SchemaContext::member_type_converter).

    XamlMember::value_cardinality

    How many values, start objects and get objects the member holds in a node stream (design D8): several for collection directives, for x:_UnknownContent and for event members, whose adder receives every value, and at most one for every other member.

    XamlMember::value_serializer

    fn XamlMember::value_serializer(self : XamlMember) -> ValueSerializer?

    The value serializer registered on the member itself. It takes precedence over the value serializer of the value type (SchemaContext::member_value_serializer).

    XamlMemberKind

    pub(all) enum XamlMemberKind {
    Property
    Attached
    Directive
    Event
    AttachedEvent
    } derive(Eq, Hash,
    Debug
    )

    XamlParameter

    pub(all) struct XamlParameter {
    name : String
    type_name :
    XamlTypeName

    nullable : Bool
    } derive(Eq,
    Debug
    )

    A parameter of a constructor or factory method: its name, its type and whether null is a value of it beyond the types that accept null anyway (design D16).

    XamlParameter::new

    fn XamlParameter::new(name : String, type_name :
    XamlTypeName
    , nullable? : Bool) -> XamlParameter

    XamlStaticMember

    pub struct XamlStaticMember {
    name : String
    kind : StaticMemberKind
    declaring_type :
    XamlTypeName

    value_type :
    XamlTypeName
    ?
    // private fields
    }

    A static member that x:Static reads: a field or a property of its declaring type, with a value or a getter.

    XamlStaticMember::value

    The value of the member, from its getter or as registered.

    XamlTimeSpan

    pub struct XamlTimeSpan {
    // private fields
    } derive(Compare, Eq, Hash,
    Debug
    )

    The value of x:TimeSpan: a signed count of 100-nanosecond ticks, as System.TimeSpan holds.

    XamlTimeSpan::new

    fn XamlTimeSpan::new(ticks : Int64) -> XamlTimeSpan

    XamlTimeSpan::ticks

    fn XamlTimeSpan::ticks(self : XamlTimeSpan) -> Int64

    XamlType

    pub struct XamlType {
    name :
    XamlTypeName

    namespaces : ReadOnlyArray[String]
    clr_namespace : String?
    scope : String?
    type_parameters : ReadOnlyArray[String]
    base_type :
    XamlTypeName
    ?
    content_property : String?
    item_type :
    XamlTypeName
    ?
    key_type :
    XamlTypeName
    ?
    enumeration : XamlEnumeration?
    // private fields
    }

    A registered XAML type. Its member table includes the members that it inherits.

    A generic type as registered is open: its name carries type_parameter references as type arguments, as do the types of its members. SchemaContext::resolve_type gives the closed type for type arguments, with the arguments substituted into its name, base type and member types.

    XamlType::aliased_member

    fn XamlType::aliased_member(self : XamlType, directive : AliasedDirective) -> XamlMember?

    The member aliased to directive, declared or inherited, unless the type or a nearer base type clears it.

    XamlType::any_value_converter

    The conversion of values of the type to AnyValue: its own, else that of its nearest base type other than x:Object.

    XamlType::attached_member

    fn XamlType::attached_member(self : XamlType, name : String) -> XamlMember?

    The attached member name that this type or a base type defines: the attached property found nearest first, and only when there is none the attached event found the same way (design D3, 2F21). An inherited attached member keeps its declaring type (F13).

    XamlType::attached_member_store

    The attached member store of the type, declared or inherited.

    XamlType::begin_init

    fn XamlType::begin_init(self : XamlType) -> (
    XamlObject
    ) -> Unit raise?

    The begin initialization callback, declared or inherited, adapted to the type's key.

    XamlType::can_convert_from

    fn XamlType::can_convert_from(self : XamlType, value :
    XamlValue
    , context? : ServiceContext) -> Bool

    Whether convert_from accepts values of the type of value. Loading passes a value that it does not accept through unconverted, as System.Xaml ClrObjectRuntime.CreateObjectWithTypeConverter.

    XamlType::constructors

    fn XamlType::constructors(self : XamlType) -> Array[XamlConstructor]

    The constructors of the type, in registration order; factory methods are not included.

    XamlType::constructors_of_arity

    fn XamlType::constructors_of_arity(self : XamlType, arity : Int) -> Array[XamlConstructor]

    The constructors that take arity arguments, in registration order.

    XamlType::content_member

    fn XamlType::content_member(self : XamlType) -> XamlMember?

    XamlType::convert_from

    Convert value to a value of this type: text with the parse function when one is registered, else with the type converter (design D19). It raises ConversionError naming the type.

    XamlType::declared_dependency_owner

    fn XamlType::declared_dependency_owner(self : XamlType) ->
    OwnerType
    ?

    The owner type that the type itself names.

    XamlType::default_constructor

    fn XamlType::default_constructor(self : XamlType) -> XamlConstructor?

    The zero-parameter constructor that default construction uses.

    XamlType::dependency_object

    The dependency object of object, an object of the type.

    XamlType::dependency_owner

    The owner type that the type or its nearest base type with one names.

    XamlType::end_init

    fn XamlType::end_init(self : XamlType) -> (
    XamlObject
    ) -> Unit raise?

    The end initialization callback, declared or inherited, adapted to the type's key.

    XamlType::entry_enumerator

    The enumerator of the entries of a dictionary, declared or inherited.

    XamlType::factory_methods

    fn XamlType::factory_methods(self : XamlType, name : String) -> Array[XamlConstructor]

    The factory methods named name, in registration order.

    XamlType::find_member

    fn XamlType::find_member(self : XamlType, name : String) -> XamlMember?

    A declared or inherited member, not an attached member: the property found nearest first, and only when there is none the event found the same way.

    XamlType::full_name

    fn XamlType::full_name(self : XamlType) -> String?

    The full CLR-style name N.Name of a type that registers a CLR-style namespace, which x:Class is compared with. A generic type has none.

    XamlType::has_object_key

    fn[T] XamlType::has_object_key(self : XamlType, key :
    ObjectKey
    [T]) -> Bool

    Whether key is the key that wraps objects of the type.

    XamlType::instance_descriptor

    The instance descriptor of the type, declared or inherited.

    XamlType::is_abstract

    fn XamlType::is_abstract(self : XamlType) -> Bool

    Whether the type is abstract.

    XamlType::is_collection

    fn XamlType::is_collection(self : XamlType) -> Bool

    XamlType::is_dictionary

    fn XamlType::is_dictionary(self : XamlType) -> Bool

    XamlType::is_keyed_instance

    fn XamlType::is_keyed_instance(self : XamlType, handle :
    XamlObject
    ) -> Bool

    Whether handle was wrapped with the key of the type.

    XamlType::is_markup_extension

    fn XamlType::is_markup_extension(self : XamlType) -> Bool

    XamlType::is_name_scope

    fn XamlType::is_name_scope(self : XamlType) -> Bool

    Whether objects of the type are name scopes: the type or a base type registers name-scope operations, as System.Xaml XamlType.IsNameScope. A name-scope property alone does not make them one.

    XamlType::is_usable_during_initialization

    fn XamlType::is_usable_during_initialization(self : XamlType) -> Bool

    Whether the nearest type of the chain that sets it makes the type usable during initialization.

    XamlType::is_whitespace_significant_collection

    fn XamlType::is_whitespace_significant_collection(self : XamlType) -> Bool

    Whether the type or a base type is a white-space significant collection.

    XamlType::item_enumerator

    The enumerator of the items of a collection, declared or inherited.

    XamlType::longest_constructor

    fn XamlType::longest_constructor(self : XamlType) -> XamlConstructor?

    The constructor with the most parameters, the last registered on a tie, as System.Xaml XamlParserContext.InitLongestConstructor picks it for the bracket pairs of positional text.

    XamlType::members

    fn XamlType::members(self : XamlType) -> Iter[XamlMember]

    The declared and inherited members, base type members first.

    XamlType::name_scope

    fn XamlType::name_scope(self : XamlType) -> NameScopeAccess?

    How objects of the type give access to their name scope, adapted to the type's key: the nearest operations of the base chain, else the nearest name-scope property.

    XamlType::object_key_id

    fn XamlType::object_key_id(self : XamlType) -> Int?

    The id of the key that wraps objects of the type, its own or its nearest base type's.

    XamlType::own_member

    fn XamlType::own_member(self : XamlType, target : XamlMember) -> XamlMember?

    The member target, which a type or one of its base types resolved, as objects of this type have it: its operations take handles of this type, also when a nearer member of the name hides it. None when this type does not have the member. An attached member is the same one on every object.

    XamlType::parse_function

    fn XamlType::parse_function(self : XamlType) -> (String) ->
    XamlValue
    raise?

    The parse function that the type registers, which reads text before the type converter.

    XamlType::positional_signature

    fn XamlType::positional_signature(self : XamlType, count : Int) -> XamlConstructor?

    The positional signature of a markup extension for count arguments: its constructor of that count, as System.Xaml keys positional parameters by count only (Owner, 2F-OD1). The one-argument signature of x:TypeExtension takes a type value.

    XamlType::static_member

    fn XamlType::static_member(self : XamlType, name : String) -> XamlStaticMember?

    The static member name of the type, as x:Static finds it (design D8, 2F12): fields of the type and then of its bases, nearest first, then properties in the same order, so a base field comes before a derived property. The values of an enumeration are its static fields.

    XamlType::trims_surrounding_whitespace

    fn XamlType::trims_surrounding_whitespace(self : XamlType) -> Bool

    Whether the type or a base type trims the white space around its objects in collections.

    XamlType::type_converter

    fn XamlType::type_converter(self : XamlType) -> TypeConverter?

    The type converter of the type: its own, else its nearest base type's other than x:Object's, else the enumeration converter of an enumeration, else a built-in one, as System.Xaml XamlType.LookupTypeConverter finds it (design D19).

    XamlType::value_serializer

    fn XamlType::value_serializer(self : XamlType) -> ValueSerializer?

    The value serializer of the type: its own, else its base types' nearest first, else the built-in one of the exact type (design D19).

    XamlTypeDefinition

    pub struct XamlTypeDefinition {
    // private fields
    }

    A type registration that a SchemaContextBuilder turns into a XamlType.

    The methods add to the definition and return it, so registrations chain.

    XamlTypeDefinition::abstract_type

    Make the type abstract, as x:Member is: documents cannot create objects of it.

    XamlTypeDefinition::add_attached_dependency_member

    fn[T] XamlTypeDefinition::add_attached_dependency_member(self : XamlTypeDefinition, name : String, property :
    DependencyProperty
    [T], conversion : PropertyConversion[T], type_converter? : TypeConverter, value_serializer? : ValueSerializer, bracket_pairs? : ArrayView[(Char, Char)], should_serialize? : (
    DependencyObject
    ) -> Bool raise, visibility? : SerializationVisibility) -> XamlTypeDefinition

    Add an attached member that is a dependency property, such as Grid.Row. It can be set on every object that has a dependency object. The type itself names the owner type of the property, or one that the property was added to.

    The options are those of add_dependency_member.

    XamlTypeDefinition::add_attached_member

    Add an attached member that the type defines for other objects, such as Grid.Row. The options are those of add_member.

    XamlTypeDefinition::add_constructor

    Register a constructor with the ordered parameters. A zero-parameter constructor is the default constructor. Two constructors with the same parameter types are a build conflict, and so, on a markup extension, are two of one count, because positional arguments select by count only.

    XamlTypeDefinition::add_dependency_member

    fn[T] XamlTypeDefinition::add_dependency_member(self : XamlTypeDefinition, name : String, property :
    DependencyProperty
    [T], conversion : PropertyConversion[T], type_converter? : TypeConverter, value_serializer? : ValueSerializer, bracket_pairs? : ArrayView[(Char, Char)], should_serialize? : (
    DependencyObject
    ) -> Bool raise, visibility? : SerializationVisibility, depends_on? : ArrayView[String], constructor_argument? : String) -> XamlTypeDefinition

    Add a member that is a dependency property of the objects of the type, as conversion converts its values. The type or a base type of it has registered dependency_objects or dependency_owner with a function.

    Loading sets the property, and a read-only property has no setter. Saving writes the local value, when there is one. The other options are those of add_member, and the contents of a read-only collection are written unless visibility is Hidden.

    XamlTypeDefinition::add_event_member

    Add an event member that adder sets: an Event of the type, or with attached an AttachedEvent that the type defines for other objects. An event shares the instance name space of the type and an attached event the attachable one. Two calls never form a pair, even with one adder.

    XamlTypeDefinition::add_factory_method

    Register the factory method name with the ordered parameters, which x:FactoryMethod names. It may take no arguments. Two factory methods of one name with the same parameter types are a build conflict.

    XamlTypeDefinition::add_member

    fn XamlTypeDefinition::add_member(self : XamlTypeDefinition, name : String, value_type? :
    XamlTypeName
    , nullable? : Bool, setter? : (
    XamlObject
    ,
    XamlValue
    ) -> Unit raise, getter? : (
    XamlObject
    ) ->
    XamlValue
    raise, save_reader? : (
    XamlObject
    ) ->
    XamlValue
    ? raise, type_converter? : TypeConverter, value_serializer? : ValueSerializer, bracket_pairs? : ArrayView[(Char, Char)], default_value? :
    XamlValue
    , should_serialize? : (
    XamlObject
    ) -> Bool raise, visibility? : SerializationVisibility, depends_on? : ArrayView[String], constructor_argument? : String) -> XamlTypeDefinition

    Add a member that the type declares. nullable makes its value type nullable: text converts with the value type's converter and null is a value of it. type_converter and value_serializer take precedence over those of the value type. bracket_pairs are the opening and closing characters inside which markup extension text for the member is not split, as System.Xaml MarkupExtensionBracketCharactersAttribute (F41). The two differ, and neither is a letter, a digit, white space, beyond U+FFFF or one of =, ,, ', ", {, } and \.

    For saving (design D20, D21): save_reader reads the value that saving compares and writes, beside the getter that loading uses, and needs the getter; default_value is the value that saving leaves out, as .NET DefaultValueAttribute, converted at build() when it is not assignable, and for a value type that is a type parameter in each derived type that closes it and can convert it; should_serialize decides otherwise, as a ShouldSerialize method; visibility is .NET DesignerSerializationVisibility; depends_on names the members written before this one, as DependsOnAttribute, ignoring names that are not members; constructor_argument names the constructor parameter that receives the value, as ConstructorArgumentAttribute.

    XamlTypeDefinition::add_namespace

    fn XamlTypeDefinition::add_namespace(self : XamlTypeDefinition, namespace_uri : String) -> XamlTypeDefinition

    Register the type under another XAML namespace URI as well, as several .NET XmlnsDefinitionAttributes map URIs to one CLR namespace. The type keeps one identity.

    XamlTypeDefinition::add_paired_event_member

    Add an Event and an AttachedEvent member of one name with one adder, recorded as a pair that XamlMember::paired_event gives, as a routed event is both. Each member takes its own name space.

    XamlTypeDefinition::add_routed_event_member

    Add a routed event as a member of the type and as one that it attaches to other objects, so that Click="OnOk" on a button and Button.Click="OnOk" on its panel add a handler. This is one pair of add_paired_event_member.

    The value is the name of a handler in the HandlerTable of the load settings. The handler is added to the dependency object of the object that has the member, which is an element. It can be an event that another type registered.

    XamlTypeDefinition::add_static_member

    Register the static member name for x:Static: a property by default, or a field, with the fixed value or a getter, one of which must be given. Static members share the instance member name space of the type, and derived types inherit them.

    XamlTypeDefinition::aliased_member

    fn XamlTypeDefinition::aliased_member(self : XamlTypeDefinition, directive : AliasedDirective, member_name : String) -> XamlTypeDefinition

    Register the member member_name as the alias of directive, as the .NET attributes that AliasedDirective lists do. Derived types inherit it unless they set or clear their own.

    XamlTypeDefinition::any_value_converter

    Register the conversion of values of the type to AnyValue, for code such as a property path that has no property with a type. Derived types inherit it.

    XamlTypeDefinition::attached_member_store

    Register the attached member store of the type, which derived types inherit.

    XamlTypeDefinition::base_type

    XamlTypeDefinition::base_view

    Register a base view: view gives, for an object of this type wrapped with key, its part that a base type's operations registered with base_key work on, the same instance each time. An inherited setter, getter, save reader, add operation, enumerator, store or callback registered with base_key then runs on objects of this type through the view (design D8). Views compose along the base chain: a type may register a view to its direct base type's key, whose own views lead further.

    XamlTypeDefinition::clear_alias

    Clear an inherited alias of directive. The member stays available by name.

    XamlTypeDefinition::clear_content_property

    fn XamlTypeDefinition::clear_content_property(self : XamlTypeDefinition) -> XamlTypeDefinition

    Clear an inherited content property. The member stays available by name.

    XamlTypeDefinition::clr_namespace

    fn XamlTypeDefinition::clr_namespace(self : XamlTypeDefinition, scope : String, clr_namespace : String) -> XamlTypeDefinition

    Register the CLR-style namespace name clr_namespace in scope for the type. Its URI clr-namespace:N;assembly=S is the type's last secondary namespace.

    XamlTypeDefinition::collection

    Make the type a collection whose items add adds. item_type is the type of its items, x:Object unless given, as System.Xaml XamlType.ItemType.

    XamlTypeDefinition::content_property

    fn XamlTypeDefinition::content_property(self : XamlTypeDefinition, name : String) -> XamlTypeDefinition

    XamlTypeDefinition::dependency_objects

    Make the objects of the type dependency objects of the type owner, which create makes. Without create the type has no constructor of its own.

    A control that keeps more than its dependency object gives itself to it with set_host, and other members of the type find it there. Each XAML type of such objects needs an owner type of its own, because a dependency object does not know more.

    XamlTypeDefinition::dependency_owner

    Name the owner type that the XAML type stands for.

    object gives the dependency object of an object of the type. Without it the type uses the function of its nearest base type that has one. A type with neither, such as the static class TextOptions, has no objects with dependency properties and only gives its name to attached ones.

    dependency_objects does this for a type whose objects are dependency objects.

    XamlTypeDefinition::dictionary

    Make the type a dictionary whose keyed entries add adds. key_type and item_type are the types of its keys and values, x:Object unless given, as System.Xaml XamlType.KeyType and ItemType.

    XamlTypeDefinition::entry_enumerator

    Register an enumerator of the entries of the dictionary type, which saving needs. The type or a base type must register an add operation.

    XamlTypeDefinition::enumeration

    fn XamlTypeDefinition::enumeration(self : XamlTypeDefinition, backing : EnumBacking, values : ArrayView[(String, Int64)], flags? : Bool) -> XamlTypeDefinition

    Make the type an enumeration with the backing type backing and the named values, in order. A value of an UInt64 enumeration above the Int64 range is given as its two's complement, such as -1 for 2^64 - 1. Without its own converter the type converts with the enumeration converter.

    XamlTypeDefinition::initialization

    Register the begin and end initialization callbacks of the type, which derived types inherit, as .NET ISupportInitialize (design D25).

    XamlTypeDefinition::instance_descriptor

    Register the instance descriptor of the type, which derived types inherit.

    XamlTypeDefinition::item_enumerator

    Register an enumerator of the items of the collection type, which saving needs. The type or a base type must register an add operation.

    XamlTypeDefinition::markup_extension

    Make the type a markup extension. Its constructors are its positional signatures, selected by argument count only (design D13).

    XamlTypeDefinition::name_scope

    Register the operations of the instance name scope of the type (design D15). They are inherited and, registered with a base type's key, run on a derived type's objects through its base views.

    XamlTypeDefinition::name_scope_property

    fn XamlTypeDefinition::name_scope_property(self : XamlTypeDefinition, name : String, attached_owner? :
    XamlTypeName
    ) -> XamlTypeDefinition

    Name the member that holds the name scope of an object of the type at the root of a document, as .NET NameScopePropertyAttribute: a member of the type, or with attached_owner the attached member name of that type (design D15). Scope operations, also inherited ones, take precedence over it.

    XamlTypeDefinition::new

    fn XamlTypeDefinition::new(namespace_uri : String, name : String, type_parameters? : Array[String], base_type? :
    XamlTypeName
    , content_property? : String, type_converter? : TypeConverter) -> XamlTypeDefinition

    A type registration. type_parameters names the type parameters of a generic type, in order; member and base types refer to them with type_parameter. Types are keyed by namespace, name and the number of type parameters, so Tuple with one and with two parameters are different types.

    XamlTypeDefinition::new_clr

    fn XamlTypeDefinition::new_clr(scope : String, clr_namespace : String, name : String, type_parameters? : Array[String], base_type? :
    XamlTypeName
    , content_property? : String, type_converter? : TypeConverter) -> XamlTypeDefinition

    A type registered only under the CLR-style namespace clr_namespace of scope, whose URI clr-namespace:N;assembly=S is then its preferred namespace (design D11, 2F27).

    XamlTypeDefinition::object_key

    Register the key that wraps objects of the type, so that build() can check that every inherited operation reaches the instance (design D3, D8). A type without a key of its own uses its base type's key. A type with instance operations (constructors, factory methods, setters, getters, adders, enumerators or callbacks) registers one, or shares its base type's.

    XamlTypeDefinition::parse_function

    Register a function that reads values of the type from text before its type converter, as Avalonia uses a static Parse(string) method (design D19). It is not inherited.

    XamlTypeDefinition::trim_surrounding_whitespace

    fn XamlTypeDefinition::trim_surrounding_whitespace(self : XamlTypeDefinition) -> XamlTypeDefinition

    Trim white space around objects of the type in collections, as .NET TrimSurroundingWhitespaceAttribute. Derived types inherit the flag.

    XamlTypeDefinition::usable_during_initialization

    fn XamlTypeDefinition::usable_during_initialization(self : XamlTypeDefinition, usable : Bool) -> XamlTypeDefinition

    Set whether an object of the type is assigned to its parent before its members are set, as .NET UsableDuringInitializationAttribute. Omitted, the type inherits its base type's setting; at the root of the chain it is false. True on a markup extension fails build().

    XamlTypeDefinition::value_serializer

    fn XamlTypeDefinition::value_serializer(self : XamlTypeDefinition, serializer : ValueSerializer) -> XamlTypeDefinition

    Register the value serializer of the type, which derived types inherit.

    XamlTypeDefinition::whitespace_significant_collection

    fn XamlTypeDefinition::whitespace_significant_collection(self : XamlTypeDefinition) -> XamlTypeDefinition

    Make the type a white-space significant collection, as .NET WhitespaceSignificantCollectionAttribute. Derived types inherit the flag.

    XamlUri

    pub struct XamlUri {
    // private fields
    }

    The value of x:Uri: the original text, accepted as .NET new Uri(text,UriKind.RelativeOrAbsolute) accepts it (design D12, Owner 2F-OD3).

    The acceptance rules are a port of the parts of .NET's System.Uri constructor that decide whether text is an absolute URI, a relative URI or an error, as .NET 10 does on Windows. The text is kept unchanged, so saving writes it back as it was read. Two values are equal when their texts are equal.
    impl Eq for XamlUri
    impl Hash for XamlUri
    impl Show for XamlUri

    XamlUri::is_absolute

    fn XamlUri::is_absolute(self : XamlUri) -> Bool

    Whether .NET reads the text as an absolute URI rather than a relative one.

    XamlUri::parse

    fn XamlUri::parse(text : String) -> XamlUri raise ValueError

    Accept text as x:Uri does, or raise ValueError naming x:Uri, the text and the reason .NET gives.

    XamlUri::text

    fn XamlUri::text(self : XamlUri) -> String

    The text as it was given.

    XamlUri::to_string

    fn XamlUri::to_string(self : XamlUri) -> String

    Default implementation for Show::to_string, uses a StringBuilder

    array_extension_type

    The markup extension x:Array, also named x:ArrayExtension.

    array_value

    The value of an x:Array: a handle of type Array in urn:moonrockz:xaml.

    array_value_type

    Array in urn:moonrockz:xaml, the type of the XamlArray values that x:Array gives.

    as_array

    The array in a value that array_value created.

    as_decimal

    The decimal in a value that decimal_value made.

    as_dependency_object

    The dependency object in a value that dependency_object_key wrapped.

    as_enum_value

    The enumeration value in a value that enum_value made.

    as_name_scope

    The scope in a value that name_scope_value created.

    as_time_span

    The time span in a value that time_span_value made.

    as_type_name

    The type name in a value that type_value created.

    as_uri

    The URI in a value that uri_value made.

    bool_conversion

    let bool_conversion : PropertyConversion[Bool]

    x:Boolean for bool_key.

    boolean_type

    x:Boolean, whose values are Bool.

    byte_conversion

    let byte_conversion : PropertyConversion[Byte]

    x:Byte for byte_key.

    byte_type

    x:Byte, whose values are Byte.

    char_conversion

    let char_conversion : PropertyConversion[Char]

    x:Char for char_key. An x:Char is one UTF-16 code unit, and a Char is a whole character. So half of a surrogate pair is no Char, and a character above U+FFFF is no x:Char.

    char_type

    x:Char, whose values are Char: one UTF-16 code unit.

    clr_namespace_uri

    fn clr_namespace_uri(clr_namespace : String, scope : String) -> String

    The URI of a CLR-style namespace in a scope: clr-namespace:N;assembly=S.

    decimal_conversion

    let decimal_conversion : PropertyConversion[XamlDecimal]

    x:Decimal for decimal_value_key.

    decimal_type

    x:Decimal, whose values are handles that decimal_value makes.

    decimal_value

    An x:Decimal value: a handle that compares by numeric value.

    decimal_value_key

    dependency_object_key

    The key of XAML objects that are dependency objects, such as those of XamlTypeDefinition::dependency_objects.

    directive_arguments

    let directive_arguments : String

    directive_initialization

    let directive_initialization : String

    directive_items

    let directive_items : String

    directive_key

    let directive_key : String

    The directive names of the XAML language namespace. _Items, _PositionalParameters and _Initialization carry collection items, positional markup extension parameters and the initialization text of an object, as in System.Xaml.

    directive_name

    let directive_name : String

    directive_positional_parameters

    let directive_positional_parameters : String

    directive_uid

    let directive_uid : String

    directive_unknown_content

    let directive_unknown_content : String

    Content that no member of its object takes, in the order of the document.

    double_conversion

    let double_conversion : PropertyConversion[Double]

    x:Double for double_key.

    double_type

    x:Double, whose values are Double.

    element_collection_type

    ElementCollection in urn:moonrockz:xaml, the type of the collections that element_collection_value gives.

    element_collection_value

    The XAML object of a collection of elements, such as the children of a panel, for the getter of a member of the type element_collection_type. Its items are objects of types with dependency_objects.

    enum_value

    An enumeration value as a XAML value: a handle of the enumeration type that compares by value.

    error_message

    fn error_message(error : Error) -> String

    The message of an error that a registered function raised.

    float_conversion

    let float_conversion : PropertyConversion[Float]

    x:Single for float_key.

    int16_conversion

    let int16_conversion : PropertyConversion[Int16]

    x:Int16 for int16_key.

    int16_type

    x:Int16, whose values are Int16.

    int32_type

    x:Int32, whose values are Int.

    int64_conversion

    let int64_conversion : PropertyConversion[Int64]

    x:Int64 for int64_key.

    int64_type

    x:Int64, whose values are Int64.

    int_conversion

    let int_conversion : PropertyConversion[Int]

    x:Int32 for int_key.

    member_definition_type

    x:Member, the abstract type of the members that x:Members defines.

    moonrockz_namespace

    let moonrockz_namespace : String

    urn:moonrockz:xaml, the namespace of the built-in types that are not XAML language types: TypeValue, Array, ObjectList and NameScope (design D8, D12, D15).

    name_scope_type

    NameScope in urn:moonrockz:xaml, the type of the name scopes that name_scope_value wraps.

    name_scope_value

    fn name_scope_value(scope : NameScope) ->
    XamlValue

    scope as the value of a member, such as a name-scope property.

    normalize_clr_namespace

    fn normalize_clr_namespace(namespace_uri : String, local_scope? : String) -> String raise NamespaceError

    Check a CLR-style namespace URI and apply the local scope (design D11, F28, 2F27). clr-namespace:N and clr-namespace:N;assembly= become clr-namespace:N;assembly=A for the local scope A, as System.Xaml XamlXmlReader maps them to the local assembly; without a local scope they are kept as written. Other URIs, using:N included, are returned unchanged.

    null_extension_type

    The markup extension {x:Null}, also named x:Null.

    null_value_key

    The key with which x:Object converts null to an AnyValue.

    object_list_type

    ObjectList in urn:moonrockz:xaml, a collection of x:Object items: the Items of x:Array, as System.Xaml's ArrayExtension.Items is an IList.

    object_type

    x:Object, the type of every value. Its converter passes values through.

    property_definition_type

    let property_definition_type :
    XamlTypeName

    x:Property, a property that x:Members defines; it derives from x:Member.

    property_path_key

    The key of the values of all types that property_path_type gives. Two values are equal when their paths are.

    property_path_type

    fn property_path_type(namespace_uri : String, name : String, registry? :
    PropertyRegistry
    ) -> XamlTypeDefinition

    A XAML type name of namespace_uri whose values are property paths of registry, as WPF's PropertyPath.

    Types in a path have the prefixes of the document. In (local:Grid.Row) it is a linked type, which has a dependency_owner. In [(x:Int32)1] it is one whose values convert from text and have an any_value_converter, and it converts the text without a context. A saved path names the type that stands for the owner type of the member, and its prefixes are those of the new document.

    reference_type

    The markup extension {x:Reference name}, also named x:ReferenceExtension. Its identity is x:Reference, because System.Xaml's type is System.Windows.Markup.Reference.

    single_type

    x:Single, whose values are Single (MoonBit Float).

    static_extension_type

    The markup extension {x:Static prefix:Type.Member}, also named x:Static.

    string_conversion

    let string_conversion : PropertyConversion[String]

    x:String for string_key.

    string_type

    x:String, whose values are String.

    time_span_conversion

    let time_span_conversion : PropertyConversion[XamlTimeSpan]

    x:TimeSpan for time_span_value_key.

    time_span_type

    x:TimeSpan, whose values are handles that time_span_value makes.

    time_span_value

    An x:TimeSpan value: a handle that compares by ticks.

    time_span_value_key

    type_extension_type

    The markup extension {x:Type TypeName}, also named x:Type.

    type_parameter

    fn type_parameter(name : String) ->
    XamlTypeName

    A reference to the type parameter name of the generic type being registered, for member and base types, such as the T of a member Value of Box(T).

    type_parameter_namespace

    let type_parameter_namespace : String

    The namespace of type parameter references. No type is registered in it.

    type_value

    A type value: a handle of type TypeValue that holds a type name, as {x:Type Name} gives.

    type_value_type

    TypeValue in urn:moonrockz:xaml, the type of resolved type values, which type_value creates. MoonBit has no System.Type, so this type stands for it, outside the XAML language namespaces (design D8, deliberate difference 12).

    uri_conversion

    let uri_conversion : PropertyConversion[XamlUri]

    x:Uri for uri_value_key.

    uri_type

    x:Uri, whose values are handles that uri_value makes.

    uri_value

    An x:Uri value: a handle that compares by text.

    value_type_name

    The XAML type of a value as a converter's source type: the primitive type of a primitive, the type of an object handle, and None for null and lists.

    xaml_language_namespace_2009

    let xaml_language_namespace_2009 : String

    The 2009 XAML language namespace URI. It is a full equivalent of the 2006 URI (@nodes.xaml_language_namespace), which identities use (design D11, F27).

    xaml_object_key

    The key with which x:Object converts an object that has no other conversion to an AnyValue.

    xaml_value_key

    The key for the values of dependency properties that keep XamlValues.

    xml_namespace

    let xml_namespace : String

    The XML namespace, http://www.w3.org/XML/1998/namespace, of xml:lang, xml:space and xml:base. The prefix xml is bound to it in every document.