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

lucaslorentz / auto-compute / 12972048738

26 Jan 2025 06:09AM UTC coverage: 83.217% (-1.2%) from 84.441%
12972048738

push

github

lucaslorentz
Add consistency checks with time filter

9 of 41 new or added lines in 9 files covered. (21.95%)

1790 of 2151 relevant lines covered (83.22%)

431.79 hits per line

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

78.57
/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 ComputedFactory<IProperty>? GetComputedFactory(this IReadOnlyProperty target)
58
    {
59
        return target[ComputedAnnotationNames.ComputedFactory] as ComputedFactory<IProperty>;
222✔
60
    }
61

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

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

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

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

82
    internal static void AddObserverFactory(this IMutableEntityType target, ObserverFactory<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.Computed) as ComputedMember;
141✔
96
    }
97

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

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

108
    internal static void SetComputedObservers(this IEntityType target, IReadOnlyList<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<ComputedBase> GetSortedComputedsOrThrow(this IModel annotatable)
125
    {
126
        return annotatable.FindRuntimeAnnotationValue(ComputedAnnotationNames.SortedComputeds) as IReadOnlyList<ComputedBase>
122✔
127
            ?? throw new Exception($"SortedComputeds not found in model");
122✔
128
    }
129

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

135
    internal static LambdaExpression? GetConsistencyFilter(
136
        this IEntityType entityType)
137
    {
NEW
138
        return entityType[ComputedAnnotationNames.ConsistencyFilter] as LambdaExpression;
×
139
    }
140

141
    internal static void SetConsistencyFilter(
142
        this IMutableEntityType entityType,
143
        LambdaExpression filter)
144
    {
NEW
145
        entityType[ComputedAnnotationNames.ConsistencyFilter] = filter;
×
146
    }
147
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc