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

lucaslorentz / auto-compute / 11744711953

08 Nov 2024 03:11PM UTC coverage: 82.369%. First build
11744711953

push

github

lucaslorentz
Add initial support for computed navigations and observers

185 of 334 new or added lines in 17 files covered. (55.39%)

1509 of 1832 relevant lines covered (82.37%)

116.56 hits per line

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

47.06
/src/LLL.AutoCompute.EFCore/Metadata/Internal/ComputedAnnotation.cs
1
using System.Diagnostics.CodeAnalysis;
2
using Microsoft.EntityFrameworkCore.Infrastructure;
3
using Microsoft.EntityFrameworkCore.Metadata;
4

5
namespace LLL.AutoCompute.EFCore.Metadata.Internal;
6

7
public class ComputedAnnotation<T>(string name)
3✔
8
{
9
    public bool TryGet(IReadOnlyAnnotatable annotatable, [NotNullWhen(true)] out T? value)
10
    {
11
        var annotation = annotatable.FindAnnotation(name);
128✔
12
        if (annotation is null)
128✔
13
        {
14
            value = default;
122✔
15
            return false;
122✔
16
        }
17

18
        value = (T)annotation.Value!;
6✔
19
        return true;
6✔
20
    }
21

22
    public void Set(IMutableAnnotatable annotatable, T value)
23
    {
24
        annotatable.SetAnnotation(name, value);
12✔
25
    }
26

27
    public T GetOrAdd(IMutableAnnotatable annotatable, Func<T> factory)
28
    {
NEW
29
        if (!TryGet(annotatable, out var value))
×
30
        {
NEW
31
            value = factory();
×
NEW
32
            Set(annotatable, value);
×
33
        }
NEW
34
        return value;
×
35
    }
36

37
    public void Set(IConventionAnnotatable annotatable, T value)
38
    {
NEW
39
        annotatable.SetAnnotation(name, value);
×
40
    }
41

42
    public T GetOrAdd(IConventionAnnotatable annotatable, Func<T> factory)
43
    {
NEW
44
        if (!TryGet(annotatable, out var value))
×
45
        {
NEW
46
            value = factory();
×
NEW
47
            Set(annotatable, value);
×
48
        }
NEW
49
        return value;
×
50
    }
51
}
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