Refactored the codebase to current C# and .NET Standards #167
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When some floofs and I were talking about the FloofBot on the r/Furry Discord, we were talking about the weird and painfully looking codebase and that it definitely needed a refactor to the current standards, so:
I took the time to refactor the code base to current standards of C# and .NET
Things I changed:
varwhere it should be used and on other places it was usedRenamed Exception variables fromApperently, a lot of people use e for exceptions and is also the default, when creating a try-block. Even tho that it is less verbose, I reverted that changeetoex.eis reserved for events; an Exception is not an eventasync Taskmembers, because of the change to async we can now also use the async overloads in those methods, making it completely asyncif's to reduce nestingWhat I noticed:
FloofDataContextsometimes get's passed as an argument to classes and stays there as an global variable. Usually you don't do that and use ausingstatement instead, so that resourced get freed and the connection can be closed. That's the EF (Core) way of using a context. Opening it via(await) using(var floofDb = new FloofDataContext())It did this on some places where I know it could be done, but at some places I were not sure. This is a bad approach, when you don't use Dependency Injection and passing it through constructors (which is bad habit).asyncoverloads where not used, even tho when you are in anasyncMethod and can use the async overload without any issues8.0and not to latest. I would suggest to set it tolatestMajorI would greatly appreaciate if this will be looked through and tested by some people, esspecialy from the maintainer and people that know most of it's codebase and how it runs.
Because you people have more experience using this bot than I, for now.