如何正确隐藏智能感知的方法和属性

发布于 2024-09-16 08:05:54 字数 667 浏览 7 评论 0原文

有人知道如何从智能感知中正确隐藏类、方法和属性,同时保留调用它们的能力吗?因此它们不会出现在从类型库生成的互操作程序集中?

我正在为自动化测试编写 API 挂钩,但我们还不想暴露给消费者。这似乎在我们的应用程序附带的内置 SaxBasic 编辑器中运行良好,但在将引用添加到我们的互操作程序集中时无法隐藏对象、方法和属性。

这是我如何尝试隐藏这些的示例;各种排列都试过了,先谢谢了!

    [
    object,
    uuid(guid),
    helpstring("help"),
    version(ver),
    dual,
    nonextensible,
    oleautomation,
    pointer_default(unique)
]IApplication.VisibleObj
interface IObj : IDispatch
{
        //tried [hidden] here, no luck
 [propget, id(91001), helpstring("Help str. Available as of Object Model Version X.X.X."), hidden]//again tried [hidden] here, no luck
    HRESULT Obj([out, retval] IObj** ppObj);
}

Would anyone know how to properly hide classes, methods and properties from intellisense while preserving the ability to call them; and so they do not appear in interop assemblies that are generated from a type library?

I'm writing API hooks for automated testing we don't want exposed to consumers yet. This appears to work well from the built in SaxBasic editor our application comes with, but fails to hide the objects, methods and properties when a reference is added to our interop assembly.

Here's an example of how I'm attempting to hide these; various permutations have been tried, thanks in advance!

    [
    object,
    uuid(guid),
    helpstring("help"),
    version(ver),
    dual,
    nonextensible,
    oleautomation,
    pointer_default(unique)
]IApplication.VisibleObj
interface IObj : IDispatch
{
        //tried [hidden] here, no luck
 [propget, id(91001), helpstring("Help str. Available as of Object Model Version X.X.X."), hidden]//again tried [hidden] here, no luck
    HRESULT Obj([out, retval] IObj** ppObj);
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

哭了丶谁疼 2024-09-23 08:05:54

Visual Studio 2008 和 2010 现在似乎忽略了“隐藏”属性,使原本隐藏的界面变得可浏览。
看来互操作程序集必须通过修饰以下类、方法和属性来修改,这些类、方法和属性旨在存在但不可浏览:

[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]

来源:http://www.summsoft.com/blogs/garyvsta/archive/2009/ 02/06/preserving-hidden-elements-in-a-com-interop- assembly.aspx

It appears Visual Studio 2008 and 2010 now ignore the 'hidden' attribute, making otherwise hidden interfaces browseable.
It appears the interop assembly must be modified by adorning the following over classes, methods and properties that are intended to exist but not be browseable:

[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]

Source: http://www.summsoft.com/blogs/garyvsta/archive/2009/02/06/preserving-hidden-elements-in-a-com-interop-assembly.aspx

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文