How to write better code in C# using Source Code Analyzers (Roslyn)

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

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

  • @nickchapsas
    @nickchapsas  3 года назад +15

    I forgot to mention it in the video but you can find more Roslyn analyzers here: github.com/Cybermaxs/awesome-analyzers
    You can also search for "Roslyn analyzers GitHub" and you will find the most popular ones. People are creating some really good stuff. Don't forget to star their GitHub repos.
    - Keep Coding

    • @GregWilliamBryant
      @GregWilliamBryant 3 года назад +1

      Hello Nick, further video creating analyzers would be awesome. Also, Rider centric tutorial would be good, as the one's I have seen have been Visual Studio-based. Further, some areas I would personally find helpful are how to efficiently distribute them with your solution (I'm guessing Nuget is the way forward here) and the foibles of how Rider interacts with Analyzers and it's own built-in one, code cleaning rules etc. I've found that this is one area the Rider has a fairly messy implementation on this front. Also, that touches on my final interest, do you have any best practices for distributing common code inside your organisation. I've seen Nuget suggested and equally frowned upon for this.

    • @seroleyat
      @seroleyat Месяц назад

      @@GregWilliamBryant well i guess he hast not made a video about that yet :/

    • @seroleyat
      @seroleyat Месяц назад

      still no video i guess? :/

  • @JJayToKlamca
    @JJayToKlamca 3 года назад +13

    Just discovered your channel. Your every video is a top notch material. Amazing work!

  • @englishmasterycorner
    @englishmasterycorner 3 года назад +41

    Roslyn analyzers are like Grammarly for coders.

    • @janne_kekalainen
      @janne_kekalainen 3 года назад +1

      So true.

    • @awesomesauce804
      @awesomesauce804 3 года назад +1

      so I'll be even better at copy/paste? Perfect. I'm not looking to increase my fundamental knowledge but instead to skate by at my day job being overpaid the entire time. It sounds like this is great for me, thanks for the feedback. /s

  • @tofraley
    @tofraley 3 года назад

    Great video! Yes, I'd love to see one on how to write a source analyzer.

  • @roro1826
    @roro1826 3 года назад +1

    I've been watching your vids for sometime now, I couldn't resist hitting the sub button for this vid

  • @thibaudgallanddemanneville174
    @thibaudgallanddemanneville174 3 года назад

    Great video as always! I finally understood exactly what the enclosure is !

  • @killpopers
    @killpopers 3 года назад +3

    I'd love to see how to write analyzers please do a video on this

  • @digitalphear1960
    @digitalphear1960 8 месяцев назад

    There was a guy i met telling me about how hw makes boxes within boxes in C#. Now that sounds nice for a guy like me who can make boolean chip sets to accomplish 'almost' any task..
    most code seems to be the same set up overall
    true/fulse.
    Light-up/black-out
    cell groups. And.OR.XOR
    But all over the place wich compared to physical boards/chips that lead into one another.. you can see how it gets confusing for someone like me. The box within box sounds nice for keeping track of group and function with an intangible :D

  • @lior279
    @lior279 3 года назад

    Great work Nick, Lots of value in your videos.
    Yes I would like Roslyn analyzers videos.
    Also, can you elaborate about how and what for do you use reflection.

  • @meirkr
    @meirkr 3 года назад

    I would also appreciate having.a video about writing analyzars. Tx.

  • @carlosalarcon2737
    @carlosalarcon2737 3 года назад +1

    Finally I found the video I wanted!! Thanks a lot!! Btw my rider in Linux shows reference not found when I compile (as a warning) but the alert is shown.

  • @sdasddsasadad2287
    @sdasddsasadad2287 3 года назад

    Thanks! it really helped me to get started programming!!

  • @nanvlad
    @nanvlad 3 года назад +8

    Hi Nick. Thanks for this video. Can you share a list of useful source analyzers, like you showed in the video? Are there many of them?

    • @nickchapsas
      @nickchapsas  3 года назад +5

      Ah damn I forgot to mention it on the video. There is a repo that contains a list of them here: github.com/Cybermaxs/awesome-analyzers but it's a bit outdated. It still contains many good ones.

  • @Pedro5antos_
    @Pedro5antos_ 3 года назад

    10:50 awesome content, mate!

  • @irelandfpv
    @irelandfpv 3 года назад

    Interesting topic. Never used it in live development yet.

  • @MrGuardianX
    @MrGuardianX 3 года назад

    As of November 2021 your example with Reflections doesn't work. I mean the analyzer doesn't highlight this field anymore (v 0.3.0)

  • @mystiqkc
    @mystiqkc 3 года назад

    Excellent video!!

  • @richardikin
    @richardikin 3 года назад

    Absolutely fascinating!

  • @PhilippeMatray
    @PhilippeMatray 3 года назад +2

    Hello Nick,
    In this video, you have shown 2 analyzers that are really interesting.
    Are there any others that you would recommend?

  • @adityashinde1657
    @adityashinde1657 3 года назад +2

    Please adjust the font size/zoom levels, to comfortably watch the content on big screens.

    • @Albileon
      @Albileon 3 года назад +1

      Seems fine on my screen? Not having any issues.

    • @diegoronkkomaki6858
      @diegoronkkomaki6858 3 года назад +1

      Nah this is perfect zoom and font size when watching on a mobile device.

  • @SimbaTheDogKing
    @SimbaTheDogKing 3 года назад +1

    Can .NET analyzer/Roslyn analyzer be added to CICD pipeline?

    • @nickchapsas
      @nickchapsas  3 года назад +1

      If it is installed as a Nuget package then yeah

  • @atikhasan7714
    @atikhasan7714 3 года назад

    Hello, Dear can you make a video tutorial about singleton, scope, and transient (which is better for.net core API)

  • @crazywill32
    @crazywill32 3 года назад +1

    I see Nick uses "!." As and operator a lot. As I am still learning C#, what does this mean?

    • @nickchapsas
      @nickchapsas  3 года назад +1

      It means that this value will definitely not be null. I’m using it to suppress the warning for the video. In a realistic scenario you might wanna handle null appropriately

    • @crazywill32
      @crazywill32 3 года назад

      @@nickchapsas Thanks Nick!
      I have found the videos super insightful and interesting. As a professional in another field that codes for a small team, they point out things I should look into to be better.

  • @zirexpl6395
    @zirexpl6395 3 года назад

    I don't understand how to get that and use it. It's something like external software which u run during programming, or nuget package... Or maybe i should write it by myself. If there is answear
    yes" for all question, i would prefer a complete package of this instead of writing it by myself

  • @khamid70
    @khamid70 3 года назад

    Bravo, keep on

  • @petrzurek5713
    @petrzurek5713 3 года назад +1

    Nick, which language do you like to use more, Kotlin or C#?

    • @nickchapsas
      @nickchapsas  3 года назад +4

      I use C# waaaaay more. It's like a 95% C# 5% Kotlin. I only use Kotlin for personal random stuff and not for an actual professional purpose. I do enjoy it a lot though.

    • @petrzurek5713
      @petrzurek5713 3 года назад

      @@nickchapsas Nice, thanks. Do you mostly write cross-platform .net core code these days or do you write windows specific stuff still (wpf, iis web apps, ...)

    • @nickchapsas
      @nickchapsas  3 года назад

      @@petrzurek5713 crossplatform. I've only worked on windows specific stuff for 1 year right before .net core came out

  • @nataliasikorka4825
    @nataliasikorka4825 3 года назад

    Hi Nick,
    I just watched your video about IHttpClientFactory and was wondering - should i dispose instance of HttpClient from factory like this:
    ```
    using var httpClient = httpClientFactory.CreateClient("Test");
    ```
    or it does not matter cause of some handling in IHttpClientFactory or even we shouldn't?
    Sorry that this is not in subject of this video, but it's the newest and there is bigger chance for reply ^^

  • @ahmedkhudhair8035
    @ahmedkhudhair8035 3 года назад

    Can you write code that Cannot be decompile for security

    • @igorthelight
      @igorthelight 3 года назад +1

      That's impossible as far as I know.
      You could make it much less readable tho.
      Also, ANY scripting language (C#, VB, Java, Kotlin, JS, Python... ) is a bad idea if you are concerned about your code security.

    • @sohampatel1063
      @sohampatel1063 3 года назад

      As far i know only c++ makes it hard to reverse engineer the code.

    • @ahmedkhudhair8035
      @ahmedkhudhair8035 3 года назад

      @@igorthelight can you make video on reverse engineering in .net

    • @igorthelight
      @igorthelight 3 года назад +2

      @@sohampatel1063 Not only C++ but ALL programming languages that produce native binaries (C, C++, Rust, COBOL, Fortran, Pascal, Kotlin Native...)

    • @igorthelight
      @igorthelight 3 года назад

      @@ahmedkhudhair8035 Sadly, I can't say that I'm professional enough to make a video.
      But I may recommend to try "Telerik JustDecompile", "JetBrains dotPeek" and "ILSpy".
      Just play around with them and you will be able to decompile most .NET programs. To decompile more professional programs you will need more knowledge (Google Search is a good tool ;-) )

  • @sohampatel1063
    @sohampatel1063 3 года назад +2

    Pleas make video on how to mak custom analyzers and more and more❤️

  • @weluvmusicz
    @weluvmusicz 3 года назад +7

    Make an analyzer that prevents my colleagues from using foreign language words instead of english in source code.

    • @danielschulz7391
      @danielschulz7391 3 года назад

      Best is two languages mixed in one property or function^^

    • @carlosalarcon2737
      @carlosalarcon2737 3 года назад +1

      It's called pull request rejected :)

  • @pawetarsaa9904
    @pawetarsaa9904 3 года назад

    You missed the opportunity to type ANALyzer

  • @clearlyunwell
    @clearlyunwell 3 года назад

    👍🏽

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

    I am honestly very disappointed in this Video... I was actually expecting to see some actual code of an individual analyzer... not just examples for given ones...