affederaffe / Tmds.DBus.SourceGenerator

A roslyn source generator for creating proxies targeting the Tmds.DBus.Protocol API
MIT License
7 stars 5 forks source link

[Proposal] Initialize collection properties to respect Nullability #11

Closed ShortDevelopment closed 5 months ago

ShortDevelopment commented 5 months ago

Issue

Unused collection properties are initialized as null. Therfore the handler code might throw a NullReferenceException.

Solution

Initialize generated collection properties to Array<T>.Empty(), new Dictionary<A, B>() or new List<T>().

affederaffe commented 5 months ago

Yeah, I always wanted to fix this someday, but haven't found the time to do so. Expect this fixed in the next version.

affederaffe commented 5 months ago

null is now an allowed value and is treated equally to an "empty instance" of the type.

affederaffe commented 5 months ago

Completed with the release of 0.016 on NuGet, see https://www.nuget.org/packages/Tmds.DBus.SourceGenerator/0.0.16.