Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The Mysterious "usage" Tag in Visual Studio Documentation XML Comment Tags

I often use XML documentation to document my classes, methods and properties but take a look at this method from Microsoft:

enter image description here

Usage? What kind of sorcery is this? How does one emulate this wizardry?

There's no such thing in the source code, I checked (.Net 4.5). There's no xmldoc tag for it either, it isn't supposed to exist and yet it shows up in the tooltip.

I noticed it a while back but haven't had time to investigate so now I had and I wasted at least an hour trying to figure it out in vain.

It's a nice thing because it shows up in tooltips. We do have the <example> tag but that's not it, this is a different beast entirely.

like image 668
bokibeg Avatar asked Nov 29 '25 16:11

bokibeg


1 Answers

All I can find is the <code> element, but it doesn't provide such neat output as one at the image.

It looks like it's hardcoded to Task static methods somewhere inside the Visual Studio: reference code and github do not contain such xml comments, and I didn't find any other methods with such Usage thing, even the async ones.

Maybe it's a part of Visual Studio support for async/await syntax, notifying the developer to not forget to await the created task.

Update: I think that this is a Visual Studio behavior. Consider such code:

public static Task<int> TestMethod1()
{
    return Task.FromResult(9);
}

public static async Task<int> TestMethod2()
{
    return await Task.FromResult(9);
}

Usage for TestMethod1

Usage for TestMethod2

Both of such methods will get the Usage section in pop-up, without any xml comments. So this is a reminder for developer to not forget to await the Tasks.

like image 98
VMAtm Avatar answered Dec 02 '25 05:12

VMAtm



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!