-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: Add Json converter for serialzing models that contain empty strings and empty lists. #40
base: main
Are you sure you want to change the base?
Conversation
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.
- Ich würde mir noch dokumentation wünschen für die klassen. nur highlevel an der klasse selbst, wozu sie gut sind und was unsere annahmen sind
- an einer stelle fehlt eine rekursion würde ich vermuten
- die write-pfade können wir weglassen oder es sollte ein test fehlschlagen, wenn wir sie rausnehmen. da wir im test bislang nur deserializen, vemrute ich dass das grün durchliefe: update: nein, ist nicht so. wir brauchen sie. haben wir dann jeweils beide fälle anders wo abgedeckt in einem test? vllt ließe sich da noch ein testfall adden.
gerne kannst du auch die converter abseits der malo-ident model klassen testen. ich mach das gerne, dass ich mir einfache test-klassen konstruiere, wie z.b. hier: https://github.com/Hochfrequenz/BO4E-dotnet/blob/50ceed1ba0d2c86e63a74929aaf40e730db79558/BO4ETestProject/TestGeraetemerkmalConverter.cs#L20-L32
das ist teilweise weniger overhead als sich "echte" malo-ident testdaten zu bauen und die intention des testes wird klarer und der konverter punktgenau getestet.
MaLoIdentModels/MaLoIdentModels/JsonSettings/EmptyListToNullConverter.cs
Show resolved
Hide resolved
MaLoIdentModels/MaLoIdentModels/JsonSettings/EmptyListToNullConverter.cs
Outdated
Show resolved
Hide resolved
MaLoIdentModels/MaLoIdentModels/JsonSettings/EmptyListToNullConverter.cs
Outdated
Show resolved
Hide resolved
MaLoIdentModels/MaLoIdentModels/JsonSettings/EmptyListToNullConverter.cs
Outdated
Show resolved
Hide resolved
MaLoIdentModels/MaLoIdentModels/JsonSettings/EmptyListToNullConverter.cs
Show resolved
Hide resolved
MaLoIdentModels/MaLoIdentModels/JsonSettings/EmptyStringConverter.cs
Outdated
Show resolved
Hide resolved
MaLoIdentModels/MaLoIdentModels/JsonSettings/EmptyListToNullConverter.cs
Outdated
Show resolved
Hide resolved
MaLoIdentModels/MaLoIdentModelsTests/v1Tests/EmptyStringAndObjectsDeserializationTests.cs
Outdated
Show resolved
Hide resolved
…nverter.cs Co-authored-by: konstantin <konstantin.klein@hochfrequenz.de>
…nverter.cs Co-authored-by: konstantin <konstantin.klein@hochfrequenz.de>
…ter.cs Co-authored-by: konstantin <konstantin.klein@hochfrequenz.de>
@hf-kklein Morgen, passt das so jetzt für dich? |
namespace MaLoIdentModels.JsonSettings; | ||
|
||
/// <summary> | ||
/// A custom JSON converter that converts empty strings to null and writes null values as empty strings. |
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.
/// A custom JSON converter that converts empty strings to null and writes null values as empty strings. | |
/// A custom JSON converter that converts empty strings to null and writes empty strings as null values. |
if (string.IsNullOrEmpty(value))
{
writer.WriteNullValue();
}
else
{
writer.WriteStringValue(value);
}
siehe unten
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.
ein kommentar ist noch falsch. danke für die zusätzlichen tests! gerne nach dem merge die minor version bummpen
No description provided.