Exemplo n.º 1
0
        string GetDefaultValue(IParameterSymbol p)
        {
            if (p.HasExplicitDefaultValue)
            {
                var ppp = p.ToDisplayParts(new SymbolDisplayFormat(parameterOptions: SymbolDisplayParameterOptions.IncludeName | SymbolDisplayParameterOptions.IncludeDefaultValue));

                if (!ppp.Any(x => x.Kind == SymbolDisplayPartKind.Keyword && x.ToString() == "default"))
                {
                    var l = ppp.Last();
                    if (l.Kind == SymbolDisplayPartKind.FieldName)
                    {
                        return(l.Symbol.ToDisplayString());
                    }
                    else
                    {
                        return(l.ToString());
                    }
                }
            }

            return("default(" + p.Type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + ")");
        }