Skip to content

feat(create): use default constructor for C# records#609

Open
riezebosch wants to merge 2 commits intobchavez:masterfrom
riezebosch:master
Open

feat(create): use default constructor for C# records#609
riezebosch wants to merge 2 commits intobchavez:masterfrom
riezebosch:master

Conversation

@riezebosch
Copy link

@riezebosch riezebosch commented Jun 24, 2025

I've done some work on instantiating c# records with reflection for some other project so I thought it could come in handy. /fix #334

Did not pay too much attention on coding guidelines or where it would fit and if it should be a separate repository, but consider this a proof-of-work and any feedback on improvements appreciated.


Update: replaced the Activator.CreateInstance with invoking the default constructor with null for all arguments since Bogus is already updating backing fields 🤷🏻 I like my records to be immutable and never contain null values, but can imagine this works best with current implementation of Bogus. Did like the fact that with this little change everything seems to just work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support c# 9 records

1 participant