https://neo-quesdon.serafuku.moe/main/user/@[email protected]/cmieanujz0w0vk70jqs9p3tlf
#neo_quesdon
A. 딱 하나의 《진리》를 알려드리겠습니다. nullable과 non-nullable형을 명백하게 구분하는 언어를 쓰세요. 아니면 최소한 몰?루형?과 아!!루형을 정적으로 구분해서 둘을 섞으려는 순간 당신의 머리를 깡!!!! 해버리는 친구를 사귀어 가까이 두어요. C#이면 #nullable 디렉티브를 켜요. TS이면 strict를 켜요. 그런 게 없어요? 오답이니까 창 밖으로 집어던지고 다른 언어를 찾아요. 그러면 그대의 가정이 당분간 평안할 것이며 당신의 두통이 최대 47%p[출처 필요] 감소할 것이에요. 그러니 깊이 새겨 두도록 해요.
Nullable-аннотации: MaybeNull и NotNullWhen в C#
Привет, Хабр! Сегодня мы рассмотрим nullable-аннотации в C#: как с помощью [MaybeNull] и [NotNullWhen] (плюс родственных атрибутов вроде [MaybeNullWhen] , [NotNullIfNotNull] , [DoesNotReturn] ) формально описывать те самые «ну тут иногда null, а тут точно нет».
https://habr.com/ru/companies/otus/articles/928286/
#c# #nullable #nullableаннотации #nullable_reference_types #SystemDiagnosticsCodeAnalysis #MaybeNull #NotNullWhen #MaybeNullWhen
Was fällt euch auf? Ist das wirklich sinnvoll so?
Diskutiert mal! 👀
Bitte denkt selbst nach und fragt nicht einfach eine KI – eure eigenen Ideen interessieren mich viel mehr!
#CSharp #dotnet #fail #dotnetperle #cleancode #boolLogic #CodeReview #nullable #bug
@badcel @khalidabuhakmeh I guess I'm not fully understanding what #nullable does then, since it clearly does not mean things can't be null, at least not in all contexts.
I did use `where T: notnull` now and the error also goes away. But in my mind, that should be the default when #nullable is enabled.
@khalidabuhakmeh But yes, nonetheless, declaring it nonnull does fix the problem.
`class Something<T> where T : notnull`
But I still don't understand why. It seems to go against what `#nullable enable` means.
@khalidabuhakmeh But I have `#nullable enable` on the file, implying all references are non-null unless declared otherwise, like `T?`.
Also, if I mark source as `T? source` then I get errors in my code, implying that it isn't actually nullable, except in this circumstance.
@andrewlock I see you enabled nullable, which is quite a minefield with a source-only package that wants to be able to work not only with nullable on or off, but also in a language where nullable isn't an option.
You end up with stuff like this:
You can't just "#nullable disable" because the compiler might not support it. So if they enable nullable but forget to "tell you", then you have to turn off a bunch of nullable "violations".