StarFuryDev.ObjectMapper 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package StarFuryDev.ObjectMapper --version 1.0.0
                    
NuGet\Install-Package StarFuryDev.ObjectMapper -Version 1.0.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="StarFuryDev.ObjectMapper" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="StarFuryDev.ObjectMapper" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="StarFuryDev.ObjectMapper" />
                    
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 StarFuryDev.ObjectMapper --version 1.0.0
                    
#r "nuget: StarFuryDev.ObjectMapper, 1.0.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 StarFuryDev.ObjectMapper@1.0.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=StarFuryDev.ObjectMapper&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=StarFuryDev.ObjectMapper&version=1.0.0
                    
Install as a Cake Tool

StarFuryDev.ObjectMapper

NuGet License: MIT

A simple and lightweighta attribute based object mapping library for .NET, built as a hobby project to make object-to-object mapping easier.

Why This Library?

I created this library as a personal learning project and wanted to share it with the community. While there are other great mapping libraries out there, I built this to:

  • Learn more about reflection and attributes in C#
  • Explore different approaches to object mapping
  • Share something useful with the .NET community

Feel free to use it or just peek at the code!

Installation

Install via NuGet Package Manager:

dotnet add package StarFuryDev.ObjectMapper

Or via Package Manager Console:

Install-Package StarFuryDev.ObjectMapper

Quick Start

using StarFuryDev.ObjectMapper;

// Source data
public class Person
{
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public int Age { get; set; }
}

// Destination
[MapFrom(nameof(Person))]
public class Profile
{
    // default mapping - source property name = destination property name
    public string FirstName { get; set; }

    // Map from using a custom converter
    [MapFromUsing(typeof(CustomConverters), nameof(CustomConverters.ConvertToFullName))]
    public string FullName { get; set; }
    
    // Map from using a different property 
    [MapFrom(nameof(Source.Age))]
    public int MyAge { get; set; }

    // Ignore when mapping
    [MapIgnore]
    prop string Address { get; set; }
}

public static class CustomConverters
{
    public static string ConvertToFullName(string firstName, string lastName)
    {
        return $"{firstName} {lastname}";
    }
}

// Simple mapping
var person = new Person { FirstName = "John", LastName = "Smith" Age = 30 };
var profile = Mapper.Map<Person, Profile>(person);

Features

  • ✨ Simple, Attribute based mapping
  • 🔧 Property name matching (case-sensitive)
  • 📦 Lightweight with no dependencies
  • 🎯 Convention-based (default name to name) mapping
  • 🔄 List<> and Dictionary<,> mapping support
  • ⚙️ Custom mapping converter support
  • 🎯 Null source properties ignored as default

Usage Examples

Basic Mapping

var mapper = new ObjectMapper();

var person = new Person { FirstName = "Jane", LastName = "Doe" };
var personDto = mapper.Map<Person, PersonDto>(person);

Custom Property Mapping

mapper.CreateMap<Source, Destination>()
    .ForMember(dest => dest.FullName, opt => opt.MapFrom(src => $"{src.FirstName} {src.LastName}"))
    .ForMember(dest => dest.IsActive, opt => opt.MapFrom(src => src.Status == "Active"));

Mapping Collections

var sourceList = new List<Source> 
{ 
    new Source { Name = "Alice" },
    new Source { Name = "Bob" }
};

var destinationList = mapper.Map<List<Source>, List<Destination>>(sourceList);

Ignore Properties

mapper.CreateMap<Source, Destination>()
    .ForMember(dest => dest.InternalId, opt => opt.Ignore());

Configuration Options

var config = new MapperConfiguration(cfg =>
{
    cfg.CaseSensitive = false; // Match properties case-insensitively
    cfg.AllowNullValues = true; // Allow mapping null values
    cfg.CreateMap<Source, Destination>();
});

var mapper = new ObjectMapper(config);

Limitations

Since this is a hobby project, there are some limitations:

  • Not as feature-rich as AutoMapper or Mapster

Contributing

This is a hobby project, but contributions are welcome! If you find a bug or have an idea:

  1. Open an issue to discuss it
  2. Create a feature branch
  3. Submit a pull request

No contribution is too small - typo fixes, documentation improvements, and feature suggestions are all appreciated!

Building from Source

# Clone the repository
git clone https://github.com/starfury-dev/ObjectMapper-.git

# Restore dependencies
dotnet restore

# Build
dotnet build

# Run tests
dotnet test

License

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

Acknowledgments

  • Inspired by other great mapping libraries in the .NET ecosystem
  • Thanks to the .NET community for feedback and support
  • Built with ❤️ as a learning project

Contact


⭐ If you find this project useful, consider giving it a star on GitHub!

Product Compatible and additional computed target framework versions.
.NET 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 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.
  • 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
1.0.1 185 12/23/2025
1.0.0 121 12/21/2025