< Summary

Information
Class: MyNet.Reflection.ObjectGraphExtensions
Assembly: MyNet.Reflection
File(s): https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.Reflection/Extensions/ObjectGraphExtensions.cs
Tag: 323_28699572109
Line coverage
100%
Covered lines: 5
Uncovered lines: 0
Coverable lines: 5
Total lines: 39
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

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
DeepClone(...)100%11100%
PopulateFrom(...)100%11100%

File(s)

https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.Reflection/Extensions/ObjectGraphExtensions.cs

#LineLine coverage
 1// -----------------------------------------------------------------------
 2// <copyright file="ObjectGraphExtensions.cs" company="Stéphane ANDRE">
 3// Copyright (c) Stéphane ANDRE. All rights reserved.
 4// </copyright>
 5// -----------------------------------------------------------------------
 6
 7using System;
 8using System.Runtime.CompilerServices;
 9
 10#pragma warning disable IDE0130 // Namespace does not match folder structure
 11namespace MyNet.Reflection;
 12#pragma warning restore IDE0130 // Namespace does not match folder structure
 13
 14public static class ObjectGraphExtensions
 15{
 16    extension<T>(T obj)
 17    {
 18        /// <summary>
 19        /// Returns a Deep Clone / Deep Copy of an object of type T using a recursive call to the CloneMethod specified 
 20        /// </summary>
 21        /// <param name="options">Options for deep copy.</param>
 22        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 923        public T? DeepClone(DeepCloneOptions? options = null) => ObjectGraphMapper.Clone(obj, options);
 24
 25        /// <summary>
 26        /// Populates the fields and properties of the current object with the values from the specified source object o
 27        /// </summary>
 28        /// <param name="source">The source object from which to copy values.</param>
 29        [MethodImpl(MethodImplOptions.AggressiveInlining)]
 30        public void PopulateFrom(T source)
 31        {
 1232            ArgumentNullException.ThrowIfNull(obj);
 1233            ArgumentNullException.ThrowIfNull(source);
 34
 1235            ObjectGraphMapper.Populate(source, obj);
 1236        }
 37    }
 38}
 39