From 42e8a0203378f0c56967ff93ff4c5eac12054b5d Mon Sep 17 00:00:00 2001 From: Carl de Billy Date: Tue, 18 Jun 2019 10:28:16 -0400 Subject: [PATCH 1/7] Remove the silent exception on non-existent resource. When the resource wasn't found on non-DEBUG build, the non-resolving of a resource wasn't throwing an exception, causing potential null-ref exception without explanation. --- .../XamlGenerator/XamlFileGenerator.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs index e59f19c74498..50ce705976d5 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs @@ -2862,14 +2862,13 @@ private string GetGlobalStaticResource(string resourceName, INamedTypeSymbol tar { return $"global::{resource.Namespace}.GlobalStaticResources.{SanitizeResourceName(resourceName)}"; } - else if (_staticResources.ContainsKey(resourceName)) + + if (_staticResources.ContainsKey(resourceName)) { return $"{GetCastString(targetType, _staticResources[resourceName])}StaticResources.{SanitizeResourceName(resourceName)}"; } - else - { - var validateString = _isDebug ? $" ?? throw new InvalidOperationException(\"The resource {resourceName} cannot be found\")" : ""; - var valueString = $"(global::Windows.UI.Xaml.Application.Current.Resources[\"{resourceName}\"]{validateString})"; + + var valueString = $"(global::Windows.UI.Xaml.Application.Current.Resources[\"{resourceName}\"] ?? throw new InvalidOperationException(\"The resource {resourceName} cannot be found\"))"; if (targetType != null) { @@ -2882,7 +2881,6 @@ private string GetGlobalStaticResource(string resourceName, INamedTypeSymbol tar return valueString; } } - } private string RewriteAttachedPropertyPath(string value) { From 879bf2f6bca14f3e238f8f848ac9c5db4979f291 Mon Sep 17 00:00:00 2001 From: Carl de Billy Date: Tue, 18 Jun 2019 10:32:40 -0400 Subject: [PATCH 2/7] Fix #706 - "The name 'Loading' does not exist in the current context" when x:Name was used in App.xaml resources --- .../XamlGenerator/XamlFileGenerator.cs | 38 +++++++++---------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs index 50ce705976d5..7877f2397732 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs @@ -855,21 +855,19 @@ IEnumerable> namedResources writer.AppendLineInvariant(0, ";", namedResource.Value.Type); } - if (namedResources.Any()) + // Styles are handled differently for now, and there's no variable generated + // for those entries. Skip the ApplyCompiledBindings for those. See + // ImportResourceDictionary handling of x:Name for more details. + var namedResourcesExcludingStyles = namedResources + .Where(nr => nr.Value.Type.Name.Equals("Style", StringComparison.Ordinal)) + .ToArray(); + + if (namedResourcesExcludingStyles.Any()) { using (writer.BlockInvariant("Loading += (s, e) =>")) { - foreach (var namedResource in namedResources) + foreach (var namedResource in namedResourcesExcludingStyles) { - if (namedResource.Value.Type.Name == "Style") - { - // Styles are handled differently for now, and there's no variable generated - // for those entries. Skip the ApplyCompiledBindings for those. See - // ImportResourceDictionary handling of x:Name for more details. - continue; - } - - writer.AppendFormatInvariant($"{namedResource.Key}.ApplyCompiledBindings();"); } } @@ -2870,17 +2868,17 @@ private string GetGlobalStaticResource(string resourceName, INamedTypeSymbol tar var valueString = $"(global::Windows.UI.Xaml.Application.Current.Resources[\"{resourceName}\"] ?? throw new InvalidOperationException(\"The resource {resourceName} cannot be found\"))"; - if (targetType != null) - { - // We do not know the type of the source, and it must be converted first - return $"global::Windows.UI.Xaml.Markup.XamlBindingHelper.ConvertValue(typeof{GetCastString(targetType, null)}, {valueString})"; - } - else - { + if (targetType != null) + { + // We do not know the type of the source, and it must be converted first + return $"global::Windows.UI.Xaml.Markup.XamlBindingHelper.ConvertValue(typeof{GetCastString(targetType, null)}, {valueString})"; + } + else + { - return valueString; - } + return valueString; } + } private string RewriteAttachedPropertyPath(string value) { From deede2bc37db8bde20dbe9afee2b8d1ee03ddc1e Mon Sep 17 00:00:00 2001 From: Carl de Billy Date: Wed, 19 Jun 2019 11:36:15 -0400 Subject: [PATCH 3/7] Added support for "BasedOn" on styles in App.Xaml Fix #854 --- src/SamplesApp/SamplesApp.Shared/App.xaml | 38 ++++++++++++++++++ src/SamplesApp/SamplesApp.Shared/App.xaml.cs | 5 +-- .../UITests.Shared/UITests.Shared.projitems | 8 ++++ .../Resources/XamlGlobalResources.xaml | 27 +++++++++++++ .../Resources/XamlGlobalResources.xaml.cs | 16 ++++++++ src/Uno.UI/FeatureConfiguration.cs | 11 +++++ .../Xaml/Markup/Reader/XamlObjectBuilder.cs | 7 +++- .../Markup/Reader/XamlObjectDefinition.cs | 18 ++++----- src/Uno.UI/UI/Xaml/ResourceDictionary.cs | 40 ++++++------------- 9 files changed, 129 insertions(+), 41 deletions(-) create mode 100644 src/SamplesApp/UITests.Shared/Windows_UI_Xaml/Resources/XamlGlobalResources.xaml create mode 100644 src/SamplesApp/UITests.Shared/Windows_UI_Xaml/Resources/XamlGlobalResources.xaml.cs diff --git a/src/SamplesApp/SamplesApp.Shared/App.xaml b/src/SamplesApp/SamplesApp.Shared/App.xaml index df8d85c0e7e3..174e677a4bba 100644 --- a/src/SamplesApp/SamplesApp.Shared/App.xaml +++ b/src/SamplesApp/SamplesApp.Shared/App.xaml @@ -4,4 +4,42 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" RequestedTheme="Light"> + + + + + + + + + + + + + + + + + + diff --git a/src/SamplesApp/SamplesApp.Shared/App.xaml.cs b/src/SamplesApp/SamplesApp.Shared/App.xaml.cs index 63789a78672c..1646c73e206e 100644 --- a/src/SamplesApp/SamplesApp.Shared/App.xaml.cs +++ b/src/SamplesApp/SamplesApp.Shared/App.xaml.cs @@ -51,9 +51,8 @@ public App() protected override void OnLaunched(LaunchActivatedEventArgs e) { var sw = Stopwatch.StartNew(); - var n = Windows.UI.Xaml.Window.Current.Dispatcher.RunAsync( - CoreDispatcherPriority.Idle, - () => Console.WriteLine("Done loading " + sw.Elapsed)); + var n = Windows.UI.Xaml.Window.Current.Dispatcher.RunIdleAsync( + _ => Console.WriteLine("Done loading " + sw.Elapsed)); #if DEBUG if (System.Diagnostics.Debugger.IsAttached) diff --git a/src/SamplesApp/UITests.Shared/UITests.Shared.projitems b/src/SamplesApp/UITests.Shared/UITests.Shared.projitems index e892c81b7ca2..c4b008d862b2 100644 --- a/src/SamplesApp/UITests.Shared/UITests.Shared.projitems +++ b/src/SamplesApp/UITests.Shared/UITests.Shared.projitems @@ -113,6 +113,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -2117,6 +2121,7 @@ + @@ -3706,6 +3711,9 @@ ToggleSwitch_IsOn.xaml + + XamlGlobalResources.xaml + diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml/Resources/XamlGlobalResources.xaml b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml/Resources/XamlGlobalResources.xaml new file mode 100644 index 000000000000..88b38fe11dd5 --- /dev/null +++ b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml/Resources/XamlGlobalResources.xaml @@ -0,0 +1,27 @@ + + + + + This text should be rendered in PINK with a PINK border around it. + + + + diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml/Resources/XamlGlobalResources.xaml.cs b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml/Resources/XamlGlobalResources.xaml.cs new file mode 100644 index 000000000000..651bae318d7d --- /dev/null +++ b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml/Resources/XamlGlobalResources.xaml.cs @@ -0,0 +1,16 @@ +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Documents; +using Uno.UI.Samples.Controls; + +namespace UITests.Shared.Windows_UI_Xaml.Resources +{ + [SampleControlInfo("XAML", "XamlGlobalResources", description: "Using a resource defined in Global.Xaml's Resources (Pink).")] + public sealed partial class XamlGlobalResources : Page + { + public XamlGlobalResources() + { + this.InitializeComponent(); + } + } +} diff --git a/src/Uno.UI/FeatureConfiguration.cs b/src/Uno.UI/FeatureConfiguration.cs index fcfd80ffe260..e06fa0fff886 100644 --- a/src/Uno.UI/FeatureConfiguration.cs +++ b/src/Uno.UI/FeatureConfiguration.cs @@ -34,6 +34,17 @@ public static class UIElement #endif } + public static class Xaml + { + /// + /// Maximal "BasedOn" recursive resoling depth. + /// + /// + /// This is a mechanism to prevent hard-to-diagnose stack overflow when a resource name is not found. + /// + public static int MaxRecursiveResolvingDepth { get; set; } = 12; + } + public static class FrameworkElement { /// diff --git a/src/Uno.UI/UI/Xaml/Markup/Reader/XamlObjectBuilder.cs b/src/Uno.UI/UI/Xaml/Markup/Reader/XamlObjectBuilder.cs index 6ac334f428bf..5ef45059cf0c 100644 --- a/src/Uno.UI/UI/Xaml/Markup/Reader/XamlObjectBuilder.cs +++ b/src/Uno.UI/UI/Xaml/Markup/Reader/XamlObjectBuilder.cs @@ -271,7 +271,7 @@ private void ProcessNamedMember(XamlObjectDefinition control, object instance, X } else if (member.Member.DeclaringType == null && member.Member.Name == "Name") { - // This is a special case, where the declaring type is from the x: namespace, + // This is a special case, where the declaring type is from the x: namespace, // but is considered of an unknown type. This can happen when providing the // name of a control using x:Name instead of Name. if (TypeResolver.GetPropertyByName(control.Type, "Name") is PropertyInfo nameInfo) @@ -466,6 +466,11 @@ void ResolveResource() _postActions.Enqueue(ResolveResource); } + else + { + // Here we assigned a {StaticResource} on a standard property (not a DependencyProperty) + // We can't resolve it. + } } } diff --git a/src/Uno.UI/UI/Xaml/Markup/Reader/XamlObjectDefinition.cs b/src/Uno.UI/UI/Xaml/Markup/Reader/XamlObjectDefinition.cs index 75e0dccfe8ad..46c1e12d4716 100644 --- a/src/Uno.UI/UI/Xaml/Markup/Reader/XamlObjectDefinition.cs +++ b/src/Uno.UI/UI/Xaml/Markup/Reader/XamlObjectDefinition.cs @@ -9,35 +9,33 @@ namespace Windows.UI.Xaml.Markup.Reader { #if DEBUG - [DebuggerDisplay("Type: {_type.Name}")] + [DebuggerDisplay("Type: {Type.Name}")] #endif - internal class XamlObjectDefinition + internal class XamlObjectDefinition { - private XamlType _type; - public XamlObjectDefinition(XamlType type, int lineNumber, int linePosition, XamlObjectDefinition owner) { LineNumber = lineNumber; LinePosition = linePosition; - _type = type; + Type = type; Owner = owner; Members = new List(); Objects = new List(); } - public XamlType Type { get { return _type; } } + public XamlType Type { get; } - public List Members { get; private set; } + public List Members { get; } - public List Objects { get; private set; } + public List Objects { get; } public object Value { get; set; } - public int LineNumber { get; private set; } + public int LineNumber { get; } public int LinePosition { get; set; } - public XamlObjectDefinition Owner { get; private set; } + public XamlObjectDefinition Owner { get; } } } diff --git a/src/Uno.UI/UI/Xaml/ResourceDictionary.cs b/src/Uno.UI/UI/Xaml/ResourceDictionary.cs index 3eacc376d5f0..0963628b0d89 100644 --- a/src/Uno.UI/UI/Xaml/ResourceDictionary.cs +++ b/src/Uno.UI/UI/Xaml/ResourceDictionary.cs @@ -1,15 +1,14 @@ using System; using System.Collections.Generic; -using System.Runtime.InteropServices; -using Windows.Foundation; -using Windows.Foundation.Collections; -using Windows.Foundation.Metadata; +using System.Threading; +using Uno.UI; + namespace Windows.UI.Xaml { public partial class ResourceDictionary : DependencyObject { - private Dictionary _values = new Dictionary(); - private bool _isResolving = false; + private readonly Dictionary _values = new Dictionary(); + private int _resolvingDepth = 0; public ResourceDictionary() { @@ -69,18 +68,19 @@ public bool TryGetValue(object key, out object value) { try { - if (!_isResolving) + _resolvingDepth++; + + if (_resolvingDepth <= FeatureConfiguration.Xaml.MaxRecursiveResolvingDepth) { // This prevents a stack overflow while looking for a // missing resource in generated xaml code. - _isResolving = true; value = DefaultResolver?.Invoke(key.ToString()); } } finally { - _isResolving = false; + _resolvingDepth--; } return value != null; @@ -102,26 +102,12 @@ public object this[object key] return value; } - set - { - _values[key] = value; - } + set => _values[key] = value; } - public global::System.Collections.Generic.ICollection Keys - { - get - { - return _values.Keys; - } - } - public global::System.Collections.Generic.ICollection Values - { - get - { - return _values.Values; - } - } + public global::System.Collections.Generic.ICollection Keys => _values.Keys; + + public global::System.Collections.Generic.ICollection Values => _values.Values; public void Add(global::System.Collections.Generic.KeyValuePair item) => _values.Add(item.Key.ToString(), item.Value); From 1a331d470109284d224e23a885632a235c5c350b Mon Sep 17 00:00:00 2001 From: Carl de Billy Date: Thu, 20 Jun 2019 16:03:01 -0400 Subject: [PATCH 4/7] Fixed compilation error on x:Name on non-dependecy objects Bug #846 --- .../UITests.Shared/UITests.Shared.projitems | 8 +++ .../Resources/XamlLocalResources.xaml | 19 ++++++ .../Resources/XamlLocalResources.xaml.cs | 18 ++++++ .../XamlGenerator/XamlFileGenerator.cs | 64 +++++++++++++------ .../UI/Xaml/DependencyObjectExtensions.cs | 10 +-- 5 files changed, 94 insertions(+), 25 deletions(-) create mode 100644 src/SamplesApp/UITests.Shared/Windows_UI_Xaml/Resources/XamlLocalResources.xaml create mode 100644 src/SamplesApp/UITests.Shared/Windows_UI_Xaml/Resources/XamlLocalResources.xaml.cs diff --git a/src/SamplesApp/UITests.Shared/UITests.Shared.projitems b/src/SamplesApp/UITests.Shared/UITests.Shared.projitems index c4b008d862b2..56a1006496b2 100644 --- a/src/SamplesApp/UITests.Shared/UITests.Shared.projitems +++ b/src/SamplesApp/UITests.Shared/UITests.Shared.projitems @@ -101,6 +101,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -2116,6 +2120,7 @@ Localization_Implicit.xaml + @@ -3714,6 +3719,9 @@ XamlGlobalResources.xaml + + XamlLocalResources.xaml + diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml/Resources/XamlLocalResources.xaml b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml/Resources/XamlLocalResources.xaml new file mode 100644 index 000000000000..c6c2709a6b8a --- /dev/null +++ b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml/Resources/XamlLocalResources.xaml @@ -0,0 +1,19 @@ + + + + + Blue + + + + + diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml/Resources/XamlLocalResources.xaml.cs b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml/Resources/XamlLocalResources.xaml.cs new file mode 100644 index 000000000000..982d6b2ff6a6 --- /dev/null +++ b/src/SamplesApp/UITests.Shared/Windows_UI_Xaml/Resources/XamlLocalResources.xaml.cs @@ -0,0 +1,18 @@ +using Windows.UI.Xaml.Controls; +using Uno.UI.Samples.Controls; + +namespace UITests.Shared.Windows_UI_Xaml.Resources +{ + public sealed partial class XamlLocalResources : Page + { + public XamlLocalResources() + { + this.InitializeComponent(); + } + } + + internal class CustomTemplateSelector : DataTemplateSelector + { + + } +} diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs index 7877f2397732..dc4427becebc 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs @@ -4,6 +4,7 @@ using Uno.UI.SourceGenerators.XamlGenerator.Utils; using System; using System.Collections.Generic; +using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; @@ -73,6 +74,7 @@ internal partial class XamlFileGenerator private readonly INamedTypeSymbol _stringSymbol; private readonly INamedTypeSymbol _objectSymbol; private readonly INamedTypeSymbol _iFrameworkElementSymbol; + private readonly INamedTypeSymbol _dependencyObjectSymbol; private readonly INamedTypeSymbol _iCollectionSymbol; private readonly INamedTypeSymbol _iCollectionOfTSymbol; @@ -80,6 +82,7 @@ internal partial class XamlFileGenerator private readonly INamedTypeSymbol _iListOfTSymbol; private readonly INamedTypeSymbol _iDictionaryOfTKeySymbol; private readonly INamedTypeSymbol _dataBindingSymbol; + private readonly INamedTypeSymbol _styleSymbol; private readonly bool _isWasm; @@ -130,12 +133,14 @@ bool isDebug _elementStubSymbol = GetType(XamlConstants.Types.ElementStub); _contentPresenterSymbol = GetType(XamlConstants.Types.ContentPresenter); _iFrameworkElementSymbol = GetType(XamlConstants.Types.IFrameworkElement); + _dependencyObjectSymbol = GetType(XamlConstants.Types.DependencyObject); _iCollectionSymbol = GetType("System.Collections.ICollection"); _iCollectionOfTSymbol = GetType("System.Collections.Generic.ICollection`1"); _iListSymbol = GetType("System.Collections.IList"); _iListOfTSymbol = GetType("System.Collections.Generic.IList`1"); _iDictionaryOfTKeySymbol = GetType("System.Collections.Generic.IDictionary`2"); _dataBindingSymbol = GetType("Windows.UI.Xaml.Data.Binding"); + _styleSymbol = GetType(XamlConstants.Types.Style); _isWasm = isWasm; } @@ -855,20 +860,39 @@ IEnumerable> namedResources writer.AppendLineInvariant(0, ";", namedResource.Value.Type); } - // Styles are handled differently for now, and there's no variable generated - // for those entries. Skip the ApplyCompiledBindings for those. See - // ImportResourceDictionary handling of x:Name for more details. - var namedResourcesExcludingStyles = namedResources - .Where(nr => nr.Value.Type.Name.Equals("Style", StringComparison.Ordinal)) + bool IsGenerateCompiledBindings(KeyValuePair nr) + { + var type = GetType(nr.Value.Type); + + // Styles are handled differently for now, and there's no variable generated + // for those entries. Skip the ApplyCompiledBindings for those. See + // ImportResourceDictionary handling of x:Name for more details. + if (type.Equals(_styleSymbol)) + { + return false; + } + + if (type.AllInterfaces.Any(i => i.Equals(_dependencyObjectSymbol))) + { + return true; + } + + return false; + } + + var resourcesTogenerateApplyCompiledBindings = namedResources + .Where(IsGenerateCompiledBindings) .ToArray(); - if (namedResourcesExcludingStyles.Any()) + if (resourcesTogenerateApplyCompiledBindings.Any()) { using (writer.BlockInvariant("Loading += (s, e) =>")) { - foreach (var namedResource in namedResourcesExcludingStyles) + foreach (var namedResource in resourcesTogenerateApplyCompiledBindings) { - writer.AppendFormatInvariant($"{namedResource.Key}.ApplyCompiledBindings();"); + var type = GetType(namedResource.Value.Type); + + writer.AppendLineInvariant($"{namedResource.Key}.ApplyCompiledBindings();"); } } writer.AppendLineInvariant(0, ";"); @@ -962,7 +986,7 @@ IEnumerable> keyedResources } else { - // If there is no method suffix, + // If there is no method suffix, using (writer.BlockInvariant("public static object FindResource(string name)")) { BuildGetResources(writer, keyedResources); @@ -1678,7 +1702,7 @@ private void RegisterResources(XamlObjectDefinition topLevelControl) if (isExplicitResDictionary) { - // To be able to have MergedDictionaries, the first node of the Resource node + // To be able to have MergedDictionaries, the first node of the Resource node // must be an explicit resource dictionary. resourcesMember = FindImplicitContentMember(resourcesMember.Objects.First()); @@ -1731,8 +1755,8 @@ private void TryExtractAutomationId(XamlMemberDefinition member, string[] target var fullMemberName = $"{FindType(member.Member.DeclaringType)?.GetFullMetadataName()}.{member.Member.Name}"; - // Try to match each potential candidate by comparing based only on the name of the member first. - // If that fails, try matching based on the full metadata name of the member + // Try to match each potential candidate by comparing based only on the name of the member first. + // If that fails, try matching based on the full metadata name of the member var hasUiAutomationMapping = targetMembers .Any(candidateMember => (!candidateMember.Contains(".") && candidateMember == member.Member.Name) || @@ -1752,7 +1776,7 @@ private void TryExtractAutomationId(XamlMemberDefinition member, string[] target string bindingPath; - // Checks the first binding member, which can be used to implicitlty declare the binding path (i.e. without + // Checks the first binding member, which can be used to implicitlty declare the binding path (i.e. without // declaring a "Path=" specifier). Otherwise, the we look for any explicit binding path declaration. var firstBindingMember = bindingMembers?.FirstOrDefault(); if (firstBindingMember != null && @@ -2162,7 +2186,7 @@ private void TryValidateContentPresenterBinding(IIndentedStringBuilder writer, X var hasRelativeSource = binding.Members .Any(m => m.Member.Name == "RelativeSource" - // It can either be TemplatedParent or Self. In either cases, it does not use the inherited + // It can either be TemplatedParent or Self. In either cases, it does not use the inherited // DataContext, which falls outside of the scenario we want to avoid. ); @@ -2229,9 +2253,9 @@ private XamlLazyApplyBlockIIndentedStringBuilder CreateApplyBlock(IIndentedStrin closureName = "c" + (_applyIndex++).ToString(CultureInfo.InvariantCulture); // - // Since we're using strings to generate the code, we can't know ahead of time if + // Since we're using strings to generate the code, we can't know ahead of time if // content will be generated only by looking at the Xaml object model. - // For now, we only observe if the inner code has generated code, and we create + // For now, we only observe if the inner code has generated code, and we create // the apply block at that time. // string delegateType = null; @@ -2604,7 +2628,7 @@ private string BuildLiteralValue(INamedTypeSymbol propertyType, string memberVal throw new Exception("Unable to convert {0} for {1} with type {2}".InvariantCultureFormat(memberValue, memberName, propertyType)); } - + private string BuildLocalizedResourceValue(XamlMemberDefinition owner, string memberName, string objectUid) { var uidParts = objectUid.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries); @@ -3028,7 +3052,7 @@ private void BuildLiteralProperties(IIndentedStringBuilder writer, XamlObjectDef } else if (member.Member.DeclaringType == null && member.Member.Name == "Name") { - // This is a special case, where the declaring type is from the x: namespace, + // This is a special case, where the declaring type is from the x: namespace, // but is considered of an unknown type. This can happen when providing the // name of a control using x:Name instead of Name. var hasNameProperty = HasProperty(objectDefinition.Type, "Name"); @@ -3195,7 +3219,7 @@ private void BuildChild(IIndentedStringBuilder writer, XamlMemberDefinition owne if (contentOwner != null) { - // This case is to support the layout switching for the ListViewBaseLayout, which is not + // This case is to support the layout switching for the ListViewBaseLayout, which is not // a FrameworkTemplate. Thsi will need to be removed when this custom list view is removed. var returnType = typeName == "ListViewBaseLayoutTemplate" ? "Uno.UI.Controls.Legacy.ListViewBaseLayout" : "_View"; @@ -3294,7 +3318,7 @@ private void BuildChild(IIndentedStringBuilder writer, XamlMemberDefinition owne } } - // Attached properties need to be expanded using the namespace, otherwise the resolution will be + // Attached properties need to be expanded using the namespace, otherwise the resolution will be // performed at runtime at a higher cost. propertyName = RewriteAttachedPropertyPath(propertyName); diff --git a/src/Uno.UI/UI/Xaml/DependencyObjectExtensions.cs b/src/Uno.UI/UI/Xaml/DependencyObjectExtensions.cs index 2d798123a152..59280b83de53 100644 --- a/src/Uno.UI/UI/Xaml/DependencyObjectExtensions.cs +++ b/src/Uno.UI/UI/Xaml/DependencyObjectExtensions.cs @@ -292,7 +292,7 @@ internal static IDisposable RegisterDisposableNestedPropertyChangedCallback(this /// Register for changes all dependency properties changes notifications for the specified instance. /// /// The instance for which to observe properties changes - /// The callback + /// The callback /// A disposable that will unregister the callback when disposed. internal static IDisposable RegisterInheritedPropertyChangedCallback(this object instance, ExplicitPropertyChangedCallback handler) { @@ -300,10 +300,10 @@ internal static IDisposable RegisterInheritedPropertyChangedCallback(this object } /// - /// Register for compiled bindinds updates progapation + /// Register for compiled bindings updates propagation /// /// The instance for which to observe compiled bindings updates - /// The callback + /// The callback /// A disposable that will unregister the callback when disposed. internal static IDisposable RegisterCompiledBindingsUpdateCallback(this object instance, Action handler) => GetStore(instance).RegisterCompiledBindingsUpdateCallback(handler); @@ -312,8 +312,8 @@ internal static IDisposable RegisterCompiledBindingsUpdateCallback(this object i /// Registers to parent changes. /// /// The target dependency object - /// A key to be passed to the callack parameter. - /// A callback to be called + /// A key to be passed to the callback parameter. + /// A callback to be called /// A disposable that cancels the subscription. internal static IDisposable RegisterParentChangedCallback(this DependencyObject instance, object key, ParentChangedCallback handler) { From ecb591b84d261a9b7656e2bc91315255b764c4b7 Mon Sep 17 00:00:00 2001 From: Carl de Billy Date: Fri, 21 Jun 2019 09:39:40 -0400 Subject: [PATCH 5/7] Update src/Uno.UI/FeatureConfiguration.cs Co-Authored-By: David Oliver --- src/Uno.UI/FeatureConfiguration.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Uno.UI/FeatureConfiguration.cs b/src/Uno.UI/FeatureConfiguration.cs index e06fa0fff886..decd60dce33b 100644 --- a/src/Uno.UI/FeatureConfiguration.cs +++ b/src/Uno.UI/FeatureConfiguration.cs @@ -37,7 +37,7 @@ public static class UIElement public static class Xaml { /// - /// Maximal "BasedOn" recursive resoling depth. + /// Maximal "BasedOn" recursive resolution depth. /// /// /// This is a mechanism to prevent hard-to-diagnose stack overflow when a resource name is not found. From 1a6f9054795772f6f114cb06dcc6d84633694e88 Mon Sep 17 00:00:00 2001 From: Carl de Billy Date: Fri, 21 Jun 2019 10:20:08 -0400 Subject: [PATCH 6/7] Moved xaml x:Name tests to right project --- src/SamplesApp/UITests.Shared/UITests.Shared.projitems | 7 +------ src/SamplesApp/UITests.Shared/UITests.Shared.shproj | 4 ++-- .../XamlGenerationTests}/XamlLocalResources.xaml | 2 -- .../XamlGenerationTests}/XamlLocalResources.xaml.cs | 1 - 4 files changed, 3 insertions(+), 11 deletions(-) rename src/{SamplesApp/UITests.Shared/Windows_UI_Xaml/Resources => SourceGenerators/XamlGenerationTests}/XamlLocalResources.xaml (85%) rename src/{SamplesApp/UITests.Shared/Windows_UI_Xaml/Resources => SourceGenerators/XamlGenerationTests}/XamlLocalResources.xaml.cs (90%) diff --git a/src/SamplesApp/UITests.Shared/UITests.Shared.projitems b/src/SamplesApp/UITests.Shared/UITests.Shared.projitems index 56a1006496b2..72d92b955b0f 100644 --- a/src/SamplesApp/UITests.Shared/UITests.Shared.projitems +++ b/src/SamplesApp/UITests.Shared/UITests.Shared.projitems @@ -1,4 +1,4 @@ - + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) @@ -101,10 +101,6 @@ Designer MSBuild:Compile - - Designer - MSBuild:Compile - Designer MSBuild:Compile @@ -2120,7 +2116,6 @@ Localization_Implicit.xaml - diff --git a/src/SamplesApp/UITests.Shared/UITests.Shared.shproj b/src/SamplesApp/UITests.Shared/UITests.Shared.shproj index bd86f4d01cdd..f91f6af970f1 100644 --- a/src/SamplesApp/UITests.Shared/UITests.Shared.shproj +++ b/src/SamplesApp/UITests.Shared/UITests.Shared.shproj @@ -1,4 +1,4 @@ - + beb0ab3a-16a7-49cf-ad5e-f4a53b985afe @@ -10,4 +10,4 @@ - + \ No newline at end of file diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml/Resources/XamlLocalResources.xaml b/src/SourceGenerators/XamlGenerationTests/XamlLocalResources.xaml similarity index 85% rename from src/SamplesApp/UITests.Shared/Windows_UI_Xaml/Resources/XamlLocalResources.xaml rename to src/SourceGenerators/XamlGenerationTests/XamlLocalResources.xaml index c6c2709a6b8a..a41563cd099c 100644 --- a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml/Resources/XamlLocalResources.xaml +++ b/src/SourceGenerators/XamlGenerationTests/XamlLocalResources.xaml @@ -14,6 +14,4 @@ - - diff --git a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml/Resources/XamlLocalResources.xaml.cs b/src/SourceGenerators/XamlGenerationTests/XamlLocalResources.xaml.cs similarity index 90% rename from src/SamplesApp/UITests.Shared/Windows_UI_Xaml/Resources/XamlLocalResources.xaml.cs rename to src/SourceGenerators/XamlGenerationTests/XamlLocalResources.xaml.cs index 982d6b2ff6a6..4fa973766438 100644 --- a/src/SamplesApp/UITests.Shared/Windows_UI_Xaml/Resources/XamlLocalResources.xaml.cs +++ b/src/SourceGenerators/XamlGenerationTests/XamlLocalResources.xaml.cs @@ -1,5 +1,4 @@ using Windows.UI.Xaml.Controls; -using Uno.UI.Samples.Controls; namespace UITests.Shared.Windows_UI_Xaml.Resources { From a216216b71089e97c2162018dd22bd800626dc55 Mon Sep 17 00:00:00 2001 From: Carl de Billy Date: Fri, 21 Jun 2019 10:20:17 -0400 Subject: [PATCH 7/7] Update release notes --- doc/ReleaseNotes/_ReleaseNotes.md | 5 ++++- .../XamlGenerationTests/XamlGenerationTests.csproj | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/doc/ReleaseNotes/_ReleaseNotes.md b/doc/ReleaseNotes/_ReleaseNotes.md index 8d87cbd9ba5f..ca782a10f550 100644 --- a/doc/ReleaseNotes/_ReleaseNotes.md +++ b/doc/ReleaseNotes/_ReleaseNotes.md @@ -6,11 +6,14 @@ * Basic support for `Windows.Devices.Sensors.Barometer` ### Breaking changes -* +* ### Bug fixes * [iOS] Area of view outside Clip rect now allows touch to pass through, this fixes NavigationView not allowing touches to children (#1018) * `ComboBox` drop down is now placed following a logic which is closer to UWP and it longer flickers when it appears (especilly on WASM) +* #854 `BasedOn` on a `