Re:It’s strange what people put up with in C#
by frabert on Saturday August 15, 2020 @06:34AM
(#24167833)
C++ introduced the [[nodiscard]] attribute for this exact use case. A C# [NoDiscard] attribute would do the same thing with the help of a Roslyn analyzer I guess.
[ Parent
| on HN ]
Re:It’s strange what people put up with in C#
by goto11 on Saturday August 15, 2020 @07:24AM
(#24168078)
C# already by default warns on discarded return values.
Re:It’s strange what people put up with in C#
by algorithmsRcool on Saturday August 15, 2020 @09:59PM
(#24174192)
No it does not, unless the discarded value is a Task in an async method. (or sometimes an IDisposable depending on what analyzers you have running)