Skip to main content

XamlSourceInfo Class

Definition

Assembly:Avalonia.Markup.Xaml
Package:Avalonia

Represents source location information for an element within a XAML or code file.

public class XamlSourceInfo

Inheritance: object -> XamlSourceInfo

Implements: IEquatable<XamlSourceInfo>

Constructors

NameDescription
XamlSourceInfoInitializes a new instance of the Avalonia.Markup.Xaml.Diagnostics.XamlSourceInfo class with a specified line, column, and file path.

XamlSourceInfo Constructor

Initializes a new instance of the Avalonia.Markup.Xaml.Diagnostics.XamlSourceInfo class with a specified line, column, and file path.

public XamlSourceInfo(int line, int column, string filePath)

Parameters

line int

The line number of the source element.

column int

The column number of the source element.

filePath string

The full path of the source file.

Methods

NameDescription
<Clone>$No summary available.
Equals (2 overloads)No summary available.
GetHashCodeNo summary available.
GetXamlSourceInfo (2 overloads)Retrieves the XAML source information associated with the specified key in the given resource dictionary, if available.
SetXamlSourceInfo (2 overloads)Associates XAML source information with the specified key in the given resource dictionary.
ToStringReturns a string that represents the current Avalonia.Markup.Xaml.Diagnostics.XamlSourceInfo.

<Clone>$ Method

public Avalonia.Markup.Xaml.Diagnostics.XamlSourceInfo <Clone>$()

Returns

Avalonia.Markup.Xaml.Diagnostics.XamlSourceInfo

Equals overloads

Equals Method

public bool Equals(Avalonia.Markup.Xaml.Diagnostics.XamlSourceInfo other)
Parameters

other Avalonia.Markup.Xaml.Diagnostics.XamlSourceInfo

Returns

bool

Equals Method

public bool Equals(object obj)
Parameters

obj object

Returns

bool

GetHashCode Method

public int GetHashCode()

Returns

int

GetXamlSourceInfo overloads

GetXamlSourceInfo Method

Retrieves the XAML source information associated with the specified key in the given resource dictionary, if available.

public Avalonia.Markup.Xaml.Diagnostics.XamlSourceInfo GetXamlSourceInfo(Avalonia.Controls.IResourceDictionary dictionary, object key)
Parameters

dictionary Avalonia.Controls.IResourceDictionary

The resource dictionary associated with the XAML source information.

key object

The key associated with the source info.

Returns

Avalonia.Markup.Xaml.Diagnostics.XamlSourceInfo

A Avalonia.Markup.Xaml.Diagnostics.XamlSourceInfo instance containing the XAML source information for the specified key, or if no source information is available.

GetXamlSourceInfo Method

Retrieves the XAML source information associated with the specified object, if available.

public Avalonia.Markup.Xaml.Diagnostics.XamlSourceInfo GetXamlSourceInfo(object obj)
Parameters

obj object

The object for which to obtain XAML source information. Cannot be null.

Returns

Avalonia.Markup.Xaml.Diagnostics.XamlSourceInfo

A Avalonia.Markup.Xaml.Diagnostics.XamlSourceInfo instance containing the XAML source information for the specified object, or if no source information is available.

SetXamlSourceInfo overloads

SetXamlSourceInfo Method

Associates XAML source information with the specified key in the given resource dictionary.

public void SetXamlSourceInfo(Avalonia.Controls.IResourceDictionary dictionary, object key, Avalonia.Markup.Xaml.Diagnostics.XamlSourceInfo info)
Parameters

dictionary Avalonia.Controls.IResourceDictionary

The resource dictionary to associate with the XAML source information.

key object

The key associated with the source info.

info Avalonia.Markup.Xaml.Diagnostics.XamlSourceInfo

The XAML source information to associate with the object, or null to remove any existing association.

SetXamlSourceInfo Method

Associates XAML source information with the specified object for debugging or diagnostic purposes.

public void SetXamlSourceInfo(object obj, Avalonia.Markup.Xaml.Diagnostics.XamlSourceInfo info)
Parameters

obj object

The object to associate with the XAML source information. Cannot be null.

info Avalonia.Markup.Xaml.Diagnostics.XamlSourceInfo

The XAML source information to associate with the object, or null to remove any existing association.

Remarks

This method is typically used to enable enhanced debugging or diagnostics by tracking the origin of XAML elements at runtime. If the same object is passed multiple times, the most recent source information will overwrite any previous value.

ToString Method

Returns a string that represents the current Avalonia.Markup.Xaml.Diagnostics.XamlSourceInfo.

public string ToString()

Returns

string

A formatted string in the form "FilePath:Line,Column", or "(unknown):Line,Column" if the file path is not set.

Properties

NameDescription
LineNumberGets the 1-based line number in the source file where the element is defined.
LinePositionGets the 1-based column number in the source file where the element is defined.
SourceUriGets the full path of the source file containing the element, or null if unavailable.

LineNumber Property

Gets the 1-based line number in the source file where the element is defined.

public int LineNumber { get; set; }

LinePosition Property

Gets the 1-based column number in the source file where the element is defined.

public int LinePosition { get; set; }

SourceUri Property

Gets the full path of the source file containing the element, or null if unavailable.

public Uri SourceUri { get; set; }