Browse Source

Fixed some FxCop warnings in WPF designer.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5479 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Daniel Grunwald 16 years ago
parent
commit
947f9ae4db
  1. 2
      clean.bat
  2. 2
      debugbuild.bat
  3. 2
      releasebuild.bat
  4. 14
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfViewContent.cs
  5. 4
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/CallExtension.cs
  6. 24
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Configuration/CodeAnalysisDictionary.xml
  7. 3
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/AdornerLayer.cs
  8. 1
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/EnumBar.xaml.cs
  9. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/GridAdorner.cs
  10. 9
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/WindowClone.cs
  11. 6
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ZoomControl.cs
  12. 8
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Converters.cs
  13. 9
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignSurface.xaml.cs
  14. 27
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DragDropExceptionHandler.cs
  15. 18
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ExtensionMethods.cs
  16. 6
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/CreateComponentTool.cs
  17. 5
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/UndoService.cs
  18. 9
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj
  19. 6
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlComponentService.cs
  20. 24
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Adorners/AdornerPanel.cs
  21. 1
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/ChangeGroup.cs
  22. 24
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Configuration/CodeAnalysisDictionary.xml
  23. 10
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignItem.cs
  24. 4
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/LogicalExtensionServers.cs
  25. 1
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementOperation.cs
  26. 11
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/PropertyNode.cs
  27. 10
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/SortedObservableCollection.cs
  28. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Services.cs
  29. 3
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/WpfDesign.csproj

2
clean.bat

@ -1,2 +1,2 @@
%windir%\microsoft.net\framework\v4.0.21006\msbuild /m /t:clean SharpDevelop.sln "/p:FSharpBuildTasksPath=%CD%\src\AddIns\BackendBindings\FSharp\RequiredLibraries" "/p:Platform=Any CPU" %windir%\microsoft.net\framework\v4.0.21006\msbuild /m SharpDevelop.sln /t:clean "/p:Platform=Any CPU"
@IF %ERRORLEVEL% NEQ 0 PAUSE @IF %ERRORLEVEL% NEQ 0 PAUSE

2
debugbuild.bat

@ -1,4 +1,4 @@
%windir%\microsoft.net\framework\v4.0.21006\msbuild /m SharpDevelop.sln /p:Configuration=Debug "/p:FSharpBuildTasksPath=%CD%\src\AddIns\BackendBindings\FSharp\RequiredLibraries" "/p:Platform=Any CPU" %windir%\microsoft.net\framework\v4.0.21006\msbuild /m SharpDevelop.sln /p:Configuration=Debug "/p:Platform=Any CPU"
@IF %ERRORLEVEL% NEQ 0 GOTO err @IF %ERRORLEVEL% NEQ 0 GOTO err
@exit /B 0 @exit /B 0
:err :err

2
releasebuild.bat

@ -1,4 +1,4 @@
%windir%\microsoft.net\framework\v4.0.21006\msbuild /m /property:Configuration=Release SharpDevelop.sln "/p:FSharpBuildTasksPath=%CD%\src\AddIns\BackendBindings\FSharp\RequiredLibraries" "/p:Platform=Any CPU" %windir%\microsoft.net\framework\v4.0.21006\msbuild /m SharpDevelop.sln /p:Configuration=Release "/p:Platform=Any CPU"
@IF %ERRORLEVEL% NEQ 0 GOTO err @IF %ERRORLEVEL% NEQ 0 GOTO err
@exit /B 0 @exit /B 0
:err :err

14
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfViewContent.cs

