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

lucaslorentz / auto-compute / 13087746143

01 Feb 2025 10:27AM UTC coverage: 83.524% (+0.3%) from 83.178%
13087746143

push

github

lucaslorentz
Split DbContext update computeds from notify observers

64 of 68 new or added lines in 9 files covered. (94.12%)

3 existing lines in 2 files now uncovered.

1825 of 2185 relevant lines covered (83.52%)

428.51 hits per line

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

80.0
/src/LLL.AutoCompute.EFCore/Metadata/Internal/ComputedAnnotationAccessors.cs
1
using System.Linq.Expressions;
2
using LLL.AutoCompute.EFCore.Internal;
3
using Microsoft.EntityFrameworkCore.Metadata;
4

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

7
public static class ComputedAnnotationAccessors
8
{
9
    internal static EFCoreObservedEntityType GetOrCreateObservedEntityType(this IEntityType entityType)
10
    {
11
        return entityType.GetOrAddRuntimeAnnotationValue(
197✔
12
            ComputedAnnotationNames.ObservedEntityType,
197✔
13
            static (entityType) => new EFCoreObservedEntityType(entityType!),
221✔
14
            entityType);
197✔
15
    }
16

17
    internal static EFCoreObservedEntityType? GetObservedEntityType(this IEntityType entityType)
18
    {
19
        return entityType.FindRuntimeAnnotationValue(
×
20
            ComputedAnnotationNames.ObservedEntityType) as EFCoreObservedEntityType;
×
21
    }
22

23
    internal static EFCoreObservedProperty GetOrCreateObservedProperty(this IProperty property)
24
    {
25
        return property.GetOrAddRuntimeAnnotationValue(
411✔
26
            ComputedAnnotationNames.ObservedMember,
411✔
27
            static (property) => new EFCoreObservedProperty(property!),
482✔
28
            property);
411✔
29
    }
30

31
    internal static EFCoreObservedProperty? GetObservedProperty(this IProperty property)
32
    {
33
        return property.FindRuntimeAnnotationValue(
×
34
            ComputedAnnotationNames.ObservedMember) as EFCoreObservedProperty;
×
35
    }
36

37
    internal static EFCoreObservedNavigation GetOrCreateObservedNavigation(this INavigationBase navigation)
38
    {
39
        return navigation.GetOrAddRuntimeAnnotationValue(
1,083✔
40
            ComputedAnnotationNames.ObservedMember,
1,083✔
41
            static (navigation) => new EFCoreObservedNavigation(navigation!),
1,122✔
42
            navigation);
1,083✔
43
    }
44

45
    internal static EFCoreObservedNavigation? GetObservedNavigation(this INavigationBase navigation)
46
    {
47
        return navigation.FindRuntimeAnnotationValue(
×
48
            ComputedAnnotationNames.ObservedMember) as EFCoreObservedNavigation;
×
49
    }
50

51
    internal static EFCoreObservedMember? GetObservedMember(this IPropertyBase member)
52
    {
53
        return member.FindRuntimeAnnotationValue(
734✔
54
            ComputedAnnotationNames.ObservedMember) as EFCoreObservedMember;
734✔
55
    }
56

57
    internal static ComputedMemberFactory<IProperty>? GetComputedFactory(this IReadOnlyProperty target)
58
    {
59
        return target[ComputedAnnotationNames.MemberFactory] as ComputedMemberFactory<IProperty>;
222✔
60
    }
61

62
    internal static void SetComputedFactory(this IMutableProperty target, ComputedMemberFactory<IProperty> factory)
63
    {
64
        target[ComputedAnnotationNames.MemberFactory] = factory;
154✔
65
    }
66

67
    internal static ComputedMemberFactory<INavigationBase>? GetComputedFactory(this IReadOnlyNavigationBase target)
68
    {
69
        return target[ComputedAnnotationNames.MemberFactory] as ComputedMemberFactory<INavigationBase>;
151✔
70
    }
71

72
    internal static void SetComputedFactory(this IMutableNavigationBase target, ComputedMemberFactory<INavigationBase> factory)
73
    {
74
        target[ComputedAnnotationNames.MemberFactory] = factory;
2✔
75
    }
76

77
    internal static List<ComputedObserverFactory<IEntityType>>? GetObserversFactories(this IReadOnlyEntityType target)
78
    {
79
        return target[ComputedAnnotationNames.ObserversFactories] as List<ComputedObserverFactory<IEntityType>>;
52✔
80
    }
81

82
    internal static void AddObserverFactory(this IMutableEntityType target, ComputedObserverFactory<IEntityType> factory)
83
    {
84
        var factories = target.GetObserversFactories();
12✔
85
        if (factories is null)
12✔
86
        {
87
            factories = [];
12✔
88
            target[ComputedAnnotationNames.ObserversFactories] = factories;
12✔
89
        }
90
        factories.Add(factory);
12✔
91
    }
92

93
    public static ComputedMember? GetComputedMember(this IPropertyBase target)
94
    {
95
        return target.FindRuntimeAnnotationValue(ComputedAnnotationNames.Member) as ComputedMember;
129✔
96
    }
97

98
    internal static void SetComputedMember(this IPropertyBase propertyBase, ComputedMember? computedMember)
99
    {
100
        propertyBase.SetRuntimeAnnotation(ComputedAnnotationNames.Member, computedMember);
78✔
101
    }
102

103
    public static IReadOnlyCollection<ComputedObserver>? GetComputedObservers(this IEntityType target)
104
    {
NEW
105
        return target.FindRuntimeAnnotationValue(ComputedAnnotationNames.Observers) as IReadOnlyCollection<ComputedObserver>;
×
106
    }
107

108
    internal static void SetComputedObservers(this IEntityType target, IReadOnlyCollection<ComputedObserver>? computedObservers)
109
    {
110
        target.SetRuntimeAnnotation(ComputedAnnotationNames.Observers, computedObservers);
6✔
111
    }
112

113
    public static IComputedExpressionAnalyzer<IEFCoreComputedInput> GetComputedExpressionAnalyzerOrThrow(this IModel annotatable)
114
    {
115
        return annotatable.FindRuntimeAnnotationValue(ComputedAnnotationNames.ExpressionAnalyzer) as IComputedExpressionAnalyzer<IEFCoreComputedInput>
78✔
116
            ?? throw new Exception($"ExpressionAnalyzer not found in model");
78✔
117
    }
118

119
    internal static void SetExpressionAnalyzer(this IModel annotatable, IComputedExpressionAnalyzer<IEFCoreComputedInput> analyzer)
120
    {
121
        annotatable.SetRuntimeAnnotation(ComputedAnnotationNames.ExpressionAnalyzer, analyzer);
10✔
122
    }
123

124
    public static IReadOnlyList<ComputedMember> GetAllComputedMembers(this IModel annotatable)
125
    {
126
        return annotatable.FindRuntimeAnnotationValue(ComputedAnnotationNames.AllMembers) as IReadOnlyList<ComputedMember>
122✔
127
            ?? throw new Exception($"{ComputedAnnotationNames.AllMembers} annotation not found in model");
122✔
128
    }
129

130
    internal static void SetAllComputedMembers(this IModel annotatable, IReadOnlyList<ComputedMember> computeds)
131
    {
132
        annotatable.SetRuntimeAnnotation(ComputedAnnotationNames.AllMembers, computeds);
10✔
133
    }
134

135
    public static IReadOnlyList<ComputedObserver> GetAllComputedObservers(this IModel annotatable)
136
    {
137
        return annotatable.FindRuntimeAnnotationValue(ComputedAnnotationNames.AllObservers) as IReadOnlyList<ComputedObserver>
122✔
138
            ?? throw new Exception($"{ComputedAnnotationNames.AllObservers} annotation not found in model");
122✔
139
    }
140

141
    internal static void SetAllComputedObservers(this IModel annotatable, IReadOnlyList<ComputedObserver> computeds)
142
    {
143
        annotatable.SetRuntimeAnnotation(ComputedAnnotationNames.AllObservers, computeds);
10✔
144
    }
145

146
    internal static LambdaExpression? GetConsistencyFilter(
147
        this IEntityType entityType)
148
    {
UNCOV
149
        return entityType[ComputedAnnotationNames.ConsistencyFilter] as LambdaExpression;
×
150
    }
151

152
    internal static void SetConsistencyFilter(
153
        this IMutableEntityType entityType,
154
        LambdaExpression filter)
155
    {
UNCOV
156
        entityType[ComputedAnnotationNames.ConsistencyFilter] = filter;
×
157
    }
158
}
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