Using microsoft/CsWin32 library in LINQPad
Hi! I'm trying to use the https://github.com/microsoft/CsWin32/ library in LINQPad. In VS, this involves adding the nuget, then creating a NativeMethods.txt in the proj root with the names of the win32 methods you want it to generate pinvokes for, which then happens as a prebuild step. Is there any way to replicate this in LINQPad? I'm guessing not, but hoping! I could create the pinvokes in a vs-built assembly and then reference that in LINQPad but that's a bit more overhead than I'd like, and also makes it harder to share the scripts. Thanks!
Comments
Source generators aren't supported in LINQPad. This is because the newer versions of LINQPad run under .NET Core / .NET 5 / .NET 6+ - runtimes which don't support application domains. This makes it difficult to reliably isolate source generator assemblies and their dependencies from the host, and would likely require running the entire Roslyn stack in a separate process. Doing so is a non-trivial task and may affect reliability and performance.
Cool, I figured that was probably the case but just wanted to be sure, as always, thanks for the quick answer, much appreciated!