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

lucaslorentz / auto-compute / 11750808709

08 Nov 2024 11:01PM UTC coverage: 81.803% (+0.4%) from 81.44%
11750808709

push

github

lucaslorentz
Add initial support for computed navigations and observers

151 of 309 new or added lines in 14 files covered. (48.87%)

12 existing lines in 5 files now uncovered.

1452 of 1775 relevant lines covered (81.8%)

116.37 hits per line

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

92.86
/src/LLL.AutoCompute.EFCore/Internal/ComputedOptionsExtension.cs
1
using System.Linq.Expressions;
2
using LLL.AutoCompute.Caching;
3
using LLL.AutoCompute.EFCore.Metadata.Conventions;
4
using Microsoft.EntityFrameworkCore.Infrastructure;
5
using Microsoft.EntityFrameworkCore.Metadata;
6
using Microsoft.EntityFrameworkCore.Metadata.Conventions.Infrastructure;
7
using Microsoft.EntityFrameworkCore.Query;
8
using Microsoft.Extensions.DependencyInjection;
9

10
namespace LLL.AutoCompute.EFCore.Internal;
11

12
public class ComputedOptionsExtension : IDbContextOptionsExtension
13
{
14
    public DbContextOptionsExtensionInfo Info => new ComputedOptionsExtensionInfo(this);
1,092✔
15

16
    public Func<IServiceProvider, IModel, IComputedExpressionAnalyzer<IEFCoreComputedInput>>? AnalyzerFactory { get; set; }
4✔
17

18
    public List<Action<IServiceProvider, IModel, ComputedExpressionAnalyzer<IEFCoreComputedInput>>> AnalyzerConfigurations { get; } = [];
95✔
19

20
    public IList<Func<LambdaExpression, LambdaExpression>> ExpressionModifiers { get; } = [];
91✔
21

22
    public void ApplyServices(IServiceCollection services)
23
    {
24
        services.AddSingleton(s => new Func<IModel, IComputedExpressionAnalyzer<IEFCoreComputedInput>>((model) =>
5✔
25
        {
5✔
26
            return AnalyzerFactory is not null
9✔
27
                ? AnalyzerFactory(s, model)
9✔
28
                : DefaultAnalyzerFactory(s, model);
9✔
29
        }));
5✔
30

31
        services.AddSingleton<IConcurrentCreationCache, ConcurrentCreationMemoryCache>();
4✔
32
        services.AddScoped<IConventionSetPlugin, ComputedConventionSetPlugin>();
4✔
33
    }
34

35
    public void Validate(IDbContextOptions options)
36
    {
37
    }
38

39
    private IComputedExpressionAnalyzer<IEFCoreComputedInput> DefaultAnalyzerFactory(
40
        IServiceProvider service, IModel model)
41
    {
42
        var concurrentCreationCache = service.GetRequiredService<IConcurrentCreationCache>();
4✔
43

44
        var analyzer = new ComputedExpressionAnalyzer<IEFCoreComputedInput>(
4✔
45
                concurrentCreationCache,
4✔
46
                ExpressionEqualityComparer.Instance
4✔
47
            )
4✔
48
            .AddDefaults()
4✔
49
            .AddEntityMemberAccessLocator(new EFCoreEntityMemberAccessLocator(model))
4✔
50
            .SetEntityActionProvider(new EFCoreEntityActionProvider());
4✔
51

52
        foreach (var customize in AnalyzerConfigurations)
8✔
UNCOV
53
            customize(service, model, analyzer);
×
54

55
        return analyzer;
4✔
56
    }
57

58
    private class ComputedOptionsExtensionInfo(IDbContextOptionsExtension extension)
59
        : DbContextOptionsExtensionInfo(extension)
1,092✔
60
    {
61
        public override bool IsDatabaseProvider => false;
4✔
UNCOV
62
        public override string LogFragment => string.Empty;
×
63
        public override void PopulateDebugInfo(IDictionary<string, string> debugInfo)
64
        {
65
        }
66
        public override int GetServiceProviderHashCode() => 0;
364✔
67
        public override bool ShouldUseSameServiceProvider(DbContextOptionsExtensionInfo other)
68
            => true;
360✔
69
    }
70
}
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