Replies: 1 comment
-
Dropping support for .NET framework would be a major breaking change. We have plans to drop it in v4 tho. And also we plan on adding nullable support in v4 too. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Include
<Nullable>enable</Nullable>
into csproj. I hate shooting myself in the foot due to the lack of nullable annotations.First, take a notice of SocketGuild.GetTextChannel(ulong):
There are no nullable annotations dictating SocketTextChannel could be null without explicitly reading the XML documentation. This can lead to this:
This code works when testing, due to the channel ID properly being found. But when this code is pushed to production, NullReferenceExceptions occur due to admins deleting guild channels, and thus the text channel wont be found.
By updating the library with proper nullable annotations, there are a lot less chances to shoot yourself in the foot:
Doing this would also make clear whether or not something COULD be null at any point, like AvatarURL or something of the sorts.
Especially with #2696, it's crucial to indicate that
GlobalName
isnullable
, or else suddenly your code can experience a NullReferenceException as you didn't directly read the XML documentation.The only caveats would be not being able to compile for .NET Framework 4.6.1, and .NET Standard 2.0, but both are out of date, with .NET Framework 4.6.1 being released in 2015 (8 years from now), and .NET Standard 2.0 being released in mid 2017 (almost 6 years from now). .NET generates the necessary attribute classes as internal, so packages referencing the code without nullable wont be affected at all.
Overall, adding nullability increases the productivity of developers using Discord.NET, and prevents newer C# devs and even new devs using the library from putting in code that could at one point
NullReferenceException
.Beta Was this translation helpful? Give feedback.
All reactions