@ -5,24 +5,26 @@
// <version>$Revision$</version> // <version>$Revision$</version>
// </file> // </file>
using ICSharpCode.WpfDesign.Designer.OutlineView;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Text; using System.Text;
using System.Threading;
using System.Windows.Forms; using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Markup; using System.Windows.Markup;
using System.Xml; using System.Xml;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor; using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.WpfDesign.Designer; using ICSharpCode.WpfDesign.Designer;
using ICSharpCode.WpfDesign.Designer.OutlineView;
using ICSharpCode.WpfDesign.Designer.PropertyGrid; using ICSharpCode.WpfDesign.Designer.PropertyGrid;
using ICSharpCode.WpfDesign.Designer.Services; using ICSharpCode.WpfDesign.Designer.Services;
using ICSharpCode.WpfDesign.Designer.Xaml; using ICSharpCode.WpfDesign.Designer.Xaml;
using ICSharpCode.WpfDesign.PropertyGrid; using ICSharpCode.WpfDesign.PropertyGrid;
using System.Windows.Input;
namespace ICSharpCode.WpfDesign.AddIn namespace ICSharpCode.WpfDesign.AddIn
{ {
@ -39,6 +41,13 @@ namespace ICSharpCode.WpfDesign.AddIn
this.IsActiveViewContentChanged += OnIsActiveViewContentChanged; this.IsActiveViewContentChanged += OnIsActiveViewContentChanged;
} }
static WpfViewContent()
{
DragDropExceptionHandler.UnhandledException += delegate(object sender, ThreadExceptionEventArgs e) {
ICSharpCode.Core.MessageService.ShowException(e.Exception);
};
}
DesignSurface designer; DesignSurface designer;
List<Task> tasks = new List<Task>(); List<Task> tasks = new List<Task>();
@ -56,7 +65,6 @@ namespace ICSharpCode.WpfDesign.AddIn
if (designer == null) { if (designer == null) {
// initialize designer on first load // initialize designer on first load
DragDropExceptionHandler.HandleException = ICSharpCode.Core.MessageService.ShowException;
designer = new DesignSurface(); designer = new DesignSurface();
this.UserContent = designer; this.UserContent = designer;
InitPropertyEditor(); InitPropertyEditor();

4
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/CallExtension.cs

@ -19,9 +19,9 @@ namespace ICSharpCode.WpfDesign.Designer
string methodName; string methodName;
public override object ProvideValue(IServiceProvider sp) public override object ProvideValue(IServiceProvider serviceProvider)
{ {
var t = (IProvideValueTarget)sp.GetService(typeof(IProvideValueTarget)); var t = (IProvideValueTarget)serviceProvider.GetService(typeof(IProvideValueTarget));
return new CallCommand(t.TargetObject as FrameworkElement, methodName); return new CallCommand(t.TargetObject as FrameworkElement, methodName);
} }
} }

24
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Configuration/CodeAnalysisDictionary.xml

@ -0,0 +1,24 @@
<?xml version="1.0"?>
<Dictionary>
<Words>
<Recognized>
<!-- add words specific to your application here -->
<Word>Headered</Word> <!-- HeaderedContentControl -->
<Word>Snapline</Word>
</Recognized>
<Unrecognized>
<!-- Disable Lineup as a single word - LineUp is the spelling used in WPF -->
<Word>Lineup</Word>
</Unrecognized>
<Deprecated>
<!-- Use this section to deprecate terms -->
<Term PreferredAlternate="Best">Bestest</Term>
</Deprecated>
</Words>
<Acronyms>
<CasingExceptions>
<!-- Use this section to tell FxCop the correct casing of acronyms. -->
<Acronym>WiX</Acronym>
</CasingExceptions>
</Acronyms>
</Dictionary>

3
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/AdornerLayer.cs

