From 0634c5aaab91766366d5ef342c01ae652f2adcfc Mon Sep 17 00:00:00 2001 From: Alexandre Zollinger Chohfi Date: Wed, 26 Mar 2014 11:28:11 -0300 Subject: [PATCH 1/2] Reload asset link fix --- MonoGame.Framework/Content/ContentManager.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/MonoGame.Framework/Content/ContentManager.cs b/MonoGame.Framework/Content/ContentManager.cs index 018988c04..727e95028 100644 --- a/MonoGame.Framework/Content/ContentManager.cs +++ b/MonoGame.Framework/Content/ContentManager.cs @@ -563,6 +563,9 @@ namespace Microsoft.Xna.Framework.Content { foreach (var asset in LoadedAssets) { + if (asset.Key == null) // if (false) link hack, to avoid ReloadAsset method from being linked + ReloadAsset(asset.Key, Convert.ChangeType(asset.Value, asset.Value.GetType())); + #if WINDOWS_STOREAPP var methodInfo = typeof(ContentManager).GetType().GetTypeInfo().GetDeclaredMethod("ReloadAsset"); #else From 3c246627a4c19d3e31a2be05b05d464a7185d4be Mon Sep 17 00:00:00 2001 From: Alexandre Zollinger Chohfi Date: Thu, 27 Mar 2014 10:09:09 -0300 Subject: [PATCH 2/2] Improved comment about the link hack --- MonoGame.Framework/Content/ContentManager.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MonoGame.Framework/Content/ContentManager.cs b/MonoGame.Framework/Content/ContentManager.cs index 727e95028..0edeb2990 100644 --- a/MonoGame.Framework/Content/ContentManager.cs +++ b/MonoGame.Framework/Content/ContentManager.cs @@ -563,7 +563,9 @@ namespace Microsoft.Xna.Framework.Content { foreach (var asset in LoadedAssets) { - if (asset.Key == null) // if (false) link hack, to avoid ReloadAsset method from being linked + // This never executes as asset.Key is never null. This just forces the + // linker to include the ReloadAsset function when AOT compiled. + if (asset.Key == null) ReloadAsset(asset.Key, Convert.ChangeType(asset.Value, asset.Value.GetType())); #if WINDOWS_STOREAPP