Browse Source

Merge remote-tracking branch 'remotes/sd/master'

pull/619/head
jogibear9988 11 years ago
parent
commit
5b0f28b5e3
  1. 41
      src/AddIns/Debugger/Debugger.AddIn/NRefactory/ExpressionEvaluationVisitor.cs
  2. 2
      src/AddIns/Debugger/Debugger.Core/Value.cs
  3. 38
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/ModelTests.cs
  4. 4
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/MarkupExtensionPrinter.cs
  5. 15
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs

41
src/AddIns/Debugger/Debugger.AddIn/NRefactory/ExpressionEvaluationVisitor.cs

@ -444,7 +444,7 @@ namespace Debugger.AddIn @@ -444,7 +444,7 @@ namespace Debugger.AddIn
} else
throw new GetValueException("Invoked member must be a method or property");
Value target = null;
if (!usedMethod.IsStatic)
if (!usedMethod.IsStatic && !usedMethod.IsConstructor)
target = Convert(result.TargetResult).GetPermanentReference(evalThread);
return InvokeMethod(target, usedMethod, result.Arguments.Select(rr => Convert(rr).GetPermanentReference(evalThread)).ToArray());
}
@ -479,26 +479,33 @@ namespace Debugger.AddIn @@ -479,26 +479,33 @@ namespace Debugger.AddIn
}
sb.Append("}");
return sb.ToString();
} else if (val.Type.GetAllBaseTypeDefinitions().Any(def => def.IsKnownType(KnownTypeCode.ICollection))) {
StringBuilder sb = new StringBuilder();
sb.Append(new CSharpAmbience().ConvertType(val.Type));
sb.Append(" {");
val = val.GetPermanentReference(evalThread);
var countProp = val.Type.GetProperties(p => p.Name == "Count" && !p.IsExplicitInterfaceImplementation).Single();
int count = (int)val.GetMemberValue(evalThread, countProp).PrimitiveValue;
for(int i = 0; i < count; i++) {
if (i > 0) sb.Append(", ");
var itemProperty = val.Type.GetProperties(p => p.IsIndexer && p.Name == "Item" && !p.IsExplicitInterfaceImplementation).Single();
Value item = val.GetPropertyValue(evalThread, itemProperty, Eval.CreateValue(evalThread, i));
sb.Append(FormatValue(evalThread, item));
} else if (val.Type.GetAllBaseTypeDefinitions().Any(def => def.IsKnownType(KnownTypeCode.ICollection) || def.IsKnownType(KnownTypeCode.ICollectionOfT))) {
var countProp = val.Type.GetProperties(p => p.Name == "Count" && !p.IsExplicitInterfaceImplementation).SingleOrDefault();
if (countProp != null) {
StringBuilder sb = new StringBuilder();
sb.Append(new CSharpAmbience().ConvertType(val.Type));
val = val.GetPermanentReference(evalThread);
int count = (int)val.GetMemberValue(evalThread, countProp).PrimitiveValue;
var itemProperty = val.Type.GetProperties(p => p.IsIndexer && p.Name == "Item" && !p.IsExplicitInterfaceImplementation).SingleOrDefault();
if (itemProperty != null) {
sb.Append(" {");
for (int i = 0; i < count; i++) {
if (i > 0)
sb.Append(", ");
Value item = val.GetPropertyValue(evalThread, itemProperty, Eval.CreateValue(evalThread, i));
sb.Append(FormatValue(evalThread, item));
}
sb.Append("}");
} else {
sb.AppendFormat(" ({0} elements)", count);
}
return sb.ToString();
}
sb.Append("}");
return sb.ToString();
} else if (val.Type.IsKnownType(KnownTypeCode.String) || val.Type.IsPrimitiveType()) {
return TextWriterTokenWriter.PrintPrimitiveValue(val.PrimitiveValue);
} else {
return val.InvokeToString(evalThread);
}
return val.InvokeToString(evalThread);
}
}

2
src/AddIns/Debugger/Debugger.Core/Value.cs

@ -416,6 +416,8 @@ namespace Debugger @@ -416,6 +416,8 @@ namespace Debugger
if (memberInfo == null)
throw new DebuggerException("memberInfo is null");
if (!memberInfo.IsStatic) {
if (memberInfo.SymbolKind == SymbolKind.Constructor)
throw new GetValueException("Constructor expression");
if (objectInstance == null)
throw new DebuggerException("No target object specified");
if (objectInstance.IsNull)

38
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/ModelTests.cs

@ -596,7 +596,13 @@ namespace ICSharpCode.WpfDesign.Tests.Designer @@ -596,7 +596,13 @@ namespace ICSharpCode.WpfDesign.Tests.Designer
DesignItem textBox = canvas.Services.Component.RegisterComponentForDesigner(new TextBox());
canvas.Properties["Children"].CollectionElements.Add(textBox);
DesignItemProperty resProp = textBox.Properties.GetProperty("Resources");
DesignItemProperty resProp = button.Properties.GetProperty("Resources");
Assert.IsTrue(resProp.IsCollection);
DesignItem dummyItem = canvas.Services.Component.RegisterComponentForDesigner(new ExampleClass());
dummyItem.Key = "dummy";
resProp.CollectionElements.Add(dummyItem);
resProp = textBox.Properties.GetProperty("Resources");
Assert.IsTrue(resProp.IsCollection);
DesignItem exampleClassItem = canvas.Services.Component.RegisterComponentForDesigner(new ExampleClass());
exampleClassItem.Key = "bindingSource";
@ -605,23 +611,39 @@ namespace ICSharpCode.WpfDesign.Tests.Designer @@ -605,23 +611,39 @@ namespace ICSharpCode.WpfDesign.Tests.Designer
DesignItem bindingItem = canvas.Services.Component.RegisterComponentForDesigner(new Binding());
if (!setBindingPropertiesAfterSet) {
bindingItem.Properties["Path"].SetValue("StringProp");
// Using resource "dummy" before "bindingSource" to enable test where not the first set property will require element-style print of the binding
bindingItem.Properties["ConverterParameter"].SetValue(new StaticResourceExtension());
bindingItem.Properties["ConverterParameter"].Value.Properties["ResourceKey"].SetValue("dummy");
bindingItem.Properties["Source"].SetValue(new StaticResourceExtension());
bindingItem.Properties["Source"].Value.Properties["ResourceKey"].SetValue("bindingSource");
}
textBox.Properties[TextBox.TextProperty].SetValue(bindingItem);
if (setBindingPropertiesAfterSet) {
bindingItem.Properties["Path"].SetValue("StringProp");
// Using resource "dummy" before "bindingSource" to enable test where not the first set property will require element-style print of the binding
bindingItem.Properties["ConverterParameter"].SetValue(new StaticResourceExtension());
bindingItem.Properties["ConverterParameter"].Value.Properties["ResourceKey"].SetValue("dummy");
bindingItem.Properties["Source"].SetValue(new StaticResourceExtension());
bindingItem.Properties["Source"].Value.Properties["ResourceKey"].SetValue("bindingSource");
}
string expectedXaml = "<Button />\n" +
"<TextBox>\n" +
" <TextBox.Resources>\n" +
" <t:ExampleClass x:Key=\"bindingSource\" />\n" +
" </TextBox.Resources>\n" +
" <Binding Path=\"StringProp\" Source=\"{StaticResource bindingSource}\" />\n" +
"</TextBox>";
var binding = bindingItem.Component as Binding;
Assert.IsNotNull(binding);
Assert.IsNotNull(binding.Source);
Assert.IsNotNull(exampleClassItem.Component);
Assert.AreSame(exampleClassItem.Component, binding.Source);
const string expectedXaml = "<Button>\n" +
" <Button.Resources>\n" +
" <t:ExampleClass x:Key=\"dummy\" />\n" +
" </Button.Resources>\n" +
"</Button>\n" +
"<TextBox>\n" +
" <TextBox.Resources>\n" +
" <t:ExampleClass x:Key=\"bindingSource\" />\n" +
" </TextBox.Resources>\n" +
" <Binding Path=\"StringProp\" ConverterParameter=\"{StaticResource dummy}\" Source=\"{StaticResource bindingSource}\" />\n" +
"</TextBox>";
AssertCanvasDesignerOutput(expectedXaml, button.Context);
AssertLog("");

4
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/MarkupExtensionPrinter.cs

@ -137,8 +137,8 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -137,8 +137,8 @@ namespace ICSharpCode.WpfDesign.XamlDom
var xamlObject = value as XamlObject;
if (xamlObject == null || !xamlObject.IsMarkupExtension)
return false;
else
return CanPrint(xamlObject, true, nonMarkupExtensionParent);
else if (!CanPrint(xamlObject, true, nonMarkupExtensionParent))
return false;
}
}

15
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs

@ -272,10 +272,23 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -272,10 +272,23 @@ namespace ICSharpCode.WpfDesign.XamlDom
NameChanged(this, EventArgs.Empty);
}
}
void UpdateChildMarkupExtensions(XamlObject obj)
{
foreach (XamlObject propXamlObject in obj.Properties.Where((prop) => prop.IsSet).Select((prop) => prop.PropertyValue).OfType<XamlObject>()) {
UpdateChildMarkupExtensions(propXamlObject);
}
if (obj.IsMarkupExtension && obj.ParentProperty != null) {
obj.ParentProperty.UpdateValueOnInstance();
}
}
void UpdateMarkupExtensionChain()
{
var obj = this;
UpdateChildMarkupExtensions(this);
var obj = this.ParentObject;
while (obj != null && obj.IsMarkupExtension && obj.ParentProperty != null) {
obj.ParentProperty.UpdateValueOnInstance();
obj = obj.ParentObject;

Loading…
Cancel
Save