Pitasoft.Parse 6.0.2

Suggested Alternatives

Pitasoft.BinaryText

Additional Details

Pitasoft.Parse is being discontinued and will no longer receive new features or evolutionary improvements. Its original scope has been divided into two independent packages to separate responsibilities and allow for clearer evolution of each area.

From now on, the functionality is distributed as follows:

Pitasoft.BinaryText: focused on transformation between binary data and text representations, with an emphasis on scenarios such as hexadecimal and related conversions.

Pitasoft.ObjectMapping: focused on object mapping in the backend, especially in Entity -> DTO, DTO -> Entity flows, partial updates, fluid configuration, validation, and performance optimizations.

This separation improves the cohesion of each package, simplifies maintenance, and allows for the incorporation of new, specialized capabilities that didn't fit well within Pitasoft.Parse as a single package.

dotnet add package Pitasoft.Parse --version 6.0.2
                    
NuGet\Install-Package Pitasoft.Parse -Version 6.0.2
                    
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="Pitasoft.Parse" Version="6.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Pitasoft.Parse" Version="6.0.2" />
                    
Directory.Packages.props
<PackageReference Include="Pitasoft.Parse" />
                    
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 Pitasoft.Parse --version 6.0.2
                    
#r "nuget: Pitasoft.Parse, 6.0.2"
                    
#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 Pitasoft.Parse@6.0.2
                    
#: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=Pitasoft.Parse&version=6.0.2
                    
Install as a Cake Addin
#tool nuget:?package=Pitasoft.Parse&version=6.0.2
                    
Install as a Cake Tool

Pitasoft.Parse

NuGet Version NuGet Downloads Build Status License .NET

English | Castellano


English

A high-performance .NET library providing extension methods for object property copying and byte/hex conversions.

Tags: Array, String, Byte, Hex, Copy, Property, Mapper, Performance, Span, Reflection

Features

  • Efficient Property Copying: Copy matching properties between objects using compiled delegates (Expression Trees) for near-native performance.
    • Alias Support: Use the [Alias("Name")] attribute to map properties with different names.
    • C# Record Support: Compatible with record types, including those with init-only properties.
  • Optimized Byte Conversions:
    • ToStringBytes / ToArrayBytes: Convert byte collections to/from comma-separated hex strings.
    • ToHexString / FromHexString: Convert byte collections to/from continuous hex strings (padded to 2 chars).
    • Try Pattern: Safe TryToArrayBytes to avoid exceptions.
  • Low Memory Footprint: Leverages Span<T>, string.Create, and caching to minimize allocations and Garbage Collector pressure.
  • Cross-Platform: Supports .NET 8.0, 9.0, and 10.0.

Installation

dotnet add package Pitasoft.Parse

Usage

Property Copying

You can copy all matching properties from one object to another (or to a new instance). It supports class and record types.

Classes and Aliases
using Pitasoft.Parse;

public class User {
    public int Id { get; set; }
    public string Name { get; set; }
}

public class UserDto {
    [Alias("Id")]
    public int Identifier { get; set; } // Matches User.Id because of the alias
    public string Name { get; set; }
}

var source = new User { Id = 1, Name = "John Doe" };

// Create a new instance and copy matching properties (including aliases)
var target = source.CopyAllProperties<User, UserDto>();
C# Records

The library works with record types. For methods that create a new instance, the record must have a parameterless constructor (required by the new() constraint).

public record UserRecord
{
    public string Name { get; init; } = string.Empty;
    public int Age { get; init; }
    
    public UserRecord() { } // Required for methods that instantiate the record
}

var source = new User { Name = "Jane Doe", Age = 30 };
var record = source.CopyAllProperties<User, UserRecord>();
Byte and Hex Conversions
using Pitasoft.Parse;

byte[] data = { 0xDE, 0xAD, 0xBE, 0xEF };

// To comma-separated hex: "de,ad,be,ef"
string csvHex = data.ToStringBytes();

// To continuous hex: "deadbeef"
string continuousHex = data.ToHexString();

// Back to byte array
byte[] recovered1 = csvHex.ToArrayBytes();
byte[] recovered2 = continuousHex.FromHexString();

// Safe conversion
if (csvHex.TryToArrayBytes(out byte[]? result)) {
    // use result
}

Performance

The library is designed for high-throughput scenarios:

  • Property Copying: ~13ns per operation (73% faster than traditional reflection).
  • Byte Conversions: Optimized with Span and pre-calculated buffers.

