如果某个方法没有自己的XML注释,则在该方法实现的接口上获取Intellisense
本文关键字:方法 实现 Intellisense 获取 接口 自己的 注释 XML 如果 | 更新日期: 2023-09-27 18:20:31
在Visual Studio 2010中,如果某个方法没有自己的任何XML注释,是否有方法在该方法实现的接口上获取Intellisense?
我想这样的东西会很有用。我喜欢在接口中包含XML注释,不喜欢在每个实现方法中重复(复制)相同的文本。只有当需要描述实现方法的特定内容时,我才会给该方法自己的XML注释。
如果你有ReSharper,你可以使用Ctrl+Shift+F1来显示方法的简短帮助。如果该方法没有任何XML注释,则显示其接口的帮助。我没有足够的声誉给你一张截图。所以我给你看我的代码并解释它:
internal interface ISomeInterface
{
/// <summary>
/// Integer1 help text by interface.
/// </summary>
int Integer1 { get; set; }
}
internal class Class2 : ISomeInterface
{
public int Integer1 { get; set; }
public int CallInterface1( )
{
return Integer1; // <- Place cursor on Integer1 and press Ctrl+Shift+F1
}
}
您可以使用Resharper来完成此操作。如果您将光标放在没有XML注释的方法声明上,Rehsarper将为您提供从基方法自动复制注释的功能。