Skip to content

Commit

Permalink
Merge branch '4.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
jfversluis committed Jan 6, 2020
2 parents dbb259f + 1ae8fb1 commit 1b9c22b
Show file tree
Hide file tree
Showing 53 changed files with 1,816 additions and 867 deletions.
14 changes: 11 additions & 3 deletions Xamarin.Forms.Build.Tasks/TypeReferenceExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -390,14 +390,22 @@ public static TypeReference ResolveGenericParameters(this TypeReference self, Me
public static TypeReference ResolveGenericParameters(this TypeReference self, TypeReference declaringTypeReference)
{
var genericdeclType = declaringTypeReference as GenericInstanceType;
if (genericdeclType == null)
var genericParameterSelf = self as GenericParameter;
var genericself = self as GenericInstanceType;

if (genericdeclType == null && genericParameterSelf == null && genericself == null)
return self;

var genericParameterSelf = self as GenericParameter;
if (genericdeclType == null && genericParameterSelf!=null)
{
var typeDef = declaringTypeReference.Resolve();
if (typeDef.BaseType == null || typeDef.BaseType.FullName == "System.Object")
return self;
return self.ResolveGenericParameters(typeDef.BaseType.ResolveGenericParameters(declaringTypeReference));
}
if (genericParameterSelf != null)
return genericdeclType.GenericArguments[genericParameterSelf.Position];

var genericself = self as GenericInstanceType;
if (genericself != null)
return genericself.ResolveGenericParameters(declaringTypeReference);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
using System.Linq;


#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, 8262, "[Android] ImageRenderer still being accessed after control destroyed",
PlatformAffected.Android)]
#if UITEST
[NUnit.Framework.Category(UITestCategories.LifeCycle)]
[NUnit.Framework.Category(UITestCategories.CollectionView)]
#endif
public class Issue8262 : TestContentPage
{
public View WithBounds(View v, double x, double y, double w, double h)
{
AbsoluteLayout.SetLayoutBounds(v, new Rectangle(x, y, w, h));
return v;
}

protected override void Init()
{
IEnumerable<View> Select((string groupHeader, IEnumerable<int> items) t)
{
yield return new AbsoluteLayout
{
Children = {
WithBounds(new Label {
Text = t.groupHeader, HorizontalTextAlignment = TextAlignment.Center,
TextColor = Color.FromUint(0xff5a5a5a), FontSize = 10
}, 0, 21.1, 310, AbsoluteLayout.AutoSize) },
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.Start,
HeightRequest = 46
};
foreach (var item in t.items)
{
yield return new AbsoluteLayout
{
Children = {

WithBounds(new Image { Source = ImageSource.FromResource("Xamarin.Forms.Controls.GalleryPages.crimson.jpg", System.Reflection.Assembly.GetCallingAssembly()) }, 23.6, 14.5, 14.9, 20.7),

WithBounds(new Label { Text = item.ToString(), TextColor = Color.FromUint(0xff5a5a5a), FontSize = 10 }, 58, 18.2, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize)
},
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.Start,
HeightRequest = 49.7
};
}
}

Content = new AbsoluteLayout
{
Children = {
new CollectionView {
ItemsSource =
new (string, Func<int, bool>)[] {
("odd", i => i % 2 == 1),
("even", i => i % 2 == 0),
("triple", i => i % 3 == 0),
("fives", i => i % 5 == 0) }
.Select(t => (t.Item1, Enumerable.Range(1, 100).Where(t.Item2)))
.SelectMany(Select),
ItemTemplate = new DataTemplate(() => {
var template = new ContentView();
template.SetBinding(ContentView.ContentProperty, ".");
return template;
}),
ItemsLayout = LinearItemsLayout.Vertical,
ItemSizingStrategy = ItemSizingStrategy.MeasureFirstItem,
AutomationId = "ScrollMe"
}
}
};
}

#if UITEST
[Test]
public void ScrollingQuicklyOnCollectionViewDoesntCrashOnDestroyedImage()
{
RunningApp.WaitForElement("ScrollMe");
RunningApp.ScrollDown("ScrollMe", ScrollStrategy.Gesture, swipeSpeed: 20000);
RunningApp.ScrollUp("ScrollMe", ScrollStrategy.Gesture, swipeSpeed: 20000);
RunningApp.ScrollDown("ScrollMe", ScrollStrategy.Gesture, swipeSpeed: 20000);
RunningApp.ScrollUp("ScrollMe", ScrollStrategy.Gesture, swipeSpeed: 20000);
RunningApp.ScrollDown("ScrollMe", ScrollStrategy.Gesture, swipeSpeed: 20000);
RunningApp.WaitForElement("ScrollMe");
}
#endif
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;


#if UITEST
using NUnit.Framework;
using Xamarin.Forms.Core.UITests;
#endif

namespace Xamarin.Forms.Controls.Issues
{
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 8461, "[Bug] [iOS] [Shell] \"Nav Stack consistency error\"",
PlatformAffected.iOS)]
#if UITEST
[NUnit.Framework.Category(UITestCategories.Shell)]
[NUnit.Framework.Category(UITestCategories.Navigation)]
#endif
public class Issue8461 : TestShell
{
const string ButtonId = "PageButtonId";
const string LayoutId = "LayoutId";

protected override void Init()
{
var page1 = CreateContentPage("page 1");
var page2 = new ContentPage() { Title = "page 2" };

var pushPageBtn = new Button();
pushPageBtn.Text = "Push Page";
pushPageBtn.AutomationId = ButtonId;
pushPageBtn.Clicked += (sender, args) =>
{
Navigation.PushAsync(page2);
};

page1.Content = new StackLayout()
{
Children =
{
pushPageBtn
}
};

var instructions = new StackLayout()
{
Children =
{
new Label()
{
Text = "1. Swipe left to dismiss this page, but cancel the gesture before it completes"
},
new Label()
{
Text = "2. Swipe left to dismiss this page again, crashes immediately"
}
}
};

Grid.SetColumn(instructions, 1);

page2.Content = new Grid()
{
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.FillAndExpand,

ColumnDefinitions = new ColumnDefinitionCollection()
{
new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) },
new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) },
},

Children =
{
// Use this BoxView to achor our swipe to left of the screen
new BoxView()
{
AutomationId = LayoutId,
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.FillAndExpand,
BackgroundColor = Color.Red
},
instructions
}
};
}

#if UITEST && __IOS__
[Test]
public void ShellSwipeToDismiss()
{
var pushButton = RunningApp.WaitForElement(ButtonId);
Assert.AreEqual(1, pushButton.Length);

RunningApp.Tap(ButtonId);

var page2Layout = RunningApp.WaitForElement(LayoutId);
Assert.AreEqual(1, page2Layout.Length);
// Swipe in from left across 1/2 of screen width
RunningApp.SwipeLeftToRight(LayoutId, 0.99, 500, false);
// Swipe in from left across full screen width
RunningApp.SwipeLeftToRight(0.99, 500);

pushButton = RunningApp.WaitForElement(ButtonId);
Assert.AreEqual(1, pushButton.Length);
}
#endif

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using System.ComponentModel;
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;

namespace Xamarin.Forms.Controls.Issues
{
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 8644, "WPF Entry crashes when IsPassword=true", PlatformAffected.WPF)]
public class Issue8644 : TestContentPage
{
public class BinCon : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
string _title;
public string Title
{
get => _title;
set
{
_title = value?.Length > 4 ? value.Substring(0, 4) : value;
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Title)));
}
}

}
protected override void Init()
{
var bc = new BinCon();
var e1 = new Entry
{
BindingContext = bc,
Margin = new Thickness(50),
HorizontalOptions = LayoutOptions.FillAndExpand,
IsPassword = true,
};
e1.SetBinding(Entry.TextProperty, nameof(BinCon.Title));

// Label just to show current Entry text, not needed for test
var lbl = new Label { BindingContext = bc };
lbl.SetBinding(Label.TextProperty, nameof(BinCon.Title));
var stack = new StackLayout
{

Children = {
new Label { Text = "Type more than 4 symbols" },
e1,
lbl,
}
};

Content = stack;
}
}
}
Loading

0 comments on commit 1b9c22b

Please sign in to comment.