Skip to content

Commit

Permalink
fix: Disable assembly loading feature in XamlSchemaContext
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromelaban committed Nov 28, 2021
1 parent c7ffe08 commit c2ddc8f
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand All @@ -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;
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit c2ddc8f

Please sign in to comment.