Assemblies should have the same version
Reports assemblies whose version differs from the one shared by most application assemblies. Double check first whether multiple versions are legitimate — typically when assemblies are not compiled, developed or deployed together.
How to fix
Use System.Reflection.AssemblyVersion in a source file shared by the assemblies, typically generated by a dedicated MSBuild task like: http://www.msbuildextensionpack.com/help/4.0.5.0/html/d6c3b5e8-00d4-c826-1a73-3cfe637f3827.htm. Versioning advices: http://stackoverflow.com/a/3905443/27194
Severity is major: improper versioning can lead to complicated deployment problems.
Severity is major: improper versioning can lead to complicated deployment problems.
CQLinq source
This rule is written in CQLinq, C# LINQ over the NDepend code model. It ships with every new NDepend project: you can read it, adapt it, or use it as a starting point for your own custom rules.
// <Name>Assemblies should have the same version</Name>
// <Id>ND2801:AssembliesShouldHaveTheSameVersion</Id>
warnif count > 0
let versionsLookup = Application.Assemblies.ToLookup(a => a.Version, a=> a)
let mostRepresentedVersion = versionsLookup.OrderByDescending(v => v.Count()).First().Key
from v in versionsLookup
where v.Key != mostRepresentedVersion
from a in v.ToArray()
select new {
a ,
version = v.Key,
mostRepresentedVersion,
Debt = 10.ToMinutes().ToDebt(),
Severity = Severity.Medium
}
//<Expl>
// The *{0}* has version *{1}* while most application assemblies have version *{2}*.
//</Expl>
//<Desc>
// Reports assemblies whose version differs from the one shared by most
// application assemblies. Double check first whether multiple versions are
// legitimate — typically when assemblies are not *compiled, developed or
// deployed* together.
//</Desc>
//<HowToFix>
// Use **System.Reflection.AssemblyVersion** in a source file shared by the
// assemblies, typically generated by a dedicated *MSBuild* task like:
// http://www.msbuildextensionpack.com/help/4.0.5.0/html/d6c3b5e8-00d4-c826-1a73-3cfe637f3827.htm.
// Versioning advices: http://stackoverflow.com/a/3905443/27194
//
// Severity is **major**: improper versioning can lead to complicated
// deployment problems.
//</HowToFix>
Open in the interactive Rules Explorer · All default rules
.NET Framework Usage / System.Reflection: all 3 items
- Mark assemblies with assembly version ND2800
- Assemblies should have the same version ND2801
- Assemblies Referenced in Multiple Versions ND2802