From d680fdb76db64455e1f95c0699c52ecfb32ee503 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Sat, 5 Apr 2014 23:00:24 +0200 Subject: [PATCH] Stylecop fixes --- Perspex.Windows/DrawingContext.cs | 1 + Perspex/Application.cs | 13 ++++++----- Perspex/BindingExtensions.cs | 2 +- Perspex/Classes.cs | 26 ++++++++++----------- Perspex/Contract.cs | 12 ++++++---- Perspex/Controls/ControlTemplate.cs | 16 ++++++------- Perspex/Controls/ITemplatedControl.cs | 4 ++-- Perspex/Controls/LogicalChildren.cs | 2 +- Perspex/Input/InputManager.cs | 2 +- Perspex/PerspexList.cs | 13 ++++++----- Perspex/PerspexObject.cs | 32 +++++++++++++------------- Perspex/PriorityValue.cs | 18 +++++++-------- Perspex/Styling/IStyler.cs | 2 +- Perspex/Styling/Selector.cs | 2 +- Perspex/Styling/StyleActivator.cs | 24 +++++++++---------- Perspex/Themes/Default/ButtonStyle.cs | 26 +++++++++++---------- Perspex/Themes/Default/DefaultTheme.cs | 13 ++++++----- 17 files changed, 108 insertions(+), 100 deletions(-) diff --git a/Perspex.Windows/DrawingContext.cs b/Perspex.Windows/DrawingContext.cs index 881a7c58d1..d10ab74e2a 100644 --- a/Perspex.Windows/DrawingContext.cs +++ b/Perspex.Windows/DrawingContext.cs @@ -71,6 +71,7 @@ namespace Perspex.Windows /// Draws text. /// /// The foreground brush. + /// The output rectangle. /// The text. public void DrawText(Perspex.Media.Brush foreground, Rect rect, FormattedText text) { diff --git a/Perspex/Application.cs b/Perspex/Application.cs index 0e094b4ffb..24ef9105ce 100644 --- a/Perspex/Application.cs +++ b/Perspex/Application.cs @@ -1,12 +1,13 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Perspex.Styling; +// ----------------------------------------------------------------------- +// +// Copyright 2014 MIT Licence. See licence.md for more information. +// +// ----------------------------------------------------------------------- namespace Perspex { + using Perspex.Styling; + public class Application { private Styles styles; diff --git a/Perspex/BindingExtensions.cs b/Perspex/BindingExtensions.cs index 8e54310da9..f739682cac 100644 --- a/Perspex/BindingExtensions.cs +++ b/Perspex/BindingExtensions.cs @@ -11,7 +11,7 @@ namespace Perspex using System.Linq; using System.Text; using System.Threading.Tasks; -using Perspex.Controls; + using Perspex.Controls; /// /// Provides binding utility extension methods. diff --git a/Perspex/Classes.cs b/Perspex/Classes.cs index bcfc627376..b05446fd0a 100644 --- a/Perspex/Classes.cs +++ b/Perspex/Classes.cs @@ -92,17 +92,6 @@ namespace Perspex this.RaiseChanged(e); } - private void RaiseChanged(NotifyCollectionChangedEventArgs e) - { - if (this.CollectionChanged != null) - { - this.CollectionChanged(this, e); - } - - this.changed.OnNext(e); - this.afterChanged.OnNext(e); - } - public void Clear() { NotifyCollectionChangedEventArgs e = new NotifyCollectionChangedEventArgs( @@ -125,7 +114,7 @@ namespace Perspex public IEnumerator GetEnumerator() { - return inner.GetEnumerator(); + return this.inner.GetEnumerator(); } public override string ToString() @@ -135,7 +124,7 @@ namespace Perspex IEnumerator IEnumerable.GetEnumerator() { - return inner.GetEnumerator(); + return this.inner.GetEnumerator(); } public bool Remove(string item) @@ -173,5 +162,16 @@ namespace Perspex return false; } } + + private void RaiseChanged(NotifyCollectionChangedEventArgs e) + { + if (this.CollectionChanged != null) + { + this.CollectionChanged(this, e); + } + + this.changed.OnNext(e); + this.afterChanged.OnNext(e); + } } } diff --git a/Perspex/Contract.cs b/Perspex/Contract.cs index 1550c098dd..18a3f65802 100644 --- a/Perspex/Contract.cs +++ b/Perspex/Contract.cs @@ -1,11 +1,13 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +// ----------------------------------------------------------------------- +// +// Copyright 2014 MIT Licence. See licence.md for more information. +// +// ----------------------------------------------------------------------- namespace Perspex { + using System; + internal static class Contract { public static void Requires(bool condition) where TException : Exception, new() diff --git a/Perspex/Controls/ControlTemplate.cs b/Perspex/Controls/ControlTemplate.cs index 2347239afc..422f472ee9 100644 --- a/Perspex/Controls/ControlTemplate.cs +++ b/Perspex/Controls/ControlTemplate.cs @@ -21,6 +21,14 @@ namespace Perspex.Controls this.build = build; } + public static ControlTemplate Create(Func build) + where TControl : ITemplatedControl + { + Contract.Requires(build != null); + + return new ControlTemplate(c => build((TControl)c)); + } + public Control Build(ITemplatedControl templatedParent) { Contract.Requires(templatedParent != null); @@ -30,14 +38,6 @@ namespace Perspex.Controls return root; } - public static ControlTemplate Create(Func build) - where TControl : ITemplatedControl - { - Contract.Requires(build != null); - - return new ControlTemplate(c => build((TControl)c)); - } - private void SetTemplatedParent(Control control, ITemplatedControl templatedParent) { Contract.Requires(control != null); diff --git a/Perspex/Controls/ITemplatedControl.cs b/Perspex/Controls/ITemplatedControl.cs index da20588791..473ab8c876 100644 --- a/Perspex/Controls/ITemplatedControl.cs +++ b/Perspex/Controls/ITemplatedControl.cs @@ -11,6 +11,8 @@ namespace Perspex.Controls public interface ITemplatedControl { + IEnumerable VisualChildren { get; } + /// /// Gets an observable for a . /// @@ -18,7 +20,5 @@ namespace Perspex.Controls /// The property to get the observable for. /// The observable. IObservable GetObservable(PerspexProperty property); - - IEnumerable VisualChildren { get; } } } diff --git a/Perspex/Controls/LogicalChildren.cs b/Perspex/Controls/LogicalChildren.cs index 9b5a308ce8..5ea6f97a71 100644 --- a/Perspex/Controls/LogicalChildren.cs +++ b/Perspex/Controls/LogicalChildren.cs @@ -41,7 +41,7 @@ namespace Perspex.Controls public void Change(PerspexList childrenCollection) { this.childrenCollection.CollectionChanged -= this.CollectionChanged; - this.Remove(inner.ToList()); + this.Remove(this.inner.ToList()); this.childrenCollection = childrenCollection; this.Add(childrenCollection); childrenCollection.CollectionChanged += this.CollectionChanged; diff --git a/Perspex/Input/InputManager.cs b/Perspex/Input/InputManager.cs index 38ad825e9c..eee08ae83f 100644 --- a/Perspex/Input/InputManager.cs +++ b/Perspex/Input/InputManager.cs @@ -13,7 +13,7 @@ namespace Perspex.Input public class InputManager : IInputManager { - List pointerOvers = new List(); + private List pointerOvers = new List(); public void Process(RawInputEventArgs e) { diff --git a/Perspex/PerspexList.cs b/Perspex/PerspexList.cs index 376f510e66..1735e73aaf 100644 --- a/Perspex/PerspexList.cs +++ b/Perspex/PerspexList.cs @@ -1,15 +1,16 @@ -namespace Perspex +// ----------------------------------------------------------------------- +// +// Copyright 2014 MIT Licence. See licence.md for more information. +// +// ----------------------------------------------------------------------- + +namespace Perspex { using System; - using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Collections.Specialized; - using System.Linq; using System.Reactive.Linq; - using System.Reactive.Subjects; - using System.Text; - using System.Threading.Tasks; public class PerspexList : ObservableCollection { diff --git a/Perspex/PerspexObject.cs b/Perspex/PerspexObject.cs index b0bbc992c5..442b08be8d 100644 --- a/Perspex/PerspexObject.cs +++ b/Perspex/PerspexObject.cs @@ -186,19 +186,19 @@ namespace Perspex public void ClearBinding(PerspexProperty property) { throw new NotImplementedException(); - //Contract.Requires(property != null); - //PriorityValue value; - - //if (this.values.TryGetValue(property, out value)) - //{ - // value.ClearLocalBinding(); - - // this.Log().Debug(string.Format( - // "Cleared binding on {0}.{1} (#{2:x8})", - // this.GetType().Name, - // property.Name, - // this.GetHashCode())); - //} + ////Contract.Requires(property != null); + ////PriorityValue value; + + ////if (this.values.TryGetValue(property, out value)) + ////{ + //// value.ClearLocalBinding(); + + //// this.Log().Debug(string.Format( + //// "Cleared binding on {0}.{1} (#{2:x8})", + //// this.GetType().Name, + //// property.Name, + //// this.GetHashCode())); + ////} } /// @@ -344,7 +344,7 @@ namespace Perspex { Contract.Requires(property != null); - const int priority = (int)BindingPriority.LocalValue; + const int Priority = (int)BindingPriority.LocalValue; PriorityValue v; if (!this.values.TryGetValue(property, out v)) @@ -365,8 +365,8 @@ namespace Perspex this.GetHashCode(), value)); - v.Clear(priority); - v.Add(Observable.Never().StartWith(value), priority); + v.Clear(Priority); + v.Add(Observable.Never().StartWith(value), Priority); } /// diff --git a/Perspex/PriorityValue.cs b/Perspex/PriorityValue.cs index d6ffe15cb5..80d9bbc4e2 100644 --- a/Perspex/PriorityValue.cs +++ b/Perspex/PriorityValue.cs @@ -219,6 +219,15 @@ namespace Perspex /// private IDisposable subscription; + /// + /// Gets a description of the binding. + /// + public string Description + { + get; + private set; + } + /// /// The priority of the binding. /// @@ -276,15 +285,6 @@ namespace Perspex () => completed(this)); } - /// - /// Gets a description of the binding. - /// - public string Description - { - get; - private set; - } - /// /// Ends the binding subscription. /// diff --git a/Perspex/Styling/IStyler.cs b/Perspex/Styling/IStyler.cs index cd296a0917..cf244d9f3e 100644 --- a/Perspex/Styling/IStyler.cs +++ b/Perspex/Styling/IStyler.cs @@ -1,5 +1,5 @@ // ----------------------------------------------------------------------- -// +// // Copyright 2014 MIT Licence. See licence.md for more information. // // ----------------------------------------------------------------------- diff --git a/Perspex/Styling/Selector.cs b/Perspex/Styling/Selector.cs index 75a44a482b..729fa78287 100644 --- a/Perspex/Styling/Selector.cs +++ b/Perspex/Styling/Selector.cs @@ -1,5 +1,5 @@ // ----------------------------------------------------------------------- -// +// // Copyright 2014 MIT Licence. See licence.md for more information. // // ----------------------------------------------------------------------- diff --git a/Perspex/Styling/StyleActivator.cs b/Perspex/Styling/StyleActivator.cs index ae0d7fe24a..faa55d87d8 100644 --- a/Perspex/Styling/StyleActivator.cs +++ b/Perspex/Styling/StyleActivator.cs @@ -1,5 +1,5 @@ // ----------------------------------------------------------------------- -// +// // Copyright 2014 MIT Licence. See licence.md for more information. // // ----------------------------------------------------------------------- @@ -19,13 +19,13 @@ namespace Perspex.Styling public class StyleActivator : IObservable, IDisposable { - ActivatorMode mode; + private ActivatorMode mode; - List values = new List(); + private List values = new List(); - List subscriptions = new List(); + private List subscriptions = new List(); - List> observers = new List>(); + private List> observers = new List>(); public StyleActivator( IEnumerable> inputs, @@ -37,14 +37,14 @@ namespace Perspex.Styling foreach (IObservable input in inputs) { - int iCaptured = i; + int capturedIndex = i; this.values.Add(false); IDisposable subscription = input.Subscribe( - x => this.Update(iCaptured, x), - x => this.Finish(iCaptured), - () => this.Finish(iCaptured)); + x => this.Update(capturedIndex, x), + x => this.Finish(capturedIndex), + () => this.Finish(capturedIndex)); this.subscriptions.Add(subscription); ++i; } @@ -80,7 +80,7 @@ namespace Perspex.Styling Contract.Requires(observer != null); this.observers.Add(observer); - observer.OnNext(CurrentValue); + observer.OnNext(this.CurrentValue); return Disposable.Create(() => this.observers.Remove(observer)); } @@ -102,10 +102,10 @@ namespace Perspex.Styling throw new InvalidOperationException("Invalid Activator mode."); } - if (current != CurrentValue) + if (current != this.CurrentValue) { this.Push(current); - CurrentValue = current; + this.CurrentValue = current; } } diff --git a/Perspex/Themes/Default/ButtonStyle.cs b/Perspex/Themes/Default/ButtonStyle.cs index 3b7c143be8..28036ec36d 100644 --- a/Perspex/Themes/Default/ButtonStyle.cs +++ b/Perspex/Themes/Default/ButtonStyle.cs @@ -1,14 +1,16 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Perspex.Controls; -using Perspex.Media; -using Perspex.Styling; +// ----------------------------------------------------------------------- +// +// Copyright 2014 MIT Licence. See licence.md for more information. +// +// ----------------------------------------------------------------------- namespace Perspex.Themes.Default { + using System.Linq; + using Perspex.Controls; + using Perspex.Media; + using Perspex.Styling; + public class ButtonStyle : Styles { public ButtonStyle() @@ -36,22 +38,22 @@ namespace Perspex.Themes.Default { Setters = new[] { - new Setter (Button.BackgroundProperty, new SolidColorBrush(0xffbee6fd)), - new Setter (Button.BorderBrushProperty, new SolidColorBrush(0xff3c7fb1)), + new Setter(Button.BackgroundProperty, new SolidColorBrush(0xffbee6fd)), + new Setter(Button.BorderBrushProperty, new SolidColorBrush(0xff3c7fb1)), }, }, new Style(x => x.OfType