1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//! Change tracking infrastructure for CIL assembly modifications.
//!
//! This module provides comprehensive change tracking capabilities for .NET assembly
//! modifications, supporting both metadata table changes and heap additions. It enables
//! efficient sparse modification tracking with minimal memory overhead.
//!
//! # Key Components
//!
//! - [`ChangeRef`] - Universal reference to any modification (heap entry or table row)
//! - [`AssemblyChanges`] - Core change tracking structure for assembly modifications
//! - [`HeapChanges`] - Heap-specific change tracking for metadata heaps
//!
//! # ChangeRef System
//!
//! The [`ChangeRef`] type provides stable references to modifications that survive
//! heap rebuilding and deduplication. Instead of returning raw offsets that become
//! invalid after write, APIs return `Arc<ChangeRef>` which resolves to the final
//! location after assembly write completes.
//!
//! ```rust,ignore
//! // Old API (problematic - offset may be invalid after write)
//! let offset = context.string_add("MyString")?; // u32
//!
//! // New API (stable reference)
//! let string_ref = context.string_add("MyString")?; // Arc<ChangeRef>
//! assembly.to_file(path)?;
//! let final_offset = string_ref.offset().unwrap(); // Resolved after write
//! ```
//!
//! # Architecture
//!
//! The change tracking system is designed around sparse storage principles:
//! - Only modified elements are tracked, not entire data structures
//! - Lazy allocation ensures minimal overhead for read-heavy operations
//! - Changes can be efficiently merged during binary output generation
//! - All four metadata heaps (#Strings, #Blob, #GUID, #US) are fully supported
//! - [`ChangeRef`] provides thread-safe deferred resolution of final locations
//!
//! # Usage Examples
//!
//! ```rust,ignore
//! use crate::cilassembly::changes::{AssemblyChanges, HeapChanges, ChangeRef};
//! use crate::metadata::cilassemblyview::CilAssemblyView;
//! use std::path::Path;
//!
//! # let view = CilAssemblyView::from_path(Path::new("test.dll"))?;
//! // Create change tracker for an assembly
//! let mut changes = AssemblyChanges::new(&view);
//!
//! // Track modifications
//! if changes.has_changes() {
//! println!("Assembly has {} table modifications",
//! changes.modified_table_count());
//! }
//! # Ok::<(), crate::Error>(())
//! ```
//!
//! # Integration
//!
//! This module integrates with:
//! - [`crate::cilassembly::CilAssembly`] - Primary assembly modification interface
//! - [`crate::cilassembly::write`] - Binary output generation system
pub use *;
pub use *;
pub use *;