summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Build.Tasks
diff options
context:
space:
mode:
authorStephane Delcroix <stephane@delcroix.org>2017-01-25 13:47:27 (GMT)
committerKangho Hur <kangho.hur@samsung.com>2017-03-24 04:14:23 (GMT)
commitc247c695cbd8613d5603ccbada92051a9ea7dbf8 (patch)
tree61ffc2f8687576377ebe71c73d74001589b9f2af /Xamarin.Forms.Build.Tasks
parentacf4a77b5a71900463f1e31cad1dab5e9593451e (diff)
downloadxamarin-forms-c247c695cbd8613d5603ccbada92051a9ea7dbf8.zip
xamarin-forms-c247c695cbd8613d5603ccbada92051a9ea7dbf8.tar.gz
xamarin-forms-c247c695cbd8613d5603ccbada92051a9ea7dbf8.tar.bz2
[Xaml[C]] Do not instantiate DataTemplate Content at parsing time (#683)
* [Xaml] rename VisitChildrenFirst * [Xaml] rework SkipChildren in XamlNode * [Xaml] fix 45179 * fix
Diffstat (limited to 'Xamarin.Forms.Build.Tasks')
-rw-r--r--Xamarin.Forms.Build.Tasks/CreateObjectVisitor.cs17
-rw-r--r--Xamarin.Forms.Build.Tasks/ExpandMarkupsVisitor.cs18
-rw-r--r--Xamarin.Forms.Build.Tasks/SetFieldVisitor.cs18
-rw-r--r--Xamarin.Forms.Build.Tasks/SetNamescopesAndRegisterNamesVisitor.cs18
-rw-r--r--Xamarin.Forms.Build.Tasks/SetPropertiesVisitor.cs17
-rw-r--r--Xamarin.Forms.Build.Tasks/SetResourcesVisitor.cs22
6 files changed, 31 insertions, 79 deletions
diff --git a/Xamarin.Forms.Build.Tasks/CreateObjectVisitor.cs b/Xamarin.Forms.Build.Tasks/CreateObjectVisitor.cs
index c684e51..b73926f 100644
--- a/Xamarin.Forms.Build.Tasks/CreateObjectVisitor.cs
+++ b/Xamarin.Forms.Build.Tasks/CreateObjectVisitor.cs
@@ -21,20 +21,11 @@ namespace Xamarin.Forms.Build.Tasks
ModuleDefinition Module { get; }
- public bool VisitChildrenFirst
- {
- get { return true; }
- }
+ public TreeVisitingMode VisitingMode => TreeVisitingMode.BottomUp;
+ public bool StopOnDataTemplate => true;
+ public bool StopOnResourceDictionary => false;
+ public bool VisitNodeOnDataTemplate => false;
- public bool StopOnDataTemplate
- {
- get { return true; }
- }
-
- public bool StopOnResourceDictionary
- {
- get { return false; }
- }
public void Visit(ValueNode node, INode parentNode)
{
diff --git a/Xamarin.Forms.Build.Tasks/ExpandMarkupsVisitor.cs b/Xamarin.Forms.Build.Tasks/ExpandMarkupsVisitor.cs
index e647f6c..ff83de7 100644
--- a/Xamarin.Forms.Build.Tasks/ExpandMarkupsVisitor.cs
+++ b/Xamarin.Forms.Build.Tasks/ExpandMarkupsVisitor.cs
@@ -24,20 +24,10 @@ namespace Xamarin.Forms.Build.Tasks
ILContext Context { get; }
- public bool VisitChildrenFirst
- {
- get { return true; }
- }
-
- public bool StopOnDataTemplate
- {
- get { return false; }
- }
-
- public bool StopOnResourceDictionary
- {
- get { return false; }
- }
+ public TreeVisitingMode VisitingMode => TreeVisitingMode.BottomUp;
+ public bool StopOnDataTemplate => false;
+ public bool StopOnResourceDictionary => false;
+ public bool VisitNodeOnDataTemplate => true;
public void Visit(ValueNode node, INode parentNode)
{
diff --git a/Xamarin.Forms.Build.Tasks/SetFieldVisitor.cs b/Xamarin.Forms.Build.Tasks/SetFieldVisitor.cs
index 1839cf7..9a5b744 100644
--- a/Xamarin.Forms.Build.Tasks/SetFieldVisitor.cs
+++ b/Xamarin.Forms.Build.Tasks/SetFieldVisitor.cs
@@ -13,20 +13,10 @@ namespace Xamarin.Forms.Build.Tasks
public ILContext Context { get; }
- public bool VisitChildrenFirst
- {
- get { return false; }
- }
-
- public bool StopOnDataTemplate
- {
- get { return true; }
- }
-
- public bool StopOnResourceDictionary
- {
- get { return false; }
- }
+ public TreeVisitingMode VisitingMode => TreeVisitingMode.TopDown;
+ public bool StopOnDataTemplate => true;
+ public bool StopOnResourceDictionary => false;
+ public bool VisitNodeOnDataTemplate => false;
public void Visit(ValueNode node, INode parentNode)
{
diff --git a/Xamarin.Forms.Build.Tasks/SetNamescopesAndRegisterNamesVisitor.cs b/Xamarin.Forms.Build.Tasks/SetNamescopesAndRegisterNamesVisitor.cs
index d810bd8..1c776ab 100644
--- a/Xamarin.Forms.Build.Tasks/SetNamescopesAndRegisterNamesVisitor.cs
+++ b/Xamarin.Forms.Build.Tasks/SetNamescopesAndRegisterNamesVisitor.cs
@@ -16,20 +16,10 @@ namespace Xamarin.Forms.Build.Tasks
ILContext Context { get; }
- public bool VisitChildrenFirst
- {
- get { return false; }
- }
-
- public bool StopOnDataTemplate
- {
- get { return true; }
- }
-
- public bool StopOnResourceDictionary
- {
- get { return false; }
- }
+ public TreeVisitingMode VisitingMode => TreeVisitingMode.TopDown;
+ public bool StopOnDataTemplate => true;
+ public bool StopOnResourceDictionary => false;
+ public bool VisitNodeOnDataTemplate => false;
public void Visit(ValueNode node, INode parentNode)
{
diff --git a/Xamarin.Forms.Build.Tasks/SetPropertiesVisitor.cs b/Xamarin.Forms.Build.Tasks/SetPropertiesVisitor.cs
index c93c14f..2c4ddbd 100644
--- a/Xamarin.Forms.Build.Tasks/SetPropertiesVisitor.cs
+++ b/Xamarin.Forms.Build.Tasks/SetPropertiesVisitor.cs
@@ -37,8 +37,9 @@ namespace Xamarin.Forms.Build.Tasks
public ILContext Context { get; }
public bool StopOnResourceDictionary { get; }
- public bool VisitChildrenFirst { get; } = true;
- public bool StopOnDataTemplate { get; } = true;
+ public TreeVisitingMode VisitingMode => TreeVisitingMode.BottomUp;
+ public bool StopOnDataTemplate => true;
+ public bool VisitNodeOnDataTemplate => true;
ModuleDefinition Module { get; }
@@ -88,6 +89,11 @@ namespace Xamarin.Forms.Build.Tasks
if ((propertyName != XmlName.Empty || TryGetPropertyName(node, parentNode, out propertyName)) && skips.Contains(propertyName))
return;
+ if (propertyName == XmlName._CreateContent) {
+ SetDataTemplate((IElementNode)parentNode, node, Context, node);
+ return;
+ }
+
//if this node is an IMarkupExtension, invoke ProvideValue() and replace the variable
var vardef = Context.Variables[node];
var vardefref = new VariableDefinitionReference(vardef);
@@ -114,11 +120,8 @@ namespace Xamarin.Forms.Build.Tasks
return;
if (parentNode is IElementNode && ((IElementNode)parentNode).SkipProperties.Contains (propertyName))
return;
-
- if (propertyName == XmlName._CreateContent)
- SetDataTemplate((IElementNode)parentNode, node, Context, node);
- else
- Context.IL.Append(SetPropertyValue(Context.Variables[(IElementNode)parentNode], propertyName, node, Context, node));
+
+ Context.IL.Append(SetPropertyValue(Context.Variables[(IElementNode)parentNode], propertyName, node, Context, node));
}
else if (IsCollectionItem(node, parentNode) && parentNode is IElementNode)
{
diff --git a/Xamarin.Forms.Build.Tasks/SetResourcesVisitor.cs b/Xamarin.Forms.Build.Tasks/SetResourcesVisitor.cs
index f046efc..c5be1fb 100644
--- a/Xamarin.Forms.Build.Tasks/SetResourcesVisitor.cs
+++ b/Xamarin.Forms.Build.Tasks/SetResourcesVisitor.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections;
-using System.Collections.Generic;
using System.Linq;
using Mono.Cecil;
using Mono.Cecil.Cil;
@@ -20,26 +19,15 @@ namespace Xamarin.Forms.Build.Tasks
ModuleDefinition Module { get; }
- public bool VisitChildrenFirst
- {
- get { return false; }
- }
-
- public bool StopOnDataTemplate
- {
- get { return true; }
- }
-
- public bool StopOnResourceDictionary
- {
- get { return false; }
- }
+ public TreeVisitingMode VisitingMode => TreeVisitingMode.TopDown;
+ public bool StopOnDataTemplate => true;
+ public bool StopOnResourceDictionary => false;
+ public bool VisitNodeOnDataTemplate => false;
public void Visit(ValueNode node, INode parentNode)
{
XmlName propertyName;
- if (!SetPropertiesVisitor.TryGetPropertyName(node, parentNode, out propertyName))
- {
+ if (!SetPropertiesVisitor.TryGetPropertyName(node, parentNode, out propertyName)) {
if (!IsCollectionItem(node, parentNode))
return;
string contentProperty;