<summary> (C# プログラミング ガイド)<summary> (C# programming guide)
構文Syntax
<summary>description</summary>
パラメーターParameters
description
オブジェクトの概要。A summary of the object.
RemarksRemarks
<summary>
タグは、型または型メンバーの説明に使用します。The <summary>
tag should be used to describe a type or a type member. 型の説明に補足情報を追加するには、<remarks> を使用します。Use <remarks> to add supplemental information to a type description. DocFX や Sandcastle などのドキュメント ツールでコード要素のドキュメント ページへの内部ハイパーリンクを作成できるようにするには、cref 属性を使用します。Use the cref Attribute to enable documentation tools such as DocFX and Sandcastle to create internal hyperlinks to documentation pages for code elements.
<summary>
タグのテキストは、IntelliSense の型に関する情報の唯一のソースで、[オブジェクト ブラウザー] ウィンドウにも表示されます。The text for the <summary>
tag is the only source of information about the type in IntelliSense, and is also displayed in the Object Browser Window.
コンパイル時に -doc を指定して、ドキュメント コメントをファイルに出力します。Compile with -doc to process documentation comments to a file. コンパイラによって生成されたファイルに基づいて最終的なドキュメントを作成するには、カスタム ツールを作成するか、DocFX や Sandcastle などのツールを使用します。To create the final documentation based on the compiler-generated file, you can create a custom tool, or use a tool such as DocFX or Sandcastle.
例Example
// compile with: -doc:DocFileName.xml
/// text for class TestClass
public class TestClass
{
/// <summary>DoWork is a method in the TestClass class.
/// <para>Here's how you could make a second paragraph in a description. <see cref="System.Console.WriteLine(System.String)"/> for information about output statements.</para>
/// <seealso cref="TestClass.Main"/>
/// </summary>
public static void DoWork(int Int1)
{
}
/// text for Main
static void Main()
{
}
}
前の例では、次の XML ファイルが生成されます。The previous example produces the following XML file.
<?xml version="1.0"?>
<doc>
<assembly>
<name>YourNamespace</name>
</assembly>
<members>
<member name="T:TestClass">
text for class TestClass
</member>
<member name="M:TestClass.DoWork(System.Int32)">
<summary>DoWork is a method in the TestClass class.
<para>Here's how you could make a second paragraph in a description. <see cref="M:System.Console.WriteLine(System.String)"/> for information about output statements.</para>
</summary>
<seealso cref="M:TestClass.Main"/>
</member>
<member name="M:TestClass.Main">
text for Main
</member>
</members>
</doc>
例Example
ジェネリック型への cref
参照を作成する方法を次の例に示します。The following example shows how to make a cref
reference to a generic type.
// compile with: -doc:DocFileName.xml
// the following cref shows how to specify the reference, such that,
// the compiler will resolve the reference
/// <summary cref="C{T}">
/// </summary>
class A { }
// the following cref shows another way to specify the reference,
// such that, the compiler will resolve the reference
// <summary cref="C < T >">
// the following cref shows how to hard-code the reference
/// <summary cref="T:C`1">
/// </summary>
class B { }
/// <summary cref="A">
/// </summary>
/// <typeparam name="T"></typeparam>
class C<T> { }
class Program
{
static void Main() { }
}
前の例では、次の XML ファイルが生成されます。The previous example produces the following XML file.
<?xml version="1.0"?>
<doc>
<assembly>
<name>CRefTest</name>
</assembly>
<members>
<member name="T:A">
<summary cref="T:C`1">
</summary>
</member>
<member name="T:B">
<summary cref="T:C`1">
</summary>
</member>
<member name="T:C`1">
<summary cref="T:A">
</summary>
<typeparam name="T"></typeparam>
</member>
</members>
</doc>