Just saw something really strange that I have never seen before as a #dotnet dev:
Using a `record` for a service that is registered in DI.
Are there any devs here that do this and can tell me why? Any huge benefits I'm not seeing here?
@dr_cox1911 Oh yes! I wrote about using it for MediatR handlers, it really shortens the code and removes repetition https://tpetrina.com/blog/2022-11-07-records-simplify-dependency-injection-for-mediat-r-handlers
@tpetrina Thanks for pointing out that usecase, that's one advantage I thought of as well. I kinda had an argument with someone who uses records now for everything and that I find problematic. E.g. you can't inherit from libs like #FluentValidation with records.
For the usecase you blogged about I think it's nice, but with .Net8 I would still prefer classes with primary constructors I guess.
@dr_cox1911 I agree, but when I wrote this (and still) .NET 8 is not something I can use in production.
Also, side note: C# is becoming too complex :/