ChilliCream / graphql-platform

Welcome to the home of the Hot Chocolate GraphQL server for .NET, the Strawberry Shake GraphQL client for .NET and Banana Cake Pop the awesome Monaco based GraphQL IDE.
https://chillicream.com
MIT License
5.27k stars 748 forks source link

StrawberryShake should generate code always in the same order, which is ideal for source control #5335

Closed GeneralSan closed 10 months ago

GeneralSan commented 2 years ago

Is your feature request related to a problem?

Every time a build occurs, a new code generation might take place. If a new code generation takes place, the new generated code is not per se in the same order, and causes a difference to be seen by git, and possibly checked in if we don't look carefully. The essence of the generated code is however exactly the same.

A original generated code could be a line for query 1 and a line for query 2.

namespace Microsoft.Extensions.DependencyInjection
{
    [global::System.CodeDom.Compiler.GeneratedCode("StrawberryShake", "12.11.1.0")]
    public static partial class OurClientServiceCollectionExtensions
    {
        public static global::StrawberryShake.IClientBuilder<global::MyNamespace.State.OurClientStoreAccessor> AddOurClient(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services, global::StrawberryShake.ExecutionStrategy strategy = global::StrawberryShake.ExecutionStrategy.NetworkOnly)
        {
...
global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services, sp => global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService<global::MyNamespace.Query1>(global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService<ClientServiceProvider>(sp)));
global::Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddSingleton(services, sp => global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService<global::MyNamespace.Query2>(global::Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService<ClientServiceProvider>(sp)));
...
}

In the regenerated code, the lines could be in a different order.

The solution you'd like

Have the generated lines always in the same order.

If the code lines for the query singletons are generated one after the other, generate them in the same order, every time, for example in alphabetical order.

Product

Strawberry Shake

GeneralSan commented 1 year ago

How can this be stale if and only because nobody responds to it ? The issue remains valid...

glen-84 commented 10 months ago

Closing, as in v13, code is generated into the obj directory, which is not committed to source control.