コード例 #1
0
        public static (string kind, string name) GetTitle(BaseInfo info)
        {
            switch (info)
            {
            case MSBuildElementSyntax el:
                if (!el.IsAbstract)
                {
                    return("keyword", info.Name);
                }
                break;

            case MSBuildAttributeSyntax att:
                if (!att.IsAbstract)
                {
                    return("keyword", info.Name);
                }
                break;

            case ItemInfo item:
                return("item", info.Name);

            case PropertyInfo prop:
                return("property", info.Name);

            case TargetInfo prop:
                return("target", info.Name);

            case MetadataInfo meta:
                return("metadata", meta.Item != null ? $"{meta.Item.Name}.{info.Name}" : info.Name);

            case TaskInfo task:
                return("task", info.Name);

            case CustomTypeValue ctVal:
                return(ctVal.TypeInfo.Name ?? "value", info.Name);

            case ValueKindValue value:
                return(FormatKind(value.ValueKind, null) ?? "value", info.Name);

            case FileOrFolderInfo value:
                return(value.IsFolder? "folder" : "file", info.Name);

            case FrameworkInfo fxi:
                return("framework", fxi.Reference.DotNetFrameworkName);

            case TaskParameterInfo tpi:
                return("parameter", tpi.Name);

            case FunctionInfo fi:
                if (fi.IsProperty)
                {
                    //FIXME: can we resolve the msbuild / .net property terminology overloading?
                    return("property", fi.Name);
                }
                return("function", fi.Name);

            case ClassInfo ci:
                return("class", ci.Name);
            }
            return(null, null);
        }
コード例 #2
0
        public static string GetDescription(BaseInfo info, MSBuildDocument doc, MSBuildResolveResult rr)
        {
            if (doc == null)
            {
                return(info.Description.Text);
            }

            //construct a customized version of the include/exclude/etc attribute if appropriate
            if (info is MSBuildAttributeSyntax att)
            {
                switch (att.Name.ToLower())
                {
                case "include":
                case "exclude":
                case "remove":
                case "update":
                    var item = doc.GetSchemas().GetItem(rr.ElementName);
                    if (item != null && !string.IsNullOrEmpty(item.IncludeDescription))
                    {
                        switch (item.ValueKind)
                        {
                        case MSBuildValueKind.File:
                        case MSBuildValueKind.Folder:
                        case MSBuildValueKind.FolderWithSlash:
                        case MSBuildValueKind.FileOrFolder:
                            return(GetDesc($"Item.{att.Name}.ParameterizedFiles"));

                        default:
                            if (!item.ValueKind.AllowLists())
                            {
                                return(GetDesc($"Item.{att.Name}.ParameterizedSingle"));
                            }
                            return(GetDesc($"Item.{att.Name}.Parameterized"));
                        }
                    }
                    string GetDesc(string id) => string.Format(
                        ElementDescriptions.ResourceManager.GetString(id, ElementDescriptions.Culture),
                        item.IncludeDescription);

                    break;
                }
            }

            if (info.Description.IsEmpty)
            {
                switch (info)
                {
                case PropertyInfo prop:
                    if (info.Name.EndsWith("DependsOn", StringComparison.OrdinalIgnoreCase))
                    {
                        var targetName = info.Name.Substring(0, info.Name.Length - "DependsOn".Length);
                        return($"The targets that the {targetName} target depends on");
                    }
                    break;

                case FrameworkInfo fxi:
                    return(FrameworkInfoProvider.GetDescription(fxi.Reference));
                }
            }

            return(info.Description.Text);
        }