Skip to content

给命令属性添加说明

有时,属性的功能或用法并不能通过属性名直接被理解,此时应该给属性添加一些描述,详细说明属性的功能,用法或特殊策略

通过标注 DescriptionAttribute 可以实现此功能

示例代码

csharp
    public class MyPluginServerCommand : Command, ICommandExecutableInServerSideAsync
    {
        [Description("这里可以写一些描述")]
        public string MyProperty1 { get; set; }
        [FormulaProperty]
        [Description("描述文本可以是多行的\r\n通过鼠标悬停到问号图标上查看")]
        public object MyProperty2 { get; set; }

        public async Task<ExecuteResult> ExecuteAsync(IServerCommandExecuteContext dataContext)
        {
            return new ExecuteResult();
        }
        public override CommandScope GetCommandScope()
        {
            return CommandScope.ExecutableInServer;
        }
    }

设计器中的效果
1670083040204-338a42dc-a969-4e0c-9169-aa3a3624d2b4.png

更新: 2022-12-04 20:36:50
原文: https://www.yuque.com/robert-bh51n/ea8l6c/igmipe7evedgggqf