In my opinion, you are right that <summary> is probably the tag that you will use most often to explain what your method should do. But if your methods have good, useful names, then expect most developers to use this to make some assumptions about how this method should behave. For example, they assume that calling "GetName" probably has no side effects and returns the name of the instance, regardless of what the comments say.
With this in mind, instead of writing paragraphs about what this method should do, I try to focus my comments on any โreceivedโ that I know about, knowing that if someone uses my code and it doesnโt work how they think they need it, the first thing they will do is look at the documentation, hoping for some kind of guidance. Below are a few examples of how I used various tags.
<returns> - Indicate that the return value may be null. Describe the semantic difference between null vs. return string.Empty
<remarks> - great for explaining "gotcha" s, for example. "The reader must be in a ready state, and the cursor is in the right position to start reading. The caller is responsible for closing the reader after this method is completed." I usually add these comments as necessary after a fuss with the API for half an hour before I realize some silly details that were not obvious.
<example> - Good APIs should be easy to use, but sometimes you cannot help them. This is great for providing guidance on how the method should be used (although you cannot guarantee that it will be used). See the example below.
<example> var token = m_caller.GetAuthToken(); var result = m_caller.Call(method, token); </example>
I'm sure there are hundreds of other examples that I could come up with, but I hope this helps you point in the right direction!
source share