From 90d8976cfdadc1582e366c0b6f6611d6fe83f5ff Mon Sep 17 00:00:00 2001 From: Samantha Houts Date: Mon, 11 Apr 2016 18:05:28 -0700 Subject: [PATCH] [iOS] Resolve Warning 0108 (#64) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit [iOS] Resolve warning 0114 `Selected` is overridable, but current behavior is to hide it, so we're going to add the `new` keyword. [iOS] Resolve warning 0618 [iOS] Resolve warning 0414, 0649, 0169 [iOS] Resolve warning 0105 Update dispose to override base dispose (#67) Add an optional extended description… --- .../ContextScrollViewDelegate.cs | 2 +- .../GlobalCloseContextGestureRecognizer.cs | 5 +- Xamarin.Forms.Platform.iOS/Platform.cs | 20 +++---- .../Renderers/CarouselViewRenderer.cs | 11 ++-- .../Renderers/FontExtensions.cs | 3 +- .../Renderers/FormattedStringExtensions.cs | 5 +- .../Renderers/NavigationMenuRenderer.cs | 2 +- .../Renderers/NavigationRenderer.cs | 9 ++-- .../Renderers/TabletMasterDetailRenderer.cs | 61 +++++++++++----------- .../Renderers/WebViewRenderer.cs | 4 -- .../Xamarin.Forms.Platform.iOS.Classic.csproj | 8 +-- .../Xamarin.Forms.Platform.iOS.csproj | 8 +-- 12 files changed, 63 insertions(+), 75 deletions(-) diff --git a/Xamarin.Forms.Platform.iOS/ContextScrollViewDelegate.cs b/Xamarin.Forms.Platform.iOS/ContextScrollViewDelegate.cs index 47ce071..b2b34e4 100644 --- a/Xamarin.Forms.Platform.iOS/ContextScrollViewDelegate.cs +++ b/Xamarin.Forms.Platform.iOS/ContextScrollViewDelegate.cs @@ -178,7 +178,7 @@ namespace Xamarin.Forms.Platform.iOS if (table != null) { _table = table; - _globalCloser = new GlobalCloseContextGestureRecognizer(scrollView, _buttons, close); + _globalCloser = new GlobalCloseContextGestureRecognizer(scrollView, close); _globalCloser.ShouldRecognizeSimultaneously = (recognizer, r) => r == _table.PanGestureRecognizer; table.AddGestureRecognizer(_globalCloser); diff --git a/Xamarin.Forms.Platform.iOS/GlobalCloseContextGestureRecognizer.cs b/Xamarin.Forms.Platform.iOS/GlobalCloseContextGestureRecognizer.cs index fa76b98..f0e8522 100644 --- a/Xamarin.Forms.Platform.iOS/GlobalCloseContextGestureRecognizer.cs +++ b/Xamarin.Forms.Platform.iOS/GlobalCloseContextGestureRecognizer.cs @@ -22,13 +22,11 @@ namespace Xamarin.Forms.Platform.iOS { internal class GlobalCloseContextGestureRecognizer : UIGestureRecognizer { - List _buttons; UIScrollView _scrollView; - public GlobalCloseContextGestureRecognizer(UIScrollView scrollView, List buttons, NSAction activated) : base(activated) + public GlobalCloseContextGestureRecognizer(UIScrollView scrollView, NSAction activated) : base(activated) { _scrollView = scrollView; - _buttons = buttons; ShouldReceiveTouch = OnShouldReceiveTouch; } @@ -57,7 +55,6 @@ namespace Xamarin.Forms.Platform.iOS if (disposing) { - _buttons = null; _scrollView = null; } } diff --git a/Xamarin.Forms.Platform.iOS/Platform.cs b/Xamarin.Forms.Platform.iOS/Platform.cs index 0293e75..3022fa0 100644 --- a/Xamarin.Forms.Platform.iOS/Platform.cs +++ b/Xamarin.Forms.Platform.iOS/Platform.cs @@ -5,32 +5,28 @@ using System.Drawing; using System.Linq; using System.Runtime.InteropServices; using System.Threading.Tasks; + #if __UNIFIED__ using CoreGraphics; using Foundation; using ObjCRuntime; using UIKit; +using RectangleF = CoreGraphics.CGRect; +using SizeF = CoreGraphics.CGSize; +using PointF = CoreGraphics.CGPoint; + #else using MonoTouch; using MonoTouch.CoreAnimation; using MonoTouch.CoreFoundation; using MonoTouch.CoreGraphics; using MonoTouch.UIKit; -using System.Drawing; -using MonoTouch.CoreAnimation; using MonoTouch.Foundation; using MonoTouch.ObjCRuntime; -using MonoTouch.UIKit; -#endif -#if __UNIFIED__ -using RectangleF = CoreGraphics.CGRect; -using SizeF = CoreGraphics.CGSize; -using PointF = CoreGraphics.CGPoint; -#else -using nfloat=System.Single; -using nint=System.Int32; -using nuint=System.UInt32; +using nfloat = System.Single; +using nint = System.Int32; +using nuint = System.UInt32; #endif namespace Xamarin.Forms.Platform.iOS diff --git a/Xamarin.Forms.Platform.iOS/Renderers/CarouselViewRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/CarouselViewRenderer.cs index 84f57a9..3efb316 100644 --- a/Xamarin.Forms.Platform.iOS/Renderers/CarouselViewRenderer.cs +++ b/Xamarin.Forms.Platform.iOS/Renderers/CarouselViewRenderer.cs @@ -46,7 +46,6 @@ namespace Xamarin.Forms.Platform.iOS { #region Static Fields const int DefaultMinimumDimension = 44; - static readonly UIColor DefaultBackgroundColor = UIColor.White; #endregion #region Fields @@ -248,11 +247,11 @@ namespace Xamarin.Forms.Platform.iOS void Bind(object item, int position) { - //if (position != this.position) - // controller.SendPositionDisappearing (this.position); + //if (position != this._position) + // controller.SendPositionDisappearing (this._position); _position = position; - OnBind?.Invoke(position); + OnBind?.Invoke(_position); _controller.BindView(_view, item); } @@ -274,7 +273,7 @@ namespace Xamarin.Forms.Platform.iOS _view = controller.CreateView(itemType); // bind view - Bind(item, position); + Bind(item, _position); // render view _renderer = Platform.CreateRenderer(_view); @@ -285,7 +284,7 @@ namespace Xamarin.Forms.Platform.iOS ContentView.AddSubview(uiView); } else - Bind(item, position); + Bind(item, _position); } public Action OnBind; diff --git a/Xamarin.Forms.Platform.iOS/Renderers/FontExtensions.cs b/Xamarin.Forms.Platform.iOS/Renderers/FontExtensions.cs index b241001..c2e565d 100644 --- a/Xamarin.Forms.Platform.iOS/Renderers/FontExtensions.cs +++ b/Xamarin.Forms.Platform.iOS/Renderers/FontExtensions.cs @@ -196,10 +196,11 @@ namespace Xamarin.Forms.Platform.iOS _size = size; _attributes = attributes; } - +#pragma warning disable 0414 // these are not called explicitly, but they are used to establish uniqueness. allow it! string _family; float _size; FontAttributes _attributes; +#pragma warning restore 0414 } } } \ No newline at end of file diff --git a/Xamarin.Forms.Platform.iOS/Renderers/FormattedStringExtensions.cs b/Xamarin.Forms.Platform.iOS/Renderers/FormattedStringExtensions.cs index 89a09e8..4bb829b 100644 --- a/Xamarin.Forms.Platform.iOS/Renderers/FormattedStringExtensions.cs +++ b/Xamarin.Forms.Platform.iOS/Renderers/FormattedStringExtensions.cs @@ -16,10 +16,9 @@ namespace Xamarin.Forms.Platform.iOS if (span == null) return null; -#pragma warning disable 618 +#pragma warning disable 0618 //retaining legacy call to obsolete code var font = span.Font != Font.Default ? span.Font : defaultFont; -#pragma warning restore 618 - +#pragma warning restore 0618 var fgcolor = span.ForegroundColor; if (fgcolor.IsDefault) fgcolor = defaultForegroundColor; diff --git a/Xamarin.Forms.Platform.iOS/Renderers/NavigationMenuRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/NavigationMenuRenderer.cs index b326992..aa9b5ff 100644 --- a/Xamarin.Forms.Platform.iOS/Renderers/NavigationMenuRenderer.cs +++ b/Xamarin.Forms.Platform.iOS/Renderers/NavigationMenuRenderer.cs @@ -89,7 +89,7 @@ namespace Xamarin.Forms.Platform.iOS set { _nameLabel.Text = value; } } - public Action Selected { get; set; } + public new Action Selected { get; set; } public override void LayoutSubviews() { diff --git a/Xamarin.Forms.Platform.iOS/Renderers/NavigationRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/NavigationRenderer.cs index 74e7fdd..ca690ee 100644 --- a/Xamarin.Forms.Platform.iOS/Renderers/NavigationRenderer.cs +++ b/Xamarin.Forms.Platform.iOS/Renderers/NavigationRenderer.cs @@ -435,9 +435,9 @@ namespace Xamarin.Forms.Platform.iOS void HandlePropertyChanged(object sender, PropertyChangedEventArgs e) { -#pragma warning disable 618 +#pragma warning disable 0618 //retaining legacy call to obsolete code if (e.PropertyName == NavigationPage.TintProperty.PropertyName) -#pragma warning restore 618 +#pragma warning restore 0618 UpdateTint(); if (e.PropertyName == NavigationPage.BarBackgroundColorProperty.PropertyName) UpdateBarBackgroundColor(); @@ -645,10 +645,9 @@ namespace Xamarin.Forms.Platform.iOS void UpdateTint() { -#pragma warning disable 618 +#pragma warning disable 0618 //retaining legacy call to obsolete code var tintColor = ((NavigationPage)Element).Tint; -#pragma warning restore 618 - +#pragma warning restore 0618 if (Forms.IsiOS7OrNewer) { NavigationBar.BarTintColor = tintColor == Color.Default ? UINavigationBar.Appearance.BarTintColor : tintColor.ToUIColor(); diff --git a/Xamarin.Forms.Platform.iOS/Renderers/TabletMasterDetailRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/TabletMasterDetailRenderer.cs index 3561322..6bf2aa8 100644 --- a/Xamarin.Forms.Platform.iOS/Renderers/TabletMasterDetailRenderer.cs +++ b/Xamarin.Forms.Platform.iOS/Renderers/TabletMasterDetailRenderer.cs @@ -69,37 +69,38 @@ namespace Xamarin.Forms.Platform.iOS get { return _innerDelegate == null ? null : _innerDelegate.PresentButton; } } - public void Dispose() + protected override void Dispose(bool disposing) { - if (_disposed) - return; - - if (Element != null) - { - ((Page)Element).SendDisappearing(); - Element.PropertyChanged -= HandlePropertyChanged; - Element = null; - } - - if (_tracker != null) - { - _tracker.Dispose(); - _tracker = null; - } - - if (_events != null) - { - _events.Dispose(); - _events = null; - } - - if (_masterController != null) - { - _masterController.WillAppear -= MasterControllerWillAppear; - _masterController.WillDisappear -= MasterControllerWillDisappear; - } - - _disposed = true; + if (!_disposed && disposing) + { + if (Element != null) + { + ((Page)Element).SendDisappearing(); + Element.PropertyChanged -= HandlePropertyChanged; + Element = null; + } + + if (_tracker != null) + { + _tracker.Dispose(); + _tracker = null; + } + + if (_events != null) + { + _events.Dispose(); + _events = null; + } + + if (_masterController != null) + { + _masterController.WillAppear -= MasterControllerWillAppear; + _masterController.WillDisappear -= MasterControllerWillDisappear; + } + + _disposed = true; + } + base.Dispose(disposing); } public VisualElement Element { get; private set; } diff --git a/Xamarin.Forms.Platform.iOS/Renderers/WebViewRenderer.cs b/Xamarin.Forms.Platform.iOS/Renderers/WebViewRenderer.cs index 538bc2d..0c6c639 100644 --- a/Xamarin.Forms.Platform.iOS/Renderers/WebViewRenderer.cs +++ b/Xamarin.Forms.Platform.iOS/Renderers/WebViewRenderer.cs @@ -19,8 +19,6 @@ namespace Xamarin.Forms.Platform.iOS WebNavigationEvent _lastBackForwardEvent; VisualElementPackager _packager; - VisualElementTracker _tracker; - public WebViewRenderer() : base(RectangleF.Empty) { } @@ -49,8 +47,6 @@ namespace Xamarin.Forms.Platform.iOS AutosizesSubviews = true; AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; - _tracker = new VisualElementTracker(this); - _packager = new VisualElementPackager(this); _packager.Load(); diff --git a/Xamarin.Forms.Platform.iOS/Xamarin.Forms.Platform.iOS.Classic.csproj b/Xamarin.Forms.Platform.iOS/Xamarin.Forms.Platform.iOS.Classic.csproj index 592c95e..d867994 100644 --- a/Xamarin.Forms.Platform.iOS/Xamarin.Forms.Platform.iOS.Classic.csproj +++ b/Xamarin.Forms.Platform.iOS/Xamarin.Forms.Platform.iOS.Classic.csproj @@ -25,7 +25,7 @@ true iPhone Developer true - 0169;0114;0108;0105;0414;0649 + none @@ -38,7 +38,7 @@ iPhone Developer TRACE;__IOS__;__MOBILE__; true - 0169;0114;0108;0105;0414;0649 + true @@ -50,11 +50,11 @@ prompt MinimumRecommendedRules.ruleset true - 0169;0114;0108;0105;0414;0649 + true - 0169;0114;0108;0105;0414;0649 + diff --git a/Xamarin.Forms.Platform.iOS/Xamarin.Forms.Platform.iOS.csproj b/Xamarin.Forms.Platform.iOS/Xamarin.Forms.Platform.iOS.csproj index 48b816b..5c75adf 100644 --- a/Xamarin.Forms.Platform.iOS/Xamarin.Forms.Platform.iOS.csproj +++ b/Xamarin.Forms.Platform.iOS/Xamarin.Forms.Platform.iOS.csproj @@ -20,7 +20,7 @@ 4 false true - 0108;0114;0414;0649 + full @@ -30,7 +30,7 @@ 4 false true - 0108;0114;0414;0649 + true @@ -42,11 +42,11 @@ prompt MinimumRecommendedRules.ruleset true - 0108;0114;0414;0649 + true - 0108;0114;0414;0649 + -- 2.7.4