Browse Source

Removed Ignore attribute from SimpleLoadTests so the tests in the class will be executed.

Made some modifications to XamlParser so it aligns with the official XamlReader and the SimpleLoadTests will pass.
pull/43/head
Tobias Gummesson 12 years ago
parent
commit
e5761c6d5c
  1. 1
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/SimpleLoadTests.cs
  2. 26
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs

1
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/SimpleLoadTests.cs

@ -7,7 +7,6 @@ using NUnit.Framework;
namespace ICSharpCode.WpfDesign.Tests.XamlDom namespace ICSharpCode.WpfDesign.Tests.XamlDom
{ {
[TestFixture] [TestFixture]
[Ignore("Broken on .NET 4")]
public class SimpleLoadTests : TestHelper public class SimpleLoadTests : TestHelper
{ {
[Test] [Test]

26
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs

@ -265,7 +265,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
void ParseObjectContent(XamlObject obj, XmlElement element, XamlPropertyInfo defaultProperty, XamlTextValue initializeFromTextValueInsteadOfConstructor) void ParseObjectContent(XamlObject obj, XmlElement element, XamlPropertyInfo defaultProperty, XamlTextValue initializeFromTextValueInsteadOfConstructor)
{ {
XamlPropertyValue setDefaultValueTo = null; bool isDefaultValueSet = false;
object defaultPropertyValue = null; object defaultPropertyValue = null;
XamlProperty defaultCollectionProperty = null; XamlProperty defaultCollectionProperty = null;
@ -290,11 +290,6 @@ namespace ICSharpCode.WpfDesign.XamlDom
continue; continue;
if (ObjectChildElementIsPropertyElement(childElement)) { if (ObjectChildElementIsPropertyElement(childElement)) {
// I don't know why the official XamlReader runs the property getter
// here, but let's try to imitate it as good as possible
if (defaultProperty != null && !defaultProperty.IsCollection) {
defaultProperty.GetValue(obj.Instance);
}
ParseObjectChildElementAsPropertyElement(obj, childElement, defaultProperty, defaultPropertyValue); ParseObjectChildElementAsPropertyElement(obj, childElement, defaultProperty, defaultPropertyValue);
continue; continue;
} }
@ -307,23 +302,16 @@ namespace ICSharpCode.WpfDesign.XamlDom
defaultCollectionProperty.ParserAddCollectionElement(null, childValue); defaultCollectionProperty.ParserAddCollectionElement(null, childValue);
CollectionSupport.AddToCollection(defaultProperty.ReturnType, defaultPropertyValue, childValue); CollectionSupport.AddToCollection(defaultProperty.ReturnType, defaultPropertyValue, childValue);
} else { } else {
if (setDefaultValueTo != null) if (defaultProperty == null)
throw new XamlLoadException("This element does not have a default value, cannot assign to it");
if (isDefaultValueSet)
throw new XamlLoadException("default property may have only one value assigned"); throw new XamlLoadException("default property may have only one value assigned");
setDefaultValueTo = childValue;
}
}
}
if (defaultProperty != null && !defaultProperty.IsCollection && !element.IsEmpty) { obj.AddProperty(new XamlProperty(obj, defaultProperty, childValue));
// Runs even when defaultValueSet==false! isDefaultValueSet = true;
// Again, no idea why the official XamlReader does this.
defaultProperty.GetValue(obj.Instance);
} }
if (setDefaultValueTo != null) {
if (defaultProperty == null) {
throw new XamlLoadException("This element does not have a default value, cannot assign to it");
} }
obj.AddProperty(new XamlProperty(obj, defaultProperty, setDefaultValueTo));
} }
} }

Loading…
Cancel
Save