@ -97,7 +97,6 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
int _totalAdornerCount; int _totalAdornerCount;
#endif #endif
internal AdornerLayer(UIElement designPanel) internal AdornerLayer(UIElement designPanel)
{ {
this._designPanel = designPanel; this._designPanel = designPanel;
@ -193,7 +192,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
int i = 0; int i = 0;
for (i = 0; i < children.Count; i++) { for (i = 0; i < children.Count; i++) {
AdornerPanel p = (AdornerPanel)children[i]; AdornerPanel p = (AdornerPanel)children[i];
if (p.Order.CompareTo(adornerPanel.Order) > 0) { if (p.Order > adornerPanel.Order) {
break; break;
} }
} }

1
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/EnumBar.xaml.cs

@ -28,6 +28,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
DependencyProperty.Register("Value", typeof(object), typeof(EnumBar), DependencyProperty.Register("Value", typeof(object), typeof(EnumBar),
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault)); new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethods")]
public object Value { public object Value {
get { return (object)GetValue(ValueProperty); } get { return (object)GetValue(ValueProperty); }
set { SetValue(ValueProperty, value); } set { SetValue(ValueProperty, value); }

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/GridAdorner.cs

@ -170,7 +170,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
} }
} }
void SplitLength(GridLength oldLength, double insertionPosition, double oldActualValue, static void SplitLength(GridLength oldLength, double insertionPosition, double oldActualValue,
out GridLength newLength1, out GridLength newLength2) out GridLength newLength1, out GridLength newLength2)
{ {
if (oldLength.IsAuto) { if (oldLength.IsAuto) {

9
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/WindowClone.cs

@ -48,6 +48,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
/// This property has no effect. (for compatibility with <see cref="Window"/> only). /// This property has no effect. (for compatibility with <see cref="Window"/> only).
/// </summary> /// </summary>
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), TypeConverter(typeof(DialogResultConverter))] [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), TypeConverter(typeof(DialogResultConverter))]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "value")]
public bool? DialogResult { public bool? DialogResult {
get { get {
return null; return null;
@ -176,41 +177,49 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
/// <summary> /// <summary>
/// This event is never raised. (for compatibility with <see cref="Window"/> only). /// This event is never raised. (for compatibility with <see cref="Window"/> only).
/// </summary> /// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "value")]
public event EventHandler Activated { add {} remove {} } public event EventHandler Activated { add {} remove {} }
/// <summary> /// <summary>
/// This event is never raised. (for compatibility with <see cref="Window"/> only). /// This event is never raised. (for compatibility with <see cref="Window"/> only).
/// </summary> /// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "value")]
public event EventHandler Closed { add {} remove {} } public event EventHandler Closed { add {} remove {} }
/// <summary> /// <summary>
/// This event is never raised. (for compatibility with <see cref="Window"/> only). /// This event is never raised. (for compatibility with <see cref="Window"/> only).
/// </summary> /// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "value")]
public event EventHandler Closing { add {} remove {} } public event EventHandler Closing { add {} remove {} }
/// <summary> /// <summary>
/// This event is never raised. (for compatibility with <see cref="Window"/> only). /// This event is never raised. (for compatibility with <see cref="Window"/> only).
/// </summary> /// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "value")]
public event EventHandler ContentRendered { add {} remove {} } public event EventHandler ContentRendered { add {} remove {} }
/// <summary> /// <summary>
/// This event is never raised. (for compatibility with <see cref="Window"/> only). /// This event is never raised. (for compatibility with <see cref="Window"/> only).
/// </summary> /// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "value")]
public event EventHandler Deactivated { add {} remove {} } public event EventHandler Deactivated { add {} remove {} }
/// <summary> /// <summary>
/// This event is never raised. (for compatibility with <see cref="Window"/> only). /// This event is never raised. (for compatibility with <see cref="Window"/> only).
/// </summary> /// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "value")]
public event EventHandler LocationChanged { add {} remove {} } public event EventHandler LocationChanged { add {} remove {} }
/// <summary> /// <summary>
/// This event is never raised. (for compatibility with <see cref="Window"/> only). /// This event is never raised. (for compatibility with <see cref="Window"/> only).
/// </summary> /// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "value")]
public event EventHandler SourceInitialized { add {} remove {} } public event EventHandler SourceInitialized { add {} remove {} }
/// <summary> /// <summary>
/// This event is never raised. (for compatibility with <see cref="Window"/> only). /// This event is never raised. (for compatibility with <see cref="Window"/> only).
/// </summary> /// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "value")]
public event EventHandler StateChanged { add {} remove {} } public event EventHandler StateChanged { add {} remove {} }
} }

6
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ZoomControl.cs

@ -39,9 +39,9 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
static Cursor PanToolCursor; static Cursor PanToolCursor;
static Cursor PanToolCursorMouseDown; static Cursor PanToolCursorMouseDown;
public static double ZoomFactor = 1.1; public const double ZoomFactor = 1.1;
public static double Minimum = 0.1; public const double Minimum = 0.1;
public static double Maximum = 10; public const double Maximum = 10;
double startHorizontalOffset; double startHorizontalOffset;
double startVericalOffset; double startVericalOffset;

8
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Converters.cs

@ -11,6 +11,7 @@ namespace ICSharpCode.WpfDesign.Designer.Converters
{ {
public class IntFromEnumConverter : IValueConverter public class IntFromEnumConverter : IValueConverter
{ {
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "converter is immutable")]
public static readonly IntFromEnumConverter Instance = new IntFromEnumConverter(); public static readonly IntFromEnumConverter Instance = new IntFromEnumConverter();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
@ -26,6 +27,7 @@ namespace ICSharpCode.WpfDesign.Designer.Converters
public class HiddenWhenFalse : IValueConverter public class HiddenWhenFalse : IValueConverter
{ {
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "converter is immutable")]
public static readonly HiddenWhenFalse Instance = new HiddenWhenFalse(); public static readonly HiddenWhenFalse Instance = new HiddenWhenFalse();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
@ -41,6 +43,7 @@ namespace ICSharpCode.WpfDesign.Designer.Converters
public class CollapsedWhenFalse : IValueConverter public class CollapsedWhenFalse : IValueConverter
{ {
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "converter is immutable")]
public static readonly CollapsedWhenFalse Instance = new CollapsedWhenFalse(); public static readonly CollapsedWhenFalse Instance = new CollapsedWhenFalse();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
@ -56,6 +59,7 @@ namespace ICSharpCode.WpfDesign.Designer.Converters
public class LevelConverter : IValueConverter public class LevelConverter : IValueConverter
{ {
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "converter is immutable")]
public static readonly LevelConverter Instance = new LevelConverter(); public static readonly LevelConverter Instance = new LevelConverter();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
@ -71,6 +75,7 @@ namespace ICSharpCode.WpfDesign.Designer.Converters
public class CollapsedWhenZero : IValueConverter public class CollapsedWhenZero : IValueConverter
{ {
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "converter is immutable")]
public static readonly CollapsedWhenZero Instance = new CollapsedWhenZero(); public static readonly CollapsedWhenZero Instance = new CollapsedWhenZero();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
@ -89,6 +94,7 @@ namespace ICSharpCode.WpfDesign.Designer.Converters
public class FalseWhenNull : IValueConverter public class FalseWhenNull : IValueConverter
{ {
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "converter is immutable")]
public static readonly FalseWhenNull Instance = new FalseWhenNull(); public static readonly FalseWhenNull Instance = new FalseWhenNull();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
@ -104,6 +110,7 @@ namespace ICSharpCode.WpfDesign.Designer.Converters
public class BoldWhenTrue : IValueConverter public class BoldWhenTrue : IValueConverter
{ {
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "converter is immutable")]
public static readonly BoldWhenTrue Instance = new BoldWhenTrue(); public static readonly BoldWhenTrue Instance = new BoldWhenTrue();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
@ -120,6 +127,7 @@ namespace ICSharpCode.WpfDesign.Designer.Converters
// Boxed int throw exception without converter (wpf bug?) // Boxed int throw exception without converter (wpf bug?)
public class DummyConverter : IValueConverter public class DummyConverter : IValueConverter
{ {
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "converter is immutable")]
public static readonly DummyConverter Instance = new DummyConverter(); public static readonly DummyConverter Instance = new DummyConverter();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) public object Convert(object value, Type targetType, object parameter, CultureInfo culture)

9
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignSurface.xaml.cs

@ -43,6 +43,15 @@ namespace ICSharpCode.WpfDesign.Designer
this.AddCommandHandler(ApplicationCommands.Delete, Delete, CanDelete); this.AddCommandHandler(ApplicationCommands.Delete, Delete, CanDelete);
this.AddCommandHandler(ApplicationCommands.Paste, Paste, CanPaste); this.AddCommandHandler(ApplicationCommands.Paste, Paste, CanPaste);
this.AddCommandHandler(ApplicationCommands.SelectAll, SelectAll, CanSelectAll); this.AddCommandHandler(ApplicationCommands.SelectAll, SelectAll, CanSelectAll);
#if DEBUG || CODE_ANALYSIS
if (_designPanel == null) {
Environment.FailFast("designpanel should be initialized earlier");
// Fake call to DesignPanel constructor because FxCop doesn't look inside XAML files
// and we'd get tons of warnings about uncalled private code.
_designPanel = new DesignPanel();
}
#endif
} }
protected override void OnPreviewMouseLeftButtonDown(MouseButtonEventArgs e) protected override void OnPreviewMouseLeftButtonDown(MouseButtonEventArgs e)

27
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DragDropExceptionHandler.cs

@ -6,19 +6,36 @@
// </file> // </file>
using System; using System;
using System.Threading;
namespace ICSharpCode.WpfDesign.Designer namespace ICSharpCode.WpfDesign.Designer
{ {
/// <summary> /// <summary>
/// When the designer is hosted in a Windows.Forms application, exceptions in /// When the designer is hosted in a Windows.Forms application, exceptions in
/// drag'n'drop handlers are silently ignored. /// drag'n'drop handlers are silently ignored.
/// Applications hosting the designer should specify a delegate to their own exception handling /// Applications hosting the designer should listen to the event and provide their own exception handling
/// method. The default is Environment.FailFast. /// method. If no event listener is registered, exceptions will call Environment.FailFast.
/// </summary> /// </summary>
public static class DragDropExceptionHandler public static class DragDropExceptionHandler
{ {
public static Action<Exception> HandleException = delegate(Exception ex) { /// <summary>
Environment.FailFast(ex.ToString()); /// Event that occors when an unhandled exception occurs during drag'n'drop operators.
}; /// </summary>
public static event ThreadExceptionEventHandler UnhandledException;
/// <summary>
/// Raises the UnhandledException event, or calls Environment.FailFast if no event handlers are present.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1030:UseEventsWhereAppropriate", Justification = "We're raising an event")]
public static void RaiseUnhandledException(Exception exception)
{
if (exception == null)
throw new ArgumentNullException("exception");
ThreadExceptionEventHandler eh = UnhandledException;
if (eh != null)
eh(null, new ThreadExceptionEventArgs(exception));
else
Environment.FailFast(exception.ToString());
}
} }
} }

18
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ExtensionMethods.cs

@ -13,9 +13,9 @@ namespace ICSharpCode.WpfDesign.Designer
{ {
public static class ExtensionMethods public static class ExtensionMethods
{ {
public static double Coerce(this double d, double min, double max) public static double Coerce(this double value, double min, double max)
{ {
return Math.Max(Math.Min(d, max), min); return Math.Max(Math.Min(value, max), min);
} }
public static void AddRange<T>(this ICollection<T> col, IEnumerable<T> items) public static void AddRange<T>(this ICollection<T> col, IEnumerable<T> items)
@ -31,15 +31,15 @@ namespace ICSharpCode.WpfDesign.Designer
} }
/// <summary> /// <summary>
/// Gets all ancestors in the visual tree (including d itself). /// Gets all ancestors in the visual tree (including <paramref name="visual"/> itself).
/// Returns an empty list if d is null or not a visual. /// Returns an empty list if <paramref name="visual"/> is null or not a visual.
/// </summary> /// </summary>
public static IEnumerable<DependencyObject> GetVisualAncestors(this DependencyObject d) public static IEnumerable<DependencyObject> GetVisualAncestors(this DependencyObject visual)
{ {
if (IsVisual(d)) { if (IsVisual(visual)) {
while (d != null) { while (visual != null) {
yield return d; yield return visual;
d = VisualTreeHelper.GetParent(d); visual = VisualTreeHelper.GetParent(visual);
} }
} }
} }

6
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/CreateComponentTool.cs

@ -95,7 +95,7 @@ namespace ICSharpCode.WpfDesign.Designer.Services
} }
} }
} catch (Exception x) { } catch (Exception x) {
DragDropExceptionHandler.HandleException(x); DragDropExceptionHandler.RaiseUnhandledException(x);
} }
} }
@ -112,7 +112,7 @@ namespace ICSharpCode.WpfDesign.Designer.Services
changeGroup.Commit(); changeGroup.Commit();
} }
} catch (Exception x) { } catch (Exception x) {
DragDropExceptionHandler.HandleException(x); DragDropExceptionHandler.RaiseUnhandledException(x);
} }
} }
@ -128,7 +128,7 @@ namespace ICSharpCode.WpfDesign.Designer.Services
} }
} catch (Exception x) { } catch (Exception x) {
DragDropExceptionHandler.HandleException(x); DragDropExceptionHandler.RaiseUnhandledException(x);
} }
} }

