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

lucaslorentz / auto-compute / 11986839382

23 Nov 2024 11:38AM UTC coverage: 80.885% (-0.05%) from 80.939%
11986839382

push

github

lucaslorentz
Add support for self referencing computeds

53 of 61 new or added lines in 9 files covered. (86.89%)

38 existing lines in 3 files now uncovered.

1481 of 1831 relevant lines covered (80.88%)

117.05 hits per line

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

64.71
/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 EFCoreObservedProperty GetOrCreateObservedProperty(this IProperty property)
9
    {
10
        return property.GetOrAddRuntimeAnnotationValue(
108✔
11
            ComputedAnnotationNames.ObservedMember,
108✔
12
            static (property) => new EFCoreObservedProperty(property!),
119✔
13
            property);
108✔
14
    }
15

16
    internal static EFCoreObservedProperty? GetObservedProperty(this IProperty property)
17
    {
UNCOV
18
        return property.FindRuntimeAnnotationValue(
×
UNCOV
19
            ComputedAnnotationNames.ObservedMember) as EFCoreObservedProperty;
×
20
    }
21

22
    internal static EFCoreObservedNavigation GetOrCreateObservedNavigation(this INavigationBase navigation)
23
    {
24
        return navigation.GetOrAddRuntimeAnnotationValue(
578✔
25
            ComputedAnnotationNames.ObservedMember,
578✔
26
            static (navigation) => new EFCoreObservedNavigation(navigation!),
599✔
27
            navigation);
578✔
28
    }
29

30
    internal static EFCoreObservedNavigation? GetObservedNavigation(this INavigationBase navigation)
31
    {
UNCOV
32
        return navigation.FindRuntimeAnnotationValue(
×
UNCOV
33
            ComputedAnnotationNames.ObservedMember) as EFCoreObservedNavigation;
×
34
    }
35

36
    internal static EFCoreObservedMember? GetObservedMember(this IPropertyBase member)
37
    {
38
        return member.FindRuntimeAnnotationValue(
58✔
39
            ComputedAnnotationNames.ObservedMember) as EFCoreObservedMember;
58✔
40
    }
41

42
    internal static ComputedFactory<IProperty>? GetComputedFactory(this IReadOnlyProperty target)
43
    {
44
        return target[ComputedAnnotationNames.ComputedFactory] as ComputedFactory<IProperty>;
64✔
45
    }
46

47
    internal static void SetComputedFactory(this IMutableProperty target, ComputedFactory<IProperty> factory)
48
    {
49
        target[ComputedAnnotationNames.ComputedFactory] = factory;
12✔
50
    }
51

52
    internal static ComputedFactory<INavigationBase>? GetComputedFactory(this IReadOnlyNavigationBase target)
53
    {
54
        return target[ComputedAnnotationNames.ComputedFactory] as ComputedFactory<INavigationBase>;
48✔
55
    }
56

57
    internal static void SetComputedFactory(this IMutableNavigationBase target, ComputedFactory<INavigationBase> factory)
58
    {
UNCOV
59
        target[ComputedAnnotationNames.ComputedFactory] = factory;
×
60
    }
61

62
    internal static List<ObserverFactory<IEntityType>>? GetObserversFactories(this IReadOnlyEntityType target)
63
    {
64
        return target[ComputedAnnotationNames.ObserversFactories] as List<ObserverFactory<IEntityType>>;
16✔
65
    }
66

67
    internal static void AddObserverFactory(this IMutableEntityType target, ObserverFactory<IEntityType> factory)
68
    {
UNCOV
69
        var factories = target.GetObserversFactories();
×
UNCOV
70
        if (factories is null)
×
71
        {
UNCOV
72
            factories = [];
×
UNCOV
73
            target[ComputedAnnotationNames.ObserversFactories] = factories;
×
74
        }
UNCOV
75
        factories.Add(factory);
×
76
    }
77

78
    public static ComputedMember? GetComputed(this IPropertyBase target)
79
    {
80
        return target.FindRuntimeAnnotationValue(ComputedAnnotationNames.Computed) as ComputedMember;
11✔
81
    }
82

83
    internal static void SetComputed(this IPropertyBase propertyBase, ComputedMember? computeds)
84
    {
85
        propertyBase.SetRuntimeAnnotation(ComputedAnnotationNames.Computed, computeds);
6✔
86
    }
87

88
    public static IReadOnlyList<Observer>? GetObservers(this IEntityType target)
89
    {
UNCOV
90
        return target.FindRuntimeAnnotationValue(ComputedAnnotationNames.Observers) as IReadOnlyList<Observer>;
×
91
    }
92

93
    internal static void SetObservers(this IEntityType target, IReadOnlyList<Observer>? observers)
94
    {
UNCOV
95
        target.SetRuntimeAnnotation(ComputedAnnotationNames.Observers, observers);
×
96
    }
97

98
    public static IComputedExpressionAnalyzer<IEFCoreComputedInput> GetComputedExpressionAnalyzerOrThrow(this IModel annotatable)
99
    {
100
        return annotatable.FindRuntimeAnnotationValue(ComputedAnnotationNames.ExpressionAnalyzer) as IComputedExpressionAnalyzer<IEFCoreComputedInput>
77✔
101
            ?? throw new Exception($"ExpressionAnalyzer not found in model");
77✔
102
    }
103

104
    internal static void SetExpressionAnalyzer(this IModel annotatable, IComputedExpressionAnalyzer<IEFCoreComputedInput> analyzer)
105
    {
106
        annotatable.SetRuntimeAnnotation(ComputedAnnotationNames.ExpressionAnalyzer, analyzer);
4✔
107
    }
108

109
    internal static IReadOnlyList<ComputedBase> GetSortedComputedsOrThrow(this IModel annotatable)
110
    {
111
        return annotatable.FindRuntimeAnnotationValue(ComputedAnnotationNames.SortedComputeds) as IReadOnlyList<ComputedBase>
114✔
112
            ?? throw new Exception($"SortedComputeds not found in model");
114✔
113
    }
114

115
    internal static void SetSortedComputeds(this IModel annotatable, IReadOnlyList<ComputedBase> computeds)
116
    {
117
        annotatable.SetRuntimeAnnotation(ComputedAnnotationNames.SortedComputeds, computeds);
4✔
118
    }
119
}
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