Struct ValidationConfig
pub struct ValidationConfig {
pub enable_structural_validation: bool,
pub enable_cross_table_validation: bool,
pub enable_field_layout_validation: bool,
pub enable_type_system_validation: bool,
pub enable_semantic_validation: bool,
pub enable_method_validation: bool,
pub enable_token_validation: bool,
pub max_nesting_depth: usize,
}Expand description
Configuration for controlling validation behavior and performance. Configuration for metadata validation during assembly loading.
Controls the depth and scope of validation performed during .NET assembly loading. The loading process already performs essential structural validation (token format, table structure, heap references, signature format, basic type references). This configuration controls additional semantic validation that requires cross-table analysis.
§Design Philosophy
The validation system is designed with performance in mind:
- Basic structural validation is always recommended
- Expensive semantic validations can be selectively disabled
- Configuration presets provide common validation scenarios
- Fine-grained control allows optimization for specific use cases
§Validation Layers
- Structural: Token integrity, heap references (fast)
- Cross-table: Reference consistency between tables (moderate)
- Semantic: ECMA-335 compliance, logical consistency (variable)
- Type system: Inheritance, generics, constraints (expensive)
§Thread Safety
This struct is Copy and all fields are simple values, making it inherently
thread-safe for concurrent use across multiple assembly loading operations.
Fields§
§enable_structural_validation: boolEnable basic structural validation during table loading (recommended: always true) Note: Most structural validation is done during loading; this adds extra safety checks
enable_cross_table_validation: boolEnable expensive cross-table validation after loading (can be disabled for performance) Validates semantic consistency across metadata tables
enable_field_layout_validation: boolEnable field layout validation (overlap detection, offset validation) Only useful for types with explicit layout; detects problematic overlaps
enable_type_system_validation: boolEnable type system validation (inheritance chains, generic constraints) Validates logical consistency of type hierarchies and generic constraints
enable_semantic_validation: boolEnable semantic validation (method consistency, access modifiers, abstract/concrete rules) Validates logical consistency of type and method semantics
enable_method_validation: boolEnable method validation (constructor rules, virtual method consistency) Validates method-specific semantic rules
enable_token_validation: boolEnable token validation (cross-reference consistency, token relationship validation) Validates token references and relationships beyond basic loading
max_nesting_depth: usizeMaximum nesting depth for nested classes (default: 64)
Implementations§
§impl ValidationConfig
impl ValidationConfig
pub fn disabled() -> Self
pub fn disabled() -> Self
Creates a disabled validation configuration for maximum performance.
⚠️ Warning: This disables ALL validation checks, including basic structural validation. Use only when you absolutely trust the assembly format and need maximum performance. Malformed assemblies may cause panics or undefined behavior.
§Use Cases
- Parsing known-good assemblies in performance-critical loops
- Bulk processing of trusted assembly collections
- Scenarios where external validation has already been performed
§Risks
- No protection against malformed metadata
- Potential for crashes on invalid data
- Silent acceptance of ECMA-335 violations
pub fn minimal() -> Self
pub fn minimal() -> Self
Creates a minimal validation configuration for maximum performance.
Enables only essential structural validation while disabling expensive semantic checks. Provides a good balance between safety and performance for most use cases.
§What’s Validated
- Basic token format and resolution
- Table structure integrity
- Heap reference validity
- Signature format correctness
§What’s Skipped
- Cross-table relationship validation
- Type system consistency checks
- Semantic rule enforcement
- Method signature validation
pub fn comprehensive() -> Self
pub fn comprehensive() -> Self
Creates a comprehensive validation configuration for maximum safety.
Enables all validation features to catch every possible metadata issue. Recommended for development, testing, and scenarios where correctness is more important than performance.
Note: May be slow for large assemblies with complex type hierarchies.
pub fn production() -> Self
pub fn production() -> Self
Creates a validation configuration suitable for production use.
This configuration mirrors the validation performed by the .NET runtime, focusing on checks that would cause actual runtime failures. Based on analysis of CoreCLR and runtime source code.
§Validation Profile
- Structural: ✅ Essential for basic safety
- Cross-table: ✅ Runtime validates cross-references
- Field layout: ❌ Runtime handles layout validation differently
- Type system: ❌ Runtime validates lazily during type loading
- Semantic: ✅ Runtime enforces ECMA-335 semantic rules
- Method: ✅ Runtime enforces method constraints
- Token: ❌ Runtime validates only critical token references
This provides excellent runtime compatibility while maintaining good performance.
pub fn strict() -> Self
pub fn strict() -> Self
Creates a validation configuration with all checks enabled.
Similar to comprehensive() but with explicit emphasis
on strictness. All validation categories are enabled with maximum sensitivity.
⚠️ Warning: Field layout validation may produce false positives on legitimate overlapping fields (unions, explicit layout structs). Review results carefully when working with low-level interop types.
Trait Implementations§
§impl Clone for ValidationConfig
impl Clone for ValidationConfig
§fn clone(&self) -> ValidationConfig
fn clone(&self) -> ValidationConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for ValidationConfig
impl Debug for ValidationConfig
§impl Default for ValidationConfig
impl Default for ValidationConfig
§impl PartialEq for ValidationConfig
impl PartialEq for ValidationConfig
impl Copy for ValidationConfig
impl Eq for ValidationConfig
impl StructuralPartialEq for ValidationConfig
Auto Trait Implementations§
impl Freeze for ValidationConfig
impl RefUnwindSafe for ValidationConfig
impl Send for ValidationConfig
impl Sync for ValidationConfig
impl Unpin for ValidationConfig
impl UnwindSafe for ValidationConfig
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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