private static string GenerateString(PropertyInfo propertyInfo) { var attrs = (MaxLengthAttribute[]) propertyInfo.GetCustomAttributes(typeof(MaxLengthAttribute), false); return attrs.Length > 0 ? new string('v', attrs[0].Length) : "v"; }