< Summary - ZhEaIsNsAaBn.Libraries coverage (affected: 23 packages)

Information
Class: ZhEaIsNsAaBn.DbSeeder.Design.SeedJsonValue
Assembly: ZhEaIsNsAaBn.DbSeeder.Design
File(s): /home/runner/work/ZhEaIsNsAaBn.Libraries.V1/ZhEaIsNsAaBn.Libraries.V1/src/DataBasePackages/ZhEaIsNsAaBn.DbSeeder.Design/Files/SeedJsonValue.cs
Line coverage
42%
Covered lines: 9
Uncovered lines: 12
Coverable lines: 21
Total lines: 42
Line coverage: 42.8%
Branch coverage
46%
Covered branches: 23
Total branches: 50
Branch coverage: 46%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.cctor()100%11100%
Format(...)52.94%3773433.33%
Text(...)100%11100%
IsInteger(...)31.25%1616100%

File(s)

/home/runner/work/ZhEaIsNsAaBn.Libraries.V1/ZhEaIsNsAaBn.Libraries.V1/src/DataBasePackages/ZhEaIsNsAaBn.DbSeeder.Design/Files/SeedJsonValue.cs

#LineLine coverage
 1#region Usings
 2using System.Text.Encodings.Web;
 3using System.Text.Unicode;
 4#endregion
 5
 6namespace ZhEaIsNsAaBn.DbSeeder.Design;
 7
 8/// <summary>
 9/// The one canonical JSON text of a provider value (§4.4): invariant culture, dates <c>"O"</c>, <c>decimal</c> as a num
 10/// base64, Guid lower case, text with <see cref="UnicodeRanges.All"/> (Arabic stays readable). Files are written with i
 11/// diffed by it, so "unchanged" means byte-identical.
 12/// </summary>
 13internal static class SeedJsonValue
 14{
 315    private static readonly JsonSerializerOptions Options = new() { Encoder = JavaScriptEncoder.Create( UnicodeRanges.Al
 16
 17
 18    public static string Format( object? value )
 542719        => value switch
 542720               {
 15621                   null                => "null",
 301222                   string text         => Text( text ),
 023                   char character      => Text( character.ToString() ),
 024                   bool flag           => flag ? "true" : "false",
 025                   DateTime date       => Text( date.ToString( "O", CultureInfo.InvariantCulture ) ),
 026                   DateTimeOffset date => Text( date.ToString( "O", CultureInfo.InvariantCulture ) ),
 027                   DateOnly date       => Text( date.ToString( "yyyy-MM-dd", CultureInfo.InvariantCulture ) ),
 028                   TimeOnly time       => Text( time.ToString( "HH:mm:ss.fffffff", CultureInfo.InvariantCulture ) ),
 029                   TimeSpan span       => Text( span.ToString( "c", CultureInfo.InvariantCulture ) ),
 030                   Guid guid           => Text( guid.ToString( "D" ) ),
 031                   byte[] bytes        => Text( Convert.ToBase64String( bytes ) ),
 032                   double number       => number.ToString( "R", CultureInfo.InvariantCulture ),
 033                   float number        => number.ToString( "R", CultureInfo.InvariantCulture ),
 451834                   IFormattable number when IsInteger( number ) || number is decimal => number.ToString( null, CultureIn
 035                   _                   => JsonSerializer.Serialize( value, value.GetType(), Options )
 542736               };
 37
 38    /// A JSON string literal.
 1362339    public static string Text( string value ) => JsonSerializer.Serialize( value, Options );
 40
 225941    private static bool IsInteger( object value ) => value is sbyte or byte or short or ushort or int or uint or long or
 42}