Introduction to Plugin Architecture in C#

Поделиться
HTML-код
  • Опубликовано: 23 ноя 2024

Комментарии • 57

  • @unhandledexception1948
    @unhandledexception1948 Год назад +10

    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 ;-)

    • @sumitevs
      @sumitevs 2 месяца назад

      yea. how do you know all this :/

  • @grumpydeveloper69
    @grumpydeveloper69 Год назад +3

    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.

  • @MuharremGorkem
    @MuharremGorkem Год назад +3

    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.

  • @wymdlon
    @wymdlon Год назад +12

    As always a beautiful video 👍
    Anyway, if you want to define middleware you can just use the IMiddleware interface

  • @kabalikaala
    @kabalikaala 2 месяца назад

    Thanks for this wonderful article. I have some queries. In this you loaded the assembly as hardcoded. How to achieve this for multiple plugins. For example, if I have employee, department, staff plugins and these need to load at runtime. How to achieve this.
    Also, is it possible to load the Web API Controllers in similar ways.
    Thanks.

  • @christiandicostanzo154
    @christiandicostanzo154 Год назад

    I really like the microkernel architecture.

  • @mottahh4162
    @mottahh4162 Год назад +1

    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

  • @ИванБармин-ю1т
    @ИванБармин-ю1т Год назад

    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

  • @JB-tq1ly
    @JB-tq1ly Год назад

    As usual, your content blows me off Thanks !

  • @jexes2020
    @jexes2020 Год назад

    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?

  • @ic_1234
    @ic_1234 2 месяца назад

    which keyboard do you use? sounds good lol

  • @mostafafathy6309
    @mostafafathy6309 Год назад +2

    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

  • @sergeys5270
    @sergeys5270 Год назад

    All of your videos are very cool, thank you!

  • @nilokillian
    @nilokillian Год назад

    love your stuff mate, really enjoying

  • @olivier0003
    @olivier0003 Год назад

    Thank, that what i was looking for à long time!

  • @gaborkonstanzer4237
    @gaborkonstanzer4237 Год назад +1

    Very nice topic, sir!
    Wut is 'dotwatch' that you use in the terminal?

  • @johncerpa3782
    @johncerpa3782 Год назад

    Thank you, great video!

  • @robl39
    @robl39 Год назад +1

    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  Год назад +1

      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 Год назад

      @@RawCoding thanks! Keep up the great content

  • @coder1c
    @coder1c Год назад +1

    Cool video!
    What about plugin debugging?

    • @RawCoding
      @RawCoding  Год назад +1

      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? :)

  • @s0weer
    @s0weer Год назад

    Great content, thank you

  • @mzg147
    @mzg147 Год назад +3

    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  Год назад +4

      Ehh it’s the same thing

  • @josepvg
    @josepvg Год назад +1

    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  Год назад +1

      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  Год назад +1

      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 :)

  • @mibli2935
    @mibli2935 Год назад

    Yes. Yessss!!!

  • @caglarcansarikaya1550
    @caglarcansarikaya1550 11 месяцев назад

    thank you :)

  • @kostasgkoutis8534
    @kostasgkoutis8534 Год назад

    Superb

  • @justinth83
    @justinth83 Год назад +1

    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  Год назад +1

      All of that is viable both have their own pros and cons
      Plug-ins being flaky is a .NET issue.

  • @shakeuk
    @shakeuk Год назад

    Good video!

  • @bbeda
    @bbeda Год назад

    Thank you

  • @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

  • @evilroxxx
    @evilroxxx Год назад +1

    Why use HttpContext instead of IContextAccessor?

    • @RawCoding
      @RawCoding  Год назад

      what's the difference?

    • @evilroxxx
      @evilroxxx Год назад +1

      @@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  Год назад +3

      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 8 месяцев назад

    This is too much voodoo

  • @JorgeJaen-g9r
    @JorgeJaen-g9r Год назад

    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?

    • @JorgeJaen-g9r
      @JorgeJaen-g9r Год назад

      it was from here right?
      [Path("get", "/plugin/test")]
      public class AnEndpoint : IPluginEndpont