Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C# Source Generator instead of MSBuild task juggling #28

Open
Gulum opened this issue Jul 10, 2024 · 3 comments
Open

C# Source Generator instead of MSBuild task juggling #28

Gulum opened this issue Jul 10, 2024 · 3 comments

Comments

@Gulum
Copy link

Gulum commented Jul 10, 2024

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
Copy link
Member

pepone commented Jul 10, 2024

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
Copy link
Author

Gulum commented Jul 10, 2024

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
Copy link
Member

pepone commented Jul 10, 2024

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 icerpc/icerpc-csharp#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# icerpc/icerpc-csharp#3978

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants