是否有任何工具可以检查从其他命名空间对 C# 内部成员的访问?
我有两个松散耦合的组件A和B。每个组件都是一组 C# 类型。其中许多类型是内部的。所有组件都将一起编译到同一个程序集中并位于同一个项目中。
事实上,B 依赖于 A,反之亦然,可以使用新的 VS2010 功能 图层图。但似乎没有办法检查B是否没有接触A的内部部分。
我无法将组件分成不同的程序集并让编译器为我检查这一点,因为那样就会有太多的程序集,而且我必须对它们进行 IL 合并,这就是我不想付出的代价。
我正在寻找解决这个问题的工具。我需要一些工具,可以将我所认为的组件的描述作为输入,并验证组件之间的任何依赖关系,它们都不会触及彼此的内部内容。
我听说 PostSharp 可以通过将某些属性应用于内部类型来执行类似的操作。在编织阶段,PostSharp 验证没有从不同名称空间访问这些类型。这对我来说就足够了,但我不记得属性名称,也找不到它。
谁能提醒我 PostSharp 中的属性名称或提出任何其他工具?
I have two loosely coupled components A and B. Each component is a set of C# types. Many of those types are internal. All components are to be compiled together into the same assembly and sit in the same project.
The fact that B is dependent on A and not vice-versa can be checked with the new VS2010 feature layer diagram. But it seems there is no way to check that B is not touching internal parts of A.
I cannot separate components into different assemblies and make compiler to check this for me, because then there would have to be too many assemblies, and I would have to IL-merge them, and that is the price I don't want to pay.
I'm looking for some instrumental solution for this problem. I need some tool that could take description of what I consider components as input and verify that whatever dependencies between components there are they do not touch each other internal stuff.
I've heard that PostSharp could do something like that by applying some attribute to internal types. On the weaving stage PostSharp verifies that there is no acces to those types from different namespaces. That would be enough for me, but I don't remember attribute name and couldn't find it.
Can anyone remind me the attribute name in PostSharp or come up with any other tool?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议您使用 Doxygen,它将使用 Graphviz 生成必要的图表并显示关系。
I recommend use you use Doxygen, which will use Graphviz to generate the necessary diagrams and show the relationships.