< Summary - Jellyfin

Information
Class: Jellyfin.Server.Migrations.Stages.CodeMigration
Assembly: jellyfin
File(s): /srv/git/jellyfin/Jellyfin.Server/Migrations/Stages/CodeMigration.cs
Line coverage
100%
Covered lines: 1
Uncovered lines: 0
Coverable lines: 1
Total lines: 51
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
BuildCodeMigrationId()100%11100%

File(s)

/srv/git/jellyfin/Jellyfin.Server/Migrations/Stages/CodeMigration.cs

#LineLine coverage
 1using System;
 2using System.Globalization;
 3using System.Threading;
 4using System.Threading.Tasks;
 5using Microsoft.Extensions.DependencyInjection;
 6
 7namespace Jellyfin.Server.Migrations.Stages;
 8
 9internal class CodeMigration(Type migrationType, JellyfinMigrationAttribute metadata)
 10{
 11    public Type MigrationType { get; } = migrationType;
 12
 13    public JellyfinMigrationAttribute Metadata { get; } = metadata;
 14
 15    public string BuildCodeMigrationId()
 16    {
 2137817        return Metadata.Order.ToString("yyyyMMddHHmmsss", CultureInfo.InvariantCulture) + "_" + MigrationType.Name!;
 18    }
 19
 20    public async Task Perform(IServiceProvider? serviceProvider, CancellationToken cancellationToken)
 21    {
 22#pragma warning disable CS0618 // Type or member is obsolete
 23        if (typeof(IMigrationRoutine).IsAssignableFrom(MigrationType))
 24        {
 25            if (serviceProvider is null)
 26            {
 27                ((IMigrationRoutine)Activator.CreateInstance(MigrationType)!).Perform();
 28            }
 29            else
 30            {
 31                ((IMigrationRoutine)ActivatorUtilities.CreateInstance(serviceProvider, MigrationType)).Perform();
 32#pragma warning restore CS0618 // Type or member is obsolete
 33            }
 34        }
 35        else if (typeof(IAsyncMigrationRoutine).IsAssignableFrom(MigrationType))
 36        {
 37            if (serviceProvider is null)
 38            {
 39                await ((IAsyncMigrationRoutine)Activator.CreateInstance(MigrationType)!).PerformAsync(cancellationToken)
 40            }
 41            else
 42            {
 43                await ((IAsyncMigrationRoutine)ActivatorUtilities.CreateInstance(serviceProvider, MigrationType)).Perfor
 44            }
 45        }
 46        else
 47        {
 48            throw new InvalidOperationException($"The type {MigrationType} does not implement either IMigrationRoutine o
 49        }
 50    }
 51}

Methods/Properties

BuildCodeMigrationId()