Skip to content

Commit 5a57b1e

Browse files
maxkatz6MrJul
authored andcommitted
Root assemblies for SRE XAML loader (#18290)
* Root assemblies for SRE XAML loader * Update XamlTestBase.cs
1 parent b5cfcf2 commit 5a57b1e

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/Markup/Avalonia.Markup.Xaml.Loader/AvaloniaXamlIlRuntimeCompiler.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,15 @@ public static void DumpRuntimeCompilationResults()
7474
[MemberNotNull(nameof(_ignoresAccessChecksFromAttribute))]
7575
static void InitializeSre()
7676
{
77+
// SRE backend doesn't load assemblies, unless they are already in the memory.
78+
// At the very least, we should make sure that assemblies necessary for `AvaloniaXamlIlWellKnownTypes` are loaded.
79+
// Root `Avalonia.Controls`.
80+
GC.KeepAlive(typeof(Avalonia.Controls.Control));
81+
// Root `Avalonia.Markup`.
82+
GC.KeepAlive(typeof(Avalonia.Data.Binding));
83+
// Root `System.ObjectModel`
84+
GC.KeepAlive(typeof(System.ComponentModel.TypeConverterAttribute));
85+
7786
if (_sreTypeSystem == null)
7887
_sreTypeSystem = new SreTypeSystem();
7988
if (_sreBuilder == null)

tests/Avalonia.Markup.Xaml.UnitTests/XamlTestBase.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,6 @@
1010

1111
namespace Avalonia.Markup.Xaml.UnitTests
1212
{
13-
static class XamlLoaderInit
14-
{
15-
[ModuleInitializer]
16-
public static void Init()
17-
{
18-
var _ = typeof(Binding);
19-
}
20-
}
21-
2213
public class XamlTestBase : ScopedTestBase
2314
{
2415
public XamlTestBase()

0 commit comments

Comments
 (0)