❔ Native DLL in source generator
I am trying to make source generator that relies on custom native DLL, compiled from Rust.
But Issue I am facing issues with managing it to be able to load them.
ExtBySharp.Generator
is project containing HybridByondCodeGenerator
DMNet.SpacemanDMM
is project containing native bindings and wrapper for native DLL.
libdreammaker.a
and dreammaker.dll
are native DLLs.
ExtBySharp.Game
is project for containing generator source files *.dm
and *.dme
and needs code to be generated for.
I tried renfrecing project directly, but it didn't work, then I ended up packaging it as nuget package, and generator seems to load things, just it fails at loading native dlls, I tried putting them under analyzers/dotnet/cs
, build/
and I am out of idea what to try.8 Replies
Do not do IO in your generator. It is not supported
Loading a native assembly is IO
Does this mean I need to translate everything in to intermediate things via custom program and then compile them via source generator in to final csharp?
I'm not entirely sure what you're describing. Can you be more specific?
What is the intermediate thing you mean here?
Aka make console program that transforms things and loads dm and dme files, via native dll and then emit files thar are 80% transformed and then use sourcegenerator to load them and do final pass to compile them in to csharp?
That sounds like it would work. You could make it an msbuild task that runs before CoreCompile
And then you include those transformed things as additional files and retrieve them from the AdditionalFilesProvider
Yeah, then that is solution, I think I am going to try 🙂
Also, remember that #roslyn exists and more of the team monitors that channel for questions
(Or if you didn't know, now you do 🙂 )
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.