Skip to content

Commit 8a52b4a

Browse files
committed
Skip registrations with empty ViewModelTypeName
Added checks to skip processing registrations where ViewModelTypeName is null, empty, or whitespace. This prevents potential errors from invalid or incomplete registration data.
1 parent d281bcd commit 8a52b4a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,12 @@ private static string GenerateRegistrationExtensions(in ImmutableArray<IViewForI
346346
foreach (var item in registrations)
347347
{
348348
var vmType = item.ViewModelTypeName;
349+
if (string.IsNullOrWhiteSpace(vmType))
350+
{
351+
// Something's wrong, skip it
352+
continue;
353+
}
354+
349355
if (!string.IsNullOrEmpty(vmType) && !vmType.StartsWith("global::", System.StringComparison.Ordinal))
350356
{
351357
vmType = "global::" + vmType;
@@ -372,6 +378,12 @@ private static string GenerateRegistrationExtensions(in ImmutableArray<IViewForI
372378
foreach (var item in viewModelRegistrations)
373379
{
374380
var vmType = item.ViewModelTypeName;
381+
if (string.IsNullOrWhiteSpace(vmType))
382+
{
383+
// Something's wrong, skip it
384+
continue;
385+
}
386+
375387
if (!string.IsNullOrEmpty(vmType) && !vmType.StartsWith("global::", System.StringComparison.Ordinal))
376388
{
377389
vmType = "global::" + vmType;

0 commit comments

Comments
 (0)