Search code examples
c#xmldocumentationxml-documentationcode-documentation

How to properly specify on code-documentation a function may return null on C#?


I'm creating some code-documentation and I want to properly display that the function may return null if the resource isn't found.

Dummy method with some code-documentation I created, having GhostDoc auto generated documentation as a base:

///<summary>Gets something for the specified unique identifier.</summary>
///<param name="id">Something's unique identifier.</param>
///<returns>Something if found; otherwise <c>null</c>.</returns>
private Something GetSomethingById(int id)
{ }

I'm currently using the XML tag < c > around Null but I wanted to know if that's the best/correct way.


Solution

  • For future reference, after some digging into Microsoft code, i.e., decompiling some DLLs, I found they are using the following standard: <paramref name="sourceTimeZone" /> is <see langword="null" />.

    The example was extracted from the System.TimeZoneInfo.

    Don't know if this was what @Ian was referencing on his comment.