ObjectSemantics.NET
7.0.1
dotnet add package ObjectSemantics.NET --version 7.0.1
NuGet\Install-Package ObjectSemantics.NET -Version 7.0.1
<PackageReference Include="ObjectSemantics.NET" Version="7.0.1" />
<PackageVersion Include="ObjectSemantics.NET" Version="7.0.1" />
<PackageReference Include="ObjectSemantics.NET" />
paket add ObjectSemantics.NET --version 7.0.1
#r "nuget: ObjectSemantics.NET, 7.0.1"
#:package ObjectSemantics.NET@7.0.1
#addin nuget:?package=ObjectSemantics.NET&version=7.0.1
#tool nuget:?package=ObjectSemantics.NET&version=7.0.1
ObjectSemantics.NET
Simple and flexible object-to-template string mapper with formatting support
🧠 Overview
ObjectSemantics.NET is a lightweight C# library that lets you inject object property values directly into string templates much like Handlebars or Helm templates, but focused on .NET.
This is especially useful when you want to dynamically generate content such as:
- Email templates
- HTML fragments
- Reports or invoices
- Config files
- Logging output
📦 Installation
Install from NuGet:
Install-Package ObjectSemantics.NET
🚀 Quick Start
Example 1: Mapping Object Properties
Person person = new Person
{
Name = "John Doe"
};
// Define template and map it using the object
string result = person.Map("I am {{ Name }}!");
Console.WriteLine(result);
Output:
I am John Doe!
Example 2: Mapping Using String Extension
Person person = new Person
{
Name = "Jane Doe"
};
// You can also start with the string template
string result = "I am {{ Name }}!".Map(person);
Console.WriteLine(result);
Output:
I am Jane Doe!
Example 3: Mapping Enumerable Collections (Looping)
Person person = new Person
{
MyCars = new List<Car>
{
new Car { Make = "BMW", Year = 2023 },
new Car { Make = "Rolls-Royce", Year = 2020 }
}
};
string template = @"
{{ #foreach(MyCars) }}
- {{ Year }} {{ Make }}
{{ #endforeach }}";
string result = person.Map(template);
Console.WriteLine(result);
Output:
- 2023 BMW
- 2020 Rolls-Royce
Example 4: Conditional Logic with #if, #else, and #endif
Person person = new Person
{
Age = 40
};
string template = @"
{{ #if(Age >= 18) }}
Adult
{{ #else }}
Minor
{{ #endif }}";
string result = person.Map(template);
Console.WriteLine(result);
Output:
Adult
Example 5: Number Formatting Support
Car car = new Car
{
Price = 50000
};
string result = car.Map("{{ Price:#,##0 }} | {{ Price:N2 }}");
Console.WriteLine(result);
Output:
50,000 | 50,000.00
💡 More Examples & Documentation
Explore more usage examples and edge cases in the Wiki Page:
🤝 Contributing
Feel free to open issues or contribute improvements via pull requests!
📄 MIT License
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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 was computed. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.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 | |
|---|---|---|---|
| 7.0.1 | 203 | 10/29/2025 | |
| 7.0.0 | 182 | 10/7/2025 | |
| 6.0.5 | 571 | 7/23/2025 | |
| 6.0.4 | 544 | 5/19/2024 | |
| 6.0.3 | 205 | 5/19/2024 | |
| 6.0.2 | 543 | 5/16/2023 | |
| 6.0.1 | 332 | 4/14/2023 | |
| 5.1.5 | 292 | 4/12/2023 | |
| 5.1.4 | 306 | 4/12/2023 | |
| 5.1.3 | 300 | 4/11/2023 | |
| 5.1.2 | 296 | 4/10/2023 | |
| 5.0.1 | 309 | 4/7/2023 | |
| 4.0.1 | 350 | 4/7/2023 | |
| 3.0.2 | 587 | 1/13/2023 |
. Added support for single arrays Loop Support
. Added encoding string formattings
ToMD5
ToBase64
FromBase64
. Added template extension method to allow mapping directly from Template