-
Notifications
You must be signed in to change notification settings - Fork 750
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Disable assembly loading feature in XamlSchemaContext
- Loading branch information
1 parent
c7ffe08
commit c2ddc8f
Showing
1 changed file
with
9 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,9 @@ | |
// | ||
// History: | ||
// - 2021/02/21 ([email protected]): Adjust for hard link to AppDomain.AssemblyLoad | ||
// - 2021/11/28 ([email protected]): Disable assembly loading for Uno's as loaded types are never used. | ||
|
||
// #define SUPPORTS_LOAD_ASSEMBLIES | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
|
@@ -74,6 +77,7 @@ public XamlSchemaContext (IEnumerable<Assembly> referenceAssemblies, XamlSchemaC | |
|
||
private void RegisterAssemblyLoaded() | ||
{ | ||
#if SUPPORTS_LOAD_ASSEMBLIES | ||
var that = new WeakReference<XamlSchemaContext>(this); | ||
|
||
void Hook(object o, AssemblyLoadEventArgs e) | ||
|
@@ -95,12 +99,15 @@ void Hook(object o, AssemblyLoadEventArgs e) | |
// Register the Hook method to the AssemblyLoad event, so there's no | ||
// hard link between "this" and the AssemblyLoad event delegate. | ||
AppDomain.CurrentDomain.AssemblyLoad += Hook; | ||
#endif | ||
} | ||
|
||
~XamlSchemaContext () | ||
{ | ||
#if SUPPORTS_LOAD_ASSEMBLIES | ||
if (reference_assemblies == null) | ||
unhookAssemblyLoad?.Invoke(); | ||
#endif | ||
} | ||
|
||
IList<Assembly> reference_assemblies; | ||
|
@@ -321,6 +328,7 @@ public virtual bool TryGetCompatibleXamlNamespace (string xamlNamespace, out str | |
} | ||
} | ||
|
||
#if SUPPORTS_LOAD_ASSEMBLIES | ||
void OnAssemblyLoaded (object o, AssemblyLoadEventArgs e) | ||
{ | ||
if (reference_assemblies != null) | ||
|
@@ -335,6 +343,7 @@ void OnAssemblyLoaded (object o, AssemblyLoadEventArgs e) | |
if (all_xaml_types != null) | ||
FillAllXamlTypes (e.LoadedAssembly); | ||
} | ||
#endif | ||
|
||
// cache updater methods | ||
void FillXamlNamespaces (Assembly ass) | ||
|