S3904 — Assemblies should have version information

Language
C#
Type
Code smell
Severity
Critical
Tags
pitfall

Why is this an issue?

The AssemblyVersion attribute is used to specify the version number of an assembly. An assembly is a compiled unit of code, which can be marked with a version number by applying the attribute to an assembly’s source code file.

The AssemblyVersion attribute is useful for many reasons:

If no AssemblyVersion is provided, the same default version will be used for every build. Since the version number is used by .NET Framework to uniquely identify an assembly, this can lead to broken dependencies.

How to fix it

Code examples

Noncompliant code example


using System.Reflection;

[assembly: AssemblyTitle("MyAssembly")] // Noncompliant
namespace MyLibrary
{
    // ...
}

Compliant solution


using System.Reflection;

[assembly: AssemblyTitle("MyAssembly")]
[assembly: AssemblyVersion("42.1.125.0")]
namespace MyLibrary
{
    // ...
}

Resources

Documentation

↑ Back to top