English 中文(简体)
Building CQL in NDepend for verifying MVVM patterns
原标题:

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

最佳回答

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

问题回答

暂无回答




相关问题
Choosing the right subclass to instantiate programmatically

Ok, the context is some serialization / deserialization code that will parse a byte stream into an object representation that s easier to work with (and vice-versa). Here s a simplified example ...

Design pattern for managing queues and stacks?

Is there a design pattern for managing a queue or a stack? For example, we are looking to manage a list of tasks. These tasks will be added to a group queue, users will then be able to pull off the ...

Organizing classes using the repository design pattern

I have started upgrading one of our internal software applications, written in ASP.NET Web Forms, and moving to ASP.NET MVC. I am trying to leverage the Repository design pattern for my classes, ...

Misuse of Observer Pattern?

I have a Car object which contains a latitude field and a longitude field. I use the observer pattern so that any time either of these fields change in my application, my car object is notified. I ...

How are Models (in MVC) and DAOs supposed to interact?

How are models and DAOs supposed to interact? I m in the process of putting together a simple login module and I m unsure where to put the "business logic." If I put the logic with the data in the ...

热门标签