8000 GitHub - Tim-Maes/Facet: Source generator that instantly scaffolds DTOs, ViewModels and typed LINQ projections without any runtime overhead.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
/ Facet Public

Source generator that instantly scaffolds DTOs, ViewModels and typed LINQ projections without any runtime overhead.

License

Notifications You must be signed in to change notification settings

Tim-Maes/Facet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Facet

"One part of a subject, situation, object that has many parts."

NuGet Downloads License: MIT

Facet is a C# source generator that lets you define lightweight projections (DTOs, API models, etc.) directly from your domain models — without writing boilerplate.

It generates partial classes, records, structs, or record structs with constructors, optional LINQ projections, and even supports custom mappings — all at compile time, with zero runtime cost.


What is Facetting?

Facetting is the process of defining focused views of a larger model at compile time.

Instead of manually writing separate DTOs, mappers, and projections, Facet allows you to declare what you want to keep — and generates everything else.

You can think of it like carving out a specific facet of a gem:

  • The part you care about
  • Leaving the rest behind.

Why Facetting?

  • Reduce duplication across DTOs, projections, and ViewModels
  • Maintain strong typing with no runtime cost
  • Stay DRY (Don't Repeat Yourself) without sacrificing performance
  • Works seamlessly with LINQ providers like Entity Framework

Key Features

  • ✅ Generate classes, records, structs, or record structs from existing types
  • ✅ Exclude fields/properties you don't want (create a Facetted view of your model)
  • ✅ Include/redact public fields
  • ✅ Auto-generate constructors for fast mapping
  • ✅ LINQ projection expressions (Expression<Func<TSource,TTarget>>)
  • ✅ Custom mapping via IFacetMapConfiguration

Documentation

The Facet Ecosystem

Facet is modular and consists of several NuGet packages:

  • Facet: The core source generator. Generates DTOs, projections, and mapping code.

  • Facet.Extensions: Provider-agnostic extension methods for mapping and projecting (works with any LINQ provider, no EF Core dependency).

  • Facet.Extensions.EFCore: Async extension methods for Entity Framework Core (requires EF Core 6+).

  • Facet.Mapping: (Optional) Advanced static mapping configuration support for Facet.


Facet — Define less, project more.

About

Source generator that instantly scaffolds DTOs, ViewModels and typed LINQ projections without any runtime overhead.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

0