C# Source Generators - Write code that writes code - David Wengier

แชร์
ฝัง
  • เผยแพร่เมื่อ 14 ต.ค. 2024
  • Generating source code is not a new technology, and there are lots of different offerings out there available for you to use, or that you may in fact be using right now. Tools like PostSharp, Fody, CodeSmith, and many, many more. What is new however, with C# 9 and .NET 5, is a formal source generation offering from Microsoft, taking advantage of a unique opportunity that only the Roslyn team can provide, that lets you run your generator inside the compiler pipeline, with access to the internal data structures the compiler produces. In this session we'll cover source generators in general, deep dive into the C# 9 offering, and then run through some examples, talk about the possibilities, and leave you with no shortage of ideas for your own generators that you can run wild with. When all you have is a hammer, everything looks like a nail, and with source generators in your toolbelt, you won't look at that slow old reflection code the same way ever again.
    Check out more of our talks at:
    ndcsydney.com
    www.ndcconfere...

ความคิดเห็น • 14

  • @jonohiggs
    @jonohiggs 3 ปีที่แล้ว +2

    On the AutoNotify example it really kills me that you have to put the generator attribute on the private storage field and not the public property. Storage field is internal implementation detail but is visible in the code, where as the property which is the class public interface is missing

  • @Bjarkediedrage
    @Bjarkediedrage 3 ปีที่แล้ว +1

    I don't understand why there's so much boilerplate required in order to get this working. Seem like it should be possible make it work just by referencing the generator stuff, and start writing generators, without doing any setup in the csproject file.

  • @Kooshad1
    @Kooshad1 2 ปีที่แล้ว +1

    sourcegen.dev is no longer up?

  • @declup
    @declup 3 ปีที่แล้ว +1

    Does anyone have any considered opinions about Fody?

  • @Naster001
    @Naster001 3 ปีที่แล้ว

    Awsome presentation!

  • @muhammeda1426
    @muhammeda1426 ปีที่แล้ว

    İf i cant save class to the path i want , whats the meaning of this? Please someone explain me

  • @ShadoFXPerino
    @ShadoFXPerino 3 ปีที่แล้ว +3

    Sweet, a replacement for T4 text templates.

  • @alirezanet
    @alirezanet 3 ปีที่แล้ว +1

    I still prefer CodeSmith :)

  • @fr3ddyfr3sh
    @fr3ddyfr3sh 3 ปีที่แล้ว

    Nice video.
    Horrible Audio jitter from time to time.

  • @rpreviato
    @rpreviato 3 ปีที่แล้ว

    Too many ads in the middle of whole video, impossible to watch.

    • @waynegreen7970
      @waynegreen7970 3 ปีที่แล้ว

      To get around this problem on videos that I REALLY want to watch, I use a TH-cam video downloader to download the video as a .mp4 file and watch it that way. No ads. I bought one for 10 bucks about 6 years ago. 10 dollars well spent.

    • @ysink
      @ysink 2 ปีที่แล้ว

      @@waynegreen7970 you got ripped off bad god damn... The youtube-dl project is AWESOME and totally free

    • @waynegreen7970
      @waynegreen7970 2 ปีที่แล้ว +1

      @@ysink You consider spending 10 dollars and using a product for 6 years as getting ripped off bad?