diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SnaplinePlacementBehavior.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SnaplinePlacementBehavior.cs
index f9c32ddca7..b29ea43538 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SnaplinePlacementBehavior.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SnaplinePlacementBehavior.cs
@@ -139,7 +139,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
void CreateSurface(PlacementOperation operation)
{
- if (ExtendedItem.Services.Tool.DesignPanel != null) {
+ if (ExtendedItem.Services.DesignPanel != null) {
surface = new Canvas();
adornerPanel = new AdornerPanel();
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlModelProperty.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlModelProperty.cs
index 0ede39b180..b30ac06a6b 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlModelProperty.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlModelProperty.cs
@@ -47,7 +47,10 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
public bool Equals(XamlModelProperty other)
{
- return this._designItem == other._designItem && this._property == other._property;
+ if (other == null)
+ return false;
+ else
+ return this._designItem == other._designItem && this._property == other._property;
}
public override int GetHashCode()
@@ -107,7 +110,7 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
}
}
- // There may be multipley XamlModelProperty instances for the same property,
+ // There may be multiple XamlModelProperty instances for the same property,
// so this class may not have any mutable fields / events - instead,
// we forward all event handlers to the XamlProperty.
public override event EventHandler ValueChanged {
@@ -132,21 +135,17 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
}
public override event EventHandler ValueOnInstanceChanged {
- add { _property.ValueOnIstanceChanged += value; }
- remove { _property.ValueOnIstanceChanged -= value; }
+ add { _property.ValueOnInstanceChanged += value; }
+ remove { _property.ValueOnInstanceChanged -= value; }
}
public override object ValueOnInstance {
- get {
- return _property.ValueOnInstance;
- }
+ get { return _property.ValueOnInstance; }
set { _property.ValueOnInstance = value; }
}
public override bool IsSet {
- get { if (_property.IsSet) {
- }
- return _property.IsSet; }
+ get { return _property.IsSet; }
}
#if EventHandlerDebugging
@@ -203,8 +202,8 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
}
void SetValueInternal(XamlPropertyValue newValue)
- {
- _property.PropertyValue = newValue;
+ {
+ _property.PropertyValue = newValue;
_designItem.NotifyPropertyChanged(this);
}
@@ -227,7 +226,7 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
public sealed class PropertyChangeAction : ITransactionItem
{
- XamlModelProperty property;
+ XamlModelProperty property;
XamlPropertyValue oldValue;
XamlPropertyValue newValue;
bool oldIsSet;
@@ -237,7 +236,7 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
{
this.property = property;
this.newValue = newValue;
- this.newIsSet = newIsSet;
+ this.newIsSet = newIsSet;
oldIsSet = property._property.IsSet;
oldValue = property._property.PropertyValue;
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/CollectionSupport.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/CollectionSupport.cs
index 61546f6330..8d8f00adad 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/CollectionSupport.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/CollectionSupport.cs
@@ -16,8 +16,14 @@ using System.Windows.Markup;
namespace ICSharpCode.WpfDesign.XamlDom
{
+ ///
+ /// Static class containing helper methods to work with collections (like the XamlParser does)
+ ///
public static class CollectionSupport
{
+ ///
+ /// Gets if the type is considered a collection in XAML.
+ ///
public static bool IsCollectionType(Type type)
{
return typeof(IList).IsAssignableFrom(type)
@@ -26,6 +32,10 @@ namespace ICSharpCode.WpfDesign.XamlDom
|| typeof(ResourceDictionary).IsAssignableFrom(type);
}
+ ///
+ /// Gets if the collection type can accepts items of type
+ /// .
+ ///
public static bool CanCollectionAdd(Type col, Type item)
{
var e = col.GetInterface("IEnumerable`1");
@@ -36,6 +46,9 @@ namespace ICSharpCode.WpfDesign.XamlDom
return true;
}
+ ///
+ /// Gets if the collection type can accept the specified items.
+ ///
public static bool CanCollectionAdd(Type col, IEnumerable items)
{
foreach (var item in items) {
@@ -44,6 +57,9 @@ namespace ICSharpCode.WpfDesign.XamlDom
return true;
}
+ ///
+ /// Adds a value to the end of a collection.
+ ///
public static void AddToCollection(Type collectionType, object collectionInstance, XamlPropertyValue newElement)
{
IAddChild addChild = collectionInstance as IAddChild;
@@ -70,6 +86,9 @@ namespace ICSharpCode.WpfDesign.XamlDom
}
}
+ ///
+ /// Adds a value at the specified index in the collection.
+ ///
public static void Insert(Type collectionType, object collectionInstance, XamlPropertyValue newElement, int index)
{
collectionType.InvokeMember(
@@ -81,6 +100,10 @@ namespace ICSharpCode.WpfDesign.XamlDom
static readonly Type[] RemoveAtParameters = { typeof(int) };
+ ///
+ /// Removes the item at the specified index of the collection.
+ ///
+ /// True if the removal succeeded, false if the collection type does not support RemoveAt.
public static bool RemoveItemAt(Type collectionType, object collectionInstance, int index)
{
MethodInfo m = collectionType.GetMethod("RemoveAt", RemoveAtParameters);
@@ -92,6 +115,9 @@ namespace ICSharpCode.WpfDesign.XamlDom
}
}
+ ///
+ /// Removes an item instance from the specified collection.
+ ///
public static void RemoveItem(Type collectionType, object collectionInstance, object item)
{
collectionType.InvokeMember(
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/IXamlErrorSink.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/IXamlErrorSink.cs
index ba537dc600..01b75c89f0 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/IXamlErrorSink.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/IXamlErrorSink.cs
@@ -5,8 +5,14 @@ using System.Text;
namespace ICSharpCode.WpfDesign.XamlDom
{
+ ///
+ /// Interface where errors during XAML loading are reported.
+ ///
public interface IXamlErrorSink
{
+ ///
+ /// Reports a XAML load error.
+ ///
void ReportError(string message, int line, int column);
}
}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/MarkupExtensionPrinter.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/MarkupExtensionPrinter.cs
index 234dd8a62f..dee154ae18 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/MarkupExtensionPrinter.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/MarkupExtensionPrinter.cs
@@ -5,13 +5,22 @@ using System.Text;
namespace ICSharpCode.WpfDesign.XamlDom
{
+ ///
+ /// Static class that can generate XAML markup extension code ("{Binding Path=...}").
+ ///
public static class MarkupExtensionPrinter
{
+ ///
+ /// Gets whether shorthand XAML markup extension code can be generated for the object.
+ ///
public static bool CanPrint(XamlObject obj)
{
return true;
}
-
+
+ ///
+ /// Generates XAML markup extension code for the object.
+ ///
public static string Print(XamlObject obj)
{
StringBuilder sb = new StringBuilder();
@@ -22,9 +31,9 @@ namespace ICSharpCode.WpfDesign.XamlDom
foreach (var property in obj.Properties) {
if (!property.IsSet) continue;
- if (first)
+ if (first)
sb.Append(" ");
- else
+ else
sb.Append(", ");
first = false;
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/PositionXmlDocument.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/PositionXmlDocument.cs
index 5e9ee78588..99227bbf78 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/PositionXmlDocument.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/PositionXmlDocument.cs
@@ -6,89 +6,136 @@ using System.Xml;
namespace ICSharpCode.WpfDesign.XamlDom
{
+ // SuppressMessage justification: we're just adding position info to XmlDocument and don't want to fix
+ // any of it's other issues.
+
+ ///
+ /// Class derived from System.Xml.XmlDocument that remembers line/column information for elements and attributes
+ /// when loading from a or other -implementing reader.
+ ///
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1010:CollectionsShouldImplementGenericInterface")]
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1058:TypesShouldNotExtendCertainBaseTypes")]
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")]
public class PositionXmlDocument : XmlDocument
{
- IXmlLineInfo lineInfo;
-
- public override XmlElement CreateElement (string prefix, string localName, string namespaceURI)
- {
- return new PositionXmlElement(prefix, localName, namespaceURI, this, lineInfo);
- }
-
+ IXmlLineInfo lineInfo; // a reference to the XmlReader, only set during load time
+
+ ///
+ /// Creates a PositionXmlElement.
+ ///
+ public override XmlElement CreateElement(string prefix, string localName, string namespaceURI)
+ {
+ return new PositionXmlElement(prefix, localName, namespaceURI, this, lineInfo);
+ }
+
+ ///
+ /// Creates a PositionXmlAttribute.
+ ///
public override XmlAttribute CreateAttribute(string prefix, string localName, string namespaceURI)
{
return new PositionXmlAttribute(prefix, localName, namespaceURI, this, lineInfo);
}
-
- public override void Load (XmlReader reader)
- {
- if (reader is IXmlLineInfo) lineInfo = (IXmlLineInfo)reader;
- base.Load(reader);
- lineInfo = null;
- }
- }
-
+
+ ///
+ /// Loads the XML document from the specified .
+ ///
+ public override void Load(XmlReader reader)
+ {
+ lineInfo = reader as IXmlLineInfo;
+ try {
+ base.Load(reader);
+ } finally {
+ lineInfo = null;
+ }
+ }
+ }
+
+ ///
+ /// XML Element with line/column information.
+ ///
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1010:CollectionsShouldImplementGenericInterface")]
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")]
public class PositionXmlElement : XmlElement, IXmlLineInfo
{
- public PositionXmlElement (string prefix, string localName, string namespaceURI, XmlDocument doc, IXmlLineInfo lineInfo)
- : base(prefix, localName, namespaceURI, doc)
- {
+ internal PositionXmlElement (string prefix, string localName, string namespaceURI, XmlDocument doc, IXmlLineInfo lineInfo)
+ : base(prefix, localName, namespaceURI, doc)
+ {
if (lineInfo != null) {
this.lineNumber = lineInfo.LineNumber;
this.linePosition = lineInfo.LinePosition;
this.hasLineInfo = true;
}
- }
+ }
int lineNumber;
int linePosition;
bool hasLineInfo;
-
- public bool HasLineInfo ()
- {
- return hasLineInfo;
- }
-
- public int LineNumber
- {
- get { return lineNumber; }
- }
-
- public int LinePosition
- {
- get { return linePosition; }
- }
+
+ ///
+ /// Gets whether the element has line information.
+ ///
+ public bool HasLineInfo()
+ {
+ return hasLineInfo;
+ }
+
+ ///
+ /// Gets the line number.
+ ///
+ public int LineNumber {
+ get { return lineNumber; }
+ }
+
+ ///
+ /// Gets the line position (column).
+ ///
+ public int LinePosition {
+ get { return linePosition; }
+ }
}
-
+
+ ///
+ /// XML Attribute with line/column information.
+ ///
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix")]
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")]
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1010:CollectionsShouldImplementGenericInterface")]
public class PositionXmlAttribute : XmlAttribute, IXmlLineInfo
{
- public PositionXmlAttribute (string prefix, string localName, string namespaceURI, XmlDocument doc, IXmlLineInfo lineInfo)
- : base(prefix, localName, namespaceURI, doc)
- {
- if (lineInfo != null) {
+ internal PositionXmlAttribute (string prefix, string localName, string namespaceURI, XmlDocument doc, IXmlLineInfo lineInfo)
+ : base(prefix, localName, namespaceURI, doc)
+ {
+ if (lineInfo != null) {
this.lineNumber = lineInfo.LineNumber;
this.linePosition = lineInfo.LinePosition;
this.hasLineInfo = true;
}
- }
+ }
int lineNumber;
int linePosition;
bool hasLineInfo;
-
- public bool HasLineInfo ()
- {
- return hasLineInfo;
- }
-
- public int LineNumber
- {
- get { return lineNumber; }
- }
-
- public int LinePosition
- {
- get { return linePosition; }
- }
+
+ ///
+ /// Gets whether the element has line information.
+ ///
+ public bool HasLineInfo()
+ {
+ return hasLineInfo;
+ }
+
+ ///
+ /// Gets the line number.
+ ///
+ public int LineNumber {
+ get { return lineNumber; }
+ }
+
+ ///
+ /// Gets the line position (column).
+ ///
+ public int LinePosition {
+ get { return linePosition; }
+ }
}
}
\ No newline at end of file
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/WpfDesign.XamlDom.csproj b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/WpfDesign.XamlDom.csproj
index 23cb25471a..2536ee12c1 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/WpfDesign.XamlDom.csproj
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/WpfDesign.XamlDom.csproj
@@ -15,10 +15,11 @@
False
File
False
- -Microsoft.Globalization#CA1303
+ -Microsoft.Performance#CA1800
..\..\..\..\..\..\AddIns\AddIns\DisplayBindings\WpfDesign\
..\..\..\..\..\..\AddIns\AddIns\DisplayBindings\WpfDesign\ICSharpCode.WpfDesign.XamlDom.xml
v3.5
+ C:\Users\Daniel\AppData\Roaming\ICSharpCode/SharpDevelop3.0\Settings.SourceAnalysis
true
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs
index de5c9fa43f..148a493439 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs
@@ -112,6 +112,9 @@ namespace ICSharpCode.WpfDesign.XamlDom
}
}
+ ///
+ /// Gets whether this XamlObject represents a markup extension in short form ("{Binding}" syntax)
+ ///
public bool IsMarkupExtensionRoot {
get { return XmlAttribute != null; }
}
@@ -122,7 +125,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
XmlElement newElement = e.OwnerDocument.CreateElement(prefix, e.Name, e.NamespaceURI);
foreach (XmlAttribute a in target.Attributes) {
- if (a.Name.StartsWith("xmlns")) {
+ if (a.Prefix == "xmlns") {
newElement.Attributes.Append(a.Clone() as XmlAttribute);
}
}
@@ -197,16 +200,18 @@ namespace ICSharpCode.WpfDesign.XamlDom
get { return instance; }
}
+ ///
+ /// Gets whether this instance represents a MarkupExtension.
+ ///
public bool IsMarkupExtension {
get { return instance is MarkupExtension; }
}
+ ///
+ /// Gets whether there were load errors for this object.
+ ///
public bool HasErrors { get; internal set; }
- public DependencyObject DependencyObject {
- get { return instance as DependencyObject; }
- }
-
///
/// Gets the type of this object element.
///
@@ -226,6 +231,9 @@ namespace ICSharpCode.WpfDesign.XamlDom
string contentPropertyName;
+ ///
+ /// Gets the name of the content property.
+ ///
public string ContentPropertyName {
get {
return contentPropertyName;
@@ -304,6 +312,9 @@ namespace ICSharpCode.WpfDesign.XamlDom
element.SetAttribute(name, XamlConstants.XamlNamespace, value);
}
+ ///
+ /// Gets/Sets the associated with this XamlObject.
+ ///
public XamlObjectServiceProvider ServiceProvider { get; set; }
MarkupExtensionWrapper wrapper;
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObjectServiceProvider.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObjectServiceProvider.cs
index 5347b11f5b..18a906a06c 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObjectServiceProvider.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObjectServiceProvider.cs
@@ -6,19 +6,34 @@ using System.Windows.Markup;
namespace ICSharpCode.WpfDesign.XamlDom
{
+ ///
+ /// A service provider that provides the IProvideValueTarget and IXamlTypeResolver services.
+ /// No other services (e.g. from the document's service provider) are offered.
+ ///
public class XamlObjectServiceProvider : IServiceProvider, IProvideValueTarget
{
+ ///
+ /// Creates a new XamlObjectServiceProvider instance.
+ ///
public XamlObjectServiceProvider(XamlObject obj)
{
+ if (obj == null)
+ throw new ArgumentNullException("obj");
XamlObject = obj;
Resolver = new XamlTypeResolverProvider(obj);
}
+ ///
+ /// Gets the XamlObject that owns this service provider (e.g. the XamlObject that represents a markup extension).
+ ///
public XamlObject XamlObject { get; private set; }
internal XamlTypeResolverProvider Resolver { get; private set; }
#region IServiceProvider Members
+ ///
+ /// Retrieves the service of the specified type.
+ ///
public object GetService(Type serviceType)
{
if (serviceType == typeof(IProvideValueTarget)) {
@@ -34,10 +49,16 @@ namespace ICSharpCode.WpfDesign.XamlDom
#region IProvideValueTarget Members
+ ///
+ /// Gets the target object (the DependencyObject instance on which a property should be set)
+ ///
public object TargetObject {
get { return XamlObject.ParentProperty.ParentObject.Instance; }
}
+ ///
+ /// Gets the target dependency property.
+ ///
public object TargetProperty {
get { return XamlObject.ParentProperty.DependencyProperty; }
}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs
index e6e6e9c0e0..3afceaa0ec 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs
@@ -53,7 +53,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
///
public static XamlDocument Parse(Stream stream, XamlParserSettings settings)
{
- if (stream == null)
+ if (stream == null)
throw new ArgumentNullException("stream");
return Parse(XmlReader.Create(stream), settings);
}
@@ -63,7 +63,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
///
public static XamlDocument Parse(TextReader reader, XamlParserSettings settings)
{
- if (reader == null)
+ if (reader == null)
throw new ArgumentNullException("reader");
return Parse(XmlReader.Create(reader), settings);
}
@@ -80,11 +80,11 @@ namespace ICSharpCode.WpfDesign.XamlDom
var errorSink = (IXamlErrorSink)settings.ServiceProvider.GetService(typeof(IXamlErrorSink));
try {
- doc.Load(reader);
- return Parse(doc, settings);
+ doc.Load(reader);
+ return Parse(doc, settings);
} catch (XmlException x) {
if (errorSink != null)
- errorSink.ReportError(x.Message, x.LineNumber, x.LinePosition);
+ errorSink.ReportError(x.Message, x.LineNumber, x.LinePosition);
}
return null;
@@ -93,6 +93,8 @@ namespace ICSharpCode.WpfDesign.XamlDom
///
/// Creates a XAML document from an existing XmlDocument.
///
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes",
+ Justification="We need to continue parsing, and the error is reported to the user.")]
internal static XamlDocument Parse(XmlDocument document, XamlParserSettings settings)
{
if (settings == null)
@@ -104,7 +106,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
p.errorSink = (IXamlErrorSink)settings.ServiceProvider.GetService(typeof(IXamlErrorSink));
p.document = new XamlDocument(document, settings);
- try {
+ try {
var root = p.ParseObject(document.DocumentElement);
p.document.ParseComplete(root);
} catch (Exception x) {
@@ -121,11 +123,6 @@ namespace ICSharpCode.WpfDesign.XamlDom
XamlParserSettings settings;
IXamlErrorSink errorSink;
- Type FindType(string namespaceUri, string localName)
- {
- return FindType(settings.TypeFinder, namespaceUri, localName);
- }
-
static Type FindType(XamlTypeFinder typeFinder, string namespaceUri, string localName)
{
Type elementType = typeFinder.GetType(namespaceUri, localName);
@@ -159,6 +156,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
currentXamlObject.HasErrors = true;
}
}
+ // TODO: what when there's no error sink? I think we should throw exception
}
XamlObject ParseObject(XmlElement element)
@@ -214,8 +212,8 @@ namespace ICSharpCode.WpfDesign.XamlDom
currentXamlObject = obj;
obj.ParentObject = parentXamlObject;
- if (parentXamlObject == null && obj.DependencyObject != null) {
- NameScope.SetNameScope(obj.DependencyObject, new NameScope());
+ if (parentXamlObject == null && obj.Instance is DependencyObject) {
+ NameScope.SetNameScope((DependencyObject)obj.Instance, new NameScope());
}
ISupportInitialize iSupportInitializeInstance = instance as ISupportInitialize;
@@ -348,6 +346,8 @@ namespace ICSharpCode.WpfDesign.XamlDom
}
}
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes",
+ Justification="We need to continue parsing, and the error is reported to the user.")]
XamlPropertyValue ParseValue(XmlNode childNode)
{
try {
@@ -466,13 +466,15 @@ namespace ICSharpCode.WpfDesign.XamlDom
propertyName = qualifiedName.Substring(pos + 1);
}
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes",
+ Justification="We need to continue parsing, and the error is reported to the user.")]
void ParseObjectAttribute(XamlObject obj, XmlAttribute attribute)
{
try {
ParseObjectAttribute(obj, attribute, true);
} catch (Exception x) {
ReportException(x, attribute);
- }
+ }
}
internal static void ParseObjectAttribute(XamlObject obj, XmlAttribute attribute, bool real)
@@ -481,18 +483,18 @@ namespace ICSharpCode.WpfDesign.XamlDom
XamlPropertyValue value = null;
var valueText = attribute.Value;
- if (valueText.StartsWith("{") && !valueText.StartsWith("{}")) {
+ if (valueText.StartsWith("{", StringComparison.Ordinal) && !valueText.StartsWith("{}", StringComparison.Ordinal)) {
var xamlObject = MarkupExtensionParser.Parse(valueText, obj, real ? attribute : null);
value = xamlObject;
} else {
- if (real)
+ if (real)
value = new XamlTextValue(obj.OwnerDocument, attribute);
else
value = new XamlTextValue(obj.OwnerDocument, valueText);
}
var property = new XamlProperty(obj, propertyInfo, value);
- obj.AddProperty(property);
+ obj.AddProperty(property);
}
static bool ObjectChildElementIsPropertyElement(XmlElement element)
@@ -562,8 +564,8 @@ namespace ICSharpCode.WpfDesign.XamlDom
internal static object CreateObjectFromAttributeText(string valueText, Type targetType, XamlObject scope)
{
- var converter =
- XamlNormalPropertyInfo.GetCustomTypeConverter(targetType) ??
+ var converter =
+ XamlNormalPropertyInfo.GetCustomTypeConverter(targetType) ??
TypeDescriptor.GetConverter(targetType);
return converter.ConvertFromInvariantString(
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlProperty.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlProperty.cs
index 7279ef28be..74adaeb084 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlProperty.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlProperty.cs
@@ -139,7 +139,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
///
public bool IsSet {
get { return propertyValue != null ||
- _propertyElement != null; // collection
+ _propertyElement != null; // collection
}
}
@@ -153,8 +153,10 @@ namespace ICSharpCode.WpfDesign.XamlDom
///
public event EventHandler ValueChanged;
- //When ME evaluated PropertyValue dosn't changed but ValueOnIstance does.
- public event EventHandler ValueOnIstanceChanged;
+ ///
+ /// Occurs when MarkupExtension evaluated PropertyValue dosn't changed but ValueOnInstance does.
+ ///
+ public event EventHandler ValueOnInstanceChanged;
void SetPropertyValue(XamlPropertyValue value)
{
@@ -164,7 +166,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
//}
bool wasSet = this.IsSet;
-
+
PossiblyNameChanged(propertyValue, value);
//reset expression
@@ -174,7 +176,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
ResetInternal();
- propertyValue = value;
+ propertyValue = value;
propertyValue.ParentProperty = this;
propertyValue.AddNodeTo(this);
UpdateValueOnInstance();
@@ -235,8 +237,8 @@ namespace ICSharpCode.WpfDesign.XamlDom
if (_propertyElement != null) {
_propertyElement.ParentNode.RemoveChild(_propertyElement);
_propertyElement = null;
- }
- }
+ }
+ }
XmlElement _propertyElement;
@@ -314,7 +316,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
name = PropertyName;
var element = ParentObject.XmlElement;
- if (element.GetPrefixOfNamespace(ns) == "") {
+ if (string.IsNullOrEmpty(element.GetPrefixOfNamespace(ns))) {
element.SetAttribute(name, value);
return element.GetAttributeNode(name);
} else {
@@ -334,8 +336,10 @@ namespace ICSharpCode.WpfDesign.XamlDom
var element = ParentObject.XmlElement;
string ns = ParentObject.OwnerDocument.GetNamespaceFor(PropertyTargetType);
var prefix = element.GetPrefixOfNamespace(ns);
- if (prefix == "") return name;
- return prefix + ":" + name;
+ if (string.IsNullOrEmpty(prefix))
+ return name;
+ else
+ return prefix + ":" + name;
}
///
@@ -371,15 +375,21 @@ namespace ICSharpCode.WpfDesign.XamlDom
}
set {
propertyInfo.SetValue(parentObject.Instance, value);
- if (ValueOnIstanceChanged != null)
- ValueOnIstanceChanged(this, EventArgs.Empty);
+ if (ValueOnInstanceChanged != null)
+ ValueOnInstanceChanged(this, EventArgs.Empty);
}
}
+ ///
+ /// Gets if this property is considered "advanced" and should be hidden by default in a property grid.
+ ///
public bool IsAdvanced {
get { return propertyInfo.IsAdvanced; }
}
+ ///
+ /// Gets the dependency property.
+ ///
public DependencyProperty DependencyProperty {
get {
return propertyInfo.DependencyProperty;
@@ -387,7 +397,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
}
void PossiblyNameChanged(XamlPropertyValue oldValue, XamlPropertyValue newValue)
- {
+ {
if (PropertyName == "Name" && ReturnType == typeof(string)) {
string oldName = null;
@@ -403,8 +413,8 @@ namespace ICSharpCode.WpfDesign.XamlDom
while (obj != null) {
var nameScope = obj.Instance as INameScope;
if (nameScope == null) {
- if (obj.DependencyObject != null)
- nameScope = NameScope.GetNameScope(obj.DependencyObject);
+ if (obj.Instance is DependencyObject)
+ nameScope = NameScope.GetNameScope((DependencyObject)obj.Instance);
}
if (nameScope != null) {
if (oldName != null) {
@@ -420,10 +430,6 @@ namespace ICSharpCode.WpfDesign.XamlDom
}
}
- void PossiblyMarkupExtensionChanged(XamlPropertyValue part)
- {
- }
-
/*public bool IsAttributeSyntax {
get {
return attribute != null;
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlTextValue.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlTextValue.cs
index e37734f5f4..9e9f632d6e 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlTextValue.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlTextValue.cs
@@ -60,7 +60,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
public string Text {
get {
if (attribute != null) {
- if (attribute.Value.StartsWith("{}"))
+ if (attribute.Value.StartsWith("{}", StringComparison.Ordinal))
return attribute.Value.Substring(2);
else
return attribute.Value;
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlTypeFinder.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlTypeFinder.cs
index bc9f589c13..ad61fc8733 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlTypeFinder.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlTypeFinder.cs
@@ -85,7 +85,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
throw new ArgumentNullException("localName");
XamlNamespace ns;
if (!namespaces.TryGetValue(xmlNamespace, out ns)) {
- if (xmlNamespace.StartsWith("clr-namespace:")) {
+ if (xmlNamespace.StartsWith("clr-namespace:", StringComparison.Ordinal)) {
ns = namespaces[xmlNamespace] = ParseNamespace(xmlNamespace);
} else {
return null;
@@ -116,7 +116,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
XamlNamespace ParseNamespace(string xmlNamespace)
{
string name = xmlNamespace;
- Debug.Assert(name.StartsWith("clr-namespace:"));
+ Debug.Assert(name.StartsWith("clr-namespace:", StringComparison.Ordinal));
name = name.Substring("clr-namespace:".Length);
string namespaceName, assembly;
int pos = name.IndexOf(';');
@@ -126,7 +126,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
} else {
namespaceName = name.Substring(0, pos);
name = name.Substring(pos + 1).Trim();
- if (!name.StartsWith("assembly=")) {
+ if (!name.StartsWith("assembly=", StringComparison.Ordinal)) {
throw new XamlLoadException("Expected: 'assembly='");
}
assembly = name.Substring("assembly=".Length);
@@ -227,7 +227,8 @@ namespace ICSharpCode.WpfDesign.XamlDom
{
internal static readonly XamlTypeFinder Instance;
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1810:InitializeReferenceTypeStaticFieldsInline")]
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1810:InitializeReferenceTypeStaticFieldsInline",
+ Justification = "We're using an explicit constructor to get it's lazy-loading semantics.")]
static WpfTypeFinder()
{
Instance = new XamlTypeFinder();
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignContext.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignContext.cs
index a831b42039..372044af0c 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignContext.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignContext.cs
@@ -42,6 +42,9 @@ namespace ICSharpCode.WpfDesign
get;
}
+ ///
+ /// Gets whether the design context can be saved.
+ ///
public abstract bool CanSave { get; }
///
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/EditorManager.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/EditorManager.cs
index 5bbcab340f..330f4d4d17 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/EditorManager.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/EditorManager.cs
@@ -19,6 +19,9 @@ namespace ICSharpCode.WpfDesign.PropertyGrid
// property full name => editor type
static Dictionary propertyEditors = new Dictionary();
+ ///
+ /// Creates a property editor for the specified
+ ///
public static FrameworkElement CreateEditor(DesignItemProperty property)
{
Type editorType;
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/Editors/ComboBoxEditor.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/Editors/ComboBoxEditor.xaml.cs
index 83f376f62c..bef62a96f1 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/Editors/ComboBoxEditor.xaml.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/Editors/ComboBoxEditor.xaml.cs
@@ -19,11 +19,15 @@ namespace ICSharpCode.WpfDesign.PropertyGrid.Editors
[TypeEditor(typeof(Enum))]
public partial class ComboBoxEditor
{
+ ///
+ /// Create a new ComboBoxEditor instance.
+ ///
public ComboBoxEditor()
{
InitializeComponent();
}
+ ///
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/Editors/TextBoxEditor.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/Editors/TextBoxEditor.xaml.cs
index 1f57be49b8..54fd974a86 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/Editors/TextBoxEditor.xaml.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/Editors/TextBoxEditor.xaml.cs
@@ -16,18 +16,21 @@ namespace ICSharpCode.WpfDesign.PropertyGrid.Editors
{
public partial class TextBoxEditor
{
+ ///
+ /// Creates a new TextBoxEditor instance.
+ ///
public TextBoxEditor()
{
InitializeComponent();
}
-
+
+ ///
protected override void OnKeyDown(KeyEventArgs e)
{
if (e.Key == Key.Enter) {
BindingOperations.GetBindingExpressionBase(this, TextProperty).UpdateSource();
SelectAll();
- }
- else if (e.Key == Key.Escape) {
+ } else if (e.Key == Key.Escape) {
BindingOperations.GetBindingExpression(this, TextProperty).UpdateTarget();
}
}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/SortedObservableCollection.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/SortedObservableCollection.cs
index 761b704b73..9197e0e87f 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/SortedObservableCollection.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/SortedObservableCollection.cs
@@ -6,8 +6,15 @@ using System.Collections.ObjectModel;
namespace ICSharpCode.WpfDesign.PropertyGrid
{
+ ///
+ /// Extends ObservableCollection{T} with an AddSorted method to insert items in a sorted collection.
+ ///
public class SortedObservableCollection : ObservableCollection
{
+ ///
+ /// Creates a new SortedObservableCollection instance.
+ ///
+ /// The function to select the sorting key.
public SortedObservableCollection(Func keySelector)
{
this.keySelector = keySelector;
@@ -17,6 +24,9 @@ namespace ICSharpCode.WpfDesign.PropertyGrid
Func keySelector;
IComparer comparer;
+ ///
+ /// Adds an item to a sorted collection.
+ ///
public void AddSorted(T item)
{
int i = 0;
@@ -34,9 +44,15 @@ namespace ICSharpCode.WpfDesign.PropertyGrid
Insert(i, item);
}
}
-
+
+ ///
+ /// A SortedObservableCollection{PropertyNode, string} that sorts by the PropertyNode's Name.
+ ///
public class PropertyNodeCollection : SortedObservableCollection
{
+ ///
+ /// Creates a new PropertyNodeCollection instance.
+ ///
public PropertyNodeCollection() : base(n => n.Name)
{
}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/TypeHelper.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/TypeHelper.cs
index 9b13426680..4a521b99b8 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/TypeHelper.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/TypeHelper.cs
@@ -6,8 +6,15 @@ using System.ComponentModel;
namespace ICSharpCode.WpfDesign.PropertyGrid
{
+ ///
+ /// Helper class with static methods to get the list of available properties/events.
+ ///
public static class TypeHelper
{
+ ///
+ /// Gets the available properties common to all input types.
+ ///
+ /// List of input types. The list must have at least one element.
public static IEnumerable GetCommonAvailableProperties(IEnumerable types)
{
foreach (var pd1 in GetAvailableProperties(types.First())) {
@@ -29,6 +36,9 @@ namespace ICSharpCode.WpfDesign.PropertyGrid
}
}
+ ///
+ /// Gets the available properties for the type.
+ ///
public static IEnumerable GetAvailableProperties(Type forType)
{
foreach (PropertyDescriptor p in TypeDescriptor.GetProperties(forType)) {
@@ -39,6 +49,9 @@ namespace ICSharpCode.WpfDesign.PropertyGrid
}
}
+ ///
+ /// Gets the available events for the type.
+ ///
public static IEnumerable GetAvailableEvents(Type forType)
{
foreach (EventDescriptor e in TypeDescriptor.GetEvents(forType)) {
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/ServiceContainer.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/ServiceContainer.cs
index 875902aeac..928567c8ec 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/ServiceContainer.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/ServiceContainer.cs
@@ -152,5 +152,15 @@ namespace ICSharpCode.WpfDesign
return GetServiceOrThrowException();
}
}
+
+ ///
+ /// Gets the .
+ /// Throws an exception if the service is not found.
+ ///
+ public IDesignPanel DesignPanel {
+ get {
+ return GetServiceOrThrowException();
+ }
+ }
}
}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Tools.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Tools.cs
index 3711aaf803..26c9734af2 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Tools.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Tools.cs
@@ -57,8 +57,6 @@ namespace ICSharpCode.WpfDesign
/// Is raised when the current tool changes.
///
event EventHandler CurrentToolChanged;
-
- IDesignPanel DesignPanel { get; }
}
///
diff --git a/src/Main/GlobalAssemblyInfo.template b/src/Main/GlobalAssemblyInfo.template
index f44700ea57..ff7d6ad732 100644
--- a/src/Main/GlobalAssemblyInfo.template
+++ b/src/Main/GlobalAssemblyInfo.template
@@ -14,6 +14,7 @@
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
+using System.Resources;
using System.Reflection;
[assembly: System.Runtime.InteropServices.ComVisible(false)]
@@ -21,6 +22,7 @@ using System.Reflection;
[assembly: AssemblyProduct("SharpDevelop")]
[assembly: AssemblyCopyright("2000-2008 AlphaSierraPapa")]
[assembly: AssemblyVersion(RevisionClass.FullVersion)]
+[assembly: NeutralResourcesLanguage("en-US")]
internal static class RevisionClass
{