Граф зависимостей проектов Visual Studio

Проверьте, пожалуйста, пример ниже, super работает как ожидалось. Используя несколько трюков, даже instanceof работает (большую часть времени):

// base class
class A {  
  foo() {
    console.log(`from A -> inside instance of A: ${this instanceof A}`);
  }
}

// B mixin, will need a wrapper over it to be used
const B = (B) => class extends B {
  foo() {
    if (super.foo) super.foo(); // mixins don't know who is super, guard against not having the method
    console.log(`from B -> inside instance of B: ${this instanceof B}`);
  }
};

// C mixin, will need a wrapper over it to be used
const C = (C) => class extends C {
  foo() {
    if (super.foo) super.foo(); // mixins don't know who is super, guard against not having the method
    console.log(`from C -> inside instance of C: ${this instanceof C}`);
  }
};

// D class, extends A, B and C, preserving composition and super method
class D extends C(B(A)) {  
  foo() {
    super.foo();
    console.log(`from D -> inside instance of D: ${this instanceof D}`);
  }
}

// E class, extends A and C
class E extends C(A) {
  foo() {
    super.foo();
    console.log(`from E -> inside instance of E: ${this instanceof E}`);
  }
}

// F class, extends B only
class F extends B(Object) {
  foo() {
    super.foo();
    console.log(`from F -> inside instance of F: ${this instanceof F}`);
  }
}

// G class, C wrap to be used with new decorator, pretty format
class G extends C(Object) {}

const inst1 = new D(),
      inst2 = new E(),
      inst3 = new F(),
      inst4 = new G(),
      inst5 = new (B(Object)); // instance only B, ugly format

console.log(`Test D: extends A, B, C -> outside instance of D: ${inst1 instanceof D}`);
inst1.foo();
console.log('-');
console.log(`Test E: extends A, C -> outside instance of E: ${inst2 instanceof E}`);
inst2.foo();
console.log('-');
console.log(`Test F: extends B -> outside instance of F: ${inst3 instanceof F}`);
inst3.foo();
console.log('-');
console.log(`Test G: wraper to use C alone with "new" decorator, pretty format -> outside instance of G: ${inst4 instanceof G}`);
inst4.foo();
console.log('-');
console.log(`Test B alone, ugly format "new (B(Object))" -> outside instance of B: ${inst5 instanceof B}, this one fails`);
inst5.foo();

Выведет

Test D: extends A, B, C -> outside instance of D: true
from A -> inside instance of A: true
from B -> inside instance of B: true
from C -> inside instance of C: true
from D -> inside instance of D: true
-
Test E: extends A, C -> outside instance of E: true
from A -> inside instance of A: true
from C -> inside instance of C: true
from E -> inside instance of E: true
-
Test F: extends B -> outside instance of F: true
from B -> inside instance of B: true
from F -> inside instance of F: true
-
Test G: wraper to use C alone with "new" decorator, pretty format -> outside instance of G: true
from C -> inside instance of C: true
-
Test B alone, ugly format "new (B(Object))" -> outside instance of B: false, this one fails
from B -> inside instance of B: true

Ссылка на скрипку вокруг

115
задан GregD 28 February 2009 в 15:21
поделиться

6 ответов

Вы попробовали NDepend? Это будет показывать Вам зависимости, и можно также проанализировать удобство использования классов и методов.

Их веб-сайт:

http://ndepend.com

39
ответ дан Eriawan Kusumawardhono 5 November 2019 в 09:05
поделиться

VS 2019 переименовал модуль графа зависимостей к Кодированной карте

здесь, является официальной документацией: https://docs.microsoft.com/en-us/visualstudio/modeling/map-dependencies-across-your-solutions? view=vs-2019

1
ответ дан 24 November 2019 в 01:53
поделиться

Если вам просто нужен граф зависимостей, я обнаружил, что это один из самых простых способов его получить:

Dependency Analyzer

3
ответ дан 24 November 2019 в 01:53
поделиться

В VS 2010 Ultimate вы можете создать граф зависимостей ваших проектов. Architecture Explorer позволяет просматривать ваше решение, выбирать проекты и связи, которые вы хотите визуализировать, а затем создавать граф зависимостей на основе выбранных объектов.

Для получения дополнительной информации см. следующие темы:

Как: Генерировать графические документы из кода: http://msdn.microsoft.com/en-us/library/dd409453%28VS.100%29.aspx#SeeSpecificSource

Как: Поиск кода с помощью Architecture Explorer: http://msdn.microsoft.com/en-us/library/dd409431%28VS.100%29.aspx

RC download: http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=457bab91-5eb2-4b36-b0f4-d6f34683c62a.

Visual Studio 2010 Architectural Discovery & Modeling Tools форум: http://social.msdn.microsoft.com/Forums/en-US/vsarch/threads

8
ответ дан 24 November 2019 в 01:53
поделиться

Вы можете создать красивый график ссылок в ваших проектах. Я описал, как я это сделал, в своем блоге http://www.mellekoning.nl/index.php/2010/03/11/project-references-in-ddd/

3
ответ дан 24 November 2019 в 01:53
поделиться

Вы можете легко получить граф зависимостей проекта с помощью Visual Studio 2010 Ultimate, отсканируйте это видео до 5 минут, чтобы увидеть, как: http://www.lovettsoftware.com/blogengine.net/post/2010/05 /27/Architecture-Explorer.aspx

В Visual Studio 2010 Ultimate: Архитектура | Сгенерировать график зависимостей | По сборке.

31
ответ дан 24 November 2019 в 01:53
поделиться