Commit Graph

61 Commits

Author SHA1 Message Date
Archi
3e2951d1d0 Fix old IBotCommand plugin answers 2022-01-23 14:27:54 +01:00
Archi
dae6f9d328 Use newer syntax for Enum.IsDefined() 2022-01-23 01:37:43 +01:00
Łukasz Domeradzki
4258fed873 Closes #2500 (#2501)
* Start work on #2500

* Update Bot.cs

* Misc refactor

* Update Bot.cs

* Add fallback for older plugins

* Misc

* Apply feedback
2022-01-23 00:14:14 +01:00
Archi
bf4bb7225c More Rider cleanups 2022-01-06 20:37:00 +01:00
Archi
1809028c77 Rider cleanup 2022-01-06 20:22:38 +01:00
Archi
225003c5d1 Try to fix netf, once again into the breach 2021-12-12 01:44:17 +01:00
Archi
4f598d5c8f Latest Rider cleanups 2021-12-12 01:12:54 +01:00
Archi
5d33bca611 Add IUpdateAware plugin interface 2021-12-08 19:48:59 +01:00
Archi
0eab358af9 Plugins breaking: Convert all synchronous interface methods to Task
Okay, I wish we had uncovered it earlier as part of V5.2 but it has bitten us in the back just now, so I'm addressing it as part of monthly cycle instead.

Previously used void methods did not allow async operations in plugins in a "nice way". If plugin didn't require synchronization with the ASF and just minded its own business, it wasn't half bad as it could use async void signature. However, if plugin by any chance had to do something BEFORE ASF continued with the rest of the logic, it had to explicitly leave non-async void signature and call its async-capable stuff in synchronous manner (usually with Wait() or .Result), which is vastly suboptimal.

This was visible even in our STD plugin, which previously had (and still has) GlobalCache initialization in OnASFInit(). If that cache initialization took a bit longer time, STD would hit InvalidOperationException() in OnLicenseList() callback as global cache didn't load yet while we were already long past OnASFInit().

Therefore, I've decided to make a breaking change for a very good reason - all previous methods were converted to tasks, which allows from plugin to do one of three things:

- If plugin is async and requires synchronization (like STD), it can declare itself as async await, and do its awaits as-needed, and ASF will wait for those.
- If plugin is truly synchronous (and not just a synchronous signature with awful Wait() or .Result, see above), it can simply return Task.CompletedTask and has exactly the same logic.
- Finally, if plugin calls some async stuff but doesn't need ASF synchronization, it can "offload" itself from it by calling e.g. ASF's Utilities.InBackground() with whole logic, while returning Task.CompletedTask from the main method. This will allow it to effectively do what async void previously did, by just hooking into the process without intention of slowing it down.

All in all I'm confident this approach, while a bit counter-intuitive at first, will result in better compatibility between ASF and the plugins, as if I wanted to fix my STD issue right now without that breaking change, I'd have to actually call .Result on my async global cache loader function, which is utterly stupid if we can fix ASF to do the right thing instead.

This "approach" can be commonly found in some other libs with similar to ASF's event-hook behaviour, e.g. Discord.Net.

