Table of Contents

Interface ICompareContext

Namespace
NDepend.CodeModel
Assembly
NDepend.API.dll

Represents a diff context of two ICodeBase objects compared, NewerCodeBase and OlderCodeBase. A ICompareContext object can be obtained through the extension method CreateCompareContextWithOlder(ICodeBase, ICodeBase).

public interface ICompareContext
Extension Methods

Properties (3)

ContainsChanges

Returns true if any change is detected between OlderCodeBase and NewerCodeBase.

bool ContainsChanges { get; }

Property Value

bool

NewerCodeBase

Gets the newer version of the code base for this ICompareContext object.

ICodeBase NewerCodeBase { get; }

Property Value

ICodeBase

Remarks

This property getter has a constant time complexity.

See Also

OlderCodeBase

Gets the older version of the code base for this ICompareContext object.

ICodeBase OlderCodeBase { get; }

Property Value

ICodeBase

Remarks

This property getter has a constant time complexity.

See Also

Methods (22)

BecameObsolete(IMember)

Returns true if the member is not tagged with System.ObsoleteAttribute in the older version of the code base, but is tagged as obsolete in the newer version of the code base.

bool BecameObsolete(IMember member)

Parameters

member IMember

The IMember object. A IMember object can be a IType, IMethod or IField object.

Returns

bool

Remarks

This method has a constant time complexity.

Exceptions

ArgumentException

member does not belong to NewerCodeBase nor OlderCodeBase.

See Also

CodeWasChanged(ICodeContainer)

Returns true if the code of this codeContainer object, has been modified.

bool CodeWasChanged(ICodeContainer codeContainer)

Parameters

codeContainer ICodeContainer

The ICodeContainer object. A ICodeContainer object can be a IAssembly, INamespace, IType or IMethod object.

Returns

bool

Remarks

This method has a constant time complexity.

Exceptions

ArgumentException

codeContainer is not NewerCodeBase nor OlderCodeBase not a code element that belong to any of these code base.

See Also

CommentsWereChanged(ICodeContainer)

Returns true if comments of this codeContainer object, have been modified.

bool CommentsWereChanged(ICodeContainer codeContainer)

Parameters

codeContainer ICodeContainer

The ICodeContainer object. A ICodeContainer object can be a IAssembly, INamespace, IType or IMethod object.

Returns

bool

Remarks

So far, comments change is detected only when ICodeContainer.NbLinesOfComment has been changed.
This method has a constant time complexity.

Exceptions

ArgumentException

codeContainer is not NewerCodeBase nor OlderCodeBase not a code element that belong to any of these code base.

See Also

IsInNewerBuild(ICodeElement)

Returns true if the codeElement object is in the newer version of the code base.

bool IsInNewerBuild(ICodeElement codeElement)

Parameters

codeElement ICodeElement

The ICodeElement object.

Returns

bool

Remarks

This method has a constant time complexity.

Exceptions

ArgumentException

codeElement is not NewerCodeBase nor OlderCodeBase not a code element that belong to any of these code base.

See Also

IsInOlderBuild(ICodeElement)

Returns true if the codeElement object is in the older version of the code base.

bool IsInOlderBuild(ICodeElement codeElement)

Parameters

codeElement ICodeElement

The ICodeElement object.

Returns

bool

Remarks

This method has a constant time complexity.

Exceptions

ArgumentException

codeElement is not NewerCodeBase nor OlderCodeBase not a code element that belong to any of these code base.

See Also

IsNotUsedAnymore(ICodeElement)

Returns true if the codeElement object is in a third-party assembly (or is a third-party assembly itself), and if it is used by the older version of the code base, but not by the newer version.

bool IsNotUsedAnymore(ICodeElement codeElement)

Parameters

codeElement ICodeElement

The ICodeElement object. A ICodeElement object can be a IAssembly, INamespace, IType, IMethod or IField object.

Returns

bool

Remarks

This method has a constant time complexity.

Exceptions

ArgumentException

codeElement is not NewerCodeBase nor OlderCodeBase not a code element that belong to any of these code base.

See Also

IsPresentInBothBuilds(ICodeElement)

Returns true if the codeElement object is both in the newer and older versions of the code base.

bool IsPresentInBothBuilds(ICodeElement codeElement)

Parameters

codeElement ICodeElement

