Open Patonymous opened 1 month ago
Unfortunately, because of how MSBuild works, supporting .NET higher than 6 in contracts is mostly impossible in the current architecture.
Also, initializing properties directly in DTOs is considered an anti-pattern, as this is a representation of the mythical logic.
Oh, right. I suggested posting an issue because I forgot that the problem is with MSBuild rather than just a missing portion of the reflection.
Also, initializing properties directly in DTOs is considered an anti-pattern, as this is a representation of the mythical logic.
I somewhat disagree with this, though. For me, it's more about providing a saner default value than null
for non-nullable reference types that have a natural default (so, mostly for collections, using an empty collection as the default). I think it's better than an unexpected null
, at least until we can't use required
...
I think it's better than an unexpected null, at least until we can't use required...
Exactly - with .NET 8, required
should be used, but not default initialization. :P
I think it's better than an unexpected null, at least until we can't use required...
Exactly - with .NET 8,
required
should be used, but not default initialization. :P
The point is that we can't do that, required
is not available in projects targeting .NET 6, so we can't use it in contracts. That is unless without using something line PolySharp, which I doubt we'd like to incorporate.
Yes, I know - I'm just saying that provided that we can use .NET 8, then required
should be used and not the = []
default initialization (nor = new List<Result>()
in older versions).
File:
Output: