2
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【Visual Studio】特定メンバーのXMLコメントを使う

Last updated at Posted at 2021-10-04

やりたいこと

例えば、下のようなクラスがあったとき、HogeClass は Hoge プロパティ専用のクラスなので、Hoge プロパティの XML コメントを、HogeClass のと同じに(共通化)したいと思った。

class TestClass
{
	// このsummaryを、HogeClassと共通化したい
	/// <summary>
	/// 説明文
	/// </summary>
	public HogeClass Hoge { get; }

	/// <summary>
	/// 説明文
	/// </summary>
	public class HogeClass { }
}

解決策

summary タグの代わりに、 inheritdoc タグを使い、cref="" に XML コメントを同じにしたいメンバーの名前を入れる。

class TestClass
{
	/// <inheritdoc cref="HogeClass"/>
	public HogeClass Hoge { get; }

	/// <summary>
	/// 説明文
	/// </summary>
	public class HogeClass { }
}

参考

2
5
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?