SAProduction.BuilderHacker.Core 1.1.11

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

SAProduction.BuilderHacker.Core

SAProduction.BuilderHacker.Core provides two main capabilities:

  1. EntityBuilder<T> (runtime, reflection-based)
  2. HTML Builder (UI) (fluent HTML composition with type-safe child validation for table/media)

Install

Install-Package SAProduction.BuilderHacker.Core

Supported Targets

  • .NET Standard 2.0+
  • .NET Core / .NET 5+
  • .NET Framework (via compatible target graphs)

1) EntityBuilder<T>

A runtime builder for dynamic object construction.

Features

  • Fluent API
  • Set by expression (Set(x => x.Name, value)) for compile-time safety
  • Set by property/field name (Set("Name", value)) for dynamic scenarios
  • Optional strict mode (property-only assignments)
  • Reflection member caching for better repeated performance

Example (Expression-based)

using BuilderHacker.Core.EntityBuilder;

var user = EntityBuilder<User>.Create()
    .Set(x => x.Name, "Alice")
    .Set(x => x.Age, 30)
    .Build();

Example (String-based)

var user = EntityBuilder<User>.Create()
    .Set("Name", "Bob")
    .Set("Age", 25)
    .Build();

Strict mode

var user = EntityBuilder<User>.Create()
    .StrictMode(true)
    .Set(x => x.Name, "Safe")
    .Build();

2) HTML Builder (UI)

Use BuilderHacker.Core.HtmlBuilder.UI to create HTML trees fluently.

Highlights

  • Broad HTML tag coverage (inline, semantic, form, media, embed, table)
  • Type-safe composition for tags that require specific children
  • Render to string with Render()

Type-safe composition rules

Table
  • UI.Tr(...) returns ITableRow
  • UI.THead(...), UI.TBody(...), UI.TFoot(...) accept only ITableRow[]
Media
  • UI.Video(...) accepts only IVideoContent children (UI.Source, UI.Track)
  • UI.Audio(...) accepts only IAudioContent children (UI.Source, UI.Track)
  • UI.Picture(...) accepts only IPictureContent children (UI.Source, UI.Img)

Full table example

using BuilderHacker.Core.HtmlBuilder;

var table = UI.Table(
    UI.TableCaption(UI.TextNode("Employee Directory")),
    UI.THead(UI.Tr(UI.Th("Name"), UI.Th("Age"), UI.Th("Department"))),
    UI.TBody(
        UI.Tr(UI.Td("Alice"), UI.Td("31"), UI.Td("Engineering")),
        UI.Tr(UI.Td("Bob"), UI.Td("28"), UI.Td("Product"))
    ),
    UI.TFoot(UI.Tr(UI.Td("Total"), UI.Td("2"), UI.Td("Employees")))
);

string html = table.Render();

Video example

var video = UI.Video(
    "video.mp4",
    UI.Source("video.webm", "video/webm"),
    UI.Track("subtitles", "captions.vtt", "en", "English")
);

string html = video.Render();

Picture example

var picture = UI.Picture(
    UI.Source("banner.webp", "image/webp"),
    UI.Img("banner.png", "Banner")
);

3) Builder Factory Pattern

Use IBuilderHackerFactory when you want to resolve builders from dependency injection.

What it does

  • Resolves IBuilder<T> instances from an IServiceProvider
  • Resolves a specific TBuilder when you know the generated builder type
  • Falls back to IBuilder<T> if the concrete builder type is not registered

Typical usage

services.AddSingleton<IBuilderHackerFactory, DefaultBuilderHackerFactory>();
services.AddTransient<IBuilder<SimpleUser>, SimpleUserBuilder>();

var factory = serviceProvider.GetRequiredService<IBuilderHackerFactory>();
var builder = factory.CreateBuilder<SimpleUser>();
var user = builder.Name("Sam").Age(25).Build();

Documentation


Thread Safety

EntityBuilder<T> instances are not thread-safe. Use one builder instance per thread/request.


  • SAProduction.BuilderHacker.Abstraction
  • SAProduction.BuilderHacker.Generator

Source & Issues

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.