Interface IAssembly
Represents an application assembly, or a third-party assembly used by one or several application assemblies.
public interface IAssembly : ICodeElementParent, ICodeContainer, IUser, IAttributeTarget, ICodeElement, IUsed
- Inherited Members
- Extension Methods
Properties (22)
Abstractness
Gets a float numeric nullable value in the range [0,1] assessing the ratio of the number of internal abstract types (i.e abstract classes and interfaces) to the number of internal types.
float? Abstractness { get; }
Property Value
- float?
null if this assembly is a third-party assembly.
Otherwise returns this assembly Abstractness numeric value.
Remarks
Abstractness=0 indicates a completely concrete assembly and Abstractness=1 indicates a completely abstract assembly.
More information concerning the usefulness of this code metric is available in the descripion of the NormDistFromMainSeq code metric.
Availability:
A null numeric value is returned for any third-party assembly.
AssembliesUsed
Gets a sequence of assemblies that this assembly is using. If this assembly is a third-party assembly, gets an empty sequence.
IEnumerable<IAssembly> AssembliesUsed { get; }
Property Value
Remarks
This property getter has a O(this.AssembliesUsed.Count) time complexity.
AssembliesUsingMe
Gets a sequence of assemblies that are using this assembly.
IEnumerable<IAssembly> AssembliesUsingMe { get; }
Property Value
Remarks
This property getter has a O(this.AssembliesUsingMe.Count) time complexity.
AssemblyReferences
Get the list of assemblies referenced by this assembly.
IReadOnlyList<IAssemblyReference> AssemblyReferences { get; }
Property Value
Remarks
Unlike AssembliesUsed this returns simple IAssemblyReference with only name and version. Also for third-party assemblies resolved AssembliesUsed is empty but not this list.
CompanyName
Get the string value of the attribute System.Reflection.AssemblyCompanyAttribute, or empty string if this assembly hasn't such attribute.
string CompanyName { get; }
Property Value
ContainsNamespaceDependencyCycle
Gets a value indicating whether this application assembly contains a dependency cycle between its ChildNamespaces. Gets null if this assembly is a third-party assembly.
bool? ContainsNamespaceDependencyCycle { get; }
Property Value
- bool?
Remarks
The result of this property getter is lazy computed.
The first time it is called it has a O(this.ChildNamespaces.Count ^2) time complexity.
Further calls result in a constant time complexity.
DistFromMainSeq
Gets a float numeric nullable value equals to NormDistFromMainSeq / Sqrt(2), assessing the balance between Abstractness and Instability for this assembly. A returned value close to 0 indicates an ideal balance.
float? DistFromMainSeq { get; }
Property Value
- float?
null if this assembly is a third-party assembly.
Otherwise returns this assembly DistFromMainSeq numeric value.
Remarks
More information concerning the usefulness of this code metric is available in the descripion of the NormDistFromMainSeq code metric.
FilePath
Gets this assembly main module file path, found during analysis.
IAbsoluteFilePath FilePath { get; }
Property Value
Remarks
The returned reference is null if the assembly IsThirdPartyInferredFromRef is true. In such case the third-party assembly hasn't been found and has been inferred from references.
FileVersion
Gets the assembly file version, the version specified with the System.Reflection.AssemblyFileVersionAttribute attribute.
Version FileVersion { get; }
Property Value
Remarks
If the file version is not specified, the version "0.0.0.0" will be returned.
Instability
Gets a float numeric nullable value in the range [0,1] assessing an value of the assembly's resilience to change..
float? Instability { get; }
Property Value
- float?
null if this assembly is a third-party assembly.
Otherwise returns this assembly Instability numeric value.
Remarks
The Instability value for an assembly is equal to the ratio of the incoming coupling (NbTypesUsingMe) to the total coupling (NbTypesUsingMe + NbTypesUsed).
This metric is an indicator of the assembly's resilience to change.
The range for this metric is 0 to 1, with Instability=0 indicating a completely stable package and Instability=1 indicating a completely instable package.
More information concerning the usefulness of this code metric is available in the descripion of the NormDistFromMainSeq code metric.
NbNamespaces
Gets the number of namespaces declared in this assembly. Gets null if this assembly is a third-party assembly.
ushort? NbNamespaces { get; }
Property Value
NbTypes
Gets the number of types declared in this assembly. Gets null if this assembly is a third-party assembly.
uint? NbTypes { get; }
Property Value
- uint?
NbTypesUsed
Gets a numeric nullable value counting types outside this assembly used by child types of this assembly. Third-party types are taken account in this cout.
uint? NbTypesUsed { get; }
Property Value
- uint?
null if this assembly is a third-party assembly.
Otherwise returns this assembly NbTypesUsed numeric value.
Remarks
More information concerning the usefulness of this code metric is available in the descripions of the NormDistFromMainSeq and RelationalCohesion code metrics.
s
NbTypesUsingMe
Gets a numeric nullable value counting types outside this assembly using a child type of this assembly.
uint? NbTypesUsingMe { get; }
Property Value
- uint?
null if this assembly is a third-party assembly.
Otherwise returns this assembly NbTypesUsingMe numeric value.
Remarks
More information concerning the usefulness of this code metric is available in the descripions of the NormDistFromMainSeq and RelationalCohesion code metrics.
NormDistFromMainSeq
Gets a float numeric nullable value in the range [0,1] assessing the balance between Abstractness and Instability for this assembly. A returned value close to 0 indicates an ideal balance.
float? NormDistFromMainSeq { get; }
Property Value
- float?
null if this assembly is a third-party assembly.
Otherwise returns this assembly NormDistFromMainSeq numeric value.
Remarks
By measuring coupling between types of your application, NDepend assesses the stability of each assembly.
An assembly is considered stable if its child types are used by a lot of types of others application assemblies (i.e stable = painful to modify).
If an assembly contains many abstract types (i.e interfaces and abstract classes) and few concrete types, it is considered as abstract.
Thus, NDepend helps you detect which assemblies are potentially painful to maintain (i.e concrete and stable) and which assemblies are potentially useless (i.e abstract and instable).
This theory and metrics have been first introduced by the excellent book Agile Software Development: Principles, Patterns, and Practices in C#, Robert C. Martin (Prentice Hall PTR, 2006).
Distance from main Sequence definition:
It represents the perpendicular normalized distance of an assembly from the idealized line A + I = 1. A stands for Abstractness and I for Instability. This line is called main sequence.
This metric is an indicator of the assembly's balance between abstractness and instability. An assembly squarely on the main sequence is optimally balanced with respect to its abstractness and stability.
Ideal assemblies are either completely abstract and stable (I=0, A=1) or completely concrete and instable (I=1, A=0).
The range for this NormDistFromMainSeq metric is 0 to 1, with D=0 indicating an assembly that is coincident with the main sequence and D=1 indicating an assembly that is as far from the main sequence as possible.
A picture provided within the NDepend report reveals if an assembly is in the zone of pain (I and A both close to 0) or in the zone of uselessness (I and A both close to 1).
Recommendations:
Assemblies where NormDistFromMainSeq is higher than 0.7 might be problematic. However, in the real world it is very hard to avoid such assemblies.
Therefore, you should allow just a few of your application assemblies to violate this 0.7 threshold.
PDBFound
Gets a boolean value that indicates if the PDB file for this assembly has been found at analysis time.
bool PDBFound { get; }
Property Value
PublicKeyToken
Get the hexadecimal upper string value of the PublicKeyToken, or empty string if this assembly is not signed.
string PublicKeyToken { get; }
Property Value
RelationalCohesion
Gets a float numeric nullable value assessing this assembly child types average cohesion.
float? RelationalCohesion { get; }
Property Value
- float?
null if this assembly is a third-party assembly.
Otherwise returns this assembly RelationalCohesion numeric value.
Remarks
Let R be the number of types relationships that are internal to this assembly (i.e that do not connect to types outside the assembly).
Let N be the number of types within the assembly.
H = (R + 1)/ N. The extra 1 in the formula prevents H=0 when N=1.
The relational cohesion represents the relationship that this assembly has to all its types.
Recommendations:
As classes inside an assembly should be strongly related, the cohesion should be high. On the other hand, too high values may indicate over-coupling.
A good range for RelationalCohesion is 1.5 to 4.0.
Hence, assemblies where RelationalCohesion < 1.5 or RelationalCohesion > 4.0 might be problematic.
TargetFrameworkName
Gets the target framework name (TFM) of the assembly.
string TargetFrameworkName { get; }
Property Value
Remarks
Returns a string such as 'net5.0', 'net5.0-windows', 'netcoreapp3.1', 'netstandard2.0', 'net462', 'net4x'.
Related documentation: https://github.com/dotnet/designs/blob/main/accepted/2020/net5/net5.md
The string "Not available" is returned for third-party assemblies. This is because the NDepend third-party assemblies resolution logic can differ in some situations from the CLR resolution logic and the value returned could be wrong.
TargetPlatform
Gets the target platform of the assembly (Any CPU, x86, x64...).
string TargetPlatform { get; }
Property Value
Version
Gets the assembly version, the version specified with the System.Reflection.AssemblyVersionAttribute attribute.
Version Version { get; }
Property Value
Remarks
If the version is not specified, the version "0.0.0.0" will be returned.
VisualStudioProjectFilePath
Gets this assembly corresponding Visual Studio project file path, if found at analysis-time, otherwise gets null.
IAbsoluteFilePath VisualStudioProjectFilePath { get; }
Property Value
Remarks
NDepend uses an heuristic to try to infer the Visual Studio project file corresponding to this assembly.
This facility is only supported for C# project so far.