Skip to content
This repository has been archived by the owner on Oct 6, 2023. It is now read-only.

Property backing fields

Kalle Jillheden edited this page Jan 10, 2021 · 1 revision

Specifying a <property> element should be enough to target a backing field, but if for some reason that is not enough you can in addition target the backing field separately.

namespace MyAssembly {
    public class MyClass {
        public int MyProperty1 { get; set; }
        public int MyProperty2 { get; set; }
    }
}
<linker>
    <assembly fullname="MyAssembly">
        <type fullname="MyAssembly.MyClass">
            <!-- the name of a backing field is "<PropertyName>k_BackingField" -->
            <field name="&lt;MyProperty1&gt;k_BackingField" />
            <field signature="System.Int32 &lt;MyProperty2&gt;k_BackingField" />
        </type>
    </assembly>
</linker>

Since link.xml uses XML syntax, we must escape the < symbols as &lt; and > symbols as &gt;.

Unlike traditional HTML with its large range of character entity references, in XML there are only five predefined character entity references. These are used to escape characters that are markup sensitive in certain contexts:

  • &amp;& (ampersand, U+0026)
  • &lt;< (less-than sign, U+003C)
  • &gt;> (greater-than sign, U+003E)
  • &quot;" (quotation mark, U+0022)
  • &apos;' (apostrophe, U+0027)

https://en.wikipedia.org/wiki/Character_encodings_in_HTML#XML_character_references