Тёмный

Introduction to Plugin Architecture in C# 

Raw Coding
Подписаться 71 тыс.
Просмотров 22 тыс.
50% 1

Guide for implementing plugin architecture in c#. In this tutorial we enable adding and updating endpoints dynamically at runtime in our asp.net core web app.
Patreon 🤝 / raw_coding
Courses 📚 learning.raw-coding.dev
Shop 🛒 shop.raw-coding.dev
Discord 💬 / discord
Twitter 📣 / anton_t0shik
Twitch 🎥 / raw_coding
Docs: learn.microsoft.com/en-us/dot...
#csharp #dotnet #plugin

Опубликовано:

 

8 апр 2023

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 53   
@unhandledexception1948
@unhandledexception1948 Год назад
I am always amazed at the focus, and speed in which you are able to live code and explain, but what really is impressive is the amount of knowledge you have on aspnet at such a young age ;-)
@grumpydeveloper69
@grumpydeveloper69 Год назад
Wow I learned a lot of technical things in this one video that I had never heard of or even thought about looking up in Docs. Thank you.
@JB-tq1ly
@JB-tq1ly Год назад
As usual, your content blows me off Thanks !
@sergeys5270
@sergeys5270 Год назад
All of your videos are very cool, thank you!
@nilokillian
@nilokillian 10 месяцев назад
love your stuff mate, really enjoying
@olivier0003
@olivier0003 Год назад
Thank, that what i was looking for à long time!
@johncerpa3782
@johncerpa3782 Год назад
Thank you, great video!
@MuharremGorkem
@MuharremGorkem Год назад
Another way to go for plug-in based architecture is source-code-based-plugins where you load the source code of a plugin at run-time, compile it, and, the rest is very similar. If the source code changes, you re-compile the code for changes to take effect.
@RawCoding
@RawCoding Год назад
Yea boi!
@wymdlon
@wymdlon Год назад
As always a beautiful video 👍 Anyway, if you want to define middleware you can just use the IMiddleware interface
@RawCoding
@RawCoding Год назад
Ah didn’t know
@east1sup
@east1sup Год назад
Late for party 😢
@user-ff7ei4ob8b
@user-ff7ei4ob8b Год назад
thanks, just writing a similar application and wondered why in the microsoft documentation they offer to inherit from the AssemblyLoadContext class for the sake of uncomplicated lines of code that is already in it and without me
@mottahh4162
@mottahh4162 Год назад
What a great video I like the approach I think you should look for the plugin interface and what classes are implementing it in the assembly instead of the concrete class as you shouldn't know what is in the plugin yet I beleive most of the payment gateways plugins using similar approach
@s0weer
@s0weer Год назад
Great content, thank you
@jexes2020
@jexes2020 11 месяцев назад
This is good subject. I tried similar thing using ApplicationParts and Features. In you solution, how would you pass arguments from the DI container into your plugin? do you think it possible to initialize a custom DI container in the plugin from the main DI of the application?
@christiandicostanzo154
@christiandicostanzo154 8 месяцев назад
I really like the microkernel architecture.
@shakeuk
@shakeuk Год назад
Good video!
@bbeda
@bbeda Год назад
Thank you
@mostafafathy6309
@mostafafathy6309 Год назад
Great content. Can you load a plugin with dependencies that are of a different version than the main app?
@RawCoding
@RawCoding Год назад
I think it's possible yes
@kostasgkoutis8534
@kostasgkoutis8534 Год назад
Superb
@caglarcansarikaya1550
@caglarcansarikaya1550 7 месяцев назад
thank you :)
@mibli2935
@mibli2935 Год назад
Yes. Yessss!!!
@gaborkonstanzer4237
@gaborkonstanzer4237 Год назад
Very nice topic, sir! Wut is 'dotwatch' that you use in the terminal?
@RawCoding
@RawCoding Год назад
it's an alias for dotnet watch --no-hot-reload
@gaborkonstanzer4237
@gaborkonstanzer4237 Год назад
@@RawCoding Ah okey, thank you.
@josepvg
@josepvg Год назад
Thanks, great video like always, I was doing very similar this weekend and stumbled on the same error of not being able to unload my dll after serializing, both with newtonsoft and the microsoft one. I tried various third party and they all appear to hold a reference. Has anyone found one that doesn't stop us from unloading the plugin assembly?
@RawCoding
@RawCoding Год назад
you can trying doing serialisation outside of the plugin if possible
@josepvg
@josepvg Год назад
@@RawCoding Good idea, but the problem i'm facing is that the service loading up and executing the plugin takes a json string as parameters and uses reflection to get the input parameter class type then creates and deserializes the input string to create that valuemodel class so the plugin creator can just work with his valuemodel directly. But to get this to work i'm using the newtonsoft serializer outside the plugin to deserialize a class defined inside the plugin :P
@RawCoding
@RawCoding Год назад
mhmmm, from what I read there might a converter implementation that you have to substitute.
@josepvg
@josepvg Год назад
@@RawCoding I solved it today by asking chatgtp to write me a basic json serializer/deserializer that only relies on reflection. it was 250 lines of code but it worked for the project :)
@robl39
@robl39 10 месяцев назад
Really good video, you clearly know your stuff. However, I don’t really understand what “leaking into global space” means. I was confused at the end with the serializer example and the WeakReference… why would you have to call GC 10 times…?
@RawCoding
@RawCoding 10 месяцев назад
Global namespace was probably a bad choice of words. Think of the app that you start as the main assembly. If you add an assembly dynamically and then then something from the main assembly holds a reference to your dynamic one; the dynamic one will fail to unload. WeakReference is holding a reference from main to dynamic but doesn’t prevent unloading.
@robl39
@robl39 10 месяцев назад
@@RawCoding thanks! Keep up the great content
@amnashahid9464
@amnashahid9464 Год назад
it was really interesting, but in nopcommerce we only write plugins and install them without chnaging anything in main nopcpmments. So is it possible for u to help us understand this
@RawCoding
@RawCoding Год назад
sorry I don't understand
@mzg147
@mzg147 Год назад
I'm sorry, I thought because of the title that this will be about c# plugins and not asp core plugins 😢 Great video though!
@RawCoding
@RawCoding Год назад
Ehh it’s the same thing
@coder1c
@coder1c Год назад
Cool video! What about plugin debugging?
@RawCoding
@RawCoding Год назад
What about it? :D test your plugin before you deploy it or use an ide that has a decompiler
@coder1c
@coder1c Год назад
@@RawCoding Maybe something like saving a dump from a serverapp with executing a plugin method and replayi it with a plugin assembly? Maybe in the next video? :)
@justinth83
@justinth83 Год назад
An interesting video but I think trying to reload the plugin assemblies in-process is too fraught with pitfalls some of which this video highlights. Perhaps it would be better to just load the plugins at startup, registering the endpoints in the usual manner without custom middleware, and then have a separate process watch the plugin folder and spool up new instances of the web app, and use a reverse proxy to switch over, like you demonstrate in the 0 downtime deployment using YARP video.
@RawCoding
@RawCoding Год назад
All of that is viable both have their own pros and cons Plug-ins being flaky is a .NET issue.
@evilroxxx
@evilroxxx Год назад
Why use HttpContext instead of IContextAccessor?
@RawCoding
@RawCoding Год назад
what's the difference?
@evilroxxx
@evilroxxx Год назад
@@RawCoding besides using interface vs concrete implementation for testability or no dependence on aspnet.core lib in the lower layer, I cannot think of anything else.
@RawCoding
@RawCoding Год назад
IHttpContextAccessor has HttpContext getter, I'd have to create a mock of HttpContext then configure the IHttpContextAccessor mock. Here I can just pass HttpContext directly so no testability advantage, as most of the time interfaces for "testability" and "decoupling" are bull shit.
@timoshaht8499
@timoshaht8499 4 месяца назад
This is too much voodoo
@user-hh4re9by5f
@user-hh4re9by5f 10 месяцев назад
Excelent Video Thank you, but i didint get from where took pathinfo their properties values for Method and path var pathInfo = endpointType?.GetCustomAttribute(); pathInfo.Method ¿From where took its value? pathInfo .path ¿from where took its value?
@user-hh4re9by5f
@user-hh4re9by5f 10 месяцев назад
it was from here right? [Path("get", "/plugin/test")] public class AnEndpoint : IPluginEndpont
Далее
Constraint Oriented Programming in C#
29:51
Просмотров 3,7 тыс.
Understanding .NET C# Heaps (Deep Dive)
28:23
Просмотров 12 тыс.
ЧУТЬ НЕ УТОНУЛ #shorts
00:27
Просмотров 6 млн
Don't let MediatR hold you back, try this...
17:48
Просмотров 12 тыс.
The Power Of The Plugin Architecture In Python
24:06
Просмотров 111 тыс.
Don't throw exceptions in C#. Do this instead
18:13
Просмотров 253 тыс.
Top 5 Most Used Architecture Patterns
5:53
Просмотров 233 тыс.
C# Async/Await/Task Explained (Deep Dive)
24:22
Просмотров 393 тыс.
Unit of Work in ASP.NET Core
14:57
Просмотров 18 тыс.
Understanding CORS with ASP.NET Core C#
17:44
Просмотров 11 тыс.
What Is .NET Aspire? The Insane Future of .NET!
18:35
Просмотров 264 тыс.
Start with plugin development for Dataverse
18:11
Просмотров 9 тыс.