On .NET Live: Lessons Learned Building Source Generators

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

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

  • @daniloa.1455
    @daniloa.1455 6 месяцев назад +2

    20:28 Target .NET Standard 2.0
    22:37 Use IIncrementalGenerator
    23:44 ForAttributeWithMetadataName()
    27:37 Use Immutable, Read-Only Models
    ???? Code Generation
    32:14 Naming Collisions
    37:25 Avoid Package References
    39:18 Be Nullable, but Be Forgiving
    42:16 Reloading Sucks
    46:47 Roslyn APIs can be "Surprising"

  • @NotInventedHereShow
    @NotInventedHereShow 7 месяцев назад +3

    Excellent walkthrough. A few suggestions:
    You don't need to restart VS to observe changes to a source generator in another project. A `dotnet build-server shutdown` at the command line resets the build-server cache and forces the generators to re-run from scratch.
    Wrt. to nullable, I typically wrap generated code in `#nullable annotation`/`#nullable restore`. Then I do not have to use the damn-it operator in the generated code.

  • @IgnatAndrei
    @IgnatAndrei 7 месяцев назад +1

    You can modify source code with Roslyn Code Generator that writes interceptors.

    • @JasonBock
      @JasonBock 7 месяцев назад +1

      ....sort of. You can intercept method invocations, but you can't change method bodies. Also, AFAIK, interceptors are still an experimental feature, so I didn't want to get into that in the talk - I had to enough to cover as-is :)

  • @StephenJWalter
    @StephenJWalter 7 месяцев назад

    Starts at about 3:56

  • @VOXindie
    @VOXindie 7 месяцев назад

    Start at 5:30

  • @ilayarajag6064
    @ilayarajag6064 7 месяцев назад

    hi