Skip to content

Commit ae26d3e

Browse files
Optimize Options Source Gen when no need to run (#93481)
Co-authored-by: Tarek Mahmoud Sayed <tarekms@microsoft.com>
1 parent fb1d8b4 commit ae26d3e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/libraries/Microsoft.Extensions.Options/gen/Generator.cs

+5
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
3232

3333
private static void HandleAnnotatedTypes(Compilation compilation, ImmutableArray<(TypeDeclarationSyntax? TypeSyntax, SemanticModel SemanticModel)> types, SourceProductionContext context)
3434
{
35+
if (types.Length == 0)
36+
{
37+
return;
38+
}
39+
3540
if (!SymbolLoader.TryLoad(compilation, out var symbolHolder))
3641
{
3742
// Not eligible compilation

0 commit comments

Comments
 (0)