public override string ToString() { if (MemberNames.Any()) { string membersNames = string.Join(",", !string.IsNullOrEmpty(Prefix) ? MemberNames.Select(x => string.Format("{0}.{1}", Prefix, x)) : MemberNames); return(string.Format("Name = {0}. {1}", membersNames, ErrorMessage)); } return(ErrorMessage); }
public override string ToStringMethod() { var code = new CSharpBuilder(Options.LanguageVersion); code.Indent(1) .AppendLine($"private static readonly Dictionary<{TypeName}, string> ToStringMap = new Dictionary<{TypeName}, string>"); code.Indent(1).AppendLine("{"); var toStringMappings = MemberNames .Select(memberName => $"{{{memberName}, {NameOf(memberName)}}}") .ToArray(); code.Indent(2); code.AppendLine(string.Join($",\r\n{Indent(2)}", toStringMappings)); code.Indent(1).AppendLine("};"); code.AppendLine(); code.Indent(1).Append("public override string ToString()") .ExpressionBody("ToStringMap[this]"); return(code.ToString()); }