From f12f1ab43b38b6c71b5539d4ca765d842a303a7e Mon Sep 17 00:00:00 2001 From: Paul Betts Date: Sun, 14 Jul 2013 18:23:10 -0700 Subject: [PATCH 1/4] Create some global constants for cache limits --- ReactiveUI/RxApp.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ReactiveUI/RxApp.cs b/ReactiveUI/RxApp.cs index a1d2ab5552..e63f38f23b 100644 --- a/ReactiveUI/RxApp.cs +++ b/ReactiveUI/RxApp.cs @@ -290,6 +290,14 @@ static void initializeDependencyResolver() } static internal bool suppressLogging { get; set; } + +#if ANDROID || SILVERLIGHT || UIKIT + public const int SmallCacheLimit = 4; + public const int BigCacheLimit = 8; +#else + public const int SmallCacheLimit = 32; + public const int BigCacheLimit = 64; +#endif } } From 4359771f91425ee33611b0df6f06327536627943 Mon Sep 17 00:00:00 2001 From: Paul Betts Date: Sun, 14 Jul 2013 18:23:31 -0700 Subject: [PATCH 2/4] Set the cache limits on a bunch of internal caches --- ReactiveUI.Platforms/ComponentModelTypeConverter.cs | 3 ++- ReactiveUI/AutoPersistHelper.cs | 6 +++--- ReactiveUI/BindingTypeConverters.cs | 4 ++-- ReactiveUI/CommandBinding.cs | 4 ++-- ReactiveUI/Logging.cs | 2 +- ReactiveUI/PropertyBinding.cs | 2 +- ReactiveUI/ReactiveNotifyPropertyChangedMixin.cs | 2 +- ReactiveUI/Reflection.cs | 6 +++--- 8 files changed, 15 insertions(+), 14 deletions(-) diff --git a/ReactiveUI.Platforms/ComponentModelTypeConverter.cs b/ReactiveUI.Platforms/ComponentModelTypeConverter.cs index de09c0bbba..48a1838790 100644 --- a/ReactiveUI.Platforms/ComponentModelTypeConverter.cs +++ b/ReactiveUI.Platforms/ComponentModelTypeConverter.cs @@ -3,6 +3,7 @@ namespace ReactiveUI { + /// /// This binding type converter uses the built-in WPF component model /// conversions to get a whole bunch of conversions for free. Unfortunately, @@ -21,7 +22,7 @@ public class ComponentModelTypeConverter : IBindingTypeConverter var converter = TypeDescriptor.GetConverter(types.Item1); return converter.CanConvertTo(types.Item2) ? converter : null; - }, 25); + }, RxApp.SmallCacheLimit); public int GetAffinityForObjects(Type lhs, Type rhs) { diff --git a/ReactiveUI/AutoPersistHelper.cs b/ReactiveUI/AutoPersistHelper.cs index 34c5039660..d81db3a512 100644 --- a/ReactiveUI/AutoPersistHelper.cs +++ b/ReactiveUI/AutoPersistHelper.cs @@ -18,11 +18,11 @@ public static class AutoPersistHelper return type.GetProperties() .Where(x => x.CustomAttributes.Any(y => typeof(DataMemberAttribute).IsAssignableFrom(y.AttributeType))) .ToDictionary(k => k.Name, v => true); - }, 32); + }, RxApp.SmallCacheLimit); static MemoizingMRUCache dataContractCheckCache = new MemoizingMRUCache((t, _) => { return t.GetCustomAttributes(typeof(DataContractAttribute), true).Any(); - }, 64); + }, RxApp.SmallCacheLimit); public static IDisposable AutoPersist(this T This, Func> doPersist, TimeSpan? interval = null) where T : IReactiveNotifyPropertyChanged @@ -131,4 +131,4 @@ public static IDisposable ActOnEveryObject(this ReactiveList This, Action< }); } } -} \ No newline at end of file +} diff --git a/ReactiveUI/BindingTypeConverters.cs b/ReactiveUI/BindingTypeConverters.cs index e7e5179e4d..da60c13f4d 100644 --- a/ReactiveUI/BindingTypeConverters.cs +++ b/ReactiveUI/BindingTypeConverters.cs @@ -43,7 +43,7 @@ public int GetAffinityForObjects(Type lhs, Type rhs) genericMi = genericMi ?? typeof (EqualityTypeConverter).GetMethod("DoReferenceCast", BindingFlags.Public | BindingFlags.Static); return genericMi.MakeGenericMethod(new[] {t}); - }, 25); + }, RxApp.SmallCacheLimit); public bool TryConvert(object from, Type toType, object conversionHint, out object result) { @@ -103,4 +103,4 @@ public bool TryConvert(object from, Type toType, object conversionHint, out obje return true; } } -} \ No newline at end of file +} diff --git a/ReactiveUI/CommandBinding.cs b/ReactiveUI/CommandBinding.cs index c602957d2f..03a12e4079 100644 --- a/ReactiveUI/CommandBinding.cs +++ b/ReactiveUI/CommandBinding.cs @@ -347,7 +347,7 @@ class CreatesCommandBinding int score = x.GetAffinityForObject(t, false); return (score > acc.Item1) ? Tuple.Create(score, x) : acc; }).Item2; - }, 50); + }, RxApp.SmallCacheLimit); static readonly MemoizingMRUCache bindCommandEventCache = new MemoizingMRUCache((t, _) => { @@ -356,7 +356,7 @@ class CreatesCommandBinding int score = x.GetAffinityForObject(t, true); return (score > acc.Item1) ? Tuple.Create(score, x) : acc; }).Item2; - }, 50); + }, RxApp.SmallCacheLimit); public static IDisposable BindCommandToObject(ICommand command, object target, IObservable commandParameter) { diff --git a/ReactiveUI/Logging.cs b/ReactiveUI/Logging.cs index bb9507c299..25ed55468a 100644 --- a/ReactiveUI/Logging.cs +++ b/ReactiveUI/Logging.cs @@ -112,7 +112,7 @@ public DefaultLogManager(IDependencyResolver dependencyResolver = null) } return new WrappingFullLogger(ret, type); - }, 30); + }, RxApp.BigCacheLimit); } static readonly IFullLogger nullLogger = new WrappingFullLogger(new NullLogger(), typeof(MemoizingMRUCache)); diff --git a/ReactiveUI/PropertyBinding.cs b/ReactiveUI/PropertyBinding.cs index 642a27d24b..cbcccf195b 100644 --- a/ReactiveUI/PropertyBinding.cs +++ b/ReactiveUI/PropertyBinding.cs @@ -1038,7 +1038,7 @@ bool evalBindingHooks(TViewModel viewModel, TView view, strin return score > acc.Item1 && score > 0 ? Tuple.Create(score, x) : acc; }).Item2; - }, 25); + }, RxApp.SmallCacheLimit); internal IBindingTypeConverter getConverterForTypes(Type lhs, Type rhs) { diff --git a/ReactiveUI/ReactiveNotifyPropertyChangedMixin.cs b/ReactiveUI/ReactiveNotifyPropertyChangedMixin.cs index 9d47367e5d..f35f8f231a 100644 --- a/ReactiveUI/ReactiveNotifyPropertyChangedMixin.cs +++ b/ReactiveUI/ReactiveNotifyPropertyChangedMixin.cs @@ -179,7 +179,7 @@ public static IObservable> SubscribeToExpressio int score = x.GetAffinityForObject(t.Item1, t.Item2, t.Item3); return (score > acc.Item1) ? Tuple.Create(score, x) : acc; }).Item2; - }, 50); + }, RxApp.BigCacheLimit); static IObservable> notifyForProperty(object sender, string propertyName, bool beforeChange) { diff --git a/ReactiveUI/Reflection.cs b/ReactiveUI/Reflection.cs index 79767d85ba..34974ba7ed 100644 --- a/ReactiveUI/Reflection.cs +++ b/ReactiveUI/Reflection.cs @@ -24,7 +24,7 @@ public static class Reflection } return null; - }, 15); + }, RxApp.BigCacheLimit); static readonly MemoizingMRUCache, Action> propWriterCache = new MemoizingMRUCache, Action>((x,_) => { @@ -39,7 +39,7 @@ public static class Reflection } return null; - }, 15); + }, RxApp.BigCacheLimit); public static string SimpleExpressionToPropertyName(Expression> property) { @@ -331,4 +331,4 @@ internal static string[] getDefaultViewPropChain(object view, string[] vmPropCha return new[] {vmPropertyName, defaultProperty}; } } -} \ No newline at end of file +} From 3fd6b956ea527b4fa681c25f17c21d65acba9de9 Mon Sep 17 00:00:00 2001 From: Paul Betts Date: Sun, 14 Jul 2013 20:38:37 -0700 Subject: [PATCH 3/4] Add an android manifest whatever just stop doing this constantly --- ReactiveUI.Tests/Properties/AndroidManifest.xml | 6 ++++++ ReactiveUI.Tests/ReactiveUI.Tests_Monodroid.csproj | 2 ++ 2 files changed, 8 insertions(+) create mode 100644 ReactiveUI.Tests/Properties/AndroidManifest.xml diff --git a/ReactiveUI.Tests/Properties/AndroidManifest.xml b/ReactiveUI.Tests/Properties/AndroidManifest.xml new file mode 100644 index 0000000000..f61933889e --- /dev/null +++ b/ReactiveUI.Tests/Properties/AndroidManifest.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ReactiveUI.Tests/ReactiveUI.Tests_Monodroid.csproj b/ReactiveUI.Tests/ReactiveUI.Tests_Monodroid.csproj index f76e3e9f0a..93b952e042 100644 --- a/ReactiveUI.Tests/ReactiveUI.Tests_Monodroid.csproj +++ b/ReactiveUI.Tests/ReactiveUI.Tests_Monodroid.csproj @@ -19,6 +19,7 @@ armeabi%3barmeabi-v7a%3bx86 None + Properties\AndroidManifest.xml true @@ -101,6 +102,7 @@ + From b0a7f97098585a7089a7b82921f7c2bb18d6d260 Mon Sep 17 00:00:00 2001 From: Paul Betts Date: Sun, 14 Jul 2013 23:13:38 -0700 Subject: [PATCH 4/4] Use the correct constant for Xamarin.iOS --- ReactiveUI/RxApp.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ReactiveUI/RxApp.cs b/ReactiveUI/RxApp.cs index e63f38f23b..106893a9c2 100644 --- a/ReactiveUI/RxApp.cs +++ b/ReactiveUI/RxApp.cs @@ -291,7 +291,7 @@ static void initializeDependencyResolver() static internal bool suppressLogging { get; set; } -#if ANDROID || SILVERLIGHT || UIKIT +#if ANDROID || SILVERLIGHT || IOS public const int SmallCacheLimit = 4; public const int BigCacheLimit = 8; #else