Pergunta

I wanted to verify few design patterns in C# code by static analysis. I want to verify these using NDepend. The application is built with MVVM design style, so typical design patterns that I would like to verify are: 1. View-Model classes do not have any DependencyProperties (WPF elements), they should only be seen in View layer. 2. The View layer should not implement IDisposable etc

I have tried building queries in CQL to capture these details, but failed as I need to verify which level a class belongs to and also the properties of it. I understand nested query is not supported by CQL yet, so is there any way I can capture these details by NDepend? I am hoping I can somehow capture the results of multiple queries and perform intersection of them?

Thanks in advance, Shaun

Foi útil?

Solução

The easiest way to get a CQLinq rule that warns if A is using B (A and B can be Assembly/ Namespace/ Type/ Method/ Field) is to view A and B in the Dependency Matrix, and to Generate a code rule that warns if this dependency exists:

Generate a code rule that warns if this dependency exists

...and as a result, the following rule is generated:

Code rule genetaed

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top