Skip to content

Commit 5cf34d9

Browse files
committed
clean up recommended tags
final draft of recommended tags
1 parent 82bfdff commit 5cf34d9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1674
-1913
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,4 @@ ehthumbs_vista.db
4949
# Ionide folder, used in F# for VSCode
5050
.ionide/
5151
docs/core/extensions/snippets/workers/cloud-service/Properties/PublishProfiles/cloudworker.pubxml
52+
docs/csharp/language-reference/xmldoc/snippets/xmldoc/xmldoc.xml

docs/csharp/language-reference/xmldoc/examples.md

Lines changed: 281 additions & 34 deletions
Large diffs are not rendered by default.

docs/csharp/language-reference/xmldoc/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "XML documentation comments - document APIs using /// comments"
33
description: Learn about XML documentation comments. You can create documentation for your code by including XML elements in special comment fields. You can use other tools to build documentation layouts from comments.
4-
ms.date: 06/167/2021
4+
ms.date: 06/17/2021
55
f1_keywords:
66
- "cs.xml"
77
helpviewer_keywords:
@@ -99,7 +99,7 @@ The use of XML doc comments requires delimiters that indicate where a documentat
9999
```
100100
<!-- markdownlint-enable MD010 -->
101101

102-
To refer to XML elements (for example, your function processes specific XML elements that you want to describe in an XML documentation comment), you can use the standard quoting mechanism (`<` and `>`). To refer to generic identifiers in code reference (`cref`) elements, you can use either the escape characters (for example, `cref="List&lt;T&gt;"`) or braces (`cref="List{T}"`). As a special case, the compiler parses the braces as angle brackets to make the documentation comment less cumbersome to author when referring to generic identifiers.
102+
To refer to XML elements (for example, your function processes specific XML elements that you want to describe in an XML documentation comment), you can use the standard quoting mechanism (`&lt;` and `&gt;`). To refer to generic identifiers in code reference (`cref`) elements, you can use either the escape characters (for example, `cref="List&lt;T&gt;"`) or braces (`cref="List{T}"`). As a special case, the compiler parses the braces as angle brackets to make the documentation comment less cumbersome to author when referring to generic identifiers.
103103

104104
> [!NOTE]
105105
> The XML documentation comments are not metadata; they are not included in the compiled assembly and therefore they are not accessible through reflection.

docs/csharp/language-reference/xmldoc/recommended-tags.md

Lines changed: 141 additions & 311 deletions
Large diffs are not rendered by default.
Lines changed: 347 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,347 @@
1+
using System;
2+
3+
//-----------------------------------------------------------------------------
4+
namespace XmlTags
5+
{
6+
//<SummaryTag>
7+
public class TestClass
8+
{
9+
/// <summary>DoWork is a method in the TestClass class.
10+
/// <para>
11+
/// Here's how you could make a second paragraph in a description.
12+
/// <see cref="System.Console.WriteLine(System.String)"/> for information about output statements.
13+
/// </para>
14+
/// <seealso cref="TestClass.Main"/>
15+
/// </summary>
16+
public static void DoWork(int Int1)
17+
{
18+
}
19+
}
20+
//</SummaryTag>
21+
22+
//<RemarksTag>
23+
/// <summary>
24+
/// You may have some primary information about this class.
25+
/// </summary>
26+
/// <remarks>
27+
/// You may have some additional information about this class.
28+
/// </remarks>
29+
public class AnotherClass
30+
{
31+
}
32+
//</RemarksTag>
33+
34+
public class TagsAndTags
35+
{
36+
//<ReturnsTag>
37+
/// <returns>Returns zero.</returns>
38+
public static int GetZero()
39+
{
40+
return 0;
41+
}
42+
//</ReturnsTag>
43+
}
44+
45+
public class ParamsAndParamRefs
46+
{
47+
//<ParamTag>
48+
// Single parameter.
49+
/// <param name="Int1">Used to indicate status.</param>
50+
public static void DoWork(int Int1)
51+
{
52+
}
53+
54+
// Multiple parameters.
55+
/// <param name="Int1">Used to indicate status.</param>
56+
/// <param name="Float1">Used to specify context.</param>
57+
public static void DoWork(int Int1, float Float1)
58+
{
59+
}
60+
//</ParamTag>
61+
62+
//<ParamRefTag>
63+
/// <summary>DoMoreWork is a method in the TestClass class.
64+
/// The <paramref name="int1"/> parameter takes a number.
65+
/// </summary>
66+
public static void DoMoreWork(int int1)
67+
{
68+
}
69+
//</ParamRefTag>
70+
71+
//<ExceptionTag>
72+
/// <exception cref="System.Exception">Thrown when...</exception>
73+
public void DoSomething()
74+
{
75+
try
76+
{
77+
}
78+
catch (InvalidOperationException)
79+
{
80+
}
81+
}
82+
//</ExceptionTag>
83+
84+
//<TypeParamTags>
85+
/// <summary>
86+
/// Creates a new array of arbitrary type <typeparamref name="T"/>
87+
/// </summary>
88+
/// <typeparam name="T">The element type of the array</typeparam>
89+
public static T[] mkArray<T>(int n)
90+
{
91+
return new T[n];
92+
}
93+
//</TypeParamTags>
94+
95+
//<IncludeTag>
96+
/// <include file='xml_include_tag.xml' path='MyDocs/MyMembers[@name="test"]/*' />
97+
class Test
98+
{
99+
static void Main()
100+
{
101+
}
102+
}
103+
104+
/// <include file='xml_include_tag.xml' path='MyDocs/MyMembers[@name="test2"]/*' />
105+
class Test2
106+
{
107+
public void Test()
108+
{
109+
}
110+
}
111+
//</IncludeTag>
112+
113+
//<cTag>
114+
/// <summary><c>DoAdditionalWork</c> is a method in the <c>TestClass</c> class.
115+
/// </summary>
116+
public static void DoAdditionalWork(int Int1)
117+
{
118+
}
119+
//</cTag>
120+
121+
//<ListTag>
122+
/// <summary>Here is an example of a bulleted list:
123+
/// <list type="bullet">
124+
/// <item>
125+
/// <description>Item 1.</description>
126+
/// </item>
127+
/// <item>
128+
/// <description>Item 2.</description>
129+
/// </item>
130+
/// </list>
131+
/// </summary>
132+
static void BulletListMethod()
133+
{
134+
}
135+
//</ListTag>
136+
137+
// <PermissionTag>
138+
/// <permission cref="System.Security.PermissionSet">Everyone can access this method.</permission>
139+
public static void Priviledged()
140+
{
141+
}
142+
// </PermissionTag>
143+
144+
}
145+
146+
//<ValueTag>
147+
public class Employee
148+
{
149+
private string _name;
150+
151+
/// <summary>The Name property represents the employee's name.</summary>
152+
/// <value>The Name property gets/sets the value of the string field, _name.</value>
153+
154+
public string Name
155+
{
156+
get
157+
{
158+
return _name;
159+
}
160+
set
161+
{
162+
_name = value;
163+
}
164+
}
165+
}
166+
//</ValueTag>
167+
}
168+
169+
// <SeeExample>
170+
/// <summary>
171+
/// The main <c>Math</c> class.
172+
/// Contains all methods for performing basic math functions.
173+
/// </summary>
174+
public class Math
175+
{
176+
// <ExampleTag>
177+
/// <summary>
178+
/// Adds two integers and returns the result.
179+
/// </summary>
180+
/// <returns>
181+
/// The sum of two integers.
182+
/// </returns>
183+
/// <example>
184+
/// <code>
185+
/// int c = Math.Add(4, 5);
186+
/// if (c > 10)
187+
/// {
188+
/// Console.WriteLine(c);
189+
/// }
190+
/// </code>
191+
/// </example>
192+
/// <exception cref="System.OverflowException">Thrown when one parameter is max
193+
/// and the other is greater than 0.</exception>
194+
/// See <see cref="Math.Add(double, double)"/> to add doubles.
195+
public static int Add(int a, int b)
196+
{
197+
if ((a == int.MaxValue && b > 0) || (b == int.MaxValue && a > 0))
198+
throw new System.OverflowException();
199+
200+
return a + b;
201+
}
202+
// </ExampleTag>
203+
204+
/// <summary>
205+
/// Adds two doubles and returns the result.
206+
/// </summary>
207+
/// <returns>
208+
/// The sum of two doubles.
209+
/// </returns>
210+
/// <exception cref="System.OverflowException">Thrown when one parameter is max
211+
/// and the other is greater than zero.</exception>
212+
/// See <see cref="Math.Add(int, int)"/> to add integers.
213+
public static double Add(double a, double b)
214+
{
215+
if ((a == double.MaxValue && b > 0) || (b == double.MaxValue && a > 0))
216+
throw new System.OverflowException();
217+
218+
return a + b;
219+
}
220+
}
221+
// </SeeExample>
222+
223+
//-----------------------------------------------------------------------------
224+
//<CRefTags>
225+
namespace TestNamespace
226+
{
227+
/// <summary>
228+
/// TestClass contains several cref examples.
229+
/// </summary>
230+
public class TestClass
231+
{
232+
/// <summary>
233+
/// This sample shows how to specify the <see cref="TestClass"/> constructor as a cref attribute.
234+
/// </summary>
235+
public TestClass()
236+
{ }
237+
238+
/// <summary>
239+
/// This sample shows how to specify the <see cref="TestClass(int)"/> constructor as a cref attribute.
240+
/// </summary>
241+
public TestClass(int value)
242+
{ }
243+
244+
/// <summary>
245+
/// The GetZero method.
246+
/// </summary>
247+
/// <example>
248+
/// This sample shows how to call the <see cref="GetZero"/> method.
249+
/// <code>
250+
/// class TestClass
251+
/// {
252+
/// static int Main()
253+
/// {
254+
/// return GetZero();
255+
/// }
256+
/// }
257+
/// </code>
258+
/// </example>
259+
public static int GetZero()
260+
{
261+
return 0;
262+
}
263+
264+
/// <summary>
265+
/// The GetGenericValue method.
266+
/// </summary>
267+
/// <remarks>
268+
/// This sample shows how to specify the <see cref="GetGenericValue"/> method as a cref attribute.
269+
/// </remarks>
270+
271+
public static T GetGenericValue<T>(T para)
272+
{
273+
return para;
274+
}
275+
}
276+
277+
/// <summary>
278+
/// GenericClass.
279+
/// </summary>
280+
/// <remarks>
281+
/// This example shows how to specify the <see cref="GenericClass{T}"/> type as a cref attribute.
282+
/// </remarks>
283+
class GenericClass<T>
284+
{
285+
// Fields and members.
286+
}
287+
288+
class Program
289+
{
290+
static int Main()
291+
{
292+
return TestClass.GetZero();
293+
}
294+
}
295+
}
296+
//</CRefTags>
297+
298+
299+
namespace InheritDoc
300+
{
301+
//<InheritDocTag>
302+
/// <summary>
303+
/// You may have some primary information about this class.
304+
/// </summary>
305+
public class MainClass
306+
{
307+
}
308+
309+
///<inheritdoc/>
310+
public class DerivedClass: MainClass
311+
{
312+
}
313+
314+
/// <summary>
315+
/// You may have some primary information about this interface.
316+
/// </summary>
317+
public interface ITestInterface
318+
{
319+
}
320+
321+
///<inheritdoc cref="ITestInterface"/>
322+
public class ImplementingClass : ITestInterface
323+
{
324+
}
325+
326+
public class InheritOnlyReturns
327+
{
328+
/// <summary>In this example, this summary is only visible for this method.</summary>
329+
/// <returns>A boolean</returns>
330+
public static bool MyParentMethod(bool x) { return x; }
331+
332+
/// <inheritdoc cref="MyParentMethod" path="/returns"/>
333+
public static bool MyChildMethod() { return false; }
334+
}
335+
336+
public class InheritAllButRemarks
337+
{
338+
/// <summary>In this example, this summary is visible on all the methods.</summary>
339+
/// <remarks>The remarks.</remarks>
340+
/// <returns>A boolean</returns>
341+
public static bool MyParentMethod(bool x) { return x; }
342+
343+
/// <inheritdoc cref="MyParentMethod" path="//*[not(self::remarks)]"/>
344+
public static bool MyChildMethod() { return false; }
345+
}
346+
//</InheritDocTag>
347+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
namespace XmlTags
2+
{
3+
/*
4+
The main Math class
5+
Contains all methods for performing basic math functions
6+
*/
7+
/// <summary>
8+
/// The main <c>Math</c> class.
9+
/// Contains all methods for performing basic math functions.
10+
/// </summary>
11+
public class Math
12+
{
13+
}
14+
}

0 commit comments

Comments
 (0)