Thank you to TwentyFourMinutes for teaching me about source generators. Please take a minute to star his PostgreSQL ORM Repo github.com/TwentyFourMinutes/Venflow
This was super helpful. I was having a hard time getting started using the Microsoft Docs, but this has given me the confidence to really dig in. Just wish I'd found this 6 months ago. Thanks for the great video!
My preferred way of debugging source generators is via unit tests. Not only are they good to do to catch all the edge cases, as usual, but for source generators they provide a very nice entry point for debugging. Can write the test code you want to drive your source generator, run the test, and debug as your source generator processes it and creates output. Nice and clean. I only try my source generator against my actual end-usage source code when I'm mostly done with the source generator and want to give it that last final test.
dotnet clean does not help on updating analyzer at all in my case. For everyone having th same issue, here is what I use: "dotnet build-server shutdown ; dotnet build"
It is worth noting that ISourceGenerator is deprecated and should NOT be used AT ALL. All generators should be using IIncrementalGenerator, the newer, much more performant and optimized, source generation API. This isn't just me saying this, this has been stated on multiple occasions by the compiler architects who work on Roslyn.
could you please make a video about incremental source generators? I'm playing around with source generators, trying to create a service client based on an interface+models. this video really set something straight in my head THANKS!!!
Why not just use AppendLine with the StringBuilder? I don't understand why you're just using Append like it's the only way to use StringBuilder But honestly I wouldn't even use StringBuilder, I'd probably opt for the new triple equals feature.
How did you manage to make the source generator work for .NET6? According to docs and my experience, the generator only works when written on .netstandard 2.0 project.
that was before the api is changed, the problem with core is it changed too many times.. good thing now that we are on .net 7 things have come to a standardized version.
How can I share my soruce generator project as nuget package or assembly/dll reference, I couldnt really find documentation and it really doesnt work by just referencing, looks like it needs some configuration.
Could you make a video about learning / debugging 3rd party code (open source)? I have Rider installed so I am able to debug some of the code with the decompilation feature but often I get the "Could Not Evaluate The Value" error when trying to inspect a variables in 3rd party code. Great video btw! With the new "Raw string literals" feature coming in C# 11, do you think it's still better to use the Roslyn Quoter? Seem like the code would be much more readable with "raw strings" tho more error-prone.
Thank you, on the debugging - what advice could I give except covering your specific usecase? I feel like debugging is a bit of a skill like googling, otherwise with programming your just zooming in on the issue, by finding the correct place in the execution sequence. as for string literals - that's a nope, you'll have alot of "logic" processing strings and values to create syntax, it's not going to be 1 neat string literal, it's going to be many little pieces put together based on your rules.
Anyone ever told you that you look very much like Topher Grace? specifically with his hair and beard style from the black mirror episode "smithereens"? - Just with darker hair and no glasses haha