Can I add links in comments to a code block in Visual studio ?
For example:
// block 1
class class1
{
}
// block 2
class class2
{
// review [___class1]
}
[___class1] is a link for class1
Thanks in advance.
Can I add links in comments to a code block in Visual studio ?
For example:
// block 1
class class1
{
}
// block 2
class class2
{
// review [___class1]
}
[___class1] is a link for class1
Thanks in advance.
It depends what you want - you can just add a URL and VS will turn it into a link automatically within the code view.
Whether this is translated into a link when you generate the documentation will depend on what tool you use for that.
EDIT: Okay, it's possible that I missed your meaning. It's not terribly clear exactly what you're trying to do.
If you want to provide some example code, you can use the example
tag:
/// <example>
/// Foo f = new Foo();
/// </example>
Is that what you meant?
You can't link to a particular block of code, but you can link to a member or type, for example:
/// <remarks>
/// You can use the <see cref="DoSomething" /> method to do something similar.
/// </remarks>
You can always put links in comments (since they are simply text, like the rest of the file).
It depends on the IDE how these will be displayed - Visual Studio will make it a clickable hyperlink.
Edit:
If you want to reference other sections of your code from comments, there is no current support in visual studio for this. The closest you can get is with code documentation comments using a referntial tag such as see
, this will still not produce a hyperlink in the IDE.
You can bookmark your code in Visual Studio, but that's stored in your user options file and isn't normally checked into source control. I don't know of a way to link to portions of code from other portions of code.
Your best bet might be to use document comments and a <see>
tag:
/// <see cref="Fully.Qualified.Type.Name"/>
But that's going to be limited to fully qualified locations, i.e. types, methods, fields, and properties. A particular block (say, an if
statement within a method) is right out, and it'll only link the documentation for that method/whatever to another documentation section, and then only if you generate the documentation using a tool like Sandcastle.
One other thing you might consider, and this is a very bad hack, is to use file hyperlinks, like so:
// file://c:/code/file.cs
There are caveats: