Skip to content

Commit 4e33115

Browse files
committed
Prevent empty source files in IViewForGenerator
Adds a check to only generate source files when a supported UI framework base type is detected, avoiding creation of empty generated files.
1 parent 3c3b9c3 commit 4e33115

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/ReactiveUI.SourceGenerators.Roslyn/IViewFor/IViewForGenerator.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,12 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
6868
}
6969

7070
var source = GenerateSource(grouping.Key.TargetName, grouping.Key.TargetNamespace, grouping.Key.TargetVisibility, grouping.Key.TargetType, grouping.FirstOrDefault());
71-
context.AddSource(grouping.Key.FileHintName + ".IViewFor.g.cs", source);
71+
72+
// Only add source if it's not empty (i.e., a supported UI framework base type was detected)
73+
if (!string.IsNullOrWhiteSpace(source))
74+
{
75+
context.AddSource(grouping.Key.FileHintName + ".IViewFor.g.cs", source);
76+
}
7277
}
7378
});
7479
}

0 commit comments

Comments
 (0)