Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. Source Generators in C# and TDD misadventure time

Source Generators in C# and TDD misadventure time

Scheduled Pinned Locked Moved The Weird and The Wonderful
csharpdesigntestingvisual-studiocom
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    honey the codewitch
    wrote on last edited by
    #1

    I'm very new to the source generator technology in C# so bear with me, as my information is probably incomplete or inaccurate but what I've discovered so far is amusing and annoying at the same time. I tried to get a source generator referenced from one project for use in another project and I was getting weird results when crawling the syntax tree. I don't even know how to google about the results I'm getting back. It's hard to explain, but it breaks the thing. Creating an incremental generator[^] I followed this code precisely, and it didn't work on my system. However, it will work when I invoke the generator to run specifically as part of a unit test. I haven't had as much luck invoking it outside a test framework. I have no idea why this is. I *believe* (read: hope) it will work when packaged as a NuGet package as well, which is how it was designed to be deployed and used. Of course, I don't want to deploy a NuGet package of code still in initial development. The bottom line for all of this is that this leaves me in the position of being forced to perform Test Driven Development in order to make source generators. I don't know if this is a weirdness with my machine, or perhaps a quirk in this relatively new technology or what, but it's just bizarre to be forced into a particular development paradigm like this.

    Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

    Graeme_GrantG 1 Reply Last reply
    0
    • H honey the codewitch

      I'm very new to the source generator technology in C# so bear with me, as my information is probably incomplete or inaccurate but what I've discovered so far is amusing and annoying at the same time. I tried to get a source generator referenced from one project for use in another project and I was getting weird results when crawling the syntax tree. I don't even know how to google about the results I'm getting back. It's hard to explain, but it breaks the thing. Creating an incremental generator[^] I followed this code precisely, and it didn't work on my system. However, it will work when I invoke the generator to run specifically as part of a unit test. I haven't had as much luck invoking it outside a test framework. I have no idea why this is. I *believe* (read: hope) it will work when packaged as a NuGet package as well, which is how it was designed to be deployed and used. Of course, I don't want to deploy a NuGet package of code still in initial development. The bottom line for all of this is that this leaves me in the position of being forced to perform Test Driven Development in order to make source generators. I don't know if this is a weirdness with my machine, or perhaps a quirk in this relatively new technology or what, but it's just bizarre to be forced into a particular development paradigm like this.

      Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

      Graeme_GrantG Offline
      Graeme_GrantG Offline
      Graeme_Grant
      wrote on last edited by
      #2

      I will be working on a Source Generator this weekend, my first time too. I was looking at the same article series and a video linked below.

      honey the codewitch wrote:

      I followed this code precisely, and it didn't work on my system.

      Have a look at this: How to Organize Your .NET Minimal APIs with Source Generator - YouTube[^] When I finish tackling this task, I will publish an article.

      Graeme


      "I fear not the man who has practiced ten thousand kicks one time, but I fear the man that has practiced one kick ten thousand times!" - Bruce Lee

      H 1 Reply Last reply
      0
      • Graeme_GrantG Graeme_Grant

        I will be working on a Source Generator this weekend, my first time too. I was looking at the same article series and a video linked below.

        honey the codewitch wrote:

        I followed this code precisely, and it didn't work on my system.

        Have a look at this: How to Organize Your .NET Minimal APIs with Source Generator - YouTube[^] When I finish tackling this task, I will publish an article.

        Graeme


        "I fear not the man who has practiced ten thousand kicks one time, but I fear the man that has practiced one kick ten thousand times!" - Bruce Lee

        H Offline
        H Offline
        honey the codewitch
        wrote on last edited by
        #3

        Yeah, I just sat through that youtube video to tell me everything I already know, and that nevertheless does not work on my system as advertised. I have to use a test framework to get the damned thing to run at all. Microsoft can get effed. :mad: Edit: IT WORKS! You just have to close VS and reopen it for it to actually take effect. Be nice if somebody said something.

        Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

        Graeme_GrantG 1 Reply Last reply
        0
        • H honey the codewitch

          Yeah, I just sat through that youtube video to tell me everything I already know, and that nevertheless does not work on my system as advertised. I have to use a test framework to get the damned thing to run at all. Microsoft can get effed. :mad: Edit: IT WORKS! You just have to close VS and reopen it for it to actually take effect. Be nice if somebody said something.

          Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

          Graeme_GrantG Offline
          Graeme_GrantG Offline
          Graeme_Grant
          wrote on last edited by
          #4

          honey the codewitch wrote:

          Edit: IT WORKS! You just have to close VS and reopen it for it to actually take effect.

          Congrats and thanks for the tip!

          Graeme


          "I fear not the man who has practiced ten thousand kicks one time, but I fear the man that has practiced one kick ten thousand times!" - Bruce Lee

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups