MemberInfoExtensions Class
Public extension methods for MemberInfo that provide unified access to fields, properties, and methods.
This utility class simplifies reflection operations by providing a consistent API for accessing member information regardless of whether the member is a field, property, or method. It's designed to work seamlessly with the Immersive Debugger's inspection and tweaking systems.
These extensions are particularly useful for:
Runtime component inspection and modification
Dynamic UI generation for debugging interfaces
Type-safe reflection operations with proper error handling
Integration with AI agents and automated debugging tools
static object GetValue ( this MemberInfo memberInfo,
object instance )
Gets the value of a field or property from the specified instance.
This method provides a unified way to retrieve values from both fields and properties, handling the underlying reflection differences automatically.
ParametersmemberInfoThe MemberInfo representing the field or property to read from
instanceThe object instance to read the value from
ReturnsThe value of the member, or null if the member cannot be read or an error occurs
static void SetValue ( this MemberInfo memberInfo,
object instance,
object value )
Sets the value of a field or property on the specified instance.
This method provides a unified way to modify values for both fields and properties, handling the underlying reflection differences automatically. It's essential for runtime tweaking and dynamic component modification in debugging scenarios.
ParametersmemberInfoThe MemberInfo representing the field or property to write to
instanceThe object instance to modify
valueThe new value to assign to the member
static Type GetDataType ( this MemberInfo memberInfo )
Gets the data type of a field or property.
This method provides a unified way to retrieve the type information from both fields and properties, which is essential for type-safe operations and UI generation.
ParametersmemberInfoThe MemberInfo representing the field or property
ReturnsThe Type of the field or property, or null if the member is not a field or property
static bool IsStatic ( this MemberInfo memberInfo )
Determines whether a field, property, or method is static.
This method provides a unified way to check if a member is static across different member types, which is important for determining how to access the member (instance vs static access).
ParametersmemberInfoThe MemberInfo to check
ReturnsTrue if the member is static, false otherwise
static bool IsPublic ( this MemberInfo memberInfo )
Determines whether a field, property, or method is public.
This method provides a unified way to check accessibility across different member types, which is crucial for filtering members that should be exposed in debugging interfaces.
ParametersmemberInfoThe MemberInfo to check
ReturnsTrue if the member is public, false otherwise
static string BuildSignatureForDebugInspector ( this MemberInfo memberInfo )
Builds a formatted signature string for display in the debug inspector UI.
This method creates human-readable signatures that include access modifiers, types, and member names with HTML formatting for rich text display in debugging interfaces.
ParametersmemberInfoThe MemberInfo to create a signature for
ReturnsA formatted HTML string representing the member signature
static bool IsCompatibleWithDebugInspector ( this MemberInfo memberInfo )
Determines whether a member is compatible with the Immersive Debugger's inspection system.
This method applies comprehensive filtering to determine if a member should be exposed in debugging interfaces. It's a core method used throughout the Immersive Debugger to ensure only appropriate members are shown to users and AI agents.
ParametersmemberInfoThe MemberInfo to check for compatibility
ReturnsTrue if the member is compatible with debug inspection, false otherwise
static bool IsTypeEqual ( this MemberInfo member,
Type type )
Determines whether a field or property has the exact specified type.
This method provides a unified way to check if a member's type matches exactly with a given type, which is useful for type-specific filtering and operations.
ParametersmemberThe MemberInfo to check
typeThe Type to compare against
ReturnsTrue if the member's type exactly matches the specified type, false otherwise
static bool IsBaseTypeEqual ( this MemberInfo member,
Type type )
Determines whether a field or property's base type matches the specified type.
This method checks if the member's type inherits from or has the specified base type, which is useful for inheritance-based filtering and polymorphic operations.
ParametersmemberThe MemberInfo to check
typeThe base Type to compare against
ReturnsTrue if the member's base type matches the specified type, false otherwise
static bool CanBeChanged ( this MemberInfo memberInfo )
Determines whether a member can be modified (is settable).
This method provides a quick way to check if a member supports value modification, which is essential for determining which members can be tweaked in debugging interfaces.
ParametersmemberInfoThe MemberInfo to check
ReturnsTrue if the member is a field or property that can potentially be changed, false otherwise