https://github.com/tim-maes/facet
Source generator that instantly scaffolds DTOs, typed LINQ projections, and ViewModels without any runtime overhead.
https://github.com/tim-maes/facet
facet generator mapper mapping model object source
Last synced: 7 months ago
JSON representation
Source generator that instantly scaffolds DTOs, typed LINQ projections, and ViewModels without any runtime overhead.
- Host: GitHub
- URL: https://github.com/tim-maes/facet
- Owner: Tim-Maes
- License: mit
- Created: 2025-04-22T19:31:43.000Z (8 months ago)
- Default Branch: master
- Last Pushed: 2025-06-03T20:56:55.000Z (7 months ago)
- Last Synced: 2025-06-04T00:33:15.985Z (7 months ago)
- Topics: facet, generator, mapper, mapping, model, object, source
- Language: C#
- Homepage:
- Size: 110 KB
- Stars: 65
- Watchers: 3
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Facet
> "One part of a subject, situation, object that has many parts."
[](https://www.nuget.org/packages/Facet)
[](https://www.nuget.org/packages/Facet)

**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
- :white_check_mark: Generate classes, records, structs, or record structs from existing types
- :white_check_mark: Exclude fields/properties you don't want (create a Facetted view of your model)
- :white_check_mark: Include/redact public fields
- :white_check_mark: Auto-generate constructors for fast mapping
- :white_check_mark: LINQ projection expressions `(Expression>)`
- :white_check_mark: Custom mapping via `IFacetMapConfiguration`
## Documentation
- **[Documentation & Guides](docs/README.md)**
- [What is being generated?](docs/07_WhatIsBeingGenerated.md)
## 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.