< Summary

Information
Class: MyNet.Platform.Windows.Registry.WindowsRegistryNavigator
Assembly: MyNet.Platform.Windows
File(s): https://raw.githubusercontent.com/sandre58/MyNet/5aaaab311aa14541478b9e402357d98b657a23e4/src/MyNet.Platform.Windows/Registry/WindowsRegistryNavigator.cs
Tag: 342_31701152804
Line coverage
100%
Covered lines: 8
Uncovered lines: 0
Coverable lines: 8
Total lines: 45
Line coverage: 100%
Branch coverage
50%
Covered branches: 2
Total branches: 4
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor()100%11100%
GetChildren(...)50%22100%
Count(...)50%22100%

File(s)

https://raw.githubusercontent.com/sandre58/MyNet/5aaaab311aa14541478b9e402357d98b657a23e4/src/MyNet.Platform.Windows/Registry/WindowsRegistryNavigator.cs

#LineLine coverage
 1// -----------------------------------------------------------------------
 2// <copyright file="WindowsRegistryNavigator.cs" company="Stéphane ANDRE">
 3// Copyright (c) Stéphane ANDRE. All rights reserved.
 4// </copyright>
 5// -----------------------------------------------------------------------
 6
 7using System.Collections.Generic;
 8using System.Linq;
 9using System.Runtime.Versioning;
 10using Microsoft.Win32;
 11using MyNet.IO.Registry;
 12
 13namespace MyNet.Platform.Windows.Registry;
 14
 15/// <summary>
 16/// Provides a registry navigator implementation for Windows using Microsoft.Win32.Registry.
 17/// </summary>
 18[SupportedOSPlatform("windows")]
 19public sealed class WindowsRegistryNavigator : IRegistryNavigator
 20{
 2421    private readonly RegistryKey _root = Microsoft.Win32.Registry.CurrentUser;
 22
 23    /// <summary>
 24    /// Gets the child registry paths of the specified parent registry path. This method opens the registry key correspo
 25    /// </summary>
 26    /// <param name="parent">The parent registry path.</param>
 27    /// <returns>An enumerable collection of child registry paths.</returns>
 28    public IEnumerable<RegistryPath> GetChildren(RegistryPath parent)
 29    {
 630        using var key = _root.OpenSubKey(parent.ToString());
 31
 632        return key is null
 633            ? []
 634            : key.GetSubKeyNames()
 635            .Select(name => RegistryPath.Combine(parent.ToString(), name));
 636    }
 37
 38    /// <summary>
 39    /// Counts the number of child registry keys under the specified parent registry path. This method opens the registr
 40    /// </summary>
 41    /// <param name="parent">The parent registry path.</param>
 42    /// <returns>The number of child registry keys.</returns>
 343    public int Count(RegistryPath parent) => _root.OpenSubKey(parent.ToString())?.SubKeyCount ?? 0;
 44}
 45