简体   繁体   English

.net-如何从Visual Studio的IntelliSense中隐藏类库(dll)的方法/属性?

[英].net - How do I hide methods/properties of my class-library (dll) from Visual Studio's IntelliSense?

I am writing my first class-library in VB.NET. 我正在VB.NET中编写我的第一个类库。 My idea is to distribute this library so others may use it in their applications. 我的想法是分发此库,以便其他人可以在其应用程序中使用它。

However, perhaps due to my lack of experience in writing and structuring the library and the classes therein, I noted that the methods/properties are ALL being shown in the IntelliSense of Visual Studio. 但是,可能由于我缺乏编写和构造库及其中的类的经验,我注意到方法/属性全部在Visual Studio的IntelliSense中显示。

The thing is that many of them are only used within the library itself and should NOT be used by the developers (could create a disaster) when they incorporate my library in their application - only a few should be visibile ie the ones which are needed by the developer. 问题是,它们中的许多仅在库本身中使用,而当开发人员将我的库合并到应用程序中时,它们不应被开发人员使用(可能会造成灾难)-只有少数是可见的,即那些需要的库开发人员。

Thus, my question is: is there a way to hide certain methods/properties of my library from Visual Studio's IntelliSense? 因此,我的问题是:有没有一种方法可以从Visual Studio的IntelliSense隐藏我的库的某些方法/属性? Maybe something similar to REM? 也许类似于REM?

Thanks in advance. 提前致谢。

EDIT: as mentioned - this is my first library and I now understand that my question could be intepreted in two ways: 编辑:如前所述-这是我的第一个库,现在我可以用两种方式理解我的问题:

1) how to hide something from IntelliSense 1)如何从IntelliSense隐藏某些内容

2) how to prevent a developer from using and calling certain methods/properties 2)如何防止开发人员使用和调用某些方法/属性

Of course, the end-result that I want is that the developer is not able to access AT ALL certain methods/properties ie No. 2 above. 当然,我想要的最终结果是开发人员无法访问某些方法/属性,即上面的第2条。

Many thanks. 非常感谢。 I just learnt something new today and I will now study Access Levels... 我今天刚刚学到新东西,现在我将学习访问级别...

Only the types/methods/properties you want to be visible should be declared Public . 仅将要显示的类型/方法/属性声明为Public The rest should be declared Private , Protected , Friend or Protected Friend . 其余应声明为“ Private ,“ Protected ,“ Friend或“ Protected Friend

You can read more about these access levels on the MSDN web page for them . 您可以在MSDN网页上了解有关它们的更多信息 In general you should usually only make things as public as they really need to be. 通常,您通常应该使事情像真正需要的那样公开。

You need to change their access modifiers to something other than Public. 您需要将其访问修饰符更改为Public以外的其他内容。 If they are just used within a given class, make them Private Sub XYZ(). 如果仅在给定的类中使用它们,则将它们设置为Private Sub XYZ()。 If they need to be accessed by other classes in the same assembly, make them Friend Sub XYZ(), etc. 如果需要由同一程序集中的其他类访问它们,请将它们设置为Friend Sub XYZ()等。

http://msdn.microsoft.com/en-us/library/76453kax.aspx http://msdn.microsoft.com/zh-CN/library/76453kax.aspx

For reference: http://www.fmsinc.com/free/NewTips/NET/NETtip23.asp 供参考: http : //www.fmsinc.com/free/NewTips/NET/NETtip23.asp

[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
public void myHiddenMethod() {
}

If you want to hide them then add a filterpriority tag to the XML comment of the function with the value 3 如果要隐藏它们,则将filterpriority标记添加到值为3的函数的XML注释中。

''' <summary>
''' </summary>
''' <filterpriority>3</filterpriority>
''' <remarks></remarks>
Sub DontShowMe()

End Sub

This will hide it by default in intellisense. 默认情况下,它将在智能感知中将其隐藏。 You can also control the placement in the Common/All tab with the values 1/2 respectively. 您也可以在“通用/所有”选项卡中分别使用值1/2控制放置。

Blog Post on the subject: http://www.lostechies.com/blogs/sdorman/archive/2009/01/10/xml-comments-filterpriority.aspx 关于该主题的博客文章: http : //www.lostechies.com/blogs/sdorman/archive/2009/01/10/xml-comments-filterpriority.aspx

There's an attribute which you can apply to your code, meta data which will encurage Visual Studio to hide code. 有一个属性可以应用到您的代码中,即元数据,它将确保Visual Studio隐藏代码。 This code can still be called and I'd recommend against it, but if you really need it, just add: 仍然可以调用此代码,我建议您反对,但是如果您确实需要它,只需添加:

What Andrew Hare said...

...to your code. ...到您的代码。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 对于我在 Visual Studio 2013 中的类库项目; 使用后期构建事件如何将创建的 dll 复制到另一个路径? - For my class Library project in visual Studio 2013 ; Using post build event how do I copy the created dll to another path? 如何在 Visual Studio 2017 中为 Python 应用程序启用我自己的 .Net 库的智能感知? - How to enable Intellisense of my own .Net library for a Python application in Visual Studio 2017? 如何在 Visual Studio 2010 中构建不依赖于 .NET 4 SDK DLL/库文件的可执行文件? - How do I build an executable file in visual studio 2010 that doesn't rely on the .NET 4 SDK DLL/Library files? 如何获取Visual Studio Intellisense工具提示以显示.NET Framework 3.5的说明? - How do I get Visual Studio Intellisense tooltips to show descriptions for .NET Framework 3.5? 如何从类库dll中提供log4net? - How do I make log4net available from a class library dll? 如何在 Visual Studio 中从我的 .NET 框架项目中定位 .NET 标准 2.0? - How do I target .NET Standard 2.0 from my .NET Framework project in Visual Studio? 如何在 IntelliSense 中隐藏公共方法 - How to hide public methods from IntelliSense 有没有办法只在Visual Studio的Intellisense中查看对象的实例方法? - Is there a way to view only the instance methods of an object in Visual Studio's Intellisense? 如何将属性选项卡添加到 Visual Studio 2019 中的 class 库项目? - How to add the properties tab to a class library project in Visual Studio 2019? 在.Net中,如何使用intellisense提示装饰类? - In .Net, how do I decorate a class with an intellisense tip?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM