Reputation: 5384
Visual Studio 2017 C#
In writing code, I find it very useful to right-click on a system element and select "Go To Definition". This very neatly shows the element's properties and methods with the leading "..." being nicely expandable to give a full text definition of the immediately following property/method.
How could I duplicate this help function for my own code? In particular, I wish to condense a leading descriptions into "..." prior to the following property/method.
TIA
Example display on "Inkcanvas[metadata]":
Upvotes: 2
Views: 229
Reputation: 135
When you select Go To Definition
, Visual Studio will show metadata if it couldn't find the source code. And the expandable "..." only appear in metadata viewer.
To achieve something like this, let's say we have a library containing the following code:
namespace Library
{
public class MyClass
{
public void MyMethod() { }
}
}
1. Add some documentation for it:
namespace Library
{
/// <summary>
/// Documentation for MyClass
/// </summary>
public class MyClass
{
/// <summary>
/// Documentation for MyMethod
/// </summary>
/// <param name="parameter">Parameter decription</param>
public void MyMethod(int parameter) { }
}
}
2. Then go to Project Properties
-> Build
and check XML documentation file
.
3. Compile the library.
4. In another solution, add reference for the compiled Library
.
5. Write some code using class from Library
:
namespace UseTheLibrary
{
class Program
{
static void Main(string[] args)
{
new MyClass().MyMethod(0);
}
}
}
6. Now use the Go To Definition
.
And you can see "..." in the metadata viewer.
Of course expandable:
Upvotes: 1
Reputation: 760
Go to definition
will navigate to the source file for that symbol. If you want just the metadata view, then you can reference the project's DLL in another project (in a solution where you don't have this one opened), and it will show you just the metadata since you can't see the source code as you only have the DLL....
part
Upvotes: 2