• 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/Config/ClientConfig.cs
1
using System.Collections.Immutable;
2
using System.Diagnostics.Contracts;
3
using Unfucked.HTTP.Filters;
4
using Unfucked.HTTP.Serialization;
5

6
namespace Unfucked.HTTP.Config;
7

8
public interface IClientConfig: Configurable<IClientConfig>, ICloneable;
9

10
public class ClientConfig: IClientConfig {
11

12
    public const int FIRST_FILTER_POSITION = 0;
13
    public const int LAST_FILTER_POSITION  = int.MaxValue;
14

UNCOV
15
    private ImmutableList<ClientRequestFilter> ReqFilters { get; init; }
×
UNCOV
16
    private ImmutableList<ClientResponseFilter> ResFilters { get; init; }
×
UNCOV
17
    private ImmutableHashSet<MessageBodyReader> Readers { get; init; }
×
UNCOV
18
    private ImmutableDictionary<PropertyKey, object> Properties { get; init; }
×
19

20
    [Pure]
21
    public IReadOnlyList<ClientRequestFilter> RequestFilters => ReqFilters.AsReadOnly();
×
22

23
    [Pure]
24
    public IReadOnlyList<ClientResponseFilter> ResponseFilters => ResFilters.AsReadOnly();
×
25

26
    [Pure]
UNCOV
27
    public IEnumerable<MessageBodyReader> MessageBodyReaders => Readers.AsEnumerable();
×
28

29
#pragma warning disable IDE0301 // Simplify collection initialization - breaks in .NET 6
UNCOV
30
    internal ClientConfig() {
×
UNCOV
31
        ReqFilters = ImmutableList<ClientRequestFilter>.Empty;
×
UNCOV
32
        ResFilters = ImmutableList<ClientResponseFilter>.Empty;
×
UNCOV
33
        Readers    = ImmutableHashSet<MessageBodyReader>.Empty;
×
UNCOV
34
        Properties = ImmutableDictionary<PropertyKey, object>.Empty;
×
UNCOV
35
    }
×
36
#pragma warning restore IDE0301 // Simplify collection initialization
37

38
    private ClientConfig(ClientConfig other) {
×
39
        ReqFilters = other.ReqFilters;
×
40
        ResFilters = other.ResFilters;
×
41
        Readers    = other.Readers;
×
42
        Properties = other.Properties;
×
43
    }
×
44

45
    public UnfuckedHttpClient CreateClient(HttpMessageHandler? handler = null, bool disposeHandler = true) => UnfuckedHttpClient.Create(handler, disposeHandler, this);
×
46

47
    /// <inheritdoc />
48
    [Pure]
49
    public object Clone() => new ClientConfig(this);
×
50

51
    /// <inheritdoc />
52
    [Pure]
53
    public IClientConfig Register(Registrable registrable) => registrable switch {
×
54
        MessageBodyReader m    => new ClientConfig(this) { Readers = Readers.Add(m) },
×
55
        ClientRequestFilter r  => Register(r, LAST_FILTER_POSITION),
×
56
        ClientResponseFilter r => Register(r, LAST_FILTER_POSITION),
×
57
        _                      => throw new ArgumentException($"This {nameof(ClientConfig)} class does not have a way to register a {registrable.GetType()}", nameof(registrable))
×
58
    };
×
59

60
    /// <inheritdoc />
61
    [Pure]
62
    public IClientConfig Register<Option>(Registrable<Option> registrable, Option registrationOption) => registrable switch {
×
63
        ClientRequestFilter r when registrationOption is int o => new ClientConfig(this) { ReqFilters = Register(ReqFilters, r, o) },
×
64
        ClientResponseFilter r when registrationOption is int o => new ClientConfig(this) { ResFilters = Register(ResFilters, r, o) },
×
65
        _ => throw new ArgumentException($"This {nameof(ClientConfig)} class does not have a way to register a {registrable.GetType()}", nameof(registrable))
×
66
    };
×
67

68
    private static ImmutableList<T> Register<T>(ImmutableList<T> list, T? newItem, int position) {
69
        int  oldCount  = list.Count;
×
70
        bool isRemoval = newItem is null;
×
71
        position = position switch {
×
72
            < FIRST_FILTER_POSITION                  => 0,
×
73
            _ when position >= oldCount && isRemoval => oldCount - 1,
×
74
            _ when position > oldCount               => oldCount,
×
75
            _                                        => position
×
76
        };
×
77
        return isRemoval ? list.RemoveAt(position) : list.Insert(position, newItem!);
×
78
    }
79

80
    /// <inheritdoc />
81
    [Pure]
82
    public IClientConfig Property<T>(PropertyKey<T> key, T? newValue) where T: notnull =>
83
        new ClientConfig(this) { Properties = newValue is not null ? Properties.SetItem(key, newValue) : Properties.Remove(key) };
×
84

85
    /// <inheritdoc cref="Configurable.Property{T}" />
86
    [Pure]
87
    public bool Property<T>(PropertyKey<T> key,
88
#if !NETSTANDARD2_0
89
                            [NotNullWhen(true)]
90
#endif
91
                            out T? existingValue) where T: notnull {
UNCOV
92
        bool exists = Properties.TryGetValue(key, out object? rawValue);
×
UNCOV
93
        existingValue = exists ? (T?) rawValue : default;
×
UNCOV
94
        return exists;
×
95
    }
96

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