Source Generator Support?

Is this something that could be integrated into LINQPad?

I love the fact that LINQPad allows me to try out new features of the language/framework usually but it looks like this needs build and IDE support. This could allow for making very dynamic LINQPad scripts with specially crafted generators that I would love to play around with.


  • LINQPad could in theory be made to work with source generators. The issue - from what I've seen so far - is in the way they're packaged, which relies on MSBuild, project files and PowerShell scripts.

    If particular source generators become popular, it's likely that I could hard-code support for those generators. Is there anything that you have in mind?

  • I don't have any particular generator in mind. Just wanted to see if this could be supported in general so I could author and use generators that I'd write and eventually share.

    But I'd imagine any generators that would come with the usual core packages ought to be included (asp.net core, ef core, etc.)

  • A possible use case I might try to create a generator for, suppose we had a class that contained a list of optional (nullable) properties. We want it to implement an interface that has a subset of the same corresponding properties, but some or all of its properties are non-nullable. The generator could generate explicit implementations of the accessors, perhaps adds a validation function as well to validate all the required properties.

  • One example of a source generator that would be very useful is Refit. I've been unable to use LinqPad to test Refit-based libraries and nuget packages because it requires running sourcegen to create interface stubs. Without that, you get the somewhat unhelpful error "ISomeRefitClient doesn't look like a Refit interface. Make sure it has at least one method with a Refit HTTP method attribute and Refit is installed in the project."

    Source generator support in general would be great but support for Refit specifically would be very helpful.

Sign In or Register to comment.