[iOS] Resolve Warning 0108 (#64)
authorSamantha Houts <samantha@teamredwall.com>
Tue, 12 Apr 2016 01:05:28 +0000 (18:05 -0700)
committerJason Smith <jason.smith@xamarin.com>
Tue, 12 Apr 2016 01:05:28 +0000 (18:05 -0700)
[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…

12 files changed:
Xamarin.Forms.Platform.iOS/ContextScrollViewDelegate.cs
Xamarin.Forms.Platform.iOS/GlobalCloseContextGestureRecognizer.cs
Xamarin.Forms.Platform.iOS/Platform.cs
Xamarin.Forms.Platform.iOS/Renderers/CarouselViewRenderer.cs
Xamarin.Forms.Platform.iOS/Renderers/FontExtensions.cs
Xamarin.Forms.Platform.iOS/Renderers/FormattedStringExtensions.cs
Xamarin.Forms.Platform.iOS/Renderers/NavigationMenuRenderer.cs
Xamarin.Forms.Platform.iOS/Renderers/NavigationRenderer.cs
Xamarin.Forms.Platform.iOS/Renderers/TabletMasterDetailRenderer.cs
Xamarin.Forms.Platform.iOS/Renderers/WebViewRenderer.cs
Xamarin.Forms.Platform.iOS/Xamarin.Forms.Platform.iOS.Classic.csproj
Xamarin.Forms.Platform.iOS/Xamarin.Forms.Platform.iOS.csproj

index 47ce071..b2b34e4 100644 (file)
@@ -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);
 
index fa76b98..f0e8522 100644 (file)
@@ -22,13 +22,11 @@ namespace Xamarin.Forms.Platform.iOS
 {
        internal class GlobalCloseContextGestureRecognizer : UIGestureRecognizer
        {
-               List<UIButton> _buttons;
                UIScrollView _scrollView;
 
-               public GlobalCloseContextGestureRecognizer(UIScrollView scrollView, List<UIButton> 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;
                        }
                }
index 0293e75..3022fa0 100644 (file)
@@ -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
index 84f57a9..3efb316 100644 (file)
@@ -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<int> OnBind;
index b241001..c2e565d 100644 (file)
@@ -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
index 89a09e8..4bb829b 100644 (file)
@@ -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;
index b326992..aa9b5ff 100644 (file)
@@ -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()
                        {
index 74e7fdd..ca690ee 100644 (file)
@@ -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();
index 3561322..6bf2aa8 100644 (file)
@@ -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; }
index 538bc2d..0c6c639 100644 (file)
@@ -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();
 
index 592c95e..d867994 100644 (file)
@@ -25,7 +25,7 @@
     <MtouchDebug>true</MtouchDebug>
     <CodesignKey>iPhone Developer</CodesignKey>
     <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
-    <NoWarn>0169;0114;0108;0105;0414;0649</NoWarn>
+    <NoWarn></NoWarn>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
     <DebugType>none</DebugType>
@@ -38,7 +38,7 @@
     <CodesignKey>iPhone Developer</CodesignKey>
     <DefineConstants>TRACE;__IOS__;__MOBILE__;</DefineConstants>
     <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
-    <NoWarn>0169;0114;0108;0105;0414;0649</NoWarn>
+    <NoWarn></NoWarn>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Turkey|AnyCPU'">
     <DebugSymbols>true</DebugSymbols>
     <ErrorReport>prompt</ErrorReport>
     <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
     <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
-    <NoWarn>0169;0114;0108;0105;0414;0649</NoWarn>
+    <NoWarn></NoWarn>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'AppStore|AnyCPU'">
     <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
-    <NoWarn>0169;0114;0108;0105;0414;0649</NoWarn>
+    <NoWarn></NoWarn>
   </PropertyGroup>
   <ItemGroup>
     <Compile Include="..\Xamarin.Forms.Core\Properties\GlobalAssemblyInfo.cs">
index 48b816b..5c75adf 100644 (file)
@@ -20,7 +20,7 @@
     <WarningLevel>4</WarningLevel>
     <ConsolePause>false</ConsolePause>
     <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
-    <NoWarn>0108;0114;0414;0649</NoWarn>
+    <NoWarn></NoWarn>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
     <DebugType>full</DebugType>
@@ -30,7 +30,7 @@
     <WarningLevel>4</WarningLevel>
     <ConsolePause>false</ConsolePause>
     <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
-    <NoWarn>0108;0114;0414;0649</NoWarn>
+    <NoWarn></NoWarn>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Turkey|AnyCPU'">
     <DebugSymbols>true</DebugSymbols>
     <ErrorReport>prompt</ErrorReport>
     <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
     <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
-    <NoWarn>0108;0114;0414;0649</NoWarn>
+    <NoWarn></NoWarn>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'AppStore|AnyCPU'">
     <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
-    <NoWarn>0108;0114;0414;0649</NoWarn>
+    <NoWarn></NoWarn>
   </PropertyGroup>
   <ItemGroup>
     <Reference Include="System" />