diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs index 1d53558a278a..7f056c1bf6f3 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs @@ -6049,11 +6049,9 @@ private void BuildChild(IIndentedStringBuilder writer, XamlMemberDefinition? own if (contentOwner != null || _isHotReloadEnabled) // If Hot Reload is enabled, we still need to attach the source location, even on empty elements { - var resourceOwner = CurrentResourceOwnerName; - - - if(contentOwner is { }) + if(contentOwner != null) { + var resourceOwner = CurrentResourceOwnerName; #if USE_NEW_TP_CODEGEN writer.Append($"{resourceOwner}, (__owner, __settings) => "); #else