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

MeltyPlayer / MeltyTool / 19622977055

24 Nov 2025 04:05AM UTC coverage: 41.989% (+2.1%) from 39.89%
19622977055

push

github

MeltyPlayer
Switched float precision to fix broken tests.

6747 of 18131 branches covered (37.21%)

Branch coverage included in aggregate %.

28639 of 66144 relevant lines covered (43.3%)

65384.8 hits per line

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

76.56
/FinModelUtility/Fin/Fin/src/io/GenericFileExtensions.cs
1
using System;
2
using System.IO;
3
using System.Runtime.CompilerServices;
4
using System.Threading.Tasks;
5

6
using fin.util.json;
7

8
using schema.binary;
9
using schema.text;
10
using schema.text.reader;
11

12
namespace fin.io;
13

14
public static class GenericFileExtensions {
15
  // JSON Serialization
16
  [MethodImpl(MethodImplOptions.AggressiveInlining)]
17
  public static T Deserialize<T>(this IReadOnlyGenericFile file)
18
    => JsonUtil.Deserialize<T>(file.ReadAllText());
1✔
19

20
  [MethodImpl(MethodImplOptions.AggressiveInlining)]
21
  public static void Serialize<T>(this IGenericFile file, T instance)
22
      where T : notnull {
×
23
    using var fs = file.OpenWrite();
×
24
    using var sw = new StreamWriter(fs);
×
25
    sw.Write(JsonUtil.Serialize(instance));
×
26
    fs.SetLength(fs.Position);
×
27
  }
×
28

29

30
  // Read methods
31
  [MethodImpl(MethodImplOptions.AggressiveInlining)]
32
  public static StreamReader OpenReadAsText(this IReadOnlyGenericFile file)
33
    => new(file.OpenRead());
1✔
34

35
  [MethodImpl(MethodImplOptions.AggressiveInlining)]
36
  public static IBinaryReader OpenReadAsBinary(this IReadOnlyGenericFile file)
37
    => new SchemaBinaryReader(file.OpenRead());
153✔
38

39
  [MethodImpl(MethodImplOptions.AggressiveInlining)]
40
  public static IBinaryReader OpenReadAsBinary(
41
      this IReadOnlyGenericFile file,
42
      Endianness endianness)
43
    => new SchemaBinaryReader(file.OpenRead(), endianness);
312✔
44

45
  [MethodImpl(MethodImplOptions.AggressiveInlining)]
46
  public static T ReadNew<T>(this IReadOnlyGenericFile file)
47
      where T : IBinaryDeserializable, new() {
90✔
48
    using var br = file.OpenReadAsBinary();
90✔
49
    return br.ReadNew<T>();
90✔
50
  }
90✔
51

52
  [MethodImpl(MethodImplOptions.AggressiveInlining)]
53
  public static T ReadNew<T>(this IReadOnlyGenericFile file,
54
                             Endianness endianness)
55
      where T : IBinaryDeserializable, new() {
287✔
56
    using var br = file.OpenReadAsBinary(endianness);
287✔
57
    return br.ReadNew<T>();
287✔
58
  }
287✔
59

60
  [MethodImpl(MethodImplOptions.AggressiveInlining)]
61
  public static T ReadNewFromText<T>(this IReadOnlyGenericFile file)
62
      where T : ITextDeserializable, new() {
1✔
63
    using var tr = new SchemaTextReader(file.OpenRead());
1✔
64
    return tr.ReadNew<T>();
1✔
65
  }
1✔
66

67
  [MethodImpl(MethodImplOptions.AggressiveInlining)]
68
  public static byte[] ReadAllBytes(this IReadOnlyGenericFile file) {
81✔
69
    using var s = file.OpenRead();
81✔
70
    using var ms = new MemoryStream();
81✔
71
    s.CopyTo(ms);
81✔
72
    return ms.ToArray();
81✔
73
  }
81✔
74

75
  [MethodImpl(MethodImplOptions.AggressiveInlining)]
76
  public static async Task<byte[]> ReadAllBytesAsync(this IReadOnlyGenericFile file) {
11,326✔
77
    await using var s = file.OpenRead();
11,326✔
78
    using var ms = new MemoryStream();
11,326✔
79
    await s.CopyToAsync(ms);
11,326✔
80
    return ms.ToArray();
11,326✔
81
  }
11,326✔
82

83
  [MethodImpl(MethodImplOptions.AggressiveInlining)]
84
  public static string ReadAllText(this IReadOnlyGenericFile file) {
1✔
85
    using var sr = file.OpenReadAsText();
1✔
86
    return sr.ReadToEnd();
1✔
87
  }
1✔
88

89
  [MethodImpl(MethodImplOptions.AggressiveInlining)]
90
  public static string[] ReadAllLines(this IReadOnlyGenericFile file)
91
    => file.ReadAllText()
×
92
           .Split(TextReaderConstants.NEWLINE_STRINGS,
×
93
                  StringSplitOptions.None);
×
94

95

96
  // Write methods
97
  [MethodImpl(MethodImplOptions.AggressiveInlining)]
98
  public static StreamWriter OpenWriteAsText(this IGenericFile file)
99
    => new(file.OpenWrite());
3,180✔
100

101
  [MethodImpl(MethodImplOptions.AggressiveInlining)]
102
  public static void WriteAllBytes(this IGenericFile file,
103
                                   ReadOnlyMemory<byte> bytes) {
1✔
104
    using var s = file.OpenWrite();
1✔
105
    s.Write(bytes.Span);
1✔
106
  }
2✔
107

108
  [MethodImpl(MethodImplOptions.AggressiveInlining)]
109
  public static void WriteAllText(this IGenericFile file,
110
                                  string text) {
3,180✔
111
    using var sw = file.OpenWriteAsText();
3,180✔
112
    sw.Write(text);
3,180✔
113
  }
6,360✔
114

115
  [MethodImpl(MethodImplOptions.AggressiveInlining)]
116
  public static void Write<T>(this IGenericFile file, T data)
117
      where T : IBinarySerializable, new() {
1✔
118
    using var fs = file.OpenWrite();
1✔
119
    using var bw = new SchemaBinaryWriter();
1✔
120
    data.Write(bw);
1✔
121
    bw.CompleteAndCopyTo(fs);
1✔
122
  }
2✔
123

124
  [MethodImpl(MethodImplOptions.AggressiveInlining)]
125
  public static void Write<T>(this IGenericFile file,
126
                              T data,
127
                              Endianness endianness)
128
      where T : IBinarySerializable, new() {
×
129
    using var fs = file.OpenWrite();
×
130
    using var bw = new SchemaBinaryWriter(endianness);
×
131
    data.Write(bw);
×
132
    bw.CompleteAndCopyTo(fs);
×
133
  }
×
134
}
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