TL.ObjectExtensionsLibrary 0.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package TL.ObjectExtensionsLibrary --version 0.2.0
                    
NuGet\Install-Package TL.ObjectExtensionsLibrary -Version 0.2.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TL.ObjectExtensionsLibrary" Version="0.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TL.ObjectExtensionsLibrary" Version="0.2.0" />
                    
Directory.Packages.props
<PackageReference Include="TL.ObjectExtensionsLibrary" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TL.ObjectExtensionsLibrary --version 0.2.0
                    
#r "nuget: TL.ObjectExtensionsLibrary, 0.2.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package TL.ObjectExtensionsLibrary@0.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TL.ObjectExtensionsLibrary&version=0.2.0
                    
Install as a Cake Addin
#tool nuget:?package=TL.ObjectExtensionsLibrary&version=0.2.0
                    
Install as a Cake Tool

🧩 TL.ObjectExtensionsLibrary

NuGet .NET License: MIT ADR

O TL.ObjectExtensionsLibrary disponibiliza métodos utilitários genéricos para qualquer instância derivada de System.Object, facilitando clonagem profunda (deep cloning), conversões para dicionários e ExpandoObject, serialização de dados e invocação reflexiva com preservação do stack trace original.


📦 Instalação

Adicione o pacote ao seu projeto através do .NET CLI:

dotnet add package TL.ObjectExtensionsLibrary

🚀 Funcionalidades Principais

Método Retorno Descrição
Clone() T Realiza a clonagem profunda (deep copy) completa do grafo do objeto em memória.
ToExpando() ExpandoObject Converte o objeto POCO em uma estrutura dinâmica expansível em tempo de execução.
Dictionary() IDictionary<string, object?> Converte todas as propriedades públicas do objeto em um dicionário chave/valor.
Bytes() byte[] Converte o objeto serializado para representação em array de bytes.
InvokeMethod(method, ...args) object? Invoca dinamicamente um método por nome preservando a causa raiz original de exceções.
TryGetProperty(prop, out val) bool Tenta ler o valor de uma propriedade pública sem disparar exceções caso ausente.
SetProperty(prop, value) void Atribui valor à propriedade pelo nome informado via reflexão.
PropertiesEqual(other) bool Compara se os valores de todas as propriedades públicas são idênticos entre dois objetos.
IsDefault() bool Verifica se o valor da instância corresponde ao default do seu tipo.
Serialize() string Serializa o objeto diretamente para formato JSON compacto.
ToJsonIndented() string Serializa o objeto para JSON formatado e indentado (pretty-print).

💡 Exemplos de Uso

using System;
using ObjectExtensionsLibrary;

public class Configuracao
{
    public string Servidor { get; set; } = "localhost";
    public int Porta { get; set; } = 8080;
    public bool Habilitado { get; set; } = true;
}

public class Exemplo
{
    public void Executar()
    {
        var config = new Configuracao();

        // 1. Clonagem Profunda Independente
        var copia = config.Clone();
        copia.Porta = 9000;

        // 2. Comparação de Propriedades
        bool saoIguais = config.PropertiesEqual(copia); // false

        // 3. Conversão para Dicionário
        var mapa = config.Dictionary();

        // 4. Transformação para ExpandoObject Dinâmico
        dynamic expando = config.ToExpando();
    }
}

🏛️ Decisões Arquiteturais

Para detalhes sobre clonagem profunda, desembrulho de TargetInvocationException e convenções de reflexão, consulte:


📄 Licença

Distribuído sob a licença MIT.

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net5.0

    • No dependencies.
  • net6.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on TL.ObjectExtensionsLibrary:

Package Downloads
TL.ExtensionLibrary.Application

Clean Architecture Application metapackage: application orchestration, object utilities, and identity extensions, transitively including Domain.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.8.0 173 10/1/2026
0.7.0 158 9/26/2026
0.6.0 169 9/22/2026
0.5.0 163 9/16/2026
0.4.2 180 9/16/2026
0.4.1 180 9/11/2026
0.4.0 185 9/6/2026
0.3.0 110 9/6/2026
0.2.0 113 9/5/2026
0.1.0 119 9/4/2026
0.0.1 221 10/19/2024