5
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/UndoService.cs

@ -131,6 +131,8 @@ namespace ICSharpCode.WpfDesign.Designer.Services
} }
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes",
Justification = "We rethrow the original exception, not the follow-up error.")]
public void Redo() public void Redo()
{ {
AssertState(TransactionState.Undone); AssertState(TransactionState.Undone);
@ -157,6 +159,9 @@ namespace ICSharpCode.WpfDesign.Designer.Services
} }
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes",
Justification = "We avoid throwing exceptions here because a disposed transaction" +
" indicates another exception happened earlier.")]
protected override void Dispose() protected override void Dispose()
{ {
if (_state == TransactionState.Open) { if (_state == TransactionState.Open) {

9
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj

@ -15,6 +15,12 @@
<DocumentationFile>..\..\..\..\..\..\AddIns\AddIns\DisplayBindings\WpfDesign\ICSharpCode.WpfDesign.Designer.xml</DocumentationFile> <DocumentationFile>..\..\..\..\..\..\AddIns\AddIns\DisplayBindings\WpfDesign\ICSharpCode.WpfDesign.Designer.xml</DocumentationFile>
<NoWarn>1591</NoWarn> <NoWarn>1591</NoWarn>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<SignAssembly>True</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\..\..\..\Main\ICSharpCode.SharpDevelop.snk</AssemblyOriginatorKeyFile>
<DelaySign>False</DelaySign>
<AssemblyOriginatorKeyMode>File</AssemblyOriginatorKeyMode>
<RunCodeAnalysis>False</RunCodeAnalysis>
<CodeAnalysisRules>-Microsoft.Performance#CA1800;-Microsoft.Performance#CA1810;-Microsoft.Performance#CA1822</CodeAnalysisRules>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@ -303,4 +309,7 @@
<Resource Include="Images\ZoomIn.png" /> <Resource Include="Images\ZoomIn.png" />
<Resource Include="Images\ZoomOut.png" /> <Resource Include="Images\ZoomOut.png" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<CodeAnalysisDictionary Include="Configuration\CodeAnalysisDictionary.xml" />
</ItemGroup>
</Project> </Project>

6
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlComponentService.cs

@ -7,9 +7,11 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using ICSharpCode.WpfDesign.XamlDom; using System.Runtime.CompilerServices;
using System.Windows.Markup; using System.Windows.Markup;
using ICSharpCode.WpfDesign.XamlDom;
namespace ICSharpCode.WpfDesign.Designer.Xaml namespace ICSharpCode.WpfDesign.Designer.Xaml
{ {
sealed class XamlComponentService : IComponentService sealed class XamlComponentService : IComponentService
@ -21,7 +23,7 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
int IEqualityComparer<object>.GetHashCode(object obj) int IEqualityComparer<object>.GetHashCode(object obj)
{ {
return obj.GetHashCode(); return RuntimeHelpers.GetHashCode(obj);
} }
bool IEqualityComparer<object>.Equals(object x, object y) bool IEqualityComparer<object>.Equals(object x, object y)

24
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Adorners/AdornerPanel.cs

@ -197,5 +197,29 @@ namespace ICSharpCode.WpfDesign.Adorners
{ {
return leftHandSide.i != rightHandSide.i; return leftHandSide.i != rightHandSide.i;
} }
/// <summary/>
public static bool operator <(AdornerOrder leftHandSide, AdornerOrder rightHandSide)
{
return leftHandSide.i < rightHandSide.i;
}
/// <summary/>
public static bool operator <=(AdornerOrder leftHandSide, AdornerOrder rightHandSide)
{
return leftHandSide.i <= rightHandSide.i;
}
/// <summary/>
public static bool operator >(AdornerOrder leftHandSide, AdornerOrder rightHandSide)
{
return leftHandSide.i > rightHandSide.i;
}
/// <summary/>
public static bool operator >=(AdornerOrder leftHandSide, AdornerOrder rightHandSide)
{
return leftHandSide.i >= rightHandSide.i;
}
} }
} }

1
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/ChangeGroup.cs

@ -40,6 +40,7 @@ namespace ICSharpCode.WpfDesign
protected abstract void Dispose(); protected abstract void Dispose();
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1816:CallGCSuppressFinalizeCorrectly")]
void IDisposable.Dispose() void IDisposable.Dispose()
{ {
Dispose(); Dispose();

24
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Configuration/CodeAnalysisDictionary.xml

@ -0,0 +1,24 @@
<?xml version="1.0"?>
<Dictionary>
<Words>
<Recognized>
<!-- add words specific to your application here -->
<Word>lhs</Word>
<Word>rhs</Word>
</Recognized>
<Unrecognized>
<!-- Disable Lineup as a single word - LineUp is the spelling used in WPF -->
<Word>Lineup</Word>
</Unrecognized>
<Deprecated>
<!-- Use this section to deprecate terms -->
<Term PreferredAlternate="Best">Bestest</Term>
</Deprecated>
</Words>
<Acronyms>
<CasingExceptions>
<!-- Use this section to tell FxCop the correct casing of acronyms. -->
<Acronym>WiX</Acronym>
</CasingExceptions>
</Acronyms>
</Dictionary>

10
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignItem.cs

@ -181,16 +181,16 @@ namespace ICSharpCode.WpfDesign
/// <summary> /// <summary>
/// Adds a bevahior extension object to this design item. /// Adds a bevahior extension object to this design item.
/// </summary> /// </summary>
public void AddBehavior(Type bevahiorInterface, object behaviorImplementation) public void AddBehavior(Type behaviorInterface, object behaviorImplementation)
{ {
if (bevahiorInterface == null) if (behaviorInterface == null)
throw new ArgumentNullException("bevahiorInterface"); throw new ArgumentNullException("behaviorInterface");
if (behaviorImplementation == null) if (behaviorImplementation == null)
throw new ArgumentNullException("behaviorImplementation"); throw new ArgumentNullException("behaviorImplementation");
if (!bevahiorInterface.IsInstanceOfType(behaviorImplementation)) if (!behaviorInterface.IsInstanceOfType(behaviorImplementation))
throw new ArgumentException("behaviorImplementation must implement bevahiorInterface", "behaviorImplementation"); throw new ArgumentException("behaviorImplementation must implement bevahiorInterface", "behaviorImplementation");
_behaviorObjects.Add(bevahiorInterface, behaviorImplementation); _behaviorObjects.Add(behaviorInterface, behaviorImplementation);
} }
/// <summary> /// <summary>

4
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/LogicalExtensionServers.cs

@ -12,6 +12,8 @@ namespace ICSharpCode.WpfDesign.Extensions
/// <summary> /// <summary>
/// Combines two extension servers using a logical OR. /// Combines two extension servers using a logical OR.
/// </summary> /// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1715:IdentifiersShouldHaveCorrectPrefix")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly")]
public sealed class LogicalOrExtensionServer<A, B> : DefaultExtensionServer public sealed class LogicalOrExtensionServer<A, B> : DefaultExtensionServer
where A : ExtensionServer where A : ExtensionServer
where B : ExtensionServer where B : ExtensionServer
@ -44,6 +46,8 @@ namespace ICSharpCode.WpfDesign.Extensions
/// <summary> /// <summary>
/// Combines two extension servers using a logical AND. /// Combines two extension servers using a logical AND.
/// </summary> /// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1715:IdentifiersShouldHaveCorrectPrefix")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly")]
public sealed class LogicalAndExtensionServer<A, B> : DefaultExtensionServer public sealed class LogicalAndExtensionServer<A, B> : DefaultExtensionServer
where A : ExtensionServer where A : ExtensionServer
where B : ExtensionServer where B : ExtensionServer

1
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementOperation.cs

@ -41,6 +41,7 @@ namespace ICSharpCode.WpfDesign
/// <summary> /// <summary>
/// The type of the placement being done. /// The type of the placement being done.
/// </summary> /// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethods")]
public PlacementType Type { public PlacementType Type {
get { return type; } get { return type; }
} }

11
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/PropertyNode.cs

@ -149,12 +149,13 @@ namespace ICSharpCode.WpfDesign.PropertyGrid
return "(" + ValueItem.ComponentType.Name + ")"; return "(" + ValueItem.ComponentType.Name + ")";
} }
set { set {
// TODO: Doesn't work for some reason // make sure we only catch specific exceptions
try { // and/or show the error message to the user
//try {
Value = FirstProperty.TypeConverter.ConvertFromInvariantString(value); Value = FirstProperty.TypeConverter.ConvertFromInvariantString(value);
} catch { //} catch {
OnValueOnInstanceChanged(); // OnValueOnInstanceChanged();
} //}
} }
} }

