From cc05cd2026200b2a5cb494e359706e2e68174eba Mon Sep 17 00:00:00 2001 From: Stephane Delcroix Date: Wed, 3 Apr 2019 08:49:40 +0200 Subject: [PATCH 1/6] try to avoid merge conflicts in GitInfo.txt (#5715) --- .gitattributes | 3 +++ .gitconfig | 2 ++ 2 files changed, 5 insertions(+) create mode 100644 .gitconfig diff --git a/.gitattributes b/.gitattributes index f724967cd..408b5738f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -15,3 +15,6 @@ # Always checkout docs using unix line endings because mdoc uses unix line endings even on windows /docs/**/*.xml text eol=lf + +# avoid overriding GitInfo.txt on merge +GitInfo.txt merge=ours diff --git a/.gitconfig b/.gitconfig new file mode 100644 index 000000000..4a8fc6b2a --- /dev/null +++ b/.gitconfig @@ -0,0 +1,2 @@ +[merge "ours"] + driver = true From 53979c8297d9860cce56a3fa767cdf2504e62eb4 Mon Sep 17 00:00:00 2001 From: Tim Barham Date: Fri, 5 Apr 2019 15:31:28 +1000 Subject: [PATCH 2/6] XamlLoader should not ignore x:TypeArguments on root node (#5804) --- .../DesignTimeLoaderTests.cs | 19 ++++++++++++++++++- Xamarin.Forms.Xaml/XamlLoader.cs | 3 ++- Xamarin.Forms.Xaml/XamlParser.cs | 14 ++++++++++---- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/Xamarin.Forms.Xaml.UnitTests/DesignTimeLoaderTests.cs b/Xamarin.Forms.Xaml.UnitTests/DesignTimeLoaderTests.cs index 775836896..deab3d543 100644 --- a/Xamarin.Forms.Xaml.UnitTests/DesignTimeLoaderTests.cs +++ b/Xamarin.Forms.Xaml.UnitTests/DesignTimeLoaderTests.cs @@ -607,7 +607,6 @@ namespace Xamarin.Forms.Xaml.UnitTests string clrNamespace = null; string typeName = null; - XamlLoader.FallbackTypeResolver = (fallbackTypeInfos, type) => { assemblyName = fallbackTypeInfos?[1].AssemblyName; @@ -682,6 +681,24 @@ namespace Xamarin.Forms.Xaml.UnitTests Assert.DoesNotThrow(() => XamlLoader.Create(xaml, true)); Assert.That(exceptions.Count, Is.GreaterThanOrEqualTo(1)); } + + [Test] + public void MissingGenericRootTypeProvidesCorrectTypeName() + { + var xaml = @" + "; + + XamlLoader.FallbackTypeResolver = (p, type) => + { + Assert.That(p.Select(i => i.TypeName), Has.Some.EqualTo("GenericContentPage`1")); + return typeof(ContentPage); + }; + + Assert.DoesNotThrow(() => XamlLoader.Create(xaml, true)); + } } public class InstantiateThrows diff --git a/Xamarin.Forms.Xaml/XamlLoader.cs b/Xamarin.Forms.Xaml/XamlLoader.cs index be449d743..4cc769c55 100644 --- a/Xamarin.Forms.Xaml/XamlLoader.cs +++ b/Xamarin.Forms.Xaml/XamlLoader.cs @@ -119,7 +119,8 @@ namespace Xamarin.Forms.Xaml continue; } - var rootnode = new RuntimeRootNode(new XmlType(reader.NamespaceURI, reader.Name, null), null, (IXmlNamespaceResolver)reader); + var typeArguments = XamlParser.GetTypeArguments(reader); + var rootnode = new RuntimeRootNode(new XmlType(reader.NamespaceURI, reader.Name, typeArguments), null, (IXmlNamespaceResolver)reader); XamlParser.ParseXaml(rootnode, reader); var visitorContext = new HydrationContext { ExceptionHandler = exceptionHandler, diff --git a/Xamarin.Forms.Xaml/XamlParser.cs b/Xamarin.Forms.Xaml/XamlParser.cs index 205e80913..c67682c13 100644 --- a/Xamarin.Forms.Xaml/XamlParser.cs +++ b/Xamarin.Forms.Xaml/XamlParser.cs @@ -155,10 +155,7 @@ namespace Xamarin.Forms.Xaml var attributes = ParseXamlAttributes(reader, out xmlns); var prefixes = PrefixesToIgnore(xmlns); - - IList typeArguments = null; - if (attributes.Any(kvp => kvp.Key == XmlName.xTypeArguments)) - typeArguments = ((ValueNode)attributes.First(kvp => kvp.Key == XmlName.xTypeArguments).Value).Value as IList; + var typeArguments = GetTypeArguments(attributes); node = new ElementNode(new XmlType(elementNsUri, elementName, typeArguments), elementNsUri, reader as IXmlNamespaceResolver, elementXmlInfo.LineNumber, elementXmlInfo.LinePosition); @@ -185,6 +182,15 @@ namespace Xamarin.Forms.Xaml throw new XamlParseException("Closing PropertyElement expected", (IXmlLineInfo)reader); } + internal static IList GetTypeArguments(XmlReader reader) => GetTypeArguments(ParseXamlAttributes(reader, out _)); + + static IList GetTypeArguments(IList> attributes) + { + return attributes.Any(kvp => kvp.Key == XmlName.xTypeArguments) + ? ((ValueNode)attributes.First(kvp => kvp.Key == XmlName.xTypeArguments).Value).Value as IList + : null; + } + static IList> ParseXamlAttributes(XmlReader reader, out IList> xmlns) { Debug.Assert(reader.NodeType == XmlNodeType.Element); From 7dc2edc7b091f2a4456fdc5d9fea04f963f21926 Mon Sep 17 00:00:00 2001 From: Pavel Yakovlev Date: Sat, 6 Apr 2019 06:42:41 +0300 Subject: [PATCH 3/6] [Android] fixes material placeholder (#5823) --- .../MaterialEditorRenderer.cs | 1 - .../MaterialFormsTextInputLayoutBase.cs | 14 ++++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/Xamarin.Forms.Material.Android/MaterialEditorRenderer.cs b/Xamarin.Forms.Material.Android/MaterialEditorRenderer.cs index 183297fbb..b7f05f5db 100644 --- a/Xamarin.Forms.Material.Android/MaterialEditorRenderer.cs +++ b/Xamarin.Forms.Material.Android/MaterialEditorRenderer.cs @@ -27,7 +27,6 @@ namespace Xamarin.Forms.Material.Android var view = inflater.Inflate(Resource.Layout.TextInputLayoutFilledBox, null); _textInputLayout = (MaterialFormsTextInputLayout)view; _textInputEditText = _textInputLayout.FindViewById(Resource.Id.materialformsedittext); - UpdatePlaceholderText(); return _textInputLayout; } diff --git a/Xamarin.Forms.Material.Android/MaterialFormsTextInputLayoutBase.cs b/Xamarin.Forms.Material.Android/MaterialFormsTextInputLayoutBase.cs index ff84257ec..9d6a5ea41 100644 --- a/Xamarin.Forms.Material.Android/MaterialFormsTextInputLayoutBase.cs +++ b/Xamarin.Forms.Material.Android/MaterialFormsTextInputLayoutBase.cs @@ -113,16 +113,14 @@ namespace Xamarin.Forms.Material.Android internal void SetHint(string hint, VisualElement element) { - if (HintEnabled != !String.IsNullOrWhiteSpace(hint)) + HintEnabled = !string.IsNullOrWhiteSpace(hint); + if (HintEnabled) { - HintEnabled = !String.IsNullOrWhiteSpace(hint); - Hint = hint ?? String.Empty; - EditText.Hint = String.Empty; element?.InvalidateMeasureNonVirtual(Internals.InvalidationTrigger.VerticalOptionsChanged); - } - else - { - Hint = hint ?? String.Empty; + Hint = hint; + // EditText.Hint => Hint + // It is impossible to reset it but you can make it invisible. + EditText.SetHintTextColor(global::Android.Graphics.Color.Transparent); } } From 80269a479018f06733d47542836951666f53ad3a Mon Sep 17 00:00:00 2001 From: Shane Neuville Date: Mon, 8 Apr 2019 10:48:23 -0600 Subject: [PATCH 4/6] update build script for mac and readme based on vs mac 2019 (#5827) --- README.md | 28 ++++++++++++++++++++++++++-- build.cake | 9 +-------- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 6b760a008..dde205d1a 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ Platform/Feature | Package name | Sta Core | `Xamarin.Forms` | [![NuGet](https://img.shields.io/nuget/v/Xamarin.Forms.svg?style=flat-square&label=nuget)](https://www.nuget.org/packages/Xamarin.Forms/)| [![MyGet](https://img.shields.io/myget/xamarinforms-ci/vpre/Xamarin.Forms.svg?style=flat-square&label=myget)](https://myget.org/feed/xamarinforms-ci/package/nuget/Xamarin.Forms) Maps | `Xamarin.Forms.Maps` | [![NuGet](https://img.shields.io/nuget/v/Xamarin.Forms.Maps.svg?style=flat-square&label=nuget)](https://www.nuget.org/packages/Xamarin.Forms.Maps/) | [![MyGet](https://img.shields.io/myget/xamarinforms-ci/vpre/Xamarin.Forms.Maps.svg?style=flat-square&label=myget)](https://myget.org/feed/xamarinforms-ci/package/nuget/Xamarin.Forms.Maps) Pages | `Xamarin.Forms.Pages` | [![NuGet](https://img.shields.io/nuget/v/Xamarin.Forms.Pages.svg?style=flat-square&label=nuget)](https://www.nuget.org/packages/Xamarin.Forms.Pages/) | [![MyGet](https://img.shields.io/myget/xamarinforms-ci/vpre/Xamarin.Forms.Pages.svg?style=flat-square&label=myget)](https://myget.org/feed/xamarin.forms-ci/package/nuget/Xamarin.Forms.Pages) +AppLinks | `Xamarin.Forms.AppLinks` | [![NuGet](https://img.shields.io/nuget/v/Xamarin.Forms.AppLinks.svg?style=flat-square&label=nuget)](https://www.nuget.org/packages/Xamarin.Forms.AppLinks/) | [![MyGet](https://img.shields.io/myget/xamarinforms-ci/vpre/Xamarin.Forms.AppLinks.svg?style=flat-square&label=myget)](https://myget.org/feed/xamarin.forms-ci/package/nuget/Xamarin.Forms.AppLinks) If you want to use the latest dev build then you should read [this blog post](https://blog.xamarin.com/try-the-latest-in-xamarin-forms-with-nightly-builds): @@ -40,6 +41,7 @@ If you want to use the latest dev build then you should read [this blog post](ht ## Getting Started ## +### Windows ### ##### Install Visual Studio 2017 ##### VS 2017 is required for developing Xamarin.Forms. If you do not already have it installed, you can download it [here](https://www.visualstudio.com/downloads/download-visual-studio-vs). VS 2017 Community is completely free. If you are installing VS 2017 for the first time, select the "Custom" installation type and select the following from the features list to install: @@ -53,6 +55,29 @@ The Android 7.0 Nougat API 24 SDK is required for developing Xamarin.Forms. It c We also recommend installing [Xamarin Android Device Manager](https://developer.xamarin.com/guides/android/getting_started/installation/android-emulator/xamarin-device-manager/) This will use the HAXM tools installed above and allow you to configure Android Virtual Devices (AVDs) that emulate Android devices. If you already have VS 2017 installed, you can verify that these features are installed by modifying the VS 2017 installation via the Visual Studio Installer. +### Mac ### +#### Install Visual Studio for Mac 2019 #### + +If you do not already have it installed, instructions to download and setup can be found [here](https://docs.microsoft.com/en-us/visualstudio/mac/installation?view=vsmac-2017). + +Because of current Multi-Targeting limitations with Visual Studio for Mac you will need to manually build/restore some projects before you are able to work on the Xamarin Forms solution. + +Here are a few different options we've put together to help make this process easier +- Branches 3.5+ come with a Cake script target that you can use to build and open VSMac +```sh +./build.sh --target vsmac +``` +- When working on an earlier branch that does not have the cake scripts then you can use the following [build.sh] script(https://gist.github.com/PureWeen/92c1e1aff0c257c3decf0bcb8d6e9296) + +- If you don't want to run any scripts then + - Open Xamarin.Forms.sln + - Wait for VSMAC to finish restoring all projects + - from the command line run: + - `msbuild Xamarin.Forms.Build.Tasks/Xamarin.Forms.Build.Tasks.csproj` + - Now you should be able to run and deploy everything. The only reason you would need to do this process again is if you clean the solution folder or delete the bin/obj folders that are part of the `Xamarin.Forms.Build.Tasks.csproj` + +If you are on Visual Studio for Mac 2017 you will need to turn off automatic package restore (Visual Studio => Preferences => Nuget => General => uncheck the Package Restore box) before working on the Xamarin.Forms solution. This step is no longer needed with Visual Studio for Mac 2019 + ##### Solution Configuration ##### Upon opening the Xamarin.Forms solution, you will find that there are a number of errors and warnings under the Error List pane; you can resolve this by changing the filter of `Build + IntelliSense` to `Build Only`. At this point, you should be able to successfully build the solution. @@ -102,5 +127,4 @@ We follow the style used by the [.NET Foundation](https://github.com/dotnet/core ### Reporting Bugs ### -We use [GitHub Issues](https://github.com/xamarin/Xamarin.Forms/issues) to track issues. If at all possible, please submit a [reproduction of your bug](https://gist.github.com/jassmith/92405c300e54a01dcc6d) along with your bug report. - +We use [GitHub Issues](https://github.com/xamarin/Xamarin.Forms/issues) to track issues. If at all possible, please submit a [reproduction of your bug](https://gist.github.com/jassmith/92405c300e54a01dcc6d) along with your bug report. \ No newline at end of file diff --git a/build.cake b/build.cake index e0893b86d..0e8541f99 100644 --- a/build.cake +++ b/build.cake @@ -140,13 +140,6 @@ Task("VSMAC") .IsDependentOn("BuildHack") .Does(() => { - MSBuild("./Xamarin.Forms.ControlGallery.Android/Xamarin.Forms.ControlGallery.Android.csproj", - GetMSBuildSettings() - .WithRestore() - // work around bug on vs mac where resources generate wrong first time - .WithTarget("rebuild") - ); - StartProcess("open", new ProcessSettings{ Arguments = "Xamarin.Forms.sln" }); }); @@ -201,4 +194,4 @@ MSBuildSettings GetMSBuildSettings() msbuildSettings.Configuration = configuration; return msbuildSettings; -} \ No newline at end of file +} From ccf8c123c42a84eb18a8e6a61602820e5994d048 Mon Sep 17 00:00:00 2001 From: Stephane Delcroix Date: Mon, 8 Apr 2019 19:15:14 +0200 Subject: [PATCH 5/6] [C] allow inheriting from Behavior (#5559) - fixes #5520 --- Xamarin.Forms.Core/Interactivity/Behavior.cs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/Xamarin.Forms.Core/Interactivity/Behavior.cs b/Xamarin.Forms.Core/Interactivity/Behavior.cs index 7a126b847..17c3b0a91 100644 --- a/Xamarin.Forms.Core/Interactivity/Behavior.cs +++ b/Xamarin.Forms.Core/Interactivity/Behavior.cs @@ -5,28 +5,24 @@ namespace Xamarin.Forms { public abstract class Behavior : BindableObject, IAttachedObject { - internal Behavior(Type associatedType) + protected Behavior() : this(typeof(BindableObject)) { - if (associatedType == null) - throw new ArgumentNullException("associatedType"); - AssociatedType = associatedType; } + internal Behavior(Type associatedType) => AssociatedType = associatedType ?? throw new ArgumentNullException(nameof(associatedType)); + protected Type AssociatedType { get; } void IAttachedObject.AttachTo(BindableObject bindable) { if (bindable == null) - throw new ArgumentNullException("bindable"); + throw new ArgumentNullException(nameof(bindable)); if (!AssociatedType.IsInstanceOfType(bindable)) throw new InvalidOperationException("bindable not an instance of AssociatedType"); OnAttachedTo(bindable); } - void IAttachedObject.DetachFrom(BindableObject bindable) - { - OnDetachingFrom(bindable); - } + void IAttachedObject.DetachFrom(BindableObject bindable) => OnDetachingFrom(bindable); protected virtual void OnAttachedTo(BindableObject bindable) { From 66062237e012e969d3bb57392a9c4f45b6014fa7 Mon Sep 17 00:00:00 2001 From: Rui Marinho Date: Mon, 8 Apr 2019 18:15:53 +0100 Subject: [PATCH 6/6] [iOS] Fix when we render the font icon image as original (#5753) fixes #5071 --- Xamarin.Forms.Platform.iOS/Renderers/ImageRenderer.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Xamarin.Forms.Platform.iOS/Renderers/ImageRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/ImageRenderer.cs index d337b8572..c5d178207 100644 --- a/Xamarin.Forms.Platform.iOS/Renderers/ImageRenderer.cs +++ b/Xamarin.Forms.Platform.iOS/Renderers/ImageRenderer.cs @@ -191,6 +191,9 @@ namespace Xamarin.Forms.Platform.iOS public sealed class FontImageSourceHandler : IImageSourceHandler { + //should this be the default color on the BP for iOS? + readonly Color _defaultColor = Color.White; + public Task LoadImageAsync( ImageSource imagesource, CancellationToken cancelationToken = default(CancellationToken), @@ -200,7 +203,7 @@ namespace Xamarin.Forms.Platform.iOS var fontsource = imagesource as FontImageSource; if (fontsource != null) { - var iconcolor = fontsource.Color != Color.Default ? fontsource.Color : Color.White; + var iconcolor = fontsource.Color.IsDefault ? _defaultColor : fontsource.Color; var imagesize = new SizeF((float)fontsource.Size, (float)fontsource.Size); var font = UIFont.FromName(fontsource.FontFamily ?? string.Empty, (float)fontsource.Size) ?? UIFont.SystemFontOfSize((float)fontsource.Size); @@ -217,7 +220,7 @@ namespace Xamarin.Forms.Platform.iOS image = UIGraphics.GetImageFromCurrentImageContext(); UIGraphics.EndImageContext(); - if (iconcolor != Color.Default) + if (iconcolor != _defaultColor) image = image.ImageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal); } return Task.FromResult(image);