Q. 요즘 C#에는 (7.0인가 8.0인가부터) #nullable 이 기본으로 켜져있어요 ㅋㅋ

A. 그런 당신에게, WELCOME TO Unity 6000.0.36f1

A: 딱 하나의 《진리》를 알려드리겠습니다. nullable과 non-nullable형을 명백하게 구분하는 언어를 쓰세요. 아니면 최소한 몰?루형?과 아!!루형을 정적으로 구분해서 둘을 섞으려는 순간 당신의 머리를 깡!!!! 해버리는 친구를 사귀어 가까이 두어요.

C#이면
#nullable 디렉티브를 켜요. TS이면 strict를 켜요. 그런 게 없어요? 오답이니까 창 밖으로 집어던지고 다른 언어를 찾아요.
그러면 그대의 가정이 당분간 평안할 것이며 당신의 두통이 최대 47%p[출처 필요] 감소할 것이에요. 그러니 깊이 새겨 두도록 해요.
https://neo-quesdon.serafuku.moe/main/user/@[email protected]/cmie56u4j0v27k70j5hjxicl0
#neo_quesdon
Q. nulltable님은 nullable한 자료를 다루는 특별한 노하우가 있나요?

A. 딱 하나의 《진리》를 알려드리겠습니다. nullable과 non-nullable형을 명백하게 구분하는 언어를 쓰세요. 아니면 최소한 몰?루형?과 아!!루형을 정적으로 구분해서 둘을 섞으려는 순간 당신의 머리를 깡!!!! 해버리는 친구를 사귀어 가까이 두어요. C#이면 #nullable 디렉티브를 켜요. TS이면 strict를 켜요. 그런 게 없어요? 오답이니까 창 밖으로 집어던지고 다른 언어를 찾아요. 그러면 그대의 가정이 당분간 평안할 것이며 당신의 두통이 최대 47%p[출처 필요] 감소할 것이에요. 그러니 깊이 새겨 두도록 해요.

#CSharp #Nullable, because you really have to emphasize the importance that this is, in fact, not null.

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

Nullable-аннотации: MaybeNull и NotNullWhen в C#

Привет, Хабр! Сегодня мы рассмотрим nullable‑аннотации в C#: как с помощью [MaybeNull] и [NotNullWhen] (плюс родственных атрибутов вроде [MaybeNullWhen] , [NotNullIfNotNull] ,...

Хабр

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.

@mortoray @khalidabuhakmeh I think it is a bit confusing because T could either be a reference type or a value type. Value types having a completely different nullability mechanic which is not at all related to #nullable pragma. If you exclude structure types via : “ where T : class” the warning goes away, too and the class should behave as expected as it does not need to care for structs anymore.

@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:

https://github.com/xunit/assert.xunit/blob/309647ac2fc29997937a22afaaeb0a73fb80d14b/CollectionAsserts.cs#L1-L8

https://github.com/xunit/assert.xunit/blob/309647ac2fc29997937a22afaaeb0a73fb80d14b/CollectionAsserts.cs#L457-L472

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".

assert.xunit/CollectionAsserts.cs at 309647ac2fc29997937a22afaaeb0a73fb80d14b · xunit/assert.xunit

xUnit.net assertion library for sub-module purposes (please open issues in https://github.com/xunit/xunit) - xunit/assert.xunit

GitHub