Skip to content

Commit c2ddc8f

Browse files
committed
fix: Disable assembly loading feature in XamlSchemaContext
1 parent c7ffe08 commit c2ddc8f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/SourceGenerators/System.Xaml/System.Xaml/XamlSchemaContext.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
//
2323
// History:
2424
// - 2021/02/21 ([email protected]): Adjust for hard link to AppDomain.AssemblyLoad
25+
// - 2021/11/28 ([email protected]): Disable assembly loading for Uno's as loaded types are never used.
26+
27+
// #define SUPPORTS_LOAD_ASSEMBLIES
2528

2629
using System;
2730
using System.Collections.Generic;
@@ -74,6 +77,7 @@ public XamlSchemaContext (IEnumerable<Assembly> referenceAssemblies, XamlSchemaC
7477

7578
private void RegisterAssemblyLoaded()
7679
{
80+
#if SUPPORTS_LOAD_ASSEMBLIES
7781
var that = new WeakReference<XamlSchemaContext>(this);
7882

7983
void Hook(object o, AssemblyLoadEventArgs e)
@@ -95,12 +99,15 @@ void Hook(object o, AssemblyLoadEventArgs e)
9599
// Register the Hook method to the AssemblyLoad event, so there's no
96100
// hard link between "this" and the AssemblyLoad event delegate.
97101
AppDomain.CurrentDomain.AssemblyLoad += Hook;
102+
#endif
98103
}
99104

100105
~XamlSchemaContext ()
101106
{
107+
#if SUPPORTS_LOAD_ASSEMBLIES
102108
if (reference_assemblies == null)
103109
unhookAssemblyLoad?.Invoke();
110+
#endif
104111
}
105112

106113
IList<Assembly> reference_assemblies;
@@ -321,6 +328,7 @@ public virtual bool TryGetCompatibleXamlNamespace (string xamlNamespace, out str
321328
}
322329
}
323330

331+
#if SUPPORTS_LOAD_ASSEMBLIES
324332
void OnAssemblyLoaded (object o, AssemblyLoadEventArgs e)
325333
{
326334
if (reference_assemblies != null)
@@ -335,6 +343,7 @@ void OnAssemblyLoaded (object o, AssemblyLoadEventArgs e)
335343
if (all_xaml_types != null)
336344
FillAllXamlTypes (e.LoadedAssembly);
337345
}
346+
#endif
338347

339348
// cache updater methods
340349
void FillXamlNamespaces (Assembly ass)

0 commit comments

Comments
 (0)