The ICodeElement object.

Returns

bool

Remarks

If true is returned, this means that the codeElement has not been added nor removed.
This method has a constant time complexity.

Exceptions

ArgumentException

codeElement is not NewerCodeBase nor OlderCodeBase not a code element that belong to any of these code base.

See Also

IsUsedDifferently(ICodeElementParent)

Returns true if the codeElementParent is a namespace or a type in a third-party assembly (or is a third-party assembly itself) and if some of its children code elements are not used anymore by the newer version of the code base, or are used by the newer version of the code base, but are not used by the older version.

bool IsUsedDifferently(ICodeElementParent codeElementParent)

Parameters

codeElementParent ICodeElementParent

The ICodeElementParent object. A ICodeElementParent object can be a IAssembly, INamespace or IType object.

Returns

bool

Remarks

This method has a constant time complexity.

Exceptions

ArgumentException

codeElementParent is not NewerCodeBase nor OlderCodeBase not a code element that belong to any of these code base.

See Also

IsUsedRecently(ICodeElement)

Returns true if the codeElement object is in a third-party assembly (or is a third-party assembly itself), and if it is used by the newer version of the code base, but not by the older version.

bool IsUsedRecently(ICodeElement codeElement)

Parameters

codeElement ICodeElement

The ICodeElement object. A ICodeElement object can be a IAssembly, INamespace, IType, IMethod or IField object.

Returns

bool

Remarks

This method has a constant time complexity.

Exceptions

ArgumentException

codeElement is not NewerCodeBase nor OlderCodeBase not a code element that belong to any of these code base.

See Also

MeInOtherBuild<T>(T)

Returns the older version of codeElement if IsInNewerBuild(ICodeElement), else return the older version.

T MeInOtherBuild<T>(T codeElement) where T : class, ICodeElement

Parameters

codeElement T

The ICodeElement object.

Returns

T

Type Parameters

T

T is a ICodeElement type.

Remarks

If codeElement has been added in newer build, or removed from older build, this method returns null. This method has a constant time complexity.

Exceptions

ArgumentException

codeElement is not NewerCodeBase nor OlderCodeBase not a code element that belong to any of these code base.

NewerVersion<T>(T)

Returns the newer version of the codeElement object.

T NewerVersion<T>(T codeElement) where T : class, ICodeElement

Parameters

codeElement T

The ICodeElement object.

Returns

T

Type Parameters

T

T is a ICodeElement type.

Remarks

If codeElement is already the newer version, returns the codeElement object.
If codeElement has been removed and has no corresponding newer version, returns null.
This method has a constant time complexity.

Exceptions

ArgumentException

codeElement is not NewerCodeBase nor OlderCodeBase not a code element that belong to any of these code base.

See Also

OlderVersion<T>(T)

Returns the older version of the codeElement object.

T OlderVersion<T>(T codeElement) where T : class, ICodeElement

Parameters

codeElement T

The ICodeElement object.

Returns

T

Type Parameters

T

T is a ICodeElement type.

Remarks

If codeElement is already the older version, returns the codeElement object.
If codeElement has been added and has no corresponding older version, returns null.
This method has a constant time complexity.

Exceptions

ArgumentException

codeElement is not NewerCodeBase nor OlderCodeBase not a code element that belong to any of these code base.

See Also

VisibilityWasChanged(IMember)

Returns true if the visibility of this member has been changed.

bool VisibilityWasChanged(IMember member)

Parameters

member IMember

The IMember object. A IMember object can be a IType, IMethod or IField object.

Returns

bool

Remarks

This method has a constant time complexity.

Exceptions

ArgumentException

member does not belong to NewerCodeBase nor OlderCodeBase.

See Also

WasAdded(ICodeElement)

Returns true if the codeElement object has been added and thus, is not present in the older version of the code base.

bool WasAdded(ICodeElement codeElement)

Parameters

codeElement ICodeElement

The ICodeElement object. A ICodeElement object can be a IAssembly, INamespace, IType, IMethod or IField object.

Returns

bool

Remarks

This method has a constant time complexity.

Exceptions

ArgumentException

codeElement is not NewerCodeBase nor OlderCodeBase not a code element that belong to any of these code base.

See Also

WasAdded(IAbsoluteDirectoryPath)

