Is it possible to mark a module function as “hidden” from Intellisense detection?

As an answer to this question, I wonder if it is possible to mark the F # function in a module (presumably through an attribute) as “hidden” from Intellisense. To repeat, I have some functions that are marked inline , but are implemented in terms of other functions that I really do not want to disclose. Therefore, although the implementation functions must be publicly available (since they are built-in), I remember that in the past I came across C # methods that were hidden from Visual Studio Intellisense, but compiled just fine if you knew what they were, but I don’t remember the exact method and are not sure if this is some special thing in Visual Studio or a useful function, for example DebuggerBrowsable(DebuggerBrowsableState.Never) .

Update: I tried applying EditorBrowsable(EditorBrowsableState.Never) , but it does not work in Visual F # projects.

+6
source share
2 answers

I tried to do this recently and I am sure that F # ignores the EditorBrowsable attribute.

The only way to make the declaration disappear from IntelliSense is to use ObsoleteAttribute , but it also means that you will get a warning when you really use this function. This is a bit unsuccessful, but it may be nice if you use this function only from some implementation file, where you can disable the warning:

Single file ad:

 module Internal = [<System.ObsoleteAttribute>] let foo = 10 

An implementation file that disables warnings and uses foo :

 // Disable 'obsolete' warning #nowarn "44" // 'Internal' is empty (and is not shown in the completion list) Internal.foo 

The attribute can be applied to modules, functions and types, so it is quite flexible.

+5
source

You can use [EditorBrowsable(EditorBrowsableState.Never)] , but this will only work for clients of your assembly that are not part of the same solution (for example, import your class library as an assembly, not as a project.) Projects in that the same solution will still show the methods in Intellisense.

+2
source

Source: https://habr.com/ru/post/891677/


All Articles