Struct AssemblyIdentity
pub struct AssemblyIdentity {
pub name: String,
pub version: AssemblyVersion,
pub culture: Option<String>,
pub strong_name: Option<Identity>,
pub processor_architecture: Option<ProcessorArchitecture>,
}Expand description
Complete identity information for a .NET assembly.
Provides comprehensive identification for .NET assemblies including name, version, culture, strong name, and architecture information. This serves as the primary identifier for assemblies in multi-assembly analysis and cross-assembly resolution.
§Identity Components
- Name: Simple assembly name used for basic identification
- Version: Four-part version for compatibility and binding decisions
- Culture: Localization culture (None for culture-neutral assemblies)
- Strong Name: Cryptographic identity for verification and security
- Architecture: Target processor architecture specification
§Equality Semantics
Important: The strong_name field is excluded from equality
comparison and hashing. This is an intentional design decision that enables:
- Assemblies with different strong name representations (Token vs PubKey vs EcmaKey) to be considered equal for dependency resolution purposes
- Consistent
HashMapbehavior when the same assembly is referenced with different key formats - Matching dependencies by name+version+culture+architecture regardless of how the strong name is stored in metadata
Two AssemblyIdentity instances are equal if and only if their name, version,
culture, and processor_architecture fields are equal. The strong_name field
is ignored in both PartialEq and Hash implementations.
If you need to compare strong names, access the strong_name field directly or use
a custom comparison function.
§Uniqueness
Two assemblies with identical identity components (excluding strong name) are considered the same assembly. The combination of name, version, culture, and architecture provides sufficient uniqueness for practical assembly identification and resolution scenarios.
§Examples
use dotscope::metadata::identity::{AssemblyIdentity, AssemblyVersion};
// Create identity for a simple library
let identity = AssemblyIdentity {
name: "MyLibrary".to_string(),
version: AssemblyVersion::new(1, 0, 0, 0),
culture: None,
strong_name: None,
processor_architecture: None,
};
// Use as key in collections
let mut assembly_map = std::collections::HashMap::new();
let assembly_data = "path/to/assembly.dll";
assembly_map.insert(identity, assembly_data);Fields§
§name: StringSimple assembly name (e.g., “mscorlib”, “System.Core”).
The primary identifier used for basic assembly lookup and display. This name appears in assembly references and is used for file system resolution when no culture or architecture specificity is required.
version: AssemblyVersionFour-part version number for compatibility and binding.
Used by the .NET runtime for version binding decisions, compatibility analysis, and side-by-side deployment scenarios. Version policies can specify exact, minimum, or range-based version requirements.
culture: Option<String>Culture information for localized assemblies.
Specifies the localization culture for satellite assemblies containing
culture-specific resources. None indicates a culture-neutral assembly
that contains the default/fallback resources and executable code.
§Examples
None- Culture-neutral assembly (default)Some("en-US")- US English localized assemblySome("fr-FR")- French (France) localized assembly
strong_name: Option<Identity>Cryptographic strong name identity.
Provides cryptographic verification for assembly integrity and origin. Strong-named assemblies can be stored in the Global Assembly Cache (GAC) and provide security guarantees about assembly authenticity.
Uses the existing cryptographic Identity system for public key
or token-based identification.
processor_architecture: Option<ProcessorArchitecture>Target processor architecture specification.
Indicates the processor architecture for which the assembly was compiled. Used for platform-specific assemblies and deployment scenarios requiring architecture-specific code or optimizations.
Implementations§
§impl AssemblyIdentity
impl AssemblyIdentity
pub fn new(
name: impl Into<String>,
version: AssemblyVersion,
culture: Option<String>,
strong_name: Option<Identity>,
processor_architecture: Option<ProcessorArchitecture>,
) -> Self
pub fn new( name: impl Into<String>, version: AssemblyVersion, culture: Option<String>, strong_name: Option<Identity>, processor_architecture: Option<ProcessorArchitecture>, ) -> Self
Create a new assembly identity with the specified components.
This constructor provides a convenient way to create assembly identities programmatically with all required and optional components.
§Arguments
name- Simple assembly name for identificationversion- Four-part version numberculture- Optional culture for localized assembliesstrong_name- Optional cryptographic identityprocessor_architecture- Optional architecture specification
§Returns
A new AssemblyIdentity with the specified components.
§Examples
use dotscope::metadata::identity::{AssemblyIdentity, AssemblyVersion};
let identity = AssemblyIdentity::new(
"MyLibrary",
AssemblyVersion::new(1, 0, 0, 0),
None,
None,
None,
);pub fn from_assembly_ref(assembly_ref: &AssemblyRef) -> Self
pub fn from_assembly_ref(assembly_ref: &AssemblyRef) -> Self
Create assembly identity from an AssemblyRef table entry.
Extracts complete assembly identity information from a metadata AssemblyRef entry, including version, culture, and strong name data. This is the primary method for creating identities during metadata loading.
§Arguments
assembly_ref- AssemblyRef table entry from metadata
§Returns
Complete AssemblyIdentity derived from the AssemblyRef data.
§Examples
use dotscope::metadata::identity::AssemblyIdentity;
let assembly_ref = // ... loaded from metadata
let identity = AssemblyIdentity::from_assembly_ref(&assembly_ref);pub fn from_assembly(assembly: &Assembly) -> Self
pub fn from_assembly(assembly: &Assembly) -> Self
Create assembly identity from an Assembly table entry.
Extracts complete assembly identity information from a metadata Assembly entry for the current assembly being analyzed.
§Arguments
assembly- Assembly table entry from metadata
§Returns
Complete AssemblyIdentity derived from the Assembly data.
§Examples
use dotscope::metadata::identity::AssemblyIdentity;
let assembly = // ... loaded from metadata
let identity = AssemblyIdentity::from_assembly(&assembly);pub fn parse(display_name: &str) -> Result<Self>
pub fn parse(display_name: &str) -> Result<Self>
Parse assembly identity from display name string.
Parses .NET assembly display names in the standard format used by the .NET runtime and development tools. Supports both simple names and fully-qualified names with version, culture, and public key token.
§Arguments
display_name- Assembly display name string to parse
§Returns
Ok(AssemblyIdentity)- Successfully parsed identityErr(Error)- Parsing failed due to invalid format
§Format
AssemblyName[, Version=Major.Minor.Build.Revision][, Culture=culture][, PublicKeyToken=token]§Examples
use dotscope::metadata::identity::AssemblyIdentity;
// Simple name only
let simple = AssemblyIdentity::parse("MyLibrary")?;
// Full specification
let full = AssemblyIdentity::parse(
"mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
)?;§Errors
Returns an error if the display name cannot be parsed.
pub fn display_name(&self) -> String
pub fn display_name(&self) -> String
Generate display name string for this assembly identity.
Creates a .NET-compatible assembly display name that includes all available identity components. This format is compatible with .NET runtime assembly loading and resolution mechanisms.
§Returns
A formatted display name string suitable for assembly loading.
§Examples
use dotscope::metadata::identity::{AssemblyIdentity, AssemblyVersion};
let identity = AssemblyIdentity::new(
"MyLibrary",
AssemblyVersion::new(1, 2, 3, 4),
Some("en-US".to_string()),
None,
None,
);
let display_name = identity.display_name();
// Result: "MyLibrary, Version=1.2.3.4, Culture=en-US, PublicKeyToken=null"pub fn simple_name(&self) -> &str
pub fn simple_name(&self) -> &str
Get the simple assembly name without version or culture information.
Returns just the primary assembly name component for cases where version and culture information is not needed.
§Returns
The simple assembly name string.
pub fn is_strong_named(&self) -> bool
pub fn is_strong_named(&self) -> bool
Check if this assembly is strong-named.
Strong-named assemblies have cryptographic identity that can be verified and are eligible for Global Assembly Cache (GAC) storage.
§Returns
true if the assembly has a strong name, false otherwise.
pub fn is_culture_neutral(&self) -> bool
pub fn is_culture_neutral(&self) -> bool
Check if this assembly is culture-neutral.
Culture-neutral assemblies contain the default resources and executable code, while culture-specific assemblies contain localized resources.
§Returns
true if the assembly is culture-neutral, false if culture-specific.
pub fn satisfies(&self, required: &AssemblyIdentity) -> bool
pub fn satisfies(&self, required: &AssemblyIdentity) -> bool
Check if this assembly identity satisfies a dependency requirement.
This method determines whether this assembly can be used to satisfy a reference to another assembly. It checks name, culture, and version compatibility according to .NET binding rules.
§Matching Rules
- Name: Must match case-insensitively
- Culture: Must match exactly (None matches None, “en-US” matches “en-US”)
- Version: Must be compatible per
AssemblyVersion::is_compatible_with
§Arguments
required- The assembly identity required by a dependency
§Returns
true if this assembly can satisfy the requirement, false otherwise.
§Examples
use dotscope::metadata::identity::{AssemblyIdentity, AssemblyVersion};
let available = AssemblyIdentity::new(
"System.Core",
AssemblyVersion::new(4, 5, 0, 0),
None,
None,
None,
);
let required = AssemblyIdentity::new(
"System.Core",
AssemblyVersion::new(4, 0, 0, 0),
None,
None,
None,
);
// v4.5 satisfies requirement for v4.0
assert!(available.satisfies(&required));
// But v4.0 does NOT satisfy requirement for v4.5
assert!(!required.satisfies(&available));Trait Implementations§
§impl Clone for AssemblyIdentity
impl Clone for AssemblyIdentity
§fn clone(&self) -> AssemblyIdentity
fn clone(&self) -> AssemblyIdentity
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for AssemblyIdentity
impl Debug for AssemblyIdentity
§impl Display for AssemblyIdentity
impl Display for AssemblyIdentity
impl Eq for AssemblyIdentity
§impl FromStr for AssemblyIdentity
impl FromStr for AssemblyIdentity
§impl Hash for AssemblyIdentity
impl Hash for AssemblyIdentity
§impl PartialEq for AssemblyIdentity
impl PartialEq for AssemblyIdentity
Auto Trait Implementations§
impl Freeze for AssemblyIdentity
impl RefUnwindSafe for AssemblyIdentity
impl Send for AssemblyIdentity
impl Sync for AssemblyIdentity
impl Unpin for AssemblyIdentity
impl UnsafeUnpin for AssemblyIdentity
impl UnwindSafe for AssemblyIdentity
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for T
impl<T> Downcast for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> Scalar for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more