10
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/SortedObservableCollection.cs

@ -9,20 +9,20 @@ namespace ICSharpCode.WpfDesign.PropertyGrid
/// <summary> /// <summary>
/// Extends ObservableCollection{T} with an AddSorted method to insert items in a sorted collection. /// Extends ObservableCollection{T} with an AddSorted method to insert items in a sorted collection.
/// </summary> /// </summary>
public class SortedObservableCollection<T, K> : ObservableCollection<T> public class SortedObservableCollection<T, TKey> : ObservableCollection<T>
{ {
/// <summary> /// <summary>
/// Creates a new SortedObservableCollection instance. /// Creates a new SortedObservableCollection instance.
/// </summary> /// </summary>
/// <param name="keySelector">The function to select the sorting key.</param> /// <param name="keySelector">The function to select the sorting key.</param>
public SortedObservableCollection(Func<T, K> keySelector) public SortedObservableCollection(Func<T, TKey> keySelector)
{ {
this.keySelector = keySelector; this.keySelector = keySelector;
this.comparer = Comparer<K>.Default; this.comparer = Comparer<TKey>.Default;
} }
Func<T, K> keySelector; Func<T, TKey> keySelector;
IComparer<K> comparer; IComparer<TKey> comparer;
/// <summary> /// <summary>
/// Adds an item to a sorted collection. /// Adds an item to a sorted collection.

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Services.cs

@ -151,7 +151,7 @@ namespace ICSharpCode.WpfDesign
/// <summary> /// <summary>
/// Gets a WPF object representing a graphical description of the property. /// Gets a WPF object representing a graphical description of the property.
/// </summary> /// </summary>
object GetDescription(DesignItemProperty property); object GetDescription(DesignItemProperty designProperty);
} }
#endregion #endregion

3
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/WpfDesign.csproj

@ -127,4 +127,7 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>
</ItemGroup> </ItemGroup>
<ItemGroup>
<CodeAnalysisDictionary Include="Configuration\CodeAnalysisDictionary.xml" />
</ItemGroup>
</Project> </Project>
Loading…
Cancel
Save