Castellano

Una librería de alto rendimiento para .NET que proporciona métodos de extensión para la copia de propiedades de objetos y conversiones de bytes/hexadecimal.

Etiquetas: Array, String, Byte, Hex, Copy, Property, Mapper, Performance, Span, Reflection

Características

  • Copia Eficiente de Propiedades: Copia propiedades coincidentes entre objetos utilizando delegados compilados (Expression Trees) para un rendimiento cercano al nativo.
    • Soporte de Alias: Utilice el atributo [Alias("Nombre")] para mapear propiedades con nombres diferentes.
    • Soporte para Records de C#: Compatible con tipos record, incluyendo aquellos con propiedades init-only.
  • Conversiones de Bytes Optimizadas:
    • ToStringBytes / ToArrayBytes: Convierte colecciones de bytes a/desde cadenas hexadecimales separadas por comas.
    • ToHexString / FromHexString: Convierte colecciones de bytes a/desde cadenas hexadecimales continuas (rellenadas a 2 caracteres).
    • Patrón Try: TryToArrayBytes para conversiones seguras sin excepciones.
  • Bajo Consumo de Memoria: Aprovecha Span<T>, string.Create y el almacenamiento en caché para minimizar las asignaciones y la presión sobre el Garbage Collector.
  • Multiplataforma: Soporta .NET 8.0, 9.0 y 10.0.

Instalación

dotnet add package Pitasoft.Parse

Uso

Copia de Propiedades

Puede copiar todas las propiedades coincidentes de un objeto a otro (o a una nueva instancia). Soporta tanto tipos class como record.

Clases y Alias
using Pitasoft.Parse;

public class Usuario {
    public int Id { get; set; }
    public string Nombre { get; set; }
}

public class UsuarioDto {
    [Alias("Id")]
    public int Identificador { get; set; } // Coincide con Usuario.Id por el alias
    public string Nombre { get; set; }
}

var fuente = new Usuario { Id = 1, Nombre = "Juan Pérez" };

// Crear una nueva instancia y copiar las propiedades coincidentes (incluyendo alias)
var destino = fuente.CopyAllProperties<Usuario, UsuarioDto>();
Records de C#

La librería funciona con tipos record. Para los métodos que crean una nueva instancia, el record debe tener un constructor sin parámetros (requerido por la restricción new()).

public record UsuarioRecord
{
    public string Nombre { get; init; } = string.Empty;
    public int Edad { get; init; }
    
    public UsuarioRecord() { } // Requerido para métodos que instancian el record
}

var fuente = new Usuario { Nombre = "Juana Pérez", Edad = 30 };
var record = fuente.CopyAllProperties<Usuario, UsuarioRecord>();
Conversiones de Bytes y Hexadecimal
using Pitasoft.Parse;

byte[] data = { 0xDE, 0xAD, 0xBE, 0xEF };

// A hex separado por comas: "de,ad,be,ef"
string csvHex = data.ToStringBytes();

// A hex continuo: "deadbeef"
string continuousHex = data.ToHexString();

// De vuelta a array de bytes
byte[] recuperado1 = csvHex.ToArrayBytes();
byte[] recuperado2 = continuousHex.FromHexString();

// Conversión segura
if (csvHex.TryToArrayBytes(out byte[]? resultado)) {
    // usar resultado
}

Rendimiento

La librería está diseñada para escenarios de alto rendimiento:

  • Copia de Propiedades: ~13ns por operación (un 73% más rápido que la reflexión tradicional).
  • Conversiones de Bytes: Optimizado con Span y buffers precalculados.

License

This project is licensed under the MIT License - see the LICENSE.txt file for details.

Copyright © 2020-2026 Pitasoft, S.L. All rights reserved.

Product Compatible and additional computed target framework versions.
.NET 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 is compatible.  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 is compatible.  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.
  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
6.0.2 140 3/6/2026 6.0.2 is deprecated because it is no longer maintained.
6.0.1 135 2/13/2026
5.5.0 302 5/19/2025
5.0.0 306 8/21/2024
4.1.1 565 11/20/2023
4.1.0 268 11/20/2023
4.0.3 292 10/23/2023
4.0.2 267 10/23/2023
4.0.1 239 10/23/2023
4.0.0 258 10/23/2023
3.2.0 542 11/18/2022
3.1.0 602 7/26/2022
3.0.0 540 1/3/2022
2.0.0 568 6/25/2021
1.0.0 689 2/18/2020