添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
干练的水煮肉  ·  BigDecimal 类 ...·  1 年前    · 
烦恼的鸵鸟  ·  .NET MVC ...·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I am reading C# code generated by the Microsoft Visual Studio Tools for Office (VSTO) framework, and have run into a case I don't understand. I have simplified it as follows (I have omitted method parameters):

public interface Tools.Factory
    RibbonFactory GetRibbonFactory();   // OK
    AddIn CreateAddIn(...);                                         // Missing
    CustomTaskPaneCollection CreateCustomTaskPaneCollection(...);   // Missing
    SmartTagCollection CreateSmartTagCollection(...);               // Missing
public interface ApplicationFactory : Tools.Factory
    SmartTag CreateSmartTag(...);       // OK
    Action CreateAction(...);           // OK
    Document GetVstoObject(...);        // OK
    bool HasVstoObject(...);            // OK
public ThisAddIn(ApplicationFactory factory, IServiceProvider serviceProvider) : 
        base(factory, serviceProvider, "AddIn", "ThisAddIn")
    Globals.Factory = factory;

The ThisAddIn constructor is code automatically generated by VSTO located in a designer.cs file. It is passed an argument (factory) that implements the ApplicationFactory interface. Using F12, I tracked down the interface as shown. That interface in return inherits the Tools.Factory interface, which I have also listed.

What I don't understand: When I trigger IntelliSense in the editor for the Globals.Factory variable (shown below), I only see five out of the eight methods listed in the two interfaces (commented as OK in the code listing). The implementations of three methods from the Tools.Factory interface are missing (commented as missing in the code listing). Why is this?

Note: The code works fine.

Can you call the methods? There are attributes that allow you to simply hide things from IntelliSense like EditorBrowsable. – Zer0 Mar 7, 2020 at 20:22 @Zer0 You are right! I am able to call the missing methods. Please post as answer and I'll accept. – Sabuncu Mar 7, 2020 at 20:31 @Zer0 In fact, the missing methods are marked [EditorBrowsable(EditorBrowsableState.Never)], which I completely ignored because I have never seen it before. You are a damn genius. :) – Sabuncu Mar 7, 2020 at 20:32

There are attributes such as EditorBrowsable that can hide methods and properties from both the designer and IntelliSense.

In this case the methods mentioned exist and can be called, but are hidden.

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.