Skip to content

Commit fc47d00

Browse files
committed
refactor: drop the redundant dedup guard when seeding direct dispatch entries
Service types are unique across instances because registrations are coalesced, so the seen.Add guard on the direct-registration pass was always true. Seed the seen set explicitly and add each entry unconditionally; the synthetic Func<T>/Lazy<T> pass still checks seen so an explicit relationship registration keeps its dispatch slot. Resolves the lone-if loop that the analyzer flagged without pushing a side-effecting predicate into a Where call.
1 parent 6d37ec1 commit fc47d00

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

Source/Awaiten.SourceGenerators/Emitter.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -228,16 +228,16 @@ private static List<DispatchEntry> BuildDispatchEntries(InstanceModel[] instance
228228
HashSet<string> seen = new(StringComparer.Ordinal);
229229

230230
// Explicit service registrations first, so a directly registered relationship type (e.g. a
231-
// registered Lazy<T>) wins the dispatch slot over the synthetic relationship entry below.
231+
// registered Lazy<T>) wins the dispatch slot over the synthetic relationship entry below. Service
232+
// types are unique across instances (registrations are coalesced), so each is added exactly once;
233+
// seeding 'seen' here lets the synthetic pass skip any key an explicit registration already claimed.
232234
for (int i = 0; i < instances.Length; i++)
233235
{
234236
string resolver = names.Resolver(i);
235237
foreach (string service in instances[i].ServiceTypes.AsArray())
236238
{
237-
if (seen.Add(service))
238-
{
239-
entries.Add(new DispatchEntry(service, resolver + "()"));
240-
}
239+
seen.Add(service);
240+
entries.Add(new DispatchEntry(service, resolver + "()"));
241241
}
242242
}
243243

0 commit comments

Comments
 (0)