Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a transitive reference?

In ReSharper, there is the Architecture View window and in it there is the term of transitive references but it's a little confusing as of what it really means. This blog post from them covers it but in an incomplete manner.

I'm starting to think that this option is solely here for simplifying a solution diagram, is this correct?

If not, can you explain what does transitive reference mean?

like image 507
aybe Avatar asked May 15 '14 19:05

aybe


1 Answers

When ReSharper speaks of a transitive reference, it means a reference to an assembly that is made implicitly by referencing another, intermediary assembly. For example, say I have a project with an assembly "Core.dll". I create a project called "Features.dll" that references Core.dll. This is a direct reference.

Now say I add a test project, Features.Tests.dll. This assembly tests the code in Features.dll, and so has a direct reference to Features.dll. The references then look like this:

Features.Tests.dll -(References)-> Features.dll -(References)-> Core.dll

Each dll directly references the dll it uses. But we can also say that Features.Tests.dll has a "transitive reference" on Core.dll. I.e.:

Features.Tests.dll -(References)-> Core.dll

After all, it can't run if Core.dll isn't present.

When using ReSharper's architecture view, transitive references are hidden by default, firstly to simplify the diagram, but also because the transitive reference is implied - if the diagram shows that Features.Tests.dll references Features.dll, and Features.dll references Core.dll, then it is visually obvious that Features.Tests.dll and Core.dll requires and therefore transitively references Core.dll. You can make the transitive references more visible by enabling the "Show transitive references" button.

One way to remember how transitive references work is to think of maths, e.g. If A > B and B > C, then A > C. The "greater than" is a transitive relation.

like image 195
citizenmatt Avatar answered Sep 20 '22 17:09

citizenmatt