1

When I right click on a class (that is part of an third party assembly - not code I have written) in Visual Studio and select "Go to Definition", I can see all the methods, properties etc of the class.

I notice all these are all public and no private(or any other level of access) members are shown.

Does this feature only show public members of the class?

dymanoid
  • 14,771
  • 4
  • 36
  • 64
SE1986
  • 2,534
  • 1
  • 10
  • 29

1 Answers1

3

You can find the answer on the doc page:

When you try to run the Go To Definition or Peek Definition command for types or members that are marked as internal, Visual Studio does not display their metadata as source code, regardless of whether the referencing assembly is a friend or not.

If you want to see the source code of the assembly, you have two options:

  • Use a decompile tool like e.g. ILSpy.
  • In Visual Studio 2017 version 15.6+, you can set an option to see decompiled source code when you view the definition of a type. This feature can be enabled in the Tools > Options > Text Editor > C# > Advanced section.
dymanoid
  • 14,771
  • 4
  • 36
  • 64
  • Whilst the wording of the document only refers to members being marked as `internal` the decompile tool confirms it is those members marked as `interal` or lower – SE1986 May 04 '18 at 09:39
  • 1
    Well, `protected` and `private` are either 'internal' from the assembly point of view. That means, they're (normally) not accessible from the outer world. But you're right, they should have stated it more clearly. – dymanoid May 04 '18 at 09:42