How can I get close to non-nullable reference types in C# today?

后端 未结 2 1048
眼角桃花
眼角桃花 2020-12-09 16:07

I\'ve read many of the non-nullable questions and answers. It looks like the best way to get close to non-nullable types in C# (4.0) is Jon Skeet\'s NonNullable<> hack.<

2条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-09 16:53

    Yep, spec#: http://research.microsoft.com/en-us/projects/specsharp/

    -- Edit: I just noticed you said C# 4.0; I'm fairly sure Spec# doesn't support that version. Nevertheless, it's worth a review.

    You may also be able (I think) to check at a slightly later stage then compile, via a rule in Gendarme: http://www.mono-project.com/Gendarme (assuming that runs against 4.0)

提交回复
热议问题