Skip to content

Commit 61d6e4b

Browse files
authored
Merge pull request #19436 from unoplatform/dev/jela/ios-hr-workaround
fix(hr): Add dummy class at the end of the generated file
2 parents 6ad9bc1 + 96a9879 commit 61d6e4b

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,26 @@ private SourceText InnerGenerateFile()
403403
BuildXBindTryGetDeclarations(writer);
404404
}
405405
}
406+
407+
if (_isHotReloadEnabled && Generation.IOSViewSymbol.Value is not null)
408+
{
409+
// Workaround for HR behaving incorrectly on iOS
410+
// https://github.com/xamarin/xamarin-macios/issues/22102
411+
412+
using (writer.BlockInvariant($"namespace __internal"))
413+
{
414+
writer.AppendLineIndented("/// <remarks>Internal Use for iOS only.</remarks>");
415+
writer.AppendLineIndented("[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]");
416+
writer.AppendLineIndented("[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]");
417+
using (writer.BlockInvariant($"static partial class __{_xClassName.ClassName}_Dummy"))
418+
{
419+
using (writer.BlockInvariant("private static class Dummy_Bindings"))
420+
{
421+
writer.AppendLineIndented("private static object Owner { get; set; }");
422+
}
423+
}
424+
}
425+
}
406426
}
407427
}
408428

0 commit comments

Comments
 (0)