问题描述
这开始作为一种方法找到C ++ / CLI和托管C ++组件,使各阶层内部他们可以测试,以确保所有继承的方法正在重新实现了。我想补充这是构建过程中的步骤,以确保它不会再发生。
This started as a way to find C++/CLI and Managed C++ assemblies so that all classes internal to them could be tested to ensure all inherited methods were being reimplemented. I would like to add this as a build process step to ensure that it never happens again.
在思考这个问题也让我有点好奇,因为这将是有趣的,能够确定使用任何.NET语言。正因为如此,我去一个远一点,比较所有的.NET语言组件。到目前为止,这里是我通过一个小程序,我写了比较类型和属性数据从任何一组.NET程序集通过反射发现:
Thinking about this problem also made me a bit curious as it would be interesting to be able to determine any .NET language used. Because of this, I went a bit further and compared assemblies from all of the .NET languages. So far here is what I've found through a small program I wrote which compares the type and attribute data from any set of .NET assemblies via reflection:
- 在C# - 有AssemblyConfigurationAttribute,具有GuidAttribute
- VB - 有许多额外的我型(前所有MyApplication,MySettings),具有GuidAttibute
- 在F# - 拥有FSharpInterfaceDataVersionAttribute这还指定使用的编译器的版本
- 在C ++(除/ CLR:安全) - 有一堆额外的类型(FrameInfo,的type_info)的
- 在C ++ / CLR:安全 - 似乎也没有独特的反射功能。
有可能是合理的顺序来解析:
It might be reasonable to parse in this order:
- 这是F#,如果它有FSharpInterfaceDataVersionAttribute
- 这是C ++,如果有任何巨大的集合额外类型的,我发现了。
- 这是VB,如果它有我*类型。
- 这是C#,如果它有AssemblyConfigurationAttribute或GuidAttribute
- 这很可能是C ++ / CLR:安全
不过,由于这是一个可怕的黑客,我想检查在这里,以确保有没有可用的另一种选择。
However, as this is a horrible hack, I wanted to check in here to make sure that there wasn't another option available.
推荐答案
检查之类的VB或F#类库引用,似乎是最不可靠的方式做到这一点,但其他人提到,这是一个启发 - 只是像有没有明确的方法来判断哪种语言本机二进制写入(但你几乎可以100%肯定通过启发式)
Checking the references for things like the VB or F# class libraries seems to be the least shaky way to do this, but as others mention, it's a heuristic - just like there's no definitive way to tell which language a native binary is written in (but you can be almost 100% sure by heuristics)
这篇关于是否有可能以确定哪种语言.NET程序集写事后?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!