-
Notifications
You must be signed in to change notification settings - Fork 244
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
Рыбин Леонид #229
base: master
Are you sure you want to change the base?
Рыбин Леонид #229
Conversation
ObjectPrinting/PrintingConfig.cs
Outdated
using System.Text; | ||
|
||
namespace ObjectPrinting | ||
{ | ||
public class PrintingConfig<TOwner> | ||
{ | ||
private readonly HashSet<Type> excludedTypes = new(); | ||
private readonly HashSet<MemberInfo> excludedProperties = new(); | ||
private readonly Dictionary<Type, Delegate> typeSerializers = new(); // ���������� ������� |
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.
Сделай UTF8, пожалуйста, а не cp1251. Комментарии ломаются
ObjectPrinting/PrintingConfig.cs
Outdated
if (nestingLevel > MaxNestingLevel) | ||
return "��������� �������� ������� ������������"; |
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.
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.
Добавил сеттер на максимальную длинну рекурсии
Console.WriteLine("-----------"); | ||
Console.WriteLine(result); |
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.
Убрать
|
||
namespace ObjectPrinting; | ||
|
||
public class PrintingConfiguration<TOwner, TPropType> |
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.
А что с названием? Чем PrintingConfig отличается от PrintingConfiguration по имени?
this PrintingConfiguration<TOwner, TNumericType> propertyStringConfiguration, | ||
CultureInfo culture) where TNumericType : IFormattable | ||
{ | ||
propertyStringConfiguration.ParentConfig.AddNumericCulture<TNumericType>(culture); |
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.
А почему только Numeric? У DateTime'а тоже есть Культура.
В условиях написано "Для всех типов, имеющих культуру, есть возможность ее указать"
ObjectPrinting/PrintingConfig.cs
Outdated
if (typeSerializers.TryGetValue(propertyType, out var typeSerializer)) | ||
{ | ||
sb.AppendLine($"{identation}{propertyName} = {typeSerializer.DynamicInvoke(propertyValue)}"); | ||
continue; | ||
} | ||
|
||
if (propertySerializers.TryGetValue(propertyName, out var propertySerializer)) | ||
{ | ||
sb.AppendLine($"{identation}{propertyName} = {propertySerializer.DynamicInvoke(propertyValue)}"); | ||
continue; | ||
} |
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.
Копипаста
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.
Опять же это можно сделать отдельной функцией, которая принимает сериалайзер, но она будет принимать очень много параметров, поэтому делать этого я не стал.
} | ||
|
||
[Test] | ||
public void PrintToString_PrintClassWithList_ShouldSerializeList() |
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.
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.
} | ||
|
||
[Test] | ||
public void PrintToString_PrintClassWithDictionary_ShouldSerializeDictionary() |
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.
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.
Моделька так же перегружена
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.
Модель для всех тестов общая, так везде используется класс Person.
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.
Добавил класс SimplePerson, чтобы в нём полей поменьше было
ObjectPrinting/Tests/Person.cs
Outdated
|
||
namespace ObjectPrinting.Tests | ||
{ | ||
public class Person | ||
public class Person//(Guid Id, string Name, double Height, int Age) |
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.
комментарий
namespace ObjectPrinting.Tests; | ||
|
||
[TestFixture] | ||
public class ObjectPrinterTests |
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.
Нету тестов пересекающихся:
- Исключить строки, но добавить для них кастомную сериализацию. А наоборот?
- Исключить из сериализации коллекции
- Не увидел тестов с сериализацией времени
- Несколько исключений подряд для разных типов
- Несколько исключений для одинаковых типов
и тд.
No description provided.