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

lucaslorentz / auto-compute / 11758703019

09 Nov 2024 07:01PM UTC coverage: 77.208% (-2.7%) from 79.869%
11758703019

push

github

lucaslorentz
Add initial support for computed navigations and observers

160 of 425 new or added lines in 23 files covered. (37.65%)

41 existing lines in 7 files now uncovered.

1460 of 1891 relevant lines covered (77.21%)

109.64 hits per line

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

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

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

7
public static class ComputedAnnotationAccessors
8
{
9
    internal static List<ComputedFactory<IEntityType>>? GetComputedFactories(
10
        this IEntityType target)
11
    {
12
        return target.GetComputedFactoriesInternal<IEntityType>();
16✔
13
    }
14

15
    internal static List<ComputedFactory<IProperty>>? GetComputedFactories(
16
        this IProperty target)
17
    {
18
        return target.GetComputedFactoriesInternal<IProperty>();
64✔
19
    }
20

21
    internal static List<ComputedFactory<INavigationBase>>? GetComputedFactories(
22
        this INavigationBase target)
23
    {
24
        return target.GetComputedFactoriesInternal<INavigationBase>();
48✔
25
    }
26

27
    internal static void AddComputedFactory(
28
        this IMutableProperty metadata,
29
        ComputedFactory<IProperty> factory)
30
    {
31
        metadata.AddComputedFactoryInternal(factory);
12✔
32
    }
33

34
    internal static void AddComputedFactory(
35
        this IMutableNavigationBase metadata,
36
        ComputedFactory<INavigationBase> factory)
37
    {
NEW
38
        metadata.AddComputedFactoryInternal(factory);
×
39
    }
40

41
    internal static void AddComputedFactory(
42
        this IMutableEntityType metadata,
43
        ComputedFactory<IEntityType> factory)
44
    {
NEW
45
        metadata.AddComputedFactoryInternal(factory);
×
46
    }
47

48
    private static List<ComputedFactory<TTarget>>? GetComputedFactoriesInternal<TTarget>(
49
        this IReadOnlyAnnotatable target)
50
    {
51
        return target[ComputedAnnotationNames.Factories] as List<ComputedFactory<TTarget>>;
140✔
52
    }
53

54
    private static void AddComputedFactoryInternal<TTarget>(
55
        this IMutableAnnotatable mutableTarget,
56
        ComputedFactory<TTarget> factory)
57
    {
58
        var factories = mutableTarget.GetComputedFactoriesInternal<TTarget>();
12✔
59
        if (factories is null)
12✔
60
        {
61
            factories = [];
12✔
62
            mutableTarget[ComputedAnnotationNames.Factories] = factories;
12✔
63
        }
64
        factories.Add(factory);
12✔
65
    }
66

67
    public static IReadOnlyList<Computed>? GetComputeds(this IAnnotatable annotatable)
68
    {
69
        return annotatable.FindRuntimeAnnotationValue(ComputedAnnotationNames.Computeds) as IReadOnlyList<Computed>;
35✔
70
    }
71

72
    internal static void SetComputeds(
73
        this IAnnotatable annotatable,
74
        IReadOnlyList<Computed>? computeds)
75
    {
76
        annotatable.SetRuntimeAnnotation(ComputedAnnotationNames.Computeds, computeds);
6✔
77
    }
78

79
    public static IComputedExpressionAnalyzer<IEFCoreComputedInput> GetComputedExpressionAnalyzerOrThrow(this IModel annotatable)
80
    {
81
        return annotatable.FindRuntimeAnnotationValue(ComputedAnnotationNames.ExpressionAnalyzer) as IComputedExpressionAnalyzer<IEFCoreComputedInput>
77✔
82
            ?? throw new Exception($"ExpressionAnalyzer not found in model");
77✔
83
    }
84

85
    internal static void SetExpressionAnalyzer(this IModel annotatable, IComputedExpressionAnalyzer<IEFCoreComputedInput> analyzer)
86
    {
87
        annotatable.SetRuntimeAnnotation(ComputedAnnotationNames.ExpressionAnalyzer, analyzer);
4✔
88
    }
89

90
    internal static IReadOnlyList<Computed> GetSortedComputedsOrThrow(this IModel annotatable)
91
    {
92
        return annotatable.FindRuntimeAnnotationValue(ComputedAnnotationNames.SortedComputeds) as IReadOnlyList<Computed>
114✔
93
            ?? throw new Exception($"SortedComputeds not found in model");
114✔
94
    }
95

96
    internal static void SetSortedComputeds(this IModel annotatable, IReadOnlyList<Computed> computeds)
97
    {
98
        annotatable.SetRuntimeAnnotation(ComputedAnnotationNames.SortedComputeds, computeds);
4✔
99
    }
100
}
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