-
Notifications
You must be signed in to change notification settings - Fork 245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Минеев Максим #233
base: master
Are you sure you want to change the base?
Минеев Максим #233
Conversation
ObjectPrinting/PrintingConfig.cs
Outdated
private string PrintPropertiesToString(object obj, int nestingLevel) | ||
{ | ||
var type = obj.GetType(); | ||
var identation = new string('\t', nestingLevel + 1); | ||
var items = (from propertyInfo in type.GetProperties() | ||
select Serialize(propertyInfo.GetValue(obj), propertyInfo.PropertyType, propertyInfo.Name, nestingLevel + 1) | ||
into serializedProperty | ||
where serializedProperty != string.Empty | ||
select identation + serializedProperty).ToList(); | ||
|
||
return string.Join(",\n", items); | ||
} | ||
|
||
private string PrintFieldsToString(object obj, int nestingLevel) | ||
{ | ||
var type = obj.GetType(); | ||
var identation = new string('\t', nestingLevel + 1); | ||
var items = (from fieldInfo in type.GetFields() | ||
select Serialize(fieldInfo.GetValue(obj), fieldInfo.FieldType, fieldInfo.Name, nestingLevel + 1) | ||
into serializedProperty | ||
where serializedProperty != string.Empty | ||
select identation + serializedProperty).ToList(); | ||
|
||
return string.Join(",\n", items); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Достаточно много дублирования
ObjectPrinting/PrintingConfig.cs
Outdated
value = PrintDictionary((IDictionary)valueToSerialize, level); | ||
if (valueToSerialize is string stringValue && MaxLengths.TryGetValue(name, out var maxLength)) | ||
value = stringValue[..Math.Min(value.Length, maxLength)]; | ||
if (value == "") value = PrintToString(valueToSerialize, level + 1); | ||
if (value.Length > 0) return name + " = " + value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
давай переносы сделаем одинаковые
ObjectPrinting/PrintingConfig.cs
Outdated
private readonly HashSet<string> excludedProperties = []; | ||
private readonly HashSet<object> visited = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Посмотри на логику visited, тоже может быть баг
Height = 123.4, | ||
Id = new Guid() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Я бы брал не 00000000-0000-0000-0000-000000000000, а какие-то опреденные Guid
ObjectPrintingTests/Person.cs
Outdated
public List<int> Weigths { get; set; } | ||
public Dictionary<string, int> Dict { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Все были связаны с человеком, а словарь просто Dict
@Pasha0666