Glossary / Assembly metadata

Assembly metadata

Assembly metadata describes a compiled .NET assembly, including its identity, referenced assemblies, types, version attributes, culture, and custom attributes. The CLR and tooling use this metadata for loading, reflection, binding, diagnostics, and package/API inspection; assembly version is distinct from package version and file version.

Identity and attributes

An assembly has a name and may include version, culture, and public key identity. SDK-style projects generate common assembly attributes from MSBuild properties, while AssemblyInfo.cs can define custom metadata. Duplicate generated and hand-authored attributes cause compiler errors unless generation is disabled or configured. AssemblyVersion, FileVersion, and InformationalVersion serve different purposes: binding identity, file properties, and human/package-facing version labels.

Metadata can include TargetFrameworkAttribute, nullable metadata, InternalsVisibleTo, and custom attributes. Reflection reads metadata at runtime, but trimming can remove unused code and affect reflective discovery. Strong naming signs assembly identity with a key; it is not equivalent to publisher trust or package provenance.

Engineering guidance

Centralize version and metadata in project/Directory.Build files, avoid duplicated attributes, and define versioning policy for libraries. Inspect output assemblies when build properties or source generators affect metadata. Keep informational version and source revision useful for diagnostics without embedding secrets.

Interview questions

  1. AssemblyVersion vs FileVersion? Assembly identity/binding version versus file informational property used by OS tools.
  2. What is InformationalVersion? Human/package-facing version string, often including prerelease or source revision.
  3. Why duplicate attributes fail? SDK-generated and source declarations both emit the same metadata.
  4. Does assembly metadata equal NuGet package metadata? Related but distinct; package manifest and assembly attributes have separate roles.
  5. What uses metadata? CLR loading, reflection, compilers, debuggers, and deployment tooling.

References