You'll sadly need to do some method signature changes in all of your plugins, as the core OnLoaded() was also changed. See the ones I did in SteamTokenDumperPlugin.cs if you need a practical example, and see ExamplePlugin.cs if you need further explanation.
2021-12-08 16:52:27 +01:00
Archi
cdd35ad29d Address new trimming warnings 2021-11-19 22:54:26 +01:00
Archi
0673b2e298 Closes #2420 2021-11-18 23:44:49 +01:00
Archi
1e6ab11d9f Use file-scoped namespaces 2021-11-10 21:23:24 +01:00
Archi
7e9e90764b Use static lambdas wherever possible
Thanks Rider
2021-09-27 21:33:52 +02:00
Archi
dcacdd802c Optimize LoadAssemblies()
We can be smart about it and avoid loading the same assemblies twice
2021-07-04 18:33:24 +02:00
Archi
fe43aa6cb6 Convert UTF-8 BOM to files to UTF-8 2021-05-22 19:45:27 +02:00
JustArchi
e60b54e402 Refactor EVERYTHING
Directories structure + namespaces relevant to them
2021-05-08 01:37:22 +02:00
JustArchi
5a8e2720fa Hide info about loaded assemblies under debug option 2021-05-07 00:30:31 +02:00
JustArchi
b6772b9b1e Resolve CA1034 2021-05-06 20:16:06 +02:00
JustArchi
efec44e593 R# code improvements & cleanups 2021-04-11 00:33:32 +02:00
JustArchi
45a5fec95a Happy 2021
And let's hope it'll be better than 2020
2021-01-03 22:24:22 +01:00
JustArchi
32a8f4bed4 Misc optimization
If we're starting from 0, pointless to ask plugins what they prefer.
2021-01-03 22:12:17 +01:00
JustArchi
cc1eb6bee2 Start saving LastChangeNumber in GlobalDatabase
Due to the fact that we're now dependent on PICS changes ourselves, we have to start saving our own LastChangeNumber in order to avoid invalidating cache every time.
2021-01-03 21:58:41 +01:00
JustArchi
34c5f5cf8b Closes #2012 2020-12-18 22:06:15 +01:00
JustArchi
d1ca1e9b2c Add a pre-container assembly verification for detecting failing plugins 2020-11-25 12:26:46 +01:00
JustArchi
e82560259b Final code cleanup 2020-11-14 22:37:00 +01:00
JustArchi
6a811008eb More code cleanups 2020-11-11 18:02:17 +01:00
Łukasz Domeradzki
35f4651ed6 .NET 5.0 (#1999)
* Initial work

* Fix CIs

* Fix warnings

* Update .travis.yml

* Update dockerfiles

* Update libraries to .NET 5.0

* Misc

* Remove workaround for #1812

* Update cc.sh

* CI updates

* CI updates

* Update .travis.yml
2020-11-10 23:22:57 +01:00
JustArchi
b3d476dea4 Round 2 of nullable checks 2020-08-23 20:45:24 +02:00
Łukasz Domeradzki
9fc1ea65a5 Closes #1543 (#1944)
* Start working on nullable checks

help me

* Update GlobalConfig.cs

* Finish initial fixup round

* nullability code review
2020-08-22 21:41:01 +02:00
JustArchi
69936d55b6 Add GET /Api/Plugins endpoint,
In regards to https://github.com/JustArchiNET/ASF-ui/issues/1015
2020-06-24 20:54:41 +02:00
JustArchi
513397ca0f Correct HasCustomPluginsLoaded check 2020-06-13 17:14:59 +02:00
JustArchi
4d1bca5e51 Introduce concept of official plugins 2020-06-13 15:09:12 +02:00
JustArchi
2a43a87e08 Initial SteamTokenDumper upload 2020-06-13 12:08:21 +02:00
JustArchi
0fa4d5e2a6 Refactor package info and their access tokens, add ISteamPICSChanges plugin interface 2020-06-09 22:56:04 +02:00
JustArchi
0370168b02 Happy new year 2020-02-01 23:33:35 +01:00
JustArchi
fef7860564 Misc fix 2019-12-03 18:58:02 +01:00
JustArchi
97e0ede181 Misc 2019-11-14 21:52:17 +01:00
JustArchi
ce5bf02313 Closes #1505 2019-11-14 21:37:26 +01:00
JustArchi
6b8fabdb71 Misc 2019-10-21 20:49:17 +02:00
JustArchi
11a5927f6b Update IBotCardsFarmerInfo.cs 2019-10-20 21:44:11 +02:00
JustArchi
b4ed859bcb Closes #1472 2019-10-20 21:36:27 +02:00
JustArchi
067293eeb5 Start with .NET Core 3.0 code enhancements 2019-09-27 20:43:11 +02:00
JustArchi
5936d16c69 Misc 2019-09-12 11:46:15 +02:00
JustArchi
055ede7f49 Kill IBotHackNewChat plugin interface 2019-08-07 13:02:43 +02:00
JustArchi
bed90d854c Misc 2019-07-08 12:34:55 +02:00
JustArchi
448482e499 Use modded identifier for plugins setups 2019-06-25 12:26:55 +02:00
JustArchi
ab67d34127 Misc 2019-04-24 11:29:49 +02:00
JustArchi
8c105b14d1 Misc 2019-04-24 11:27:09 +02:00
JustArchi
962b4a2141 Closes #1191 2019-04-11 14:04:58 +02:00
JustArchi
91f9b5d8cb Misc 2019-03-07 16:40:37 +01:00