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

lucaslorentz / auto-compute / 11911066930

19 Nov 2024 10:25AM UTC coverage: 81.029% (+4.2%) from 76.855%
11911066930

push

github

lucaslorentz
Improve EFCore computeds

27 of 85 new or added lines in 12 files covered. (31.76%)

3 existing lines in 1 file now uncovered.

1465 of 1808 relevant lines covered (81.03%)

115.3 hits per line

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

60.0
/src/LLL.AutoCompute.EFCore/Metadata/Internal/ComputedAnnotationAccessors.cs
1
using LLL.AutoCompute.EFCore.Internal;
2
using Microsoft.EntityFrameworkCore.Metadata;
3

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

6
public static class ComputedAnnotationAccessors
7
{
8
    internal static ComputedFactory<IProperty>? GetComputedFactory(this IReadOnlyProperty target)
9
    {
10
        return target[ComputedAnnotationNames.ComputedFactory] as ComputedFactory<IProperty>;
64✔
11
    }
12

13
    internal static void SetComputedFactory(this IMutableProperty target, ComputedFactory<IProperty> factory)
14
    {
15
        target[ComputedAnnotationNames.ComputedFactory] = factory;
12✔
16
    }
17

18
    internal static ComputedFactory<INavigationBase>? GetComputedFactory(this IReadOnlyNavigationBase target)
19
    {
20
        return target[ComputedAnnotationNames.ComputedFactory] as ComputedFactory<INavigationBase>;
48✔
21
    }
22

23
    internal static void SetComputedFactory(this IMutableNavigationBase target, ComputedFactory<INavigationBase> factory)
24
    {
NEW
25
        target[ComputedAnnotationNames.ComputedFactory] = factory;
×
26
    }
27

28
    internal static List<ObserverFactory<IEntityType>>? GetObserversFactories(this IReadOnlyEntityType target)
29
    {
30
        return target[ComputedAnnotationNames.ObserversFactories] as List<ObserverFactory<IEntityType>>;
16✔
31
    }
32

33
    internal static void AddObserverFactory(this IMutableEntityType target, ObserverFactory<IEntityType> factory)
34
    {
NEW
35
        var factories = target.GetObserversFactories();
×
NEW
36
        if (factories is null)
×
37
        {
NEW
38
            factories = [];
×
NEW
39
            target[ComputedAnnotationNames.ObserversFactories] = factories;
×
40
        }
NEW
41
        factories.Add(factory);
×
42
    }
43

44
    public static ComputedMember? GetComputed(this IPropertyBase target)
45
    {
46
        return target.FindRuntimeAnnotationValue(ComputedAnnotationNames.Computed) as ComputedMember;
35✔
47
    }
48

49
    internal static void SetComputed(this IPropertyBase propertyBase, ComputedMember? computeds)
50
    {
51
        propertyBase.SetRuntimeAnnotation(ComputedAnnotationNames.Computed, computeds);
6✔
52
    }
53

54
    public static IReadOnlyList<Observer>? GetObservers(this IEntityType target)
55
    {
NEW
56
        return target.FindRuntimeAnnotationValue(ComputedAnnotationNames.Observers) as IReadOnlyList<Observer>;
×
57
    }
58

59
    internal static void SetObservers(this IEntityType target, IReadOnlyList<Observer>? observers)
60
    {
NEW
61
        target.SetRuntimeAnnotation(ComputedAnnotationNames.Observers, observers);
×
62
    }
63

64
    public static IComputedExpressionAnalyzer<IEFCoreComputedInput> GetComputedExpressionAnalyzerOrThrow(this IModel annotatable)
65
    {
66
        return annotatable.FindRuntimeAnnotationValue(ComputedAnnotationNames.ExpressionAnalyzer) as IComputedExpressionAnalyzer<IEFCoreComputedInput>
77✔
67
            ?? throw new Exception($"ExpressionAnalyzer not found in model");
77✔
68
    }
69

70
    internal static void SetExpressionAnalyzer(this IModel annotatable, IComputedExpressionAnalyzer<IEFCoreComputedInput> analyzer)
71
    {
72
        annotatable.SetRuntimeAnnotation(ComputedAnnotationNames.ExpressionAnalyzer, analyzer);
4✔
73
    }
74

75
    internal static IReadOnlyList<ComputedBase> GetSortedComputedsOrThrow(this IModel annotatable)
76
    {
77
        return annotatable.FindRuntimeAnnotationValue(ComputedAnnotationNames.SortedComputeds) as IReadOnlyList<ComputedBase>
114✔
78
            ?? throw new Exception($"SortedComputeds not found in model");
114✔
79
    }
80

81
    internal static void SetSortedComputeds(this IModel annotatable, IReadOnlyList<ComputedBase> computeds)
82
    {
83
        annotatable.SetRuntimeAnnotation(ComputedAnnotationNames.SortedComputeds, computeds);
4✔
84
    }
85
}
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