Simplify documentation with inheritance. #4456
-
I like to document my code but I find C# makes me do a lot of work that is repetitive in ways that tend to lead to inconsistency and error. Consider the case where I have classes A, B, C which each declare one method: class A { /// Some documentation /// /// A parameter public virtual int Method (string param1) => 1 } class B : A{ /// The exact same documentation repeated /// /// A parameter public override int Method (string param1) => 1 } class C : A { /// A different method with a new documentation. /// /// A parameter with the same purpose as before public virtual int Method2 (string param1) => 1 } Wouldn't it be much nicer if classes inherited documentation from the parent class for overriden methods in the exact same way that they inherit code? Further, Wouldn't it be a big code improvement win if I could assign a specific documentation line to a parameter name so that it is then reused throughout a project? class B : A{ class C : A { /// A different method with a new documentation. /// /// public virtual int Method2 (string param1) => 1 } This would seem to compliment the recent thrust of C# language extensions to enable repetitive coding to be eliminated. Of course, Sandcastle, would also need to be updated to recognize this stuff... |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
I think you're looking for https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/xmldoc/inheritdoc. |
Beta Was this translation helpful? Give feedback.
I think you're looking for https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/xmldoc/inheritdoc.