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

DemoBytom / DemoEngine / 25463527634

06 May 2026 09:58PM UTC coverage: 28.38% (+0.02%) from 28.36%
25463527634

push

coveralls.net

DemoBytom
Continue working on instrumentation registration

Cleaned up instrumentation registration pattern, where any module can register it's own instrumentation package, by preparing a simple extension method, that would be called in the `Program.cs` to register it within the instrumentation sources. Everything handled by interfaces and extension methods.
A room for improvement using source generators in the future.

1226 of 4320 relevant lines covered (28.38%)

0.32 hits per line

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

0.0
/src/Demo.Engine.Core/RegistrationExtensions.cs
1
// Copyright © Michał Dembski and contributors.
2
// Distributed under MIT license. See LICENSE file in the root for more information.
3

4
using System.Threading.Channels;
5
using Demo.Engine.Core.Components.Keyboard.Internal;
6
using Demo.Engine.Core.Features.StaThread;
7
using Demo.Engine.Core.Interfaces;
8
using Demo.Engine.Core.Interfaces.Components;
9
using Demo.Engine.Core.Interfaces.Platform;
10
using Demo.Engine.Core.Platform;
11
using Demo.Engine.Core.Services;
12
using Demo.Engine.Observability.Abstractions;
13
using Microsoft.Extensions.DependencyInjection;
14

15
namespace Demo.Engine.Core;
16

17
public static class RegistrationExtensions
18
{
19
    public static IServiceCollection AddEngineCore(
20
        this IServiceCollection services) => services
×
21
                .AddSingleton<IKeyboardCache, KeyboardCache>()
×
22
                .AddTransient<IFpsTimer, FpsTimer>()
×
23
                .AddTransient<IContentFileProvider, ContentFileProvider>()
×
24
                .AddHostedService<EngineService>()
×
25
                .AddScoped<IMainLoopLifetime, MainLoopLifetime>()
×
26
                .AddScoped<ILoopJob, LoopJob>()
×
27
                .AddScoped<IMainLoopService, MainLoopService>()
×
28
                .AddStaThreadFeature()
×
29
                ;
30

31
    internal static IServiceCollection AddSingletonBoundedChannel<T>(
32
        this IServiceCollection services,
33
            BoundedChannelOptions options)
34
        => services
×
35
            .AddSingleton(_
×
36
                => Channel.CreateBounded<T>(
×
37
                    options))
×
38
            .AddSingleton(sp
×
39
                => sp.GetRequiredService<Channel<T>>().Reader)
×
40
            .AddSingleton(sp
×
41
                => sp.GetRequiredService<Channel<T>>().Writer)
×
42
        ;
43

44
    public static TTelemetryBuilder WithCoreInstrumentation<TTelemetryBuilder>(
45
        this TTelemetryBuilder telemetryBuilder)
46
        where TTelemetryBuilder : ITelemetryBuilder<TTelemetryBuilder>, allows ref struct
47
        => telemetryBuilder.WithInstrumentation<Instrumentation>();
×
48
}
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