• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

net-daemon / netdaemon / 14943290972

10 May 2025 07:39AM UTC coverage: 84.091% (-0.2%) from 84.281%
14943290972

push

github

web-flow
Fix crash in 2025.5 (#1309)

* Add test

* Add converter for arrays of arrays of strings, more test cases

* Remove testing workaroudn

---------

Co-authored-by: Frank Bakker <bakker.frank@gmail.com>
Co-authored-by: Frank Bakker <FrankBakkerNl@users.noreply.github.com>

859 of 1145 branches covered (75.02%)

Branch coverage included in aggregate %.

12 of 23 new or added lines in 2 files covered. (52.17%)

1 existing line in 1 file now uncovered.

3359 of 3871 relevant lines covered (86.77%)

127.13 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

82.61
/src/Client/NetDaemon.HassClient/Internal/Json/EnsureStringConverter.cs
1
namespace NetDaemon.Client.Internal.Json;
2

3
/// <summary>
4
/// Converts a Json element that can be a string or a number to as string, and returns null if not
5
/// </summary>
6
class EnsureStringConverter : JsonConverter<string?>
7
{
8
    public override string? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
9
    {
10
        switch (reader.TokenType)
106✔
11
        {
12
            case JsonTokenType.String:
13
                return reader.GetString();
84✔
14

15
            case JsonTokenType.Number:
16
                if (reader.TryGetInt32(out var intValue))
17✔
17
                    return intValue.ToString(CultureInfo.InvariantCulture);
13✔
18
                if (reader.TryGetInt64(out var longValue))
4✔
19
                    return longValue.ToString(CultureInfo.InvariantCulture);
1✔
20
                if (reader.TryGetDouble(out var doubleValue))
3!
21
                    return doubleValue.ToString(CultureInfo.InvariantCulture);
3✔
22

NEW
23
                reader.Skip();
×
UNCOV
24
                return null;
×
25

26
            default:
27
                reader.Skip();
5✔
28
                return null;
5✔
29
        }
30
    }
31

32
    public override void Write(Utf8JsonWriter writer, string? value, JsonSerializerOptions options) => writer.WriteStringValue(value);
×
33
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc