Skip to main content

AssemblyIdentity

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 HashMap behavior 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: String

Simple 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: AssemblyVersion

Four-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 assembly
  • Some("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

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 identification
  • version - Four-part version number
  • culture - Optional culture for localized assemblies
  • strong_name - Optional cryptographic identity
  • processor_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

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

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>

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 identity
  • Err(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

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

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

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

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

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
  1. Name: Must match case-insensitively
  2. Culture: Must match exactly (None matches None, “en-US” matches “en-US”)
  3. 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

§

fn clone(&self) -> AssemblyIdentity

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for AssemblyIdentity

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
§

impl Display for AssemblyIdentity

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Format assembly identity as display name.

Delegates to the display_name() method for consistent formatting.

§

impl Eq for AssemblyIdentity

§

impl FromStr for AssemblyIdentity

§

type Err = Error

The associated error which can be returned from parsing.
§

fn from_str(s: &str) -> Result<Self>

Parses a string s to return a value of this type. Read more
§

impl Hash for AssemblyIdentity

§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
§

impl PartialEq for AssemblyIdentity

§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AsAny for T
where T: Any,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Source§

fn type_name(&self) -> &'static str

Gets the type name of self
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast for T
where T: AsAny + ?Sized,

Source§

fn is<T>(&self) -> bool
where T: AsAny,

Returns true if the boxed type is the same as T. Read more
Source§

fn downcast_ref<T>(&self) -> Option<&T>
where T: AsAny,

Forward to the method defined on the type Any.
Source§

fn downcast_mut<T>(&mut self) -> Option<&mut T>
where T: AsAny,

Forward to the method defined on the type Any.
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, A> IntoAst<A> for T
where T: Into<A>, A: Ast,

Source§

fn into_ast(self, _a: &A) -> A

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,

Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToCompactString for T
where T: Display,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> TryClone for T
where T: Clone,

Source§

fn try_clone(&self) -> Result<T, Error>

Clones self, possibly returning an error.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more