Struct MethodSemanticsRaw
pub struct MethodSemanticsRaw {
pub rid: u32,
pub token: Token,
pub offset: usize,
pub semantics: u32,
pub method: u32,
pub association: CodedIndex,
}Expand description
Raw representation of a MethodSemantics table entry with unresolved indexes.
This structure represents an unprocessed entry from the MethodSemantics metadata table
(ID 0x18), which specifies the relationship between methods and events or properties.
It contains raw index values that require resolution to actual metadata objects.
§Purpose
The MethodSemantics table defines which methods serve specific semantic roles for
properties and events:
- Property Accessors: Getters, setters, and other property-related methods
- Event Handlers: Add, remove, fire, and other event-related methods
- Runtime Binding: Enables proper method dispatch for property/event operations
- Language Integration: Supports C#, VB.NET, and other language property/event syntax
§Raw vs Owned
This raw variant is used during initial metadata parsing and contains:
- Unresolved Indexes: Table indices requiring lookup in related tables
- Memory Efficiency: Minimal footprint for large-scale parsing operations
- Binary Compatibility: Direct representation of ECMA-335 file format
- Batch Processing: Optimized for processing multiple entries sequentially
Use crate::metadata::tables::methodsemantics::MethodSemantics for resolved references and runtime access.
§Usage Patterns
use dotscope::metadata::tables::methodsemantics::raw::MethodSemanticsRaw;
use dotscope::metadata::tables::MethodSemanticsAttributes;
// Check semantic type
match raw_entry.semantics {
MethodSemanticsAttributes::GETTER => {
println!("Property getter method: {}", raw_entry.method);
}
MethodSemanticsAttributes::ADD_ON => {
println!("Event add method: {}", raw_entry.method);
}
_ => println!("Other semantic type"),
}
// Access coded index for association
println!("Associated with: {:?}", raw_entry.association.tag);§Thread Safety
MethodSemanticsRaw is std::marker::Send and std::marker::Sync as it contains only primitive data types.
Instances can be safely shared across threads and accessed concurrently without synchronization.
§ECMA-335 Reference
Corresponds to ECMA-335 §II.22.28 MethodSemantics table structure.
- ECMA-335 Standard
- Table ID: 0x18
- Purpose: Define semantic relationships between methods and properties/events
Fields§
§rid: u32Row identifier within the MethodSemantics table.
This 1-based index uniquely identifies this entry within the table. Combined with table ID 0x18, forms the metadata token 0x18XXXXXX.
token: TokenMetadata token for this MethodSemantics entry.
Format: 0x18XXXXXX where XXXXXX is the row ID. Used for cross-referencing this entry from other metadata structures.
offset: usizeByte offset of this entry in the original metadata stream.
Points to the start of this entry’s data in the metadata file. Used for debugging and low-level metadata inspection.
semantics: u32Semantic relationship type bitmask.
2-byte value defining the method’s semantic role using MethodSemanticsAttributes:
SETTER(0x0001) - Property setter methodGETTER(0x0002) - Property getter methodOTHER(0x0004) - Other property/event methodADD_ON(0x0008) - Event add methodREMOVE_ON(0x0010) - Event remove methodFIRE(0x0020) - Event fire method
As specified in ECMA-335 §II.23.1.12.
method: u32Raw index into the MethodDef table.
This unresolved index identifies the method that implements the semantic
behavior. Must be resolved using the MethodDef table to get the actual
Method reference.
Index size depends on table size (2 or 4 bytes).
association: CodedIndexRaw HasSemantics coded index.
This coded index identifies the associated property or event that this method provides semantic behavior for. The encoding combines:
- Low 2 bits: Table tag (0=Event, 1=Property)
- High bits: Row index in the target table
Must be resolved using the appropriate table to get the actual type reference.
Implementations§
§impl MethodSemanticsRaw
impl MethodSemanticsRaw
pub fn apply<F>(&self, get_ref: F, methods: &MethodMap) -> Result<()>
pub fn apply<F>(&self, get_ref: F, methods: &MethodMap) -> Result<()>
Applies the semantic relationship directly using raw data.
This method resolves the raw indexes and applies the semantic relationship to the associated property or event without creating an owned instance. It’s more memory-efficient than conversion to owned form when only applying relationships is needed.
§Process
- Resolves the method index to an actual
Methodreference - Resolves the association coded index to a property or event
- Applies the semantic relationship based on the semantics bitmask
- Sets the appropriate method reference on the property/event
§Arguments
get_ref- Closure that resolves coded indices toCilTypeReferencemethods- Map of all parsedMethodDefentries for method resolution
§Errors
- Method token cannot be resolved (invalid index or missing entry)
- Association coded index is malformed or points to invalid entry
- Semantic attributes are invalid or unsupported
- Method is already assigned for this semantic role (duplicate)
- Property/event assignment fails due to type constraints
pub fn to_owned<F>(
&self,
get_ref: F,
methods: &MethodMap,
) -> Result<MethodSemanticsRc>
pub fn to_owned<F>( &self, get_ref: F, methods: &MethodMap, ) -> Result<MethodSemanticsRc>
Converts this raw entry to an owned MethodSemantics with resolved references.
This method performs the conversion from raw indexes to resolved object references,
creating a fully usable MethodSemantics instance with owned data. The resulting
instance contains resolved method and association references for efficient runtime access.
§Arguments
get_ref- Closure that resolves coded indices toCilTypeReferencemethods- Map of all parsedMethodDefentries for method resolution
§Returns
A reference-counted MethodSemanticsRc containing the resolved entry.
§Errors
- Method token cannot be resolved (0x06XXXXXX format expected)
- Method index points to non-existent
MethodDefentry - Association coded index is malformed or invalid
- Association resolves to
CilTypeReference::None - Required dependency data is missing or corrupted
Trait Implementations§
§impl Clone for MethodSemanticsRaw
impl Clone for MethodSemanticsRaw
§fn clone(&self) -> MethodSemanticsRaw
fn clone(&self) -> MethodSemanticsRaw
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for MethodSemanticsRaw
impl Debug for MethodSemanticsRaw
§impl RowReadable for MethodSemanticsRaw
impl RowReadable for MethodSemanticsRaw
§fn row_read(
data: &[u8],
offset: &mut usize,
rid: u32,
sizes: &TableInfoRef,
) -> Result<Self>
fn row_read( data: &[u8], offset: &mut usize, rid: u32, sizes: &TableInfoRef, ) -> Result<Self>
Reads a single MethodSemantics table row from binary data.
Parses the binary representation according to ECMA-335 §II.22.28:
- Semantics (2 bytes): Bitmask of semantic attributes
- Method (2-4 bytes): Index into
MethodDeftable - Association (2-4 bytes):
HasSemanticscoded index
§Arguments
data- Binary data containing the tableoffset- Current read position (updated by this method)rid- Row identifier for this entry (1-based)sizes- Table size information for proper index width calculation
§Returns
Parsed MethodSemanticsRaw instance with populated fields
§Errors
- Insufficient data remaining at offset
- Invalid coded index encoding
- Data corruption or malformed structure
§impl RowWritable for MethodSemanticsRaw
impl RowWritable for MethodSemanticsRaw
§fn row_write(
&self,
data: &mut [u8],
offset: &mut usize,
_rid: u32,
sizes: &TableInfoRef,
) -> Result<()>
fn row_write( &self, data: &mut [u8], offset: &mut usize, _rid: u32, sizes: &TableInfoRef, ) -> Result<()>
Serialize a MethodSemantics table row to binary format
Writes the row data according to ECMA-335 §II.22.28 specification:
semantics: 2-byte bitmask of semantic attributesmethod: MethodDef table index (method implementing the semantic)association:HasSemanticscoded index (property or event)
§Arguments
data- Target buffer for writing binary dataoffset- Current write position (updated after write)rid- Row identifier (unused in this implementation)sizes- Table sizing information for index widths
§Returns
Ok(()) on successful write, error on buffer overflow or encoding failure
§impl TableRow for MethodSemanticsRaw
impl TableRow for MethodSemanticsRaw
§fn row_size(sizes: &TableInfoRef) -> u32
fn row_size(sizes: &TableInfoRef) -> u32
Calculates the byte size of a MethodSemantics table row.
The row size depends on the metadata table sizes and is calculated as:
semantics: 2 bytes (fixed)method: 2 or 4 bytes (depends onMethodDeftable size)association: 2 or 4 bytes (depends onHasSemanticscoded index size)
§Arguments
sizes- Table size information for calculating index widths
§Returns
Total byte size of one table row
Auto Trait Implementations§
impl Freeze for MethodSemanticsRaw
impl RefUnwindSafe for MethodSemanticsRaw
impl Send for MethodSemanticsRaw
impl Sync for MethodSemanticsRaw
impl Unpin for MethodSemanticsRaw
impl UnwindSafe for MethodSemanticsRaw
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more