Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ XR Studio

attribute

  • Last UpdatedOct 07, 2026
  • 2 minute read

The attribute class in the XRS system provides a metadata annotation mechanism for classes and methods. Attributes allow developers to attach declarative information to code elements that can be queried and used at runtime for reflection, code generation, testing, and framework integration.

The attribute system enables:

• Declarative Metadata: Attach named attributes with key-value parameters to classes and methods

• Runtime Reflection: Query and enumerate attributes on classes and methods dynamically

• Parameter Access: Retrieve attribute parameters as a dictionary of string key-value pairs

• Framework Integration: Support for test frameworks, code coverage, and custom annotations

Usage

Defining Attributes in XRS Scripts.

// Class-level attribute

[TestClass(category="unit", priority="high")]

class MyTestClass {

// Method-level attribute

[TestMethod(description="Tests addition", timeout="5000")]

void TestAddition() {

// method implementation

}

[TestMethod(description="Tests subtraction")]

void TestSubtraction() {

// method implementation

}

}

Runtime Reflection API

The XRS Runtime provides comprehensive reflection functions in the Runtime::Reflection namespace.

Enumerate Classes by Attribute.

// Find all classes with a specific attribute

list<string> testClasses = Runtime::Reflection->EnumerateClassesForAttribute("TestClass");

Enumerate Methods by Attribute

// Find all methods with a specific attribute

list<string> testMethods = Runtime::Reflection->EnumerateMethodsForAttribute("TestMethod");

// Find methods for a specific attribute in SScript objects

list<string> sscriptMethods = Runtime::Reflection->EnumerateSScriptMethodsForAttribute("TestMethod");

Get Attribute parameters

// Get parameters for a class attribute

dict<string,string> params = Runtime::Reflection->GetParametersForAttribute("MyTestClass", "TestClass");

string category = params["category"]; // "unit"

string priority = params["priority"]; // "high"

// Get parameters for a method attribute

dict<string,string> methodParams = Runtime::Reflection->GetParametersForAttribute(

"MyTestClass.TestAddition",

"TestMethod"

);

string description = methodParams["description"]; // "Tests addition"

string timeout = methodParams["timeout"]; // "5000"

Get All Attributes for an Element

// Get all attributes on a class

list<string> classAttributes = Runtime::Reflection->GetAttributesForClass("MyTestClass");

// Get all attributes on a method

list<string> methodAttributes = Runtime::Reflection->GetAttributesForMethod("MyObject.MyMethod");

In This Topic
Related Links