开发者

MonoCecil Type.IsCOMObject equivalent?

开发者 https://www.devze.com 2023-02-27 12:52 出处:网络
I\'d like to make a method that takes a TypeDefinition and tells me if it represents a COM object. The method should also work in the .NET 4.0 \"Embedded COM Interop Types\"case.

I'd like to make a method that takes a TypeDefinition and tells me if it represents a COM object. The method should also work in the .NET 4.0 "Embedded COM Interop Types" case.

Any开发者_Go百科 idea how I could do that?


Maybe something like this:

    public static bool IsCOMObject(TypeDefinition type)
    {
        if (type == null)
            throw new ArgumentNullException("type");

        return (type.Attributes & TypeAttributes.Import) == TypeAttributes.Import;
    }

From official reference here: Common Language Infrastructure (CLI). Partition II: Metadata Definition and Semantics.

10.1 Type header (ClassHeader):

Implementation-specific (Microsoft)

The above grammar also includes ClassAttr ::= import to indicate that the type is imported from a COM type library.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号