Returns true if the sourceDirPath has been added since the baseline.

bool WasAdded(IAbsoluteDirectoryPath sourceDirPath)

Parameters

sourceDirPath IAbsoluteDirectoryPath

The absolute directory path that contains some source files.

Returns

bool

Remarks

sourceDirPath can be obtained from ICodeElement.SourceDecls , ISourceDecl.SourceFile.FilePath.ParentDirectoryPath.
This method works even when the path is rebased, thanks to an heuristic.

See Also

WasAdded(IAbsoluteFilePath)

Returns true if the sourceFilePath has been added since the baseline.

bool WasAdded(IAbsoluteFilePath sourceFilePath)

Parameters

sourceFilePath IAbsoluteFilePath

The absolute source file path.

Returns

bool

Remarks

sourceFilePath can be obtained from ICodeElement.SourceDecls , ISourceDecl.SourceFile.FilePath.
This method works even when the path is rebased, thanks to an heuristic.

See Also

WasChanged(ICodeElement)

Returns true if the codeElement object was changed in any way (code change, comment change, visibility change...).

bool WasChanged(ICodeElement codeElement)

Parameters

codeElement ICodeElement

The ICodeElement object.

Returns

bool

Remarks

This method has a constant time complexity.

Exceptions

ArgumentException

codeElement is not NewerCodeBase nor OlderCodeBase not a code element that belong to any of these code base.

See Also

WasChanged(IAbsoluteDirectoryPath)

Returns true if the sourceDirPath contains source files changed, added or removed since the baseline.

bool WasChanged(IAbsoluteDirectoryPath sourceDirPath)

Parameters

sourceDirPath IAbsoluteDirectoryPath

The absolute directory path that contains some source files.

Returns

bool

Remarks

sourceDirPath can be obtained from ICodeElement.SourceDecls , ISourceDecl.SourceFile.FilePath.ParentDirectoryPath.
This method works even when the path is rebased, thanks to an heuristic.

See Also

WasChanged(IAbsoluteFilePath)

Returns true if the sourceFilePath content is different between the older and the newer build.

bool WasChanged(IAbsoluteFilePath sourceFilePath)

Parameters

sourceFilePath IAbsoluteFilePath

The absolute source file path.

Returns

bool

Remarks

sourceFilePath can be obtained from ICodeElement.SourceDecls , ISourceDecl.SourceFile.FilePath.
If only some formatting have been changed within the source file without touching any code behavior, the source file is seen as changed while no code element declared within the source file is seen as changed.
This method works even when the path is rebased, thanks to an heuristic.

See Also

WasRemoved(ICodeElement)

Returns true if the codeElement object has been removed and thus, is not present in the newer version of the code base.

bool WasRemoved(ICodeElement codeElement)

Parameters

codeElement ICodeElement

The ICodeElement object. A ICodeElement object can be a IAssembly, INamespace, IType, IMethod or IField object.

Returns

bool

Remarks

This method has a constant time complexity.

Exceptions

ArgumentException

codeElement is not NewerCodeBase nor OlderCodeBase not a code element that belong to any of these code base.

See Also

WasRemoved(IAbsoluteDirectoryPath)

Returns true if the sourceDirPath has been removed since the baseline.

bool WasRemoved(IAbsoluteDirectoryPath sourceDirPath)

Parameters

sourceDirPath IAbsoluteDirectoryPath

The absolute directory path that contains some source files.

Returns

bool

Remarks

sourceDirPath can be obtained from ICodeElement.SourceDecls , ISourceDecl.SourceFile.FilePath.ParentDirectoryPath.
The code element from which the sourceDirPath is obtained must be obtained from OlderCodeBase.
This method works even when the path is rebased, thanks to an heuristic.

See Also

WasRemoved(IAbsoluteFilePath)

Returns true if the sourceFilePath has been removed since the baseline.

bool WasRemoved(IAbsoluteFilePath sourceFilePath)

Parameters

sourceFilePath IAbsoluteFilePath

The absolute source file path.

Returns

bool

Remarks

sourceFilePath can be obtained from ICodeElement.SourceDecls , ISourceDecl.SourceFile.FilePath.
The code element from which the sourceFilePath is obtained must be obtained from OlderCodeBase.
This method works even when the path is rebased, thanks to an heuristic.

See Also

See Also