Code Monkey home page Code Monkey logo

buildergenerator's Introduction

Nuget GitHub GitHub Workflow Status GitHub issues

Builder Generator

This is a .Net Source Generator designed to add "Builders" to your projects. Builders are an object creation pattern, similar to the Object Mother pattern. Object Mothers and Builders are most commonly used to create objects for testing, but they can be used anywhere you want "canned" objects.

For more complete documentation, please see the documentation site or the raw documentation source.

Known Issues

This project has moved to the .Net 6 version of source generators, which unfortuntely means that it's incompatible with Visual Studio 2019. It's also breaking the GitHub build pipeline at the moment. It all seems to work just fine in VS2022 though. If you're stuck on .Net 5 and VS2019, you can always use the v1.x series, although its usage is different.

Installation

BuilderGenerator is installed as an analyzer via NuGet package (https://www.nuget.org/packages/BuilderGenerator/). You can find it through the "Manage NuGet Packages" dialog in Visual Studio, or from the command line.

Install-Package BuilderGenerator

Usage

After installation, create a partial class to define your builder in. Decorate it with the BuilderFor attribute, specifying the type of class that the builder is meant to build (e.g. [BuilderFor(typeof(Foo))]. Define any factory and helper methods in this partial class. Meanwhile, another partial class definition will be auto-generated which contains all the "boring" parts such as the backing fields and "with" methods.

Version History

  • v2.0.7

    • Fixed #13, NetStandard2.0 compatibility
  • v2.0.6

    • Fixed #12, Generated files now marked with auth-generated header
  • v2.0.5

    • Fixed #14, duplicate properties
  • v2.0.3

    • Attempting to fix NuGet packaging problems
  • v2.0.2

    • Setters for base class properties rendering properly
  • v2.0.1

    • Improved error handling
  • v2.0.0

    • Updated to .Net 6 and IIncrementalGenerator (See note above about incompatibility with VS2019)
    • Changed usage pattern from marking target classes with attributes to marking partial builder classes
  • v1.2

    • Solution reorganization
    • Version number synchronization
    • Automated build pipeline
  • v1.0

    • First major release
  • v0.5

    • Public beta
    • Working NuGet package
    • Customizable templates

Roadmap

  • Read-only collection support in default templates
  • Attribute-less generation of partial classes
  • Completed documentation
  • Unit tests for generation components

Attributions

The BuilderGenerator logo includes tools by John Caserta from the Noun Project.

buildergenerator's People

Contributors

melgrubb avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.