Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Allow more than 1,000 handlers
  • Loading branch information
viceroypenguin committed Jul 21, 2025
commit d0d5c5d02aca212025fe553be4e205b1942fd991
31 changes: 23 additions & 8 deletions src/Immediate.Handlers.Generators/ImmediateHandlersGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Scriban;
using Scriban.Runtime;

namespace Immediate.Handlers.Generators;

Expand Down Expand Up @@ -121,15 +122,29 @@ string assemblyName
var template = GetTemplate("ServiceCollectionExtensions");

cancellationToken.ThrowIfCancellationRequested();
var source = template.Render(new

var so = new ScriptObject(StringComparer.Ordinal);

so.Import(
new
{
Namespace = @namespace,
AssemblyName = assemblyName,
Handlers = handlers.Select(x => x.displayName),
Behaviors = behaviors
.Concat(handlers.SelectMany(h => h.behaviors ?? Enumerable.Empty<Behavior?>()))
.Distinct(),
}
);

var templateContext = new TemplateContext(StringComparer.Ordinal)
{
Namespace = @namespace,
AssemblyName = assemblyName,
Handlers = handlers.Select(x => x.displayName),
Behaviors = behaviors
.Concat(handlers.SelectMany(h => h.behaviors ?? Enumerable.Empty<Behavior?>()))
.Distinct(),
});
LoopLimit = 0,
};

templateContext.PushGlobal(so);

var source = template.Render(templateContext);

cancellationToken.ThrowIfCancellationRequested();
context.AddSource("IH.ServiceCollectionExtensions.g.cs", source);
Expand Down