zeroc-ice / ice-builder-visualstudio

Configure Ice Builder for MSBuild from Visual Studio
https://zeroc.com
BSD 3-Clause "New" or "Revised" License
29 stars 22 forks source link

C# Source Generator instead of MSBuild task juggling #28

Open Gulum opened 2 months ago

Gulum commented 2 months ago

How likely is it that the .ice Source file generation for C# will be migrated to C# Source Generators instead of MSBuild task juggling? Are there any plans?

pepone commented 2 months ago

Hi Gulum,

There is no plan for this, the MSBuild task just runs the slice2cs compiler which is a C++ binary. Can you elaborate on your use case and why you would prefer to have this in a source generator?

Cheers, Jose

Gulum commented 2 months ago

In our company we would like to generate slice files based on c# classes with the help of C# Source Generators. Those generators run as a part of the compiler. The Slice2CS generator runs upfront of the CSC compiler not allowing us to use outputs from the Source Generator. This forces us to also use MSBuild based generators to ensure correct generation order. E.g. Generate .ice files -> Generate C# files (Slice2CS) -> Run C# Compiler.

From my point of view the Source Generators lacks features to allow such a flow anyway.

Both features are already on the Backlog of C#. So i might return to this request :). At the moment my question was out of curiosity if something like this is planned. Not a concrete request. However the mentioned lacking feature would not keep ICE from using Source Generators.

Thanks

pepone commented 2 months ago

This forces us to also use MSBuild based generators to ensure correct generation order. E.g. Generate .ice files -> Generate C# files (Slice2CS) -> Run C# Compiler.

One thing you can try is to run slice2cs from your generator, it shouldn't be too difficult using the Process class.

For [IceRPC] our latest RPC product, we are planning to allow using Slice without Slice files, see https://github.com/icerpc/icerpc-csharp/issues/4011

We are already using Source generators for Services https://docs.icerpc.dev/slice2/language-guide/interface#c#-mapping

And we are planning to move code generation entirely to C# https://github.com/icerpc/icerpc-csharp/issues/3978