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

Aldaviva / Unfucked / 19128584806

06 Nov 2025 07:47AM UTC coverage: 0.396% (-39.5%) from 39.923%
19128584806

push

github

Aldaviva
DateTime: added IsBefore and IsAfter for ZonedDateTime, not just OffsetDateTime. DI: Allow super registration for keyed services; fixed super registration of a hosted service causing an infinite recursion during injection. STUN: updated fallback server list, most of which have gone offline (including Google, confusingly); made HttpClient optional.

2 of 1605 branches covered (0.12%)

0 of 55 new or added lines in 2 files covered. (0.0%)

945 existing lines in 35 files now uncovered.

9 of 2272 relevant lines covered (0.4%)

0.04 hits per line

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

0.0
/HTTP/Serialization/JsonBodyReader.cs
1
using System.Text;
2
using System.Text.Json;
3
using System.Text.Json.Nodes;
4
using Unfucked.HTTP.Config;
5
#if NET6_0_OR_GREATER
6
using System.Net.Mime;
7
#endif
8

9
namespace Unfucked.HTTP.Serialization;
10

11
public class JsonBodyReader: MessageBodyReader {
12

13
    private const string APPLICATION_JSON_MEDIA_TYPE =
14
#if NET6_0_OR_GREATER
15
        MediaTypeNames.Application.Json;
16
#else
17
        "application/json";
18
#endif
19

UNCOV
20
    private static readonly JsonSerializerOptions DEFAULT_JSON_OPTIONS = new(JsonSerializerDefaults.Web) { ReadCommentHandling = JsonCommentHandling.Skip };
×
21

22
    public bool CanRead<T>(string? mimeType, string? bodyPrefix) =>
UNCOV
23
        typeof(T) == typeof(JsonDocument) ||
×
UNCOV
24
        typeof(T) == typeof(JsonNode) ||
×
UNCOV
25
        typeof(T) == typeof(JsonObject) ||
×
UNCOV
26
        typeof(T) == typeof(JsonArray) ||
×
UNCOV
27
        typeof(T) == typeof(JsonValue) ||
×
UNCOV
28
        mimeType == APPLICATION_JSON_MEDIA_TYPE ||
×
UNCOV
29
        (mimeType?.EndsWith("+json") ?? false) ||
×
UNCOV
30
        (bodyPrefix != null && (
×
UNCOV
31
            bodyPrefix.StartsWith('{') ||
×
UNCOV
32
            bodyPrefix.StartsWith('[') ||
×
UNCOV
33
            bodyPrefix.Contains("\"$schema\"")));
×
34

35
    /*
36
     * Don't parse using the convenience extension methods from System.Net.Http.Json because that closes the response body stream even when an exception is thrown, so we can't read the body to create the exception.
37
     * Instead, rely on UnfuckedWebTarget.DisposeIfNotStream<T> to close the stream when the entire response processing is done.
38
     */
39
    public async Task<T> Read<T>(HttpContent responseBody, Encoding? responseEncoding, Configurable? clientConfig, CancellationToken cancellationToken) {
UNCOV
40
        JsonSerializerOptions jsonOptions = (clientConfig?.Property(PropertyKey.JsonSerializerOptions, out JsonSerializerOptions? j) ?? false ? j : DEFAULT_JSON_OPTIONS)!;
×
41

UNCOV
42
        Task<Stream> readAsStreamAsync =
×
UNCOV
43
#if NET5_0_OR_GREATER
×
UNCOV
44
            responseBody.ReadAsStreamAsync(cancellationToken);
×
45
#else
46
            responseBody.ReadAsStreamAsync();
47
#endif
48

UNCOV
49
        return (await JsonSerializer.DeserializeAsync<T>(await readAsStreamAsync.ConfigureAwait(false), jsonOptions, cancellationToken))!;
×
UNCOV
50
    }
×
51

52
}
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