< Summary

Information
Class: Elsa.Extensions.ObjectExtensions
Assembly: Elsa.Workflows.Core
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/Extensions/ObjectExtensions.cs
Line coverage
85%
Covered lines: 6
Uncovered lines: 1
Coverable lines: 7
Total lines: 27
Line coverage: 85.7%
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

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
ToDictionary(...)100%11100%
ToReadOnlyDictionary(...)100%210%
ToDictionaryInternal(...)100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/Extensions/ObjectExtensions.cs

#LineLine coverage
 1using System.Reflection;
 2
 3// ReSharper disable once CheckNamespace
 4namespace Elsa.Extensions;
 5
 6public static class ObjectExtensions
 7{
 8    extension(object source)
 9    {
 10        /// <summary>
 11        /// Converts an object into a dictionary.
 12        /// </summary>
 120113        public IDictionary<string, object> ToDictionary(BindingFlags bindingAttr = BindingFlags.DeclaredOnly | BindingFl
 14
 15        /// <summary>
 16        /// Converts an object into a dictionary.
 17        /// </summary>
 018        public IReadOnlyDictionary<string, object> ToReadOnlyDictionary(BindingFlags bindingAttr = BindingFlags.Declared
 19
 20        private Dictionary<string, object> ToDictionaryInternal(BindingFlags bindingAttr = BindingFlags.DeclaredOnly | B
 120121            source.GetType().GetProperties(bindingAttr).ToDictionary
 120122            (
 120123                propInfo => propInfo.Name,
 120124                propInfo => propInfo.GetValue(source, null)!
 120125            );
 26    }
 27}