Skip to content

Commit

Permalink
Fixed Analyzer Namespacing
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelstaib committed Mar 7, 2024
1 parent 908ec37 commit 1c3a009
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ private static void Execute(
{
if (syntaxInfos.Length == 0)
{
WriteNoOpCompose(context);
return;
}

Expand Down Expand Up @@ -223,8 +224,11 @@ private static void Execute(

if (gateways.Count == 0)
{
WriteNoOpCompose(context);
return;
}

WriteCompose(context);

var code = StringBuilderPool.Get();
using var writer = new CodeWriter(code);
Expand Down Expand Up @@ -299,6 +303,30 @@ private static void Execute(
context.AddSource("FusionConfiguration.g.cs", code.ToString());
StringBuilderPool.Return(code);
}

private static void WriteCompose(SourceProductionContext context)
{
var code = StringBuilderPool.Get();
using var writer = new CodeWriter(code);

writer.WriteFileHeader();
writer.Write(AnalyzerResources.Compose);

context.AddSource("FusionCompose.g.cs", code.ToString());
StringBuilderPool.Return(code);
}

private static void WriteNoOpCompose(SourceProductionContext context)
{
var code = StringBuilderPool.Get();
using var writer = new CodeWriter(code);

writer.WriteFileHeader();
writer.Write(AnalyzerResources.NoOpCompose);

context.AddSource("FusionCompose.g.cs", code.ToString());
StringBuilderPool.Return(code);
}

private static void AddInitializationContent(IncrementalGeneratorPostInitializationContext context)
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ using System.Net.Mime;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using HotChocolate.Execution.Configuration;
using HotChocolate.Fusion;
using HotChocolate.Fusion.Composition;
using HotChocolate.Fusion.Composition.Features;
Expand All @@ -39,7 +38,6 @@ using Microsoft.Extensions.DependencyInjection;

namespace HotChocolate.Fusion.Composition.Tooling
{

internal static class FusionGatewayConfgHelper
{
public static async Task ConfigureAsync(CancellationToken cancellationToken = default)
Expand Down Expand Up @@ -604,19 +602,6 @@ namespace Aspire.Hosting
{
internal static class FusionExtensions
{
public static DistributedApplication Compose(this DistributedApplication application)
{
var options = application.Services.GetRequiredService<DistributedApplicationOptions>();

if (options.Args is ["compose"])
{
global::HotChocolate.Fusion.Composition.Tooling.FusionGatewayConfgHelper.ConfigureAsync().Wait();
Environment.Exit(0);
}

return application;
}

public static IResourceBuilder<FusionGatewayResource> AddFusionGateway<TProject>(
this IDistributedApplicationBuilder builder,
string name)
Expand Down Expand Up @@ -657,7 +642,42 @@ namespace Aspire.Hosting

public FusionGatewayResource Resource { get; } = new(projectResourceBuilder.Resource);
}
}
</value>
}</value>
</data>
<data name="NoOpCompose" xml:space="preserve">
<value>using Microsoft.Extensions.DependencyInjection;

namespace Aspire.Hosting
{
internal static class DistributedApplicationExtensions
{
public static DistributedApplication Compose(this DistributedApplication application)
{
return application;
}
}
}</value>
</data>
<data name="Compose" xml:space="preserve">
<value>using Microsoft.Extensions.DependencyInjection;

namespace Aspire.Hosting
{
internal static class HotChocolateDistributedApplicationExtensions
{
public static DistributedApplication Compose(this DistributedApplication application)
{
var options = application.Services.GetRequiredService&lt;DistributedApplicationOptions&gt;();

if (options.Args is ["compose"])
{
global::HotChocolate.Fusion.Composition.Tooling.FusionGatewayConfgHelper.ConfigureAsync().Wait();
Environment.Exit(0);
}

return application;
}
}
}</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,16 @@ public static void Foo(string[] args)
.WithEnvironment("Identity__Url", identityHttpsEndpoint);

// Fusion
builder
var gateway = builder
.AddFusionGateway<Projects.eShop_Gateway>("gateway")
.WithSubgraph(basketApi)
.WithSubgraph(identityApi.GetEndpoint("http"))
.WithSubgraph(identityApi)
.WithSubgraph(catalogApi)
.WithSubgraph(orderingApi)
.WithSubgraph(purchaseApi)
.WithEnvironment("Identity__Url", identityHttpsEndpoint);

.WithSubgraph(purchaseApi);

builder.Build().Compose().Run();
}
}


0 comments on commit 1c3a009

Please sign in to comment.