Last post Jun 06, 2015 07:16 PM by gerrylowry
Jun 06, 2015 11:41 AM|TheNutCracker|LINK
When I click "F12" or the more verbose option of "Go To Definition" of a class type to see a classes definition and it's a class created by Microsoft, Visual Studio shows the end developer only the method signatures and not the actual class definitions.
Is it possible for end developers to do the same? Is it simply using one or two attributes on the class? Is it done by defining a class using the partial keyword?
I can see the reason why Microsoft wants to allow us to see only method signatures and not the full class definitions for proprietary software. But I guess my question also might be...are method signatures definable outside a class definition? Or is the
source code for class definitions that Microsoft shows us using metadata simply hiding portions of the class definition? Or can they literally be in separate files, separate class definitions, or can method signatures ever literally be defined on their own?
I remember in the old days, they called them forward references or something of that nature.
Edit: It looks like the attribute "[EditorBrowsable(EditorBrowsableState.Never)]" is what Microsoft is using to hide the actual class definitions leaving only the public properties and method signatures to be seen.
Jun 06, 2015 03:14 PM|gerrylowry|LINK
FWIW, i suspect my remarks to your "Accuracy
of Visual Studio Class Definitions offered up to Developers..." very much applies here.
Microsoft is hiding relatively little this days; again, take a very good look at http://referencesource.microsoft.com/ where you will see how much Microsoft is revealing.
Also, not to you or i, but to select European governments, Microsoft is giving them everything:
if you've got the time and the motivation, with a debugger you can dig very deep into Microsoft's binary code.
Jun 06, 2015 06:40 PM|TheNutCracker|LINK
Thank you again for your post. I just thought of something. Even though forward references have gone the way of the dodo bird, when I think about it, it seems that an actual C# interface serves as a good summary of, at least a subset, of the functionality
of a given class through method signatures alone.
So, in other words, to answer my own question. Yes. method signatures can be defined outside the class that they apply to. In fact, it seems that is really the only place they can exists. Well...other than the "actual" method signature portion of the method
itself. But it doesn't exists alone in that case.
Edit: Maybe if I got straight in my head what "F12" or "Go to Definition" meant then I would be more at peace with what I see. In the Visual Studio sense it appears to mean, "Show me all the public property signatures and method signatures of the class I
am asking to see". Is it appropriate to say that properties have signatures also? Since they don't show the literal getter/setter code for properties either.
Jun 06, 2015 07:16 PM|gerrylowry|LINK
Google and MSDN are your best friends; get to know them well.
Search, for example, msdn C# language reference method signatures
from: https://msdn.microsoft.com/en-us/library/ms173114(v=vs.140).aspx "Methods (C# Programming Guide"
Methods are declared in a class or struct by
specifying ← N.B.
Note: A return type of a method is not part of the signature of the method for the purposes of method overloading.
However, it is part of the signature of the method when determining the compatibility between a delegate and the method that it points to.
These may be your three most important references for c#:
C# Programming Guide
C# Language Specification ... "the
definitive source for C# syntax and usage"
You can download this spec from the Microsoft Download Center. If you've installed Visual Studio 2013, you can also find the spec on your
computer in the Program Files (x86)/Microsoft Visual Studio 12.0/VC#/Specifications/1033 folder. However, installations of Visual Studio Express 2013 don't include this file.