dotnetdll/resolved/module.rs
1use super::attribute::Attribute;
2use std::borrow::Cow;
3
4/// Represents the identity and metadata of the current module.
5///
6/// Every .NET DLL contains exactly one module (ECMA-335, II.22.30).
7#[derive(Debug, Clone)]
8pub struct Module<'a> {
9 /// All attributes present on the module declaration.
10 pub attributes: Vec<Attribute<'a>>,
11 /// Name of the module (typically the filename of the DLL).
12 pub name: Cow<'a, str>,
13 /// Module version identifier (GUID).
14 pub mvid: [u8; 16],
15}
16impl<'a> Module<'a> {
17 /// Creates a new `Module` with the specified name and default metadata.
18 pub fn new(name: impl Into<Cow<'a, str>>) -> Self {
19 Self {
20 attributes: vec![],
21 name: name.into(),
22 mvid: [0; 16],
23 }
24 }
25}
26
27/// A reference to an external module within the same assembly.
28///
29/// See ECMA-335, II.22.31 (page 237) for more information.
30#[derive(Debug, Clone)]
31pub struct ExternalModuleReference<'a> {
32 /// All attributes present on the module reference.
33 pub attributes: Vec<Attribute<'a>>,
34 /// Name of the external module.
35 pub name: Cow<'a, str>,
36}
37impl<'a> ExternalModuleReference<'a> {
38 /// Creates a new `ExternalModuleReference` with the specified name and default metadata.
39 pub fn new(name: impl Into<Cow<'a, str>>) -> Self {
40 Self {
41 attributes: vec![],
42 name: name.into(),
43 }
44 }
45}
46
47/// A constituent file of the assembly.
48///
49/// See ECMA-335, II.22.19 (page 228) for more information.
50#[derive(Debug, Clone)]
51pub struct File<'a> {
52 /// All attributes present on the file declaration.
53 pub attributes: Vec<Attribute<'a>>,
54 /// If true, the file contains CLI metadata.
55 pub has_metadata: bool,
56 /// Name of the file.
57 pub name: Cow<'a, str>,
58 /// Hash value of the file's content.
59 pub hash_value: Cow<'a, [u8]>,
60}