From 712361c3663bcdda4c8d0b1887f6349e3cf76fe3 Mon Sep 17 00:00:00 2001 From: kingces95 Date: Tue, 21 Aug 2018 00:22:58 -1000 Subject: [PATCH 01/10] Fix NRE; Ret 0 if Text null (#3594) fixes #3579 --- Xamarin.Forms.Platform.iOS/Extensions/LabelExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xamarin.Forms.Platform.iOS/Extensions/LabelExtensions.cs b/Xamarin.Forms.Platform.iOS/Extensions/LabelExtensions.cs index e634ef187..6095a7494 100644 --- a/Xamarin.Forms.Platform.iOS/Extensions/LabelExtensions.cs +++ b/Xamarin.Forms.Platform.iOS/Extensions/LabelExtensions.cs @@ -59,7 +59,7 @@ namespace Xamarin.Forms.Platform.MacOS var span = element.FormattedText.Spans[i]; var location = currentLocation; - var length = span.Text.Length; + var length = span.Text?.Length ?? 0; if (length == 0) continue; From 865b069a9496e5e0ed5493e6baa5a1dd19103e3d Mon Sep 17 00:00:00 2001 From: Shane Neuville Date: Tue, 21 Aug 2018 12:22:06 -0600 Subject: [PATCH 02/10] [Core] Ignore Shamehat target when running DesignTimeBuild (#3605) --- Xamarin.Forms.Core/Xamarin.Forms.Core.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xamarin.Forms.Core/Xamarin.Forms.Core.csproj b/Xamarin.Forms.Core/Xamarin.Forms.Core.csproj index cfaf9193b..d585a8630 100644 --- a/Xamarin.Forms.Core/Xamarin.Forms.Core.csproj +++ b/Xamarin.Forms.Core/Xamarin.Forms.Core.csproj @@ -21,7 +21,7 @@ - + From 2ca330ecc21eceb6d8383a1decd7586cd3baf613 Mon Sep 17 00:00:00 2001 From: Stephane Delcroix Date: Wed, 22 Aug 2018 07:12:51 +0000 Subject: [PATCH 03/10] [XamlC] Fix binding compilation fo value types (#3551) properly load valuetype arguments of generated setters, using ldarg, instead of ldarga. - fixes #3539 --- .../SetPropertiesVisitor.cs | 20 +- .../Issues/Gh3539.xaml | 22 ++ .../Issues/Gh3539.xaml.cs | 214 ++++++++++++++++++ .../Xamarin.Forms.Xaml.UnitTests.csproj | 7 + 4 files changed, 252 insertions(+), 11 deletions(-) create mode 100644 Xamarin.Forms.Xaml.UnitTests/Issues/Gh3539.xaml create mode 100644 Xamarin.Forms.Xaml.UnitTests/Issues/Gh3539.xaml.cs diff --git a/Xamarin.Forms.Build.Tasks/SetPropertiesVisitor.cs b/Xamarin.Forms.Build.Tasks/SetPropertiesVisitor.cs index 9891d2cf7..cfeabe7c7 100644 --- a/Xamarin.Forms.Build.Tasks/SetPropertiesVisitor.cs +++ b/Xamarin.Forms.Build.Tasks/SetPropertiesVisitor.cs @@ -540,7 +540,7 @@ namespace Xamarin.Forms.Build.Tasks static IEnumerable CompiledBindingGetSetter(TypeReference tSourceRef, TypeReference tPropertyRef, IList> properties, ElementNode node, ILContext context) { if (properties == null || properties.Count == 0) { - yield return Instruction.Create(OpCodes.Ldnull); + yield return Create(Ldnull); yield break; } @@ -573,7 +573,7 @@ namespace Xamarin.Forms.Build.Tasks var lastProperty = properties.LastOrDefault(); var setterRef = lastProperty?.Item1.SetMethod; if (setterRef == null) { - yield return Instruction.Create(OpCodes.Ldnull); //throw or not ? + yield return Create(Ldnull); //throw or not ? yield break; } @@ -586,12 +586,12 @@ namespace Xamarin.Forms.Build.Tasks var indexerArg = properties[i].Item2; if (indexerArg != null) { if (property.GetMethod.Parameters [0].ParameterType == module.TypeSystem.String) - il.Emit(OpCodes.Ldstr, indexerArg); + il.Emit(Ldstr, indexerArg); else if (property.GetMethod.Parameters [0].ParameterType == module.TypeSystem.Int32) { int index; if (!int.TryParse(indexerArg, out index)) throw new XamlParseException($"Binding: {indexerArg} could not be parsed as an index for a {property.Name}", node as IXmlLineInfo); - il.Emit(OpCodes.Ldc_I4, index); + il.Emit(Ldc_I4, index); } } if (property.GetMethod.IsVirtual) @@ -603,25 +603,23 @@ namespace Xamarin.Forms.Build.Tasks var indexer = properties.Last().Item2; if (indexer != null) { if (lastProperty.Item1.GetMethod.Parameters [0].ParameterType == module.TypeSystem.String) - il.Emit(OpCodes.Ldstr, indexer); + il.Emit(Ldstr, indexer); else if (lastProperty.Item1.GetMethod.Parameters [0].ParameterType == module.TypeSystem.Int32) { int index; if (!int.TryParse(indexer, out index)) throw new XamlParseException($"Binding: {indexer} could not be parsed as an index for a {lastProperty.Item1.Name}", node as IXmlLineInfo); - il.Emit(OpCodes.Ldc_I4, index); + il.Emit(Ldc_I4, index); } } - if (tPropertyRef.IsValueType) - il.Emit(Ldarga_S, (byte)1); - else - il.Emit(Ldarg_1); + + il.Emit(Ldarg_1); if (setterRef.IsVirtual) il.Emit(Callvirt, module.ImportReference(setterRef)); else il.Emit(Call, module.ImportReference(setterRef)); - il.Emit(OpCodes.Ret); + il.Emit(Ret); context.Body.Method.DeclaringType.Methods.Add(setter); diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Gh3539.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Gh3539.xaml new file mode 100644 index 000000000..a6b9da7c5 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Gh3539.xaml @@ -0,0 +1,22 @@ + + + + + + + + + + + diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Gh3539.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Gh3539.xaml.cs new file mode 100644 index 000000000..24824949d --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Gh3539.xaml.cs @@ -0,0 +1,214 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Reflection; +using System.Text; +using NUnit.Framework; +using Xamarin.Forms; +using Xamarin.Forms.Core.UnitTests; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public class Gh3539ViewModel : INotifyPropertyChanged + { + Color color; + string name; + + public event PropertyChangedEventHandler PropertyChanged; + + public double Hue { + set { + if (color.Hue != value) { + Color = Color.FromHsla(value, color.Saturation, color.Luminosity); + } + } + get { + return color.Hue; + } + } + + public double Saturation { + set { + if (color.Saturation != value) { + Color = Color.FromHsla(color.Hue, value, color.Luminosity); + } + } + get { + return color.Saturation; + } + } + + public double Luminosity { + set { + if (color.Luminosity != value) { + Color = Color.FromHsla(color.Hue, color.Saturation, value); + } + } + get { + return color.Luminosity; + } + } + + public Color Color { + set { + if (color != value) { + color = value; + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Hue")); + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Saturation")); + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Luminosity")); + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Color")); + + Name = Gh3539NamedColor.GetNearestColorName(color); + } + } + get { + return color; + } + } + + public string Name { + private set { + if (name != value) { + name = value; + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Name")); + } + } + get { + return name; + } + } + } + + public class Gh3539NamedColor : IEquatable, IComparable + { + // Instance members + private Gh3539NamedColor() + { + } + + public string Name { private set; get; } + + public string FriendlyName { private set; get; } + + public Color Color { private set; get; } + + public string RgbDisplay { private set; get; } + + public bool Equals(Gh3539NamedColor other) + { + return Name.Equals(other.Name); + } + + public int CompareTo(Gh3539NamedColor other) + { + return Name.CompareTo(other.Name); + } + + // Static members + static Gh3539NamedColor() + { + List all = new List(); + StringBuilder stringBuilder = new StringBuilder(); + + // Loop through the public static fields of the Color structure. + foreach (FieldInfo fieldInfo in typeof(Color).GetRuntimeFields()) { + if (fieldInfo.IsPublic && + fieldInfo.IsStatic && + fieldInfo.FieldType == typeof(Color)) { + // Convert the name to a friendly name. + string name = fieldInfo.Name; + stringBuilder.Clear(); + int index = 0; + + foreach (char ch in name) { + if (index != 0 && Char.IsUpper(ch)) { + stringBuilder.Append(' '); + } + stringBuilder.Append(ch); + index++; + } + + // Instantiate a NamedColor object. + Color color = (Color)fieldInfo.GetValue(null); + + Gh3539NamedColor namedColor = new Gh3539NamedColor { + Name = name, + FriendlyName = stringBuilder.ToString(), + Color = color, + RgbDisplay = String.Format("{0:X2}-{1:X2}-{2:X2}", + (int)(255 * color.R), + (int)(255 * color.G), + (int)(255 * color.B)) + }; + + // Add it to the collection. + all.Add(namedColor); + } + } + all.TrimExcess(); + all.Sort(); + All = all; + } + + public static IList All { private set; get; } + + public static Gh3539NamedColor Find(string name) + { + return ((List)All).Find(nc => nc.Name == name); + } + + public static string GetNearestColorName(Color color) + { + double shortestDistance = 1000; + Gh3539NamedColor closestColor = null; + + foreach (Gh3539NamedColor namedColor in Gh3539NamedColor.All) { + double distance = Math.Sqrt(Math.Pow(color.R - namedColor.Color.R, 2) + + Math.Pow(color.G - namedColor.Color.G, 2) + + Math.Pow(color.B - namedColor.Color.B, 2)); + + if (distance < shortestDistance) { + shortestDistance = distance; + closestColor = namedColor; + } + } + return closestColor.Name; + } + } + + public partial class Gh3539 : ContentPage + { + public Gh3539() + { + InitializeComponent(); + } + + public Gh3539(bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + + [TestFixture] + class Tests + { + [SetUp] + public void Setup() + { + Device.PlatformServices = new MockPlatformServices(); + } + + [TearDown] + public void TearDown() + { + Device.PlatformServices = null; + } + + [TestCase(true)] + public void CompiledBindingCodeIsValid(bool useCompiledXaml) + { + var layout = new Gh3539(useCompiledXaml); + } + } + } +} diff --git a/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj b/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj index 6f104aa1a..19fa056bd 100644 --- a/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj +++ b/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj @@ -637,6 +637,9 @@ Gh3512.xaml + + Gh3280.xaml + @@ -1159,6 +1162,10 @@ Designer MSBuild:UpdateDesignTimeXaml + + MSBuild:UpdateDesignTimeXaml + Designer + From ee300cb2dc0bba107f597c9ec237a5580f1f7ae4 Mon Sep 17 00:00:00 2001 From: kingces95 Date: Wed, 22 Aug 2018 10:07:48 -1000 Subject: [PATCH 04/10] [Android] Fix Label LineHeight (#3452) * fix line height android * Make UAP respect initial LineHeight --- Xamarin.Forms.Platform.Android/Renderers/LabelRenderer.cs | 1 + Xamarin.Forms.Platform.UAP/LabelRenderer.cs | 1 + 2 files changed, 2 insertions(+) diff --git a/Xamarin.Forms.Platform.Android/Renderers/LabelRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/LabelRenderer.cs index f8d32de87..89f096c28 100644 --- a/Xamarin.Forms.Platform.Android/Renderers/LabelRenderer.cs +++ b/Xamarin.Forms.Platform.Android/Renderers/LabelRenderer.cs @@ -191,6 +191,7 @@ namespace Xamarin.Forms.Platform.Android void UpdateLineHeight() { + _lastSizeRequest = null; if (Element.LineHeight == -1) _view.SetLineSpacing(_lineSpacingExtraDefault, _lineSpacingMultiplierDefault); else if (Element.LineHeight >= 0) diff --git a/Xamarin.Forms.Platform.UAP/LabelRenderer.cs b/Xamarin.Forms.Platform.UAP/LabelRenderer.cs index 19bffe22b..b4cca7502 100644 --- a/Xamarin.Forms.Platform.UAP/LabelRenderer.cs +++ b/Xamarin.Forms.Platform.UAP/LabelRenderer.cs @@ -137,6 +137,7 @@ namespace Xamarin.Forms.Platform.UWP UpdateFont(Control); UpdateLineBreakMode(Control); UpdateDetectReadingOrderFromContent(Control); + UpdateLineHeight(Control); } } From 7e38a246337cc051767e6a8c24bab76ca7493ef8 Mon Sep 17 00:00:00 2001 From: kingces95 Date: Wed, 22 Aug 2018 10:31:05 -1000 Subject: [PATCH 05/10] update .create-nuget.bat (#3638) --- .create-nuget.bat | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.create-nuget.bat b/.create-nuget.bat index eaab54343..dbce3acdb 100644 --- a/.create-nuget.bat +++ b/.create-nuget.bat @@ -118,19 +118,27 @@ echo foo > Xamarin.Forms.Platform.UAP\bin\debug\FormsEmbeddedPageWrapper.xbf if "%1" == "droid" ( %NUGET_EXE% restore .xamarin.forms.android.nuget.sln - msbuild /v:m /p:platform="any cpu" .xamarin.forms.android.nuget.sln + msbuild /v:m /p:platform="any cpu" /p:WarningLevel=0 .xamarin.forms.android.nuget.sln ) if "%1" == "ios" ( %NUGET_EXE% restore .xamarin.forms.ios.nuget.sln msbuild /v:m /p:platform="any cpu" .xamarin.forms.ios.nuget.sln ) +if "%1" == "droidios" ( + %NUGET_EXE% restore .xamarin.forms.android.nuget.sln + %NUGET_EXE% restore .xamarin.forms.ios.nuget.sln + msbuild /v:m /p:platform="any cpu" /p:WarningLevel=0 .xamarin.forms.android.nuget.sln + msbuild /v:m /p:platform="any cpu" .xamarin.forms.ios.nuget.sln +) if "%1" == "uap" ( %NUGET_EXE% restore .xamarin.forms.uap.nuget.sln + msbuild /v:m /p:platform="any cpu" .xamarin.forms.uap.nuget.sln /t:restore msbuild /v:m /p:platform="any cpu" .xamarin.forms.uap.nuget.sln ) if "%1" == "all" ( %NUGET_EXE% restore .xamarin.forms.sln - msbuild /v:m /p:platform="any cpu" .xamarin.forms.nuget.sln + msbuild /v:m /p:platform="any cpu" .xamarin.forms.uap.nuget.sln /t:restore + msbuild /v:m /p:platform="any cpu" /p:WarningLevel=0 .xamarin.forms.nuget.sln ) if "%DEBUG_VERSION%"=="" set DEBUG_VERSION=0 From b1f85390e93c839e290fc22065fdd9b2b6f9d657 Mon Sep 17 00:00:00 2001 From: kingces95 Date: Wed, 22 Aug 2018 21:57:59 -1000 Subject: [PATCH 06/10] Add Null Check to GetRenderer (#3575) - fix #3563 --- Xamarin.Forms.Platform.Android/Platform.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xamarin.Forms.Platform.Android/Platform.cs b/Xamarin.Forms.Platform.Android/Platform.cs index 407e3aedc..1f3db479c 100644 --- a/Xamarin.Forms.Platform.Android/Platform.cs +++ b/Xamarin.Forms.Platform.Android/Platform.cs @@ -341,7 +341,7 @@ namespace Xamarin.Forms.Platform.Android public static IVisualElementRenderer GetRenderer(VisualElement bindable) { - return (IVisualElementRenderer)bindable.GetValue(RendererProperty); + return (IVisualElementRenderer)bindable?.GetValue(RendererProperty); } public static void SetRenderer(VisualElement bindable, IVisualElementRenderer value) From 8c53d7075961903336aae1f0e74d058591f7063f Mon Sep 17 00:00:00 2001 From: kingces95 Date: Wed, 22 Aug 2018 21:59:19 -1000 Subject: [PATCH 07/10] Fix 3562 Null Reference Exception (#3576) - fixes #3562 --- Xamarin.Forms.Platform.Android/AppCompat/Platform.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Xamarin.Forms.Platform.Android/AppCompat/Platform.cs b/Xamarin.Forms.Platform.Android/AppCompat/Platform.cs index e460e7657..afb69a7e7 100644 --- a/Xamarin.Forms.Platform.Android/AppCompat/Platform.cs +++ b/Xamarin.Forms.Platform.Android/AppCompat/Platform.cs @@ -267,7 +267,9 @@ namespace Xamarin.Forms.Platform.Android.AppCompat _renderer.RemoveAllViews(); foreach (IVisualElementRenderer rootRenderer in _navModel.Roots.Select(Android.Platform.GetRenderer)) - rootRenderer.Dispose(); + { + rootRenderer?.Dispose(); + } _navModel = new NavigationModel(); From 1584aa2ccc89c13f32d4d9ecbaf94be35f27507b Mon Sep 17 00:00:00 2001 From: kingces95 Date: Wed, 22 Aug 2018 22:00:24 -1000 Subject: [PATCH 08/10] Fix 3564 Null Reference Exception (#3578) - fixes #3564 --- .../AppCompat/MasterDetailPageRenderer.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Xamarin.Forms.Platform.Android/AppCompat/MasterDetailPageRenderer.cs b/Xamarin.Forms.Platform.Android/AppCompat/MasterDetailPageRenderer.cs index 18b8247c2..6771a1798 100644 --- a/Xamarin.Forms.Platform.Android/AppCompat/MasterDetailPageRenderer.cs +++ b/Xamarin.Forms.Platform.Android/AppCompat/MasterDetailPageRenderer.cs @@ -1,3 +1,4 @@ + using System; using System.ComponentModel; using System.Threading.Tasks; @@ -247,7 +248,7 @@ namespace Xamarin.Forms.Platform.Android.AppCompat protected override void OnDetachedFromWindow() { base.OnDetachedFromWindow(); - PageController.SendDisappearing(); + PageController?.SendDisappearing(); } protected virtual void OnElementChanged(VisualElement oldElement, VisualElement newElement) From 4222ad2542040812c907a931215fbad3f7821263 Mon Sep 17 00:00:00 2001 From: Shane Neuville Date: Fri, 24 Aug 2018 01:50:47 -0600 Subject: [PATCH 09/10] [C] Set binding context on Span Gestures (#3639) * [Core] Set binding context on Span Gestures * [Core] Simplify loop setting child binding context - fixes #3524 --- .../Issue3524.cs | 77 +++++++++++++++++++ ...rin.Forms.Controls.Issues.Shared.projitems | 3 +- .../BindableObjectExtensions.cs | 23 ++++++ Xamarin.Forms.Core/Element.cs | 17 +--- Xamarin.Forms.Core/Span.cs | 9 ++- Xamarin.Forms.Core/View.cs | 19 +---- 6 files changed, 114 insertions(+), 34 deletions(-) create mode 100644 Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3524.cs diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3524.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3524.cs new file mode 100644 index 000000000..efa593b09 --- /dev/null +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3524.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Text; +using System.Threading.Tasks; +using Xamarin.Forms.CustomAttributes; +using Xamarin.Forms.Internals; + + +#if UITEST +using Xamarin.UITest; +using NUnit.Framework; +using Xamarin.Forms.Core.UITests; +#endif + +namespace Xamarin.Forms.Controls.Issues +{ + [Preserve(AllMembers = true)] + [Issue(IssueTracker.Github, 3524, "ICommand binding from a TapGestureRecognizer on a Span doesn't work")] +#if UITEST + [NUnit.Framework.Category(UITestCategories.Gestures)] +#endif + public class Issue3524 : TestContentPage + { + const string kText = "Click Me To Increment"; + + public Command TapCommand { get; set; } + public String Text { get; set; } = kText; + + protected override void Init() + { + int i = 0; + + FormattedString formattedString = new FormattedString(); + var span = new Span() { AutomationId = kText }; + span.Text = kText; + var tapGesture = new TapGestureRecognizer(); + tapGesture.SetBinding(TapGestureRecognizer.CommandProperty, "TapCommand"); + span.GestureRecognizers.Add(tapGesture); + formattedString.Spans.Add(span); + BindingContext = this; + var label = new Label() + { + AutomationId = kText, + HorizontalOptions = LayoutOptions.Center + }; + + label.FormattedText = formattedString; + TapCommand = new Command(() => + { + i++; + span.Text = $"{kText}: {i}"; + }); + + Content = new ContentView() + { + Content = new StackLayout() + { + Children = + { + label + } + } + }; + } + +#if UITEST + [Test] + public void SpanGestureCommand() + { + RunningApp.WaitForElement(kText); + RunningApp.Tap(kText); + RunningApp.WaitForElement($"{kText}: 1"); + } +#endif + } +} diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems index 7f00b0c93..62c5e723d 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems @@ -8,7 +8,8 @@ Xamarin.Forms.Controls.Issues - + + diff --git a/Xamarin.Forms.Core/BindableObjectExtensions.cs b/Xamarin.Forms.Core/BindableObjectExtensions.cs index fec2ad881..2a54dec95 100644 --- a/Xamarin.Forms.Core/BindableObjectExtensions.cs +++ b/Xamarin.Forms.Core/BindableObjectExtensions.cs @@ -1,10 +1,33 @@ using System; +using System.Collections.Generic; using System.Linq.Expressions; namespace Xamarin.Forms { public static class BindableObjectExtensions { + internal static void PropagateBindingContext(this BindableObject self, IList children) + { + PropagateBindingContext(self, children, BindableObject.SetInheritedBindingContext); + } + + internal static void PropagateBindingContext(this BindableObject self, IList children, Action setChildBindingContext) + { + if (children == null || children.Count == 0) + return; + + var bc = self.BindingContext; + + for (var i = 0; i < children.Count; i++) + { + var bo = children[i] as BindableObject; + if (bo == null) + continue; + + setChildBindingContext(bo, bc); + } + } + public static void SetBinding(this BindableObject self, BindableProperty targetProperty, string path, BindingMode mode = BindingMode.Default, IValueConverter converter = null, string stringFormat = null) { diff --git a/Xamarin.Forms.Core/Element.cs b/Xamarin.Forms.Core/Element.cs index 79c6bc928..c9ffe1149 100644 --- a/Xamarin.Forms.Core/Element.cs +++ b/Xamarin.Forms.Core/Element.cs @@ -319,21 +319,10 @@ namespace Xamarin.Forms protected override void OnBindingContextChanged() { - var gotBindingContext = false; - object bc = null; - - for (var index = 0; index < LogicalChildrenInternal.Count; index++) + this.PropagateBindingContext(LogicalChildrenInternal, (child, bc) => { - Element child = LogicalChildrenInternal[index]; - - if (!gotBindingContext) - { - bc = BindingContext; - gotBindingContext = true; - } - - SetChildInheritedBindingContext(child, bc); - } + SetChildInheritedBindingContext((Element)child, bc); + }); if (_bindableResources != null) foreach (BindableObject item in _bindableResources) diff --git a/Xamarin.Forms.Core/Span.cs b/Xamarin.Forms.Core/Span.cs index b90287168..f4ee8a2dd 100644 --- a/Xamarin.Forms.Core/Span.cs +++ b/Xamarin.Forms.Core/Span.cs @@ -95,11 +95,18 @@ namespace Xamarin.Forms set { SetValue(FontElement.FontSizeProperty, value); } } - public double LineHeight { + public double LineHeight + { get { return (double)GetValue(LineHeightElement.LineHeightProperty); } set { SetValue(LineHeightElement.LineHeightProperty, value); } } + protected override void OnBindingContextChanged() + { + this.PropagateBindingContext(GestureRecognizers); + base.OnBindingContextChanged(); + } + void IFontElement.OnFontFamilyChanged(string oldValue, string newValue) { } diff --git a/Xamarin.Forms.Core/View.cs b/Xamarin.Forms.Core/View.cs index b513ae7da..7962212c9 100644 --- a/Xamarin.Forms.Core/View.cs +++ b/Xamarin.Forms.Core/View.cs @@ -154,24 +154,7 @@ namespace Xamarin.Forms protected override void OnBindingContextChanged() { - var gotBindingContext = false; - object bc = null; - - for (var i = 0; i < GestureRecognizers.Count; i++) - { - var bo = GestureRecognizers[i] as BindableObject; - if (bo == null) - continue; - - if (!gotBindingContext) - { - bc = BindingContext; - gotBindingContext = true; - } - - SetInheritedBindingContext(bo, bc); - } - + this.PropagateBindingContext(GestureRecognizers); base.OnBindingContextChanged(); } From c11b2863e80ef867e37065549b0ef8b0c366b085 Mon Sep 17 00:00:00 2001 From: Shane Neuville Date: Tue, 28 Aug 2018 06:04:23 -0600 Subject: [PATCH 10/10] [Android] remove deprecated AndroidUseLatestPlatformSdk (#3672) --- EmbeddingTestBeds/Embedding.Droid/Embedding.Droid.csproj | 7 ------- PagesGallery/PagesGallery.Droid/PagesGallery.Droid.csproj | 7 ------- .../Xamarin.Forms.Platform.Android (Forwarders).csproj | 7 ------- .../Properties/AndroidManifest.xml | 2 +- .../Xamarin.Forms.ControlGallery.Android.csproj | 7 ------- .../Xamarin.Forms.Maps.Android.csproj | 7 ------- .../Xamarin.Forms.Platform.Android.AppLinks.csproj | 7 ------- .../Xamarin.Forms.Platform.Android.FormsViewGroup.csproj | 8 -------- .../Xamarin.Forms.Platform.Android.csproj | 6 ------ 9 files changed, 1 insertion(+), 57 deletions(-) diff --git a/EmbeddingTestBeds/Embedding.Droid/Embedding.Droid.csproj b/EmbeddingTestBeds/Embedding.Droid/Embedding.Droid.csproj index 643c76cc2..bf235697b 100644 --- a/EmbeddingTestBeds/Embedding.Droid/Embedding.Droid.csproj +++ b/EmbeddingTestBeds/Embedding.Droid/Embedding.Droid.csproj @@ -19,13 +19,6 @@ Properties\AndroidManifest.xml - false - - - True - - - False True diff --git a/PagesGallery/PagesGallery.Droid/PagesGallery.Droid.csproj b/PagesGallery/PagesGallery.Droid/PagesGallery.Droid.csproj index 8b984ed0e..07af51a18 100644 --- a/PagesGallery/PagesGallery.Droid/PagesGallery.Droid.csproj +++ b/PagesGallery/PagesGallery.Droid/PagesGallery.Droid.csproj @@ -26,13 +26,6 @@ True 1G - false - - - True - - - False true diff --git a/Stubs/Xamarin.Forms.Platform.Android/Xamarin.Forms.Platform.Android (Forwarders).csproj b/Stubs/Xamarin.Forms.Platform.Android/Xamarin.Forms.Platform.Android (Forwarders).csproj index 67ee5d346..2600a433a 100644 --- a/Stubs/Xamarin.Forms.Platform.Android/Xamarin.Forms.Platform.Android (Forwarders).csproj +++ b/Stubs/Xamarin.Forms.Platform.Android/Xamarin.Forms.Platform.Android (Forwarders).csproj @@ -20,13 +20,6 @@ v8.1 - false - - - True - - - False true diff --git a/Xamarin.Forms.ControlGallery.Android/Properties/AndroidManifest.xml b/Xamarin.Forms.ControlGallery.Android/Properties/AndroidManifest.xml index 6b7581d53..611abb2f8 100644 --- a/Xamarin.Forms.ControlGallery.Android/Properties/AndroidManifest.xml +++ b/Xamarin.Forms.ControlGallery.Android/Properties/AndroidManifest.xml @@ -1,6 +1,6 @@  - + diff --git a/Xamarin.Forms.ControlGallery.Android/Xamarin.Forms.ControlGallery.Android.csproj b/Xamarin.Forms.ControlGallery.Android/Xamarin.Forms.ControlGallery.Android.csproj index 35885b65b..f518bb038 100644 --- a/Xamarin.Forms.ControlGallery.Android/Xamarin.Forms.ControlGallery.Android.csproj +++ b/Xamarin.Forms.ControlGallery.Android/Xamarin.Forms.ControlGallery.Android.csproj @@ -29,13 +29,6 @@ 1G - false - - - True - - - False True diff --git a/Xamarin.Forms.Maps.Android/Xamarin.Forms.Maps.Android.csproj b/Xamarin.Forms.Maps.Android/Xamarin.Forms.Maps.Android.csproj index 90fbd294b..43cbaaae8 100644 --- a/Xamarin.Forms.Maps.Android/Xamarin.Forms.Maps.Android.csproj +++ b/Xamarin.Forms.Maps.Android/Xamarin.Forms.Maps.Android.csproj @@ -20,13 +20,6 @@ true - false - - - True - - - False true diff --git a/Xamarin.Forms.Platform.Android.AppLinks/Xamarin.Forms.Platform.Android.AppLinks.csproj b/Xamarin.Forms.Platform.Android.AppLinks/Xamarin.Forms.Platform.Android.AppLinks.csproj index 408d6ee67..3cd5a094d 100644 --- a/Xamarin.Forms.Platform.Android.AppLinks/Xamarin.Forms.Platform.Android.AppLinks.csproj +++ b/Xamarin.Forms.Platform.Android.AppLinks/Xamarin.Forms.Platform.Android.AppLinks.csproj @@ -16,13 +16,6 @@ v8.1 - false - - - True - - - False true diff --git a/Xamarin.Forms.Platform.Android.FormsViewGroup/Xamarin.Forms.Platform.Android.FormsViewGroup.csproj b/Xamarin.Forms.Platform.Android.FormsViewGroup/Xamarin.Forms.Platform.Android.FormsViewGroup.csproj index d12511a44..9d6b90e7c 100644 --- a/Xamarin.Forms.Platform.Android.FormsViewGroup/Xamarin.Forms.Platform.Android.FormsViewGroup.csproj +++ b/Xamarin.Forms.Platform.Android.FormsViewGroup/Xamarin.Forms.Platform.Android.FormsViewGroup.csproj @@ -2,8 +2,6 @@ XAJavaInterop1 - v8.1 - false Debug @@ -19,12 +17,6 @@ 512 v7.0 - - True - - - False - true full diff --git a/Xamarin.Forms.Platform.Android/Xamarin.Forms.Platform.Android.csproj b/Xamarin.Forms.Platform.Android/Xamarin.Forms.Platform.Android.csproj index 8b6b4ea7e..2659f7f48 100644 --- a/Xamarin.Forms.Platform.Android/Xamarin.Forms.Platform.Android.csproj +++ b/Xamarin.Forms.Platform.Android/Xamarin.Forms.Platform.Android.csproj @@ -22,12 +22,6 @@ - - True - - - False - true full