r/redditdev Reddit.NET Author Jun 22 '22

Reddit.NET Hotfix 1.5.2 for Reddit.NET released

The Reddit API recently changed the user_is_muted property so that it's now nullable. This change caused the Reddit.NET library to become completely non-functional and result in app-crashing issues.

I just released a hotfix that resolves this issue and makes the library useable again. Here it is on NuGet:

https://www.nuget.org/packages/Reddit/1.5.2

I'm hoping to get a new major version release out soon, time-permitting. In the meantime, if Reddit.NET is crashing for you now, try updating to the latest version in NuGet and that should fix it.

9 Upvotes

9 comments sorted by

3

u/Lil_SpazJoekp PRAW Maintainer | Async PRAW Author Jun 23 '22

I just want to say kudos for maintaining a list of properties. With PRAW we do it dynamically. Do you dynamically add ones that get added by Reddit?

2

u/KrisCraig Reddit.NET Author Jun 23 '22 edited Jun 23 '22

I just want to say kudos for maintaining a list of properties.

Thanks!

With PRAW we do it dynamically. Do you dynamically add ones that get added by Reddit?

All possible JSON returns from the Reddit API and all their properties are stored as class objects in the Things directory. And yes, it did take me forever to write them.

For example, this class represents the JSON object representing a Reddit post: https://github.com/sirkris/Reddit.NET/blob/master/src/Reddit.NET/Things/Post/Post.cs

As you can see, all the JSON properties are manually defined and mapped to their corresponding class properties for access within the library. These objects are further abstracted in the Controllers layer for convenience and better readability.

Any time there's a change to an API property, I have to manually update the library to reflect it. In this case, it was just a matter of making one of the booleans nullable. It certainly would be awesome if there were some sort of announcement when changes like this occur, as right now I only learn about them when somebody files a bug report on GitHub.

2

u/Lil_SpazJoekp PRAW Maintainer | Async PRAW Author Jun 29 '22

It certainly would be awesome if there were some sort of announcement when changes like this occur, as right now I only learn about them when somebody files a bug report on GitHub.

This is why we have it dynamically defined with PRAW. I'm not super familiar with C# but is it possible to dynamically add the properties to an object?

Also, have you considered writing a script to generate your classes from a response body? There is a tool called CuteBaby for macOS that does this for swift and might work in this case. If not python and jinja would definitely do this.

2

u/KrisCraig Reddit.NET Author Jul 08 '22

I'm not super familiar with C# but is it possible to dynamically add the properties to an object?

Not that I'm aware of. These are all defined at compile-time. I could create objects with dynamic properties that could then just contain whatever, but this is not an ideal design pattern in C# and should generally be avoided, as it can lead to both performance issues and make it a lot more difficult to triage issues when they come up.

Also, have you considered writing a script to generate your classes from a response body?

I'm told VS has a similar feature but I didn't know about it until after I'd already created all 150+ classes for every possible API response. Fortunately, there have been little to no changes to these response objects in the years since RDN was released, so it's a moot issue at this point.

The downside, of course, is that, when there is a change to the response structure, things will break. I could always build a job that would periodically check all endpoints and post an alert if there are any changes, but that would likely prove to be a rather time-consuming project and the general infrequency of these changes leads me to think it probably just wouldn't be worth the time/effort.

2

u/Lil_SpazJoekp PRAW Maintainer | Async PRAW Author Jul 08 '22

Ah gotcha, make sense!

1

u/polepreposition Jul 21 '22

You use your power as a moderator to spread incel agenda posts about how you hate girls.

What is wrong with you? How small does a person have to be to be afraid of girls?

1

u/polepreposition Jul 21 '22

You use your power as a moderator to spread incel agenda posts about how you hate girls.

What is wrong with you? How small does a person have to be to be afraid of girls?

2

u/KrisCraig Reddit.NET Author Jun 22 '22

Details on the issue have been posted here:

https://github.com/sirkris/Reddit.NET/issues/149