< Summary

Information
Class: MyNet.Observable.LocalizedEnum<T>
Assembly: MyNet.Observable
File(s): https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.Observable/Base/LocalizedEnum.cs
Tag: 323_28699572109
Line coverage
90%
Covered lines: 9
Uncovered lines: 1
Coverable lines: 10
Total lines: 62
Line coverage: 90%
Branch coverage
50%
Covered branches: 7
Total branches: 14
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%
get_Description()50%44100%
get_Display()50%44100%
ToString()100%210%
OnEvent(...)100%11100%
Equals(...)50%44100%
GetHashCode()50%22100%

File(s)

https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.Observable/Base/LocalizedEnum.cs

#LineLine coverage
 1// -----------------------------------------------------------------------
 2// <copyright file="LocalizedEnum.cs" company="Stéphane ANDRE">
 3// Copyright (c) Stéphane ANDRE. All rights reserved.
 4// </copyright>
 5// -----------------------------------------------------------------------
 6
 7using System;
 8using System.Diagnostics.CodeAnalysis;
 9using MyNet.Humanizer;
 10using MyNet.Humanizer.Facade;
 11using MyNet.Observable.Behaviors.Metadata.Features.Events;
 12using MyNet.Observable.Metadata;
 13
 14#pragma warning disable IDE0130 // Namespace does not match folder structure
 15namespace MyNet.Observable;
 16#pragma warning restore IDE0130 // Namespace does not match folder structure
 17
 18/// <summary>
 19/// Culture-bound display text for a <see cref="Enum"/> value.
 20/// </summary>
 21/// <param name="enumValue">The enum value to present.</param>
 22[SuppressMessage("Naming", "CA1711:Identifiers should not have incorrect suffix", Justification = "LocalizedEnum is more
 23public class LocalizedEnum(Enum enumValue) : LocalizedEnum<Enum>(enumValue);
 24
 25/// <summary>
 26/// Culture-bound display text for an enum value.
 27/// </summary>
 28/// <typeparam name="TEnum">The enum type.</typeparam>
 29/// <param name="enumValue">The enum value to present.</param>
 30[ExemptFromGeneratedMetadata]
 31[SuppressMessage("Naming", "CA1711:Identifiers should not have incorrect suffix", Justification = "LocalizedEnum is more
 9332public class LocalizedEnum<TEnum>(TEnum enumValue) : CultureBoundValue<TEnum>(() => enumValue)
 33    where TEnum : Enum
 34{
 35    /// <summary>
 36    /// Gets the description from <see cref="System.ComponentModel.DescriptionAttribute"/> when present.
 37    /// </summary>
 338    public string Description => Value is null ? string.Empty : Value.GetDescription() ?? string.Empty;
 39
 40    /// <summary>
 41    /// Gets the localized display text for the enum value.
 42    /// </summary>
 643    public string Display => Value?.Humanize() ?? string.Empty;
 44
 45    /// <inheritdoc />
 046    public override string ToString() => Display;
 47
 48    /// <inheritdoc />
 49    public override void OnEvent(CultureChangedEvent e)
 50    {
 3351        base.OnEvent(e);
 3352        NotifyPropertyChanged(nameof(Display));
 3353        NotifyPropertyChanged(nameof(Description));
 3354    }
 55
 56    /// <inheritdoc />
 357    public override bool Equals(object? obj) => obj is LocalizedEnum<TEnum> result && (result.Value?.Equals(Value) ?? fa
 58
 59    /// <inheritdoc />
 660    public override int GetHashCode() => Value?.GetHashCode() ?? 0;
 61}
 62