|
| 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 | +} |
0 commit comments