Skip to content

Commit 9d65f3f

Browse files
authored
Reduce enumerations and delegate invocations (#28470)
1 parent 144ee57 commit 9d65f3f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/Hosting/Hosting/src/WebHostBuilder.cs

+6-2
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,13 @@ public IWebHost Build()
183183
var logger = host.Services.GetRequiredService<ILogger<WebHost>>();
184184

185185
// Warn about duplicate HostingStartupAssemblies
186-
foreach (var assemblyName in _options.GetFinalHostingStartupAssemblies().GroupBy(a => a, StringComparer.OrdinalIgnoreCase).Where(g => g.Count() > 1))
186+
var assemblyNames = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
187+
foreach (var assemblyName in _options.GetFinalHostingStartupAssemblies())
187188
{
188-
logger.LogWarning($"The assembly {assemblyName} was specified multiple times. Hosting startup assemblies should only be specified once.");
189+
if (!assemblyNames.Add(assemblyName))
190+
{
191+
logger.LogWarning($"The assembly {assemblyName} was specified multiple times. Hosting startup assemblies should only be specified once.");
192+
}
189193
}
190194

191195
return host;

0 commit comments

Comments
 (0)