From 08d28baa641f60a9bd6b9f4a6557ed2b70a54bd6 Mon Sep 17 00:00:00 2001 From: gumme Date: Tue, 24 Feb 2015 17:30:59 +0100 Subject: [PATCH 1/8] Fixed simple warnings like redundant using directives, unused variables and added some missing xml comments. --- .../WpfDesign.Designer/Project/DesignPanel.cs | 1 - .../Extensions/PointTrackerPlacementSupport.cs | 1 - .../WpfDesign.XamlDom/Project/XamlObject.cs | 4 ++++ .../WpfDesign.XamlDom/Project/XamlParser.cs | 2 +- .../WpfDesign.XamlDom/Project/XamlProperty.cs | 8 ++++++++ .../WpfDesign.XamlDom/Project/XamlTypeFinder.cs | 3 +++ .../WpfDesign/WpfDesign/Project/DesignItem.cs | 6 ++++++ .../WpfDesign/Project/DrawItemExtension.cs | 13 +++++++++++++ .../WpfDesign/Project/Extensions/Extension.cs | 13 +++++++++++++ .../Project/Extensions/ExtensionAttribute.cs | 6 ++++-- .../WpfDesign/Project/Extensions/ExtensionServer.cs | 4 ++-- 11 files changed, 54 insertions(+), 7 deletions(-) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs index 907287e1be..d038b14dfb 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs @@ -35,7 +35,6 @@ using ICSharpCode.WpfDesign.Designer.Controls; using ICSharpCode.WpfDesign.UIExtensions; using ICSharpCode.WpfDesign.Designer.Xaml; using ICSharpCode.WpfDesign.Extensions; -using System.Linq; namespace ICSharpCode.WpfDesign.Designer { diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PointTrackerPlacementSupport.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PointTrackerPlacementSupport.cs index 6065dc2479..7df22d791d 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PointTrackerPlacementSupport.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PointTrackerPlacementSupport.cs @@ -47,7 +47,6 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions public override void Arrange(AdornerPanel panel, UIElement adorner, Size adornedElementSize) { Point p = new Point(0, 0); - double distance = 0; if (shape is Line) { var s = shape as Line; diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs index 6ef01edd85..8754386444 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs @@ -206,6 +206,10 @@ namespace ICSharpCode.WpfDesign.XamlDom } private XamlType _systemXamlTypeForProperty = null; + + /// + /// Gets a representing the . + /// public XamlType SystemXamlTypeForProperty { get diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs index ab190e58ba..26af1771dc 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs @@ -607,7 +607,7 @@ namespace ICSharpCode.WpfDesign.XamlDom { propertyInfo = FindProperty(elementInstance, propertyType, propertyName); } - catch (Exception ex) + catch (Exception) { } if (propertyInfo != null) return propertyInfo; diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlProperty.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlProperty.cs index 6bb71f3e5d..34ad177489 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlProperty.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlProperty.cs @@ -250,6 +250,10 @@ namespace ICSharpCode.WpfDesign.XamlDom } private XamlMember _systemXamlMemberForProperty = null; + + /// + /// Gets a representing the property. + /// public XamlMember SystemXamlMemberForProperty { get @@ -261,6 +265,10 @@ namespace ICSharpCode.WpfDesign.XamlDom } private XamlType _systemXamlTypeForProperty = null; + + /// + /// Gets a representing the type the property is declared on. + /// public XamlType SystemXamlTypeForProperty { get diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlTypeFinder.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlTypeFinder.cs index 3373b4772d..bb28216335 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlTypeFinder.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlTypeFinder.cs @@ -304,6 +304,9 @@ namespace ICSharpCode.WpfDesign.XamlDom return WpfTypeFinder.Instance.Clone(); } + /// + /// Converts the specified to local. + /// public virtual Uri ConvertUriToLocalUri(Uri uri) { return uri; diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignItem.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignItem.cs index b47a73daf6..19b0426528 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignItem.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignItem.cs @@ -199,6 +199,9 @@ namespace ICSharpCode.WpfDesign } } + /// + /// Reapplies all extensions. + /// public void ReapplyAllExtensions() { var manager = this.Services.GetService(); @@ -293,6 +296,9 @@ namespace ICSharpCode.WpfDesign /// public abstract DesignItem Clone(); + /// + /// Gets a that represents all transforms applied to the item's view. + /// public Transform GetCompleteAppliedTransformationToView() { var retVal = new TransformGroup(); diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DrawItemExtension.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DrawItemExtension.cs index a97dffafaa..5663904e1c 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DrawItemExtension.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DrawItemExtension.cs @@ -29,7 +29,20 @@ namespace ICSharpCode.WpfDesign /// public interface IDrawItemExtension { + /// + /// Returns if the specified type can be drawn. + /// + /// The type to check. + /// True if the specified type can be drawn, otherwise false. bool CanItemBeDrawn(Type createItemType); + + /// + /// Starts to draw. + /// + /// The item. + /// The item type. + /// The design panel to draw on. + /// The argument that initiated the draw operation. void StartDrawItem(DesignItem clickedOn, Type createItemType, IDesignPanel panel, MouseEventArgs e); } } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/Extension.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/Extension.cs index 6c0dafc0d5..caf4670a82 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/Extension.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/Extension.cs @@ -33,16 +33,29 @@ namespace ICSharpCode.WpfDesign.Extensions /// public abstract class Extension { + /// + /// Gets the value of the attached property for an object. + /// + /// The object from which the property value is read. + /// The object's property value. public static string GetDisabledExtensions(DependencyObject obj) { return (string)obj.GetValue(DisabledExtensionsProperty); } + /// + /// Sets the value of the attached property for an object. + /// + /// The object to which the attached property is written. + /// The value to set. public static void SetDisabledExtensions(DependencyObject obj, string value) { obj.SetValue(DisabledExtensionsProperty, value); } + /// + /// Gets or sets a semicolon-separated list with extension names that is disabled for a component's view. + /// public static readonly DependencyProperty DisabledExtensionsProperty = DependencyProperty.RegisterAttached("DisabledExtensions", typeof(string), typeof(Extension), new PropertyMetadata(null)); diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionAttribute.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionAttribute.cs index 2f321ae680..72768e7385 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionAttribute.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionAttribute.cs @@ -26,7 +26,9 @@ namespace ICSharpCode.WpfDesign.Extensions [AttributeUsage(AttributeTargets.Class, AllowMultiple=false, Inherited=false)] public sealed class ExtensionAttribute : Attribute { - //The Order in wich the Extensions are used - public int Order { get; set; } + /// + /// Gets or sets the Order in wich the extensions are used. + /// + public int Order { get; set; } } } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionServer.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionServer.cs index 6628bb1607..8169ea3247 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionServer.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionServer.cs @@ -74,8 +74,8 @@ namespace ICSharpCode.WpfDesign.Extensions /// public abstract bool ShouldApplyExtensions(DesignItem extendedItem); - // - /// Set if the Extension Server should be reaplied (For multiple Selection extension Server for Example!) + /// + /// Returns if the Extension Server should be reapplied (for multiple selection extension server for example). /// public virtual bool ShouldBeReApplied() { From 0999a0dce5b9629fbadf14bc559807d36e1becff Mon Sep 17 00:00:00 2001 From: gumme Date: Tue, 24 Feb 2015 17:32:59 +0100 Subject: [PATCH 2/8] Fixed comparison bug and removed unreachable code. This removed two warnings. --- .../WpfDesign/WpfDesign.XamlDom/Project/CollectionSupport.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/CollectionSupport.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/CollectionSupport.cs index 42f73d18d8..375a1c939c 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/CollectionSupport.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/CollectionSupport.cs @@ -86,7 +86,7 @@ namespace ICSharpCode.WpfDesign.XamlDom } else if (collectionInstance is IDictionary) { object val = newElement.GetValueFor(null); object key = newElement is XamlObject ? ((XamlObject)newElement).GetXamlAttribute("Key") : null; - if (key == null || key == "") + if (key == null || (key as string) == "") { if (val is Style) key = ((Style)val).TargetType; @@ -134,8 +134,6 @@ namespace ICSharpCode.WpfDesign.XamlDom } catch (MissingMethodException) { return false; } - - return true; } static readonly Type[] RemoveAtParameters = { typeof(int) }; From 9b6df2e18b2fcbbb6ea5ac0dd88b28b2b022979e Mon Sep 17 00:00:00 2001 From: gumme Date: Tue, 24 Feb 2015 17:36:45 +0100 Subject: [PATCH 3/8] Disable warnings where appropriate. --- .../WpfDesign/WpfDesign.XamlDom/Project/TemplateHelper.cs | 2 ++ .../WpfDesign.XamlDom/Project/XamlObjectServiceProvider.cs | 6 ++++++ .../DummyValueInsteadOfNullTypeDescriptionProvider.cs | 5 +++++ .../Project/Extensions/SelectionExtensionServer.cs | 2 ++ .../WpfDesign/WpfDesign/Project/UIExtensions/UIHelpers.cs | 7 +++++++ 5 files changed, 22 insertions(+) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/TemplateHelper.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/TemplateHelper.cs index 6624bb4ec1..c588dd14cd 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/TemplateHelper.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/TemplateHelper.cs @@ -31,6 +31,7 @@ using System.Xml.XPath; namespace ICSharpCode.WpfDesign.XamlDom { +#pragma warning disable 1591 // Primary internal use, disable Warning CS1591: Missing XML comment for publicly visible type or member public static class TemplateHelper { public static FrameworkTemplate GetFrameworkTemplate(XmlElement xmlElement, XamlObject parentObject) @@ -135,4 +136,5 @@ namespace ICSharpCode.WpfDesign.XamlDom return stream; } } +#pragma warning restore 1591 } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObjectServiceProvider.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObjectServiceProvider.cs index e262624152..e349fa4632 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObjectServiceProvider.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObjectServiceProvider.cs @@ -124,6 +124,8 @@ namespace ICSharpCode.WpfDesign.XamlDom } #endregion + +#pragma warning disable 1591 // Implemented interfaces, disable Warning CS1591: Missing XML comment for publicly visible type or member #region IUriContext implementation @@ -255,8 +257,12 @@ namespace ICSharpCode.WpfDesign.XamlDom get { return false; } } +#pragma warning disable 0067 // Required by interface implementation, disable Warning CS0067: The event is never used public event EventHandler OnNameScopeInitializationComplete; +#pragma warning restore 0067 #endregion + +#pragma warning restore 1591 } } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DummyValueInsteadOfNullTypeDescriptionProvider.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DummyValueInsteadOfNullTypeDescriptionProvider.cs index 2834cabe6b..799e2f576a 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DummyValueInsteadOfNullTypeDescriptionProvider.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DummyValueInsteadOfNullTypeDescriptionProvider.cs @@ -35,6 +35,9 @@ namespace ICSharpCode.WpfDesign readonly string _propertyName; readonly object _dummyValue; + /// + /// Initializes a new instance of . + /// public DummyValueInsteadOfNullTypeDescriptionProvider(TypeDescriptionProvider existingProvider, string propertyName, object dummyValue) : base(existingProvider) @@ -43,10 +46,12 @@ namespace ICSharpCode.WpfDesign this._dummyValue = dummyValue; } +#pragma warning disable 1591 // Override, disable Warning CS1591: Missing XML comment for publicly visible type or member public override ICustomTypeDescriptor GetTypeDescriptor(Type objectType, object instance) { return new ShadowTypeDescriptor(this, base.GetTypeDescriptor(objectType, instance)); } +#pragma warning restore 1591 sealed class ShadowTypeDescriptor : CustomTypeDescriptor { diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/SelectionExtensionServer.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/SelectionExtensionServer.cs index 3a9011716d..40e7126884 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/SelectionExtensionServer.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/SelectionExtensionServer.cs @@ -121,10 +121,12 @@ namespace ICSharpCode.WpfDesign.Extensions ReapplyExtensions(this.Services.Selection.SelectedItems); } +#pragma warning disable 1591 // Override, disable Warning CS1591: Missing XML comment for publicly visible type or member public override bool ShouldBeReApplied() { return true; } +#pragma warning restore 1591 /// /// Gets if the item is in the secondary selection. diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/UIExtensions/UIHelpers.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/UIExtensions/UIHelpers.cs index eaffed93ae..d571bcde42 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/UIExtensions/UIHelpers.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/UIExtensions/UIHelpers.cs @@ -25,8 +25,13 @@ using System.Windows.Media; namespace ICSharpCode.WpfDesign.UIExtensions { + /// + /// Contains helper methods for UI. + /// public static class UIHelpers { +#pragma warning disable 1591 // Primary internal use, disable Warning CS1591: Missing XML comment for publicly visible type or member + public static DependencyObject GetParentObject(this DependencyObject child, bool searchCompleteVisualTree) { if (child == null) return null; @@ -119,5 +124,7 @@ namespace ICSharpCode.WpfDesign.UIExtensions } return foundChild; } + +#pragma warning restore 1591 } } From e322e41fdfaa65587def987758ed30b9140b927a Mon Sep 17 00:00:00 2001 From: gumme Date: Tue, 24 Feb 2015 17:45:28 +0100 Subject: [PATCH 4/8] Added new keyword to indicate that hiding was intended and remove warning. --- .../Project/Extensions/DrawPolyLineExtension.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DrawPolyLineExtension.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DrawPolyLineExtension.cs index 7569ece5a4..d43e250c62 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DrawPolyLineExtension.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DrawPolyLineExtension.cs @@ -82,7 +82,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions { private ChangeGroup changeGroup; private DesignItem newLine; - private Point startPoint; + private new Point startPoint; public DrawPolylineMouseGesture(DesignItem newLine, IInputElement relativeTo, ChangeGroup changeGroup) { From d87e0a64d9b7eda4f28089b09865a68a1edeb63e Mon Sep 17 00:00:00 2001 From: gumme Date: Tue, 24 Feb 2015 17:49:07 +0100 Subject: [PATCH 5/8] Removed new keyword, hiding not needed because its an interface implementation. Fixed indentation. --- .../PartialPanelSelectionHandler.cs | 158 +++++++++--------- 1 file changed, 81 insertions(+), 77 deletions(-) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PartialPanelSelectionHandler.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PartialPanelSelectionHandler.cs index 5c03df06a3..c108e6f760 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PartialPanelSelectionHandler.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PartialPanelSelectionHandler.cs @@ -32,87 +32,91 @@ using ICSharpCode.WpfDesign.Extensions; namespace ICSharpCode.WpfDesign.Designer.Extensions { public class PartialPanelSelectionHandler : BehaviorExtension, IHandlePointerToolMouseDown - { - protected override void OnInitialized() - { - base.OnInitialized(); - this.ExtendedItem.AddBehavior(typeof(IHandlePointerToolMouseDown), this); - } + { + protected override void OnInitialized() + { + base.OnInitialized(); + this.ExtendedItem.AddBehavior(typeof(IHandlePointerToolMouseDown), this); + } + + #region IHandlePointerToolMouseDown - public new void HandleSelectionMouseDown(IDesignPanel designPanel, MouseButtonEventArgs e, DesignPanelHitTestResult result) - { - if (e.ChangedButton == MouseButton.Left && MouseGestureBase.IsOnlyButtonPressed(e, MouseButton.Left)) - { - e.Handled = true; - new PartialRangeSelectionGesture(result.ModelHit).Start(designPanel, e); - } - } - } + public void HandleSelectionMouseDown(IDesignPanel designPanel, MouseButtonEventArgs e, DesignPanelHitTestResult result) + { + if (e.ChangedButton == MouseButton.Left && MouseGestureBase.IsOnlyButtonPressed(e, MouseButton.Left)) + { + e.Handled = true; + new PartialRangeSelectionGesture(result.ModelHit).Start(designPanel, e); + } + } + + #endregion + } - /// - /// - /// - internal class PartialRangeSelectionGesture : RangeSelectionGesture - { - public PartialRangeSelectionGesture(DesignItem container) - : base(container) - { - } + /// + /// + /// + internal class PartialRangeSelectionGesture : RangeSelectionGesture + { + public PartialRangeSelectionGesture(DesignItem container) + : base(container) + { + } - protected override ICollection GetChildDesignItemsInContainer(Geometry geometry) - { - HashSet resultItems = new HashSet(); - ViewService viewService = container.Services.View; + protected override ICollection GetChildDesignItemsInContainer(Geometry geometry) + { + HashSet resultItems = new HashSet(); + ViewService viewService = container.Services.View; - HitTestFilterCallback filterCallback = delegate(DependencyObject potentialHitTestTarget) - { - FrameworkElement element = potentialHitTestTarget as FrameworkElement; - if (element != null) - { - // ensure we are able to select elements with width/height=0 - if (element.ActualWidth == 0 || element.ActualHeight == 0) - { - DependencyObject tmp = element; - DesignItem model = null; - while (tmp != null) - { - model = viewService.GetModel(tmp); - if (model != null) break; - tmp = VisualTreeHelper.GetParent(tmp); - } - if (model != container) - { - resultItems.Add(model); - return HitTestFilterBehavior.ContinueSkipChildren; - } - } - } - return HitTestFilterBehavior.Continue; - }; + HitTestFilterCallback filterCallback = delegate(DependencyObject potentialHitTestTarget) + { + FrameworkElement element = potentialHitTestTarget as FrameworkElement; + if (element != null) + { + // ensure we are able to select elements with width/height=0 + if (element.ActualWidth == 0 || element.ActualHeight == 0) + { + DependencyObject tmp = element; + DesignItem model = null; + while (tmp != null) + { + model = viewService.GetModel(tmp); + if (model != null) break; + tmp = VisualTreeHelper.GetParent(tmp); + } + if (model != container) + { + resultItems.Add(model); + return HitTestFilterBehavior.ContinueSkipChildren; + } + } + } + return HitTestFilterBehavior.Continue; + }; - HitTestResultCallback resultCallback = delegate(HitTestResult result) - { - if (((GeometryHitTestResult)result).IntersectionDetail == IntersectionDetail.FullyInside || (Mouse.RightButton== MouseButtonState.Pressed && ((GeometryHitTestResult)result).IntersectionDetail == IntersectionDetail.Intersects)) - { - // find the model for the visual contained in the selection area - DependencyObject tmp = result.VisualHit; - DesignItem model = null; - while (tmp != null) - { - model = viewService.GetModel(tmp); - if (model != null) break; - tmp = VisualTreeHelper.GetParent(tmp); - } - if (model != container) - { - resultItems.Add(model); - } - } - return HitTestResultBehavior.Continue; - }; + HitTestResultCallback resultCallback = delegate(HitTestResult result) + { + if (((GeometryHitTestResult)result).IntersectionDetail == IntersectionDetail.FullyInside || (Mouse.RightButton== MouseButtonState.Pressed && ((GeometryHitTestResult)result).IntersectionDetail == IntersectionDetail.Intersects)) + { + // find the model for the visual contained in the selection area + DependencyObject tmp = result.VisualHit; + DesignItem model = null; + while (tmp != null) + { + model = viewService.GetModel(tmp); + if (model != null) break; + tmp = VisualTreeHelper.GetParent(tmp); + } + if (model != container) + { + resultItems.Add(model); + } + } + return HitTestResultBehavior.Continue; + }; - VisualTreeHelper.HitTest(container.View, filterCallback, resultCallback, new GeometryHitTestParameters(geometry)); - return resultItems; - } - } + VisualTreeHelper.HitTest(container.View, filterCallback, resultCallback, new GeometryHitTestParameters(geometry)); + return resultItems; + } + } } From 5c1c0ff0623867d8f2c2dfe054d657c1a02759e8 Mon Sep 17 00:00:00 2001 From: gumme Date: Tue, 24 Feb 2015 17:57:32 +0100 Subject: [PATCH 6/8] Removed null-check, this removed warning that value can never be null. --- .../WpfDesign.Designer/Project/OutlineView/OutlineNodeBase.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNodeBase.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNodeBase.cs index bd0df157fa..a2eaf764ed 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNodeBase.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNodeBase.cs @@ -38,7 +38,7 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView } catch (Exception) { } - if (hidden != null && (bool)hidden) { + if (hidden) { _isDesignTimeVisible = false; ((FrameworkElement)DesignItem.Component).Visibility = Visibility.Hidden; } @@ -50,7 +50,7 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView } catch (Exception) { } - if (locked != null && (bool)locked) { + if (locked) { _isDesignTimeLocked = true; } From 5a12c7c1d1788b83e7c48f7522fb281c2efc2e40 Mon Sep 17 00:00:00 2001 From: gumme Date: Tue, 24 Feb 2015 18:02:05 +0100 Subject: [PATCH 7/8] Disabled warning "field is assigned but its value is never used" because we want to keep it for future use. --- .../Project/Extensions/PathHandlerExtension.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PathHandlerExtension.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PathHandlerExtension.cs index 7cdabd4f73..5a24f6fb0f 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PathHandlerExtension.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/PathHandlerExtension.cs @@ -160,7 +160,9 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions } private readonly Dictionary _selectedThumbs = new Dictionary(); +#pragma warning disable 0414 // For future use, disable Warning CS0414: The field is assigned but its value is never used private bool _isDragging; +#pragma warning restore 0414 ZoomControl _zoom; private List pathPoints = null; From 096ecc18e10a1bccb0a4efa86bce7416988e8d74 Mon Sep 17 00:00:00 2001 From: gumme Date: Fri, 27 Feb 2015 14:18:30 +0100 Subject: [PATCH 8/8] Replaced pragmas for warning 1591 with either or proper documentation. --- .../Project/TemplateHelper.cs | 11 +++++-- .../Project/XamlObjectServiceProvider.cs | 20 +++++++++---- ...lueInsteadOfNullTypeDescriptionProvider.cs | 3 +- .../Extensions/SelectionExtensionServer.cs | 3 +- .../Project/UIExtensions/UIHelpers.cs | 30 ++++++++++++++++--- 5 files changed, 52 insertions(+), 15 deletions(-) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/TemplateHelper.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/TemplateHelper.cs index c588dd14cd..6c6f2a6537 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/TemplateHelper.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/TemplateHelper.cs @@ -31,9 +31,17 @@ using System.Xml.XPath; namespace ICSharpCode.WpfDesign.XamlDom { -#pragma warning disable 1591 // Primary internal use, disable Warning CS1591: Missing XML comment for publicly visible type or member + /// + /// Contains template related helper methods. + /// public static class TemplateHelper { + /// + /// Gets a based on the specified parameters. + /// + /// The xml element to get template xaml from. + /// The to use as source for resources and contextual information. + /// A based on the specified parameters. public static FrameworkTemplate GetFrameworkTemplate(XmlElement xmlElement, XamlObject parentObject) { @@ -136,5 +144,4 @@ namespace ICSharpCode.WpfDesign.XamlDom return stream; } } -#pragma warning restore 1591 } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObjectServiceProvider.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObjectServiceProvider.cs index e349fa4632..c66bdc25fa 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObjectServiceProvider.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObjectServiceProvider.cs @@ -125,10 +125,9 @@ namespace ICSharpCode.WpfDesign.XamlDom #endregion -#pragma warning disable 1591 // Implemented interfaces, disable Warning CS1591: Missing XML comment for publicly visible type or member - #region IUriContext implementation - + + /// public virtual Uri BaseUri { get { return new Uri("pack://application:,,,/"); @@ -153,6 +152,7 @@ namespace ICSharpCode.WpfDesign.XamlDom // } //} + /// public XamlSchemaContext SchemaContext { get @@ -165,16 +165,19 @@ namespace ICSharpCode.WpfDesign.XamlDom #region IAmbientProvider Members + /// public AmbientPropertyValue GetFirstAmbientValue(IEnumerable ceilingTypes, params XamlMember[] properties) { return GetAllAmbientValues(ceilingTypes, properties).FirstOrDefault(); } + /// public object GetFirstAmbientValue(params XamlType[] types) { return null; } + /// public IEnumerable GetAllAmbientValues(IEnumerable ceilingTypes, params XamlMember[] properties) { var obj = this.XamlObject.ParentObject; @@ -196,11 +199,13 @@ namespace ICSharpCode.WpfDesign.XamlDom } } + /// public IEnumerable GetAllAmbientValues(params XamlType[] types) { return new List(); } + /// public IEnumerable GetAllAmbientValues(IEnumerable ceilingTypes, bool searchLiveStackOnly, IEnumerable types, params XamlMember[] properties) { return new List(); @@ -210,6 +215,7 @@ namespace ICSharpCode.WpfDesign.XamlDom #region IXamlNameResolver + /// public object Resolve(string name) { INameScope ns = null; @@ -230,6 +236,7 @@ namespace ICSharpCode.WpfDesign.XamlDom return null; } + /// public object Resolve(string name, out bool isFullyInitialized) { var ret = Resolve(name); @@ -237,32 +244,35 @@ namespace ICSharpCode.WpfDesign.XamlDom return ret; } + /// public object GetFixupToken(IEnumerable names) { return null; } + /// public object GetFixupToken(IEnumerable names, bool canAssignDirectly) { return null; } + /// public IEnumerable> GetAllNamesAndValuesInScope() { return null; } + /// public bool IsFixupTokenAvailable { get { return false; } } #pragma warning disable 0067 // Required by interface implementation, disable Warning CS0067: The event is never used + /// public event EventHandler OnNameScopeInitializationComplete; #pragma warning restore 0067 #endregion - -#pragma warning restore 1591 } } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DummyValueInsteadOfNullTypeDescriptionProvider.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DummyValueInsteadOfNullTypeDescriptionProvider.cs index 799e2f576a..f921053b22 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DummyValueInsteadOfNullTypeDescriptionProvider.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DummyValueInsteadOfNullTypeDescriptionProvider.cs @@ -46,12 +46,11 @@ namespace ICSharpCode.WpfDesign this._dummyValue = dummyValue; } -#pragma warning disable 1591 // Override, disable Warning CS1591: Missing XML comment for publicly visible type or member + /// public override ICustomTypeDescriptor GetTypeDescriptor(Type objectType, object instance) { return new ShadowTypeDescriptor(this, base.GetTypeDescriptor(objectType, instance)); } -#pragma warning restore 1591 sealed class ShadowTypeDescriptor : CustomTypeDescriptor { diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/SelectionExtensionServer.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/SelectionExtensionServer.cs index 40e7126884..602a107c82 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/SelectionExtensionServer.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/SelectionExtensionServer.cs @@ -121,12 +121,11 @@ namespace ICSharpCode.WpfDesign.Extensions ReapplyExtensions(this.Services.Selection.SelectedItems); } -#pragma warning disable 1591 // Override, disable Warning CS1591: Missing XML comment for publicly visible type or member + /// public override bool ShouldBeReApplied() { return true; } -#pragma warning restore 1591 /// /// Gets if the item is in the secondary selection. diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/UIExtensions/UIHelpers.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/UIExtensions/UIHelpers.cs index d571bcde42..fe11952222 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/UIExtensions/UIHelpers.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/UIExtensions/UIHelpers.cs @@ -30,8 +30,12 @@ namespace ICSharpCode.WpfDesign.UIExtensions /// public static class UIHelpers { -#pragma warning disable 1591 // Primary internal use, disable Warning CS1591: Missing XML comment for publicly visible type or member - + /// + /// Gets the parent. Which tree the parent is retrieved from depends on the parameters. + /// + /// The child to get parent for. + /// If true the parent in the visual tree is returned, if false the parent may be retrieved from another tree depending on the child type. + /// The parent element, and depending on the parameters its retrieved from either visual tree, logical tree or a tree not strictly speaking either the logical tree or the visual tree. public static DependencyObject GetParentObject(this DependencyObject child, bool searchCompleteVisualTree) { if (child == null) return null; @@ -58,6 +62,15 @@ namespace ICSharpCode.WpfDesign.UIExtensions return VisualTreeHelper.GetParent(child); } + /// + /// Gets first parent element of the specified type. Which tree the parent is retrieved from depends on the parameters. + /// + /// The child to get parent for. + /// If true the parent in the visual tree is returned, if false the parent may be retrieved from another tree depending on the child type. + /// + /// The first parent element of the specified type, and depending on the parameters its retrieved from either visual tree, logical tree or a tree not strictly speaking either the logical tree or the visual tree. + /// null is returned if no parent of the specified type is found. + /// public static T TryFindParent(this DependencyObject child, bool searchCompleteVisualTree = false) where T : DependencyObject { DependencyObject parentObject = GetParentObject(child, searchCompleteVisualTree); @@ -73,6 +86,11 @@ namespace ICSharpCode.WpfDesign.UIExtensions return TryFindParent(parentObject); } + /// + /// Returns the first child of the specified type found in the visual tree. + /// + /// The parent element where the search is started. + /// The first child of the specified type found in the visual tree, or null if no parent of the specified type is found. public static T TryFindChild(this DependencyObject parent) where T : DependencyObject { for (int i = 0; i < VisualTreeHelper.GetChildrenCount(parent); i++) @@ -92,6 +110,12 @@ namespace ICSharpCode.WpfDesign.UIExtensions return null; } + /// + /// Returns the first child of the specified type and with the specified name found in the visual tree. + /// + /// The parent element where the search is started. + /// The name of the child element to find, or an empty string or null to only look at the type. + /// The first child that matches the specified type and child name, or null if no match is found. public static T TryFindChild(this DependencyObject parent, string childName) where T : DependencyObject { if (parent == null) return null; @@ -124,7 +148,5 @@ namespace ICSharpCode.WpfDesign.UIExtensions } return foundChild; } - -#pragma warning restore 1591 } }