OSDN Git Service

C#7.0で追加されたout変数宣言の構文を使用する
authorKimura Youichi <kim.upsilon@bucyou.net>
Mon, 24 Oct 2016 17:07:41 +0000 (02:07 +0900)
committerKimura Youichi <kim.upsilon@bucyou.net>
Sat, 11 Mar 2017 18:31:12 +0000 (03:31 +0900)
20 files changed:
OpenTween.Tests/LRUCacheDictionaryTest.cs
OpenTween.Tests/Models/TabInformationTest.cs
OpenTween/Api/TwitterApiStatus.cs
OpenTween/ApplicationEvents.cs
OpenTween/FilterDialog.cs
OpenTween/ImageCache.cs
OpenTween/LRUCacheDictionary.cs
OpenTween/MediaSelector.cs
OpenTween/Models/HomeTabModel.cs
OpenTween/Models/InternalStorageTabModel.cs
OpenTween/Models/TabInformations.cs
OpenTween/Models/TabModel.cs
OpenTween/MyCommon.cs
OpenTween/NativeMethods.cs
OpenTween/Setting/Panel/ProxyPanel.cs
OpenTween/ShortUrl.cs
OpenTween/Thumbnail/Services/Nicovideo.cs
OpenTween/Tween.cs
OpenTween/Twitter.cs
OpenTween/WebBrowserController.cs

index ab9e627..02fb9a9 100644 (file)
@@ -337,8 +337,7 @@ namespace OpenTween
                 ["key3"] = "value3",
             };
 
-            string value;
-            var ret = dict.TryGetValue("key1", out value);
+            var ret = dict.TryGetValue("key1", out var value);
             Assert.True(ret);
             Assert.Equal("value1", value);
 
index 981b73c..f44e371 100644 (file)
@@ -403,10 +403,8 @@ namespace OpenTween.Models
             // この時点ではまだ削除されない
             Assert.Equal(1, homeTab.AllCount);
 
-            string soundFile;
-            PostClass[] notifyPosts;
-            bool newMentionOrDm, isDeletePost;
-            this.tabinfo.SubmitUpdate(out soundFile, out notifyPosts, out newMentionOrDm, out isDeletePost);
+            this.tabinfo.SubmitUpdate(out var soundFile, out var notifyPosts,
+                out var newMentionOrDm, out var isDeletePost);
 
             Assert.True(isDeletePost);
             Assert.Equal(0, homeTab.AllCount);
@@ -433,10 +431,8 @@ namespace OpenTween.Models
             Assert.Equal(1, homeTab.AllCount);
             Assert.Equal(1, favTab.AllCount);
 
-            string soundFile;
-            PostClass[] notifyPosts;
-            bool newMentionOrDm, isDeletePost;
-            this.tabinfo.SubmitUpdate(out soundFile, out notifyPosts, out newMentionOrDm, out isDeletePost);
+            this.tabinfo.SubmitUpdate(out var soundFile, out var notifyPosts,
+                out var newMentionOrDm, out var isDeletePost);
 
             Assert.True(isDeletePost);
             Assert.Equal(1, homeTab.AllCount);
@@ -472,10 +468,8 @@ namespace OpenTween.Models
 
             this.tabinfo.DistributePosts();
 
-            string soundFile;
-            PostClass[] notifyPosts;
-            bool newMentionOrDm, isDeletePost;
-            this.tabinfo.SubmitUpdate(out soundFile, out notifyPosts, out newMentionOrDm, out isDeletePost);
+            this.tabinfo.SubmitUpdate(out var soundFile, out var notifyPosts,
+                out var newMentionOrDm, out var isDeletePost);
 
             // DM が最も優先度が高いため DM の通知音が再生される
             Assert.Equal("dm.wav", soundFile);
@@ -503,10 +497,8 @@ namespace OpenTween.Models
 
             this.tabinfo.DistributePosts();
 
-            string soundFile;
-            PostClass[] notifyPosts;
-            bool newMentionOrDm, isDeletePost;
-            this.tabinfo.SubmitUpdate(out soundFile, out notifyPosts, out newMentionOrDm, out isDeletePost);
+            this.tabinfo.SubmitUpdate(out var soundFile, out var notifyPosts,
+                out var newMentionOrDm, out var isDeletePost);
 
             // リプライの方が通知音の優先度が高いが、replyTab.SoundFile が空文字列なので次点の Recent の通知音を鳴らす
             Assert.Equal("home.wav", soundFile);
index 3e718b8..ace68dc 100644 (file)
@@ -106,8 +106,7 @@ namespace OpenTween.Api
             {
                 if (!dict.ContainsKey(key)) continue;
 
-                long result;
-                if (long.TryParse(dict[key], out result))
+                if (long.TryParse(dict[key], out var result))
                     return result;
             }
 
@@ -173,8 +172,7 @@ namespace OpenTween.Api
             {
                 get
                 {
-                    ApiLimit limit;
-                    return this.innerDict.TryGetValue(endpoint, out limit)
+                    return this.innerDict.TryGetValue(endpoint, out var limit)
                         ? limit
                         : null;
                 }
index c0d60d2..a67f892 100644 (file)
@@ -215,8 +215,7 @@ namespace OpenTween
 
         private static bool SetConfigDirectoryPath()
         {
-            string configDir;
-            if (StartupOptions.TryGetValue("configDir", out configDir) && !string.IsNullOrEmpty(configDir))
+            if (StartupOptions.TryGetValue("configDir", out var configDir) && !string.IsNullOrEmpty(configDir))
             {
                 // 起動オプション /configDir で設定ファイルの参照先を変更できます
                 if (!Directory.Exists(configDir))
index d7a86e5..1374f7b 100644 (file)
@@ -598,11 +598,8 @@ namespace OpenTween
 
         private void ButtonOK_Click(object sender, EventArgs e)
         {
-            bool isBlankMatch = false;
-            bool isBlankExclude = false;
-
             //入力チェック
-            if (!CheckMatchRule(out isBlankMatch) || !CheckExcludeRule(out isBlankExclude))
+            if (!CheckMatchRule(out var isBlankMatch) || !CheckExcludeRule(out var isBlankExclude))
             {
                 return;
             }
@@ -1090,8 +1087,7 @@ namespace OpenTween
                 int idx = ListTabs.SelectedIndex;
 
                 var origTabName = (string)this.ListTabs.SelectedItem;
-                string newTabName;
-                if (((TweenMain)this.Owner).TabRename(origTabName, out newTabName))
+                if (((TweenMain)this.Owner).TabRename(origTabName, out var newTabName))
                 {
                     ListTabs.Items.RemoveAt(idx);
                     ListTabs.Items.Insert(idx, newTabName);
index fff786f..5f66cfc 100644 (file)
@@ -90,10 +90,9 @@ namespace OpenTween
 
             return Task.Run(() =>
             {
-                Task<MemoryImage> cachedImageTask = null;
                 lock (this.lockObject)
                 {
-                    innerDictionary.TryGetValue(address, out cachedImageTask);
+                    innerDictionary.TryGetValue(address, out var cachedImageTask);
 
                     if (cachedImageTask != null)
                     {
@@ -134,8 +133,7 @@ namespace OpenTween
         {
             lock (this.lockObject)
             {
-                Task<MemoryImage> imageTask;
-                if (!this.innerDictionary.TryGetValue(address, out imageTask) ||
+                if (!this.innerDictionary.TryGetValue(address, out var imageTask) ||
                     imageTask.Status != TaskStatus.RanToCompletion)
                     return null;
 
index 58ff696..64e4d17 100644 (file)
@@ -135,16 +135,14 @@ namespace OpenTween
 
         public bool Contains(KeyValuePair<TKey, TValue> item)
         {
-            LinkedListNode<KeyValuePair<TKey, TValue>> node;
-            if (!this.innerDict.TryGetValue(item.Key, out node)) return false;
+            if (!this.innerDict.TryGetValue(item.Key, out var node)) return false;
 
             return node.Value.Value.Equals(item.Value);
         }
 
         public bool Remove(TKey key)
         {
-            LinkedListNode<KeyValuePair<TKey, TValue>> node;
-            if (!this.innerDict.TryGetValue(key, out node)) return false;
+            if (!this.innerDict.TryGetValue(key, out var node)) return false;
 
             this.innerList.Remove(node);
 
@@ -153,8 +151,7 @@ namespace OpenTween
 
         public bool Remove(KeyValuePair<TKey, TValue> item)
         {
-            LinkedListNode<KeyValuePair<TKey, TValue>> node;
-            if (!this.innerDict.TryGetValue(item.Key, out node)) return false;
+            if (!this.innerDict.TryGetValue(item.Key, out var node)) return false;
 
             if (!node.Value.Value.Equals(item.Value)) return false;
 
@@ -165,9 +162,7 @@ namespace OpenTween
 
         public bool TryGetValue(TKey key, out TValue value)
         {
-            LinkedListNode<KeyValuePair<TKey, TValue>> node;
-
-            var ret = this.innerDict.TryGetValue(key, out node);
+            var ret = this.innerDict.TryGetValue(key, out var node);
 
             if (!ret)
             {
@@ -208,11 +203,9 @@ namespace OpenTween
             }
             set
             {
-                LinkedListNode<KeyValuePair<TKey, TValue>> node;
-
                 var pair = new KeyValuePair<TKey, TValue>(key, value);
 
-                if (this.innerDict.TryGetValue(key, out node))
+                if (this.innerDict.TryGetValue(key, out var node))
                 {
                     this.innerList.Remove(node);
                     node.Value = pair;
index 240dce2..c2d934e 100644 (file)
@@ -81,8 +81,8 @@ namespace OpenTween
                 if (string.IsNullOrEmpty(serviceName))
                     return null;
 
-                IMediaUploadService service;
-                return this.pictureService.TryGetValue(serviceName, out service) ? service : null;
+                return this.pictureService.TryGetValue(serviceName, out var service)
+                    ? service : null;
             }
         }
 
@@ -91,8 +91,7 @@ namespace OpenTween
         /// </summary>
         public IMediaUploadService GetService(string serviceName)
         {
-            IMediaUploadService service;
-            this.pictureService.TryGetValue(serviceName, out service);
+            this.pictureService.TryGetValue(serviceName, out var service);
             return service;
         }
 
index ba93579..8b5f6ea 100644 (file)
@@ -108,9 +108,8 @@ namespace OpenTween.Models
             }
             Interlocked.Exchange(ref this.tweetsPerHour, tweetsInWindow);
 
-            int _;
             foreach (var key in removeKeys)
-                this.tweetsTimestamps.TryRemove(key, out _);
+                this.tweetsTimestamps.TryRemove(key, out var _);
         }
     }
 }
index 3512dab..b1f7ff1 100644 (file)
@@ -61,8 +61,7 @@ namespace OpenTween.Models
 
             if (setIsDeleted)
             {
-                PostClass post;
-                if (this.internalPosts.TryGetValue(statusId, out post))
+                if (this.internalPosts.TryGetValue(statusId, out var post))
                     post.IsDeleted = true;
             }
         }
@@ -72,8 +71,7 @@ namespace OpenTween.Models
             if (!base.RemovePostImmediately(statusId))
                 return false;
 
-            PostClass removedPost;
-            this.internalPosts.TryRemove(statusId, out removedPost);
+            this.internalPosts.TryRemove(statusId, out var removedPost);
 
             return true;
         }
index 22c1be7..723c362 100644 (file)
@@ -283,8 +283,7 @@ namespace OpenTween.Models
         //    }
         public PostClass RetweetSource(long Id)
         {
-            PostClass status;
-            return this._statuses.TryGetValue(Id, out status)
+            return this._statuses.TryGetValue(Id, out var status)
                 ? status
                 : null;
         }
@@ -332,20 +331,15 @@ namespace OpenTween.Models
 
             if (setIsDeleted)
             {
-                PostClass post;
-                if (this._statuses.TryGetValue(statusId, out post))
+                if (this._statuses.TryGetValue(statusId, out var post))
                     post.IsDeleted = true;
             }
         }
 
         public int SubmitUpdate()
         {
-            string soundFile;
-            PostClass[] notifyPosts;
-            bool newMentionOrDm, isDeletePost;
-
-            return this.SubmitUpdate(out soundFile, out notifyPosts, out newMentionOrDm,
-                out isDeletePost);
+            return this.SubmitUpdate(out var soundFile, out var notifyPosts,
+                out var newMentionOrDm, out var isDeletePost);
         }
 
         public int SubmitUpdate(out string soundFile, out PostClass[] notifyPosts,
@@ -384,8 +378,7 @@ namespace OpenTween.Models
                             // 通知対象のリストに追加
                             foreach (var statusId in addedIds)
                             {
-                                PostClass post;
-                                if (tab.Posts.TryGetValue(statusId, out post))
+                                if (tab.Posts.TryGetValue(statusId, out var post))
                                     notifyPostsList.Add(post);
                             }
                         }
@@ -394,8 +387,7 @@ namespace OpenTween.Models
                         // SettingCommon.PlaySound が false であれば TweenMain 側で無効化される
                         if (!string.IsNullOrEmpty(tab.SoundFile))
                         {
-                            int notifyPriority;
-                            if (!this.notifyPriorityByTabType.TryGetValue(tab.TabType, out notifyPriority))
+                            if (!this.notifyPriorityByTabType.TryGetValue(tab.TabType, out var notifyPriority))
                                 notifyPriority = 0;
 
                             if (notifyPriority > currentNotifyPriority)
@@ -432,10 +424,7 @@ namespace OpenTween.Models
 
                     // 全てのタブから表示されなくなった発言は this._statuses からも削除する
                     if (orphaned)
-                    {
-                        PostClass removedPost;
-                        this._statuses.TryRemove(removedId, out removedPost);
-                    }
+                        this._statuses.TryRemove(removedId, out var removedPost);
                 }
 
                 return addedCountTotal;
@@ -455,11 +444,9 @@ namespace OpenTween.Models
 
                 var adddedCount = 0;
 
-                long statusId;
-                while (this.addQueue.TryDequeue(out statusId))
+                while (this.addQueue.TryDequeue(out var statusId))
                 {
-                    PostClass post;
-                    if (!this._statuses.TryGetValue(statusId, out post))
+                    if (!this._statuses.TryGetValue(statusId, out var post))
                         continue;
 
                     var filterHit = false; // フィルタにヒットしたタブがあるか
@@ -524,8 +511,7 @@ namespace OpenTween.Models
                 if (this.IsMuted(Item, isHomeTimeline: true))
                     return;
 
-                PostClass status;
-                if (_statuses.TryGetValue(Item.StatusId, out status))
+                if (_statuses.TryGetValue(Item.StatusId, out var status))
                 {
                     if (Item.IsFav)
                     {
@@ -633,8 +619,7 @@ namespace OpenTween.Models
                 }
 
                 // TabInformations自身が保持しているツイートであればここで IsRead を変化させる
-                PostClass post;
-                if (this.Posts.TryGetValue(statusId, out post))
+                if (this.Posts.TryGetValue(statusId, out var post))
                     post.IsRead = read;
 
                 return true;
@@ -653,8 +638,7 @@ namespace OpenTween.Models
             {
                 foreach (var statusId in homeTab.GetUnreadIds())
                 {
-                    PostClass post;
-                    if (!this.Posts.TryGetValue(statusId, out post))
+                    if (!this.Posts.TryGetValue(statusId, out var post))
                         continue;
 
                     if (post.IsReply || post.FilterHit)
@@ -669,8 +653,7 @@ namespace OpenTween.Models
         {
             get
             {
-                PostClass status;
-                if (this._statuses.TryGetValue(ID, out status))
+                if (this._statuses.TryGetValue(ID, out var status))
                     return status;
 
                 if (this._quotes.TryGetValue(ID, out status))
@@ -792,8 +775,7 @@ namespace OpenTween.Models
 
                     if (!hit)
                     {
-                        PostClass post;
-                        if (this._statuses.TryGetValue(id, out post))
+                        if (this._statuses.TryGetValue(id, out var post))
                             homeTab.AddPostImmediately(post.StatusId, post.IsRead);
                     }
                 }
@@ -820,10 +802,7 @@ namespace OpenTween.Models
                             }
                         }
                         if (!Hit)
-                        {
-                            PostClass removedPost;
-                            _statuses.TryRemove(Id, out removedPost);
-                        }
+                            _statuses.TryRemove(Id, out var removedPost);
                     }
                 }
 
@@ -909,8 +888,7 @@ namespace OpenTween.Models
         {
             lock (LockObj)
             {
-                TabModel tab;
-                return _tabs.TryGetValue(tabName, out tab)
+                return _tabs.TryGetValue(tabName, out var tab)
                     ? tab
                     : null;
             }
index 9f4c94d..aa0ac24 100644 (file)
@@ -119,8 +119,7 @@ namespace OpenTween.Models
         {
             var addedIds = new List<long>();
 
-            TemporaryId tId;
-            while (this.addQueue.TryDequeue(out tId))
+            while (this.addQueue.TryDequeue(out var tId))
             {
                 if (this.AddPostImmediately(tId.StatusId, tId.Read))
                     addedIds.Add(tId.StatusId);
@@ -147,8 +146,7 @@ namespace OpenTween.Models
         {
             var removedIds = new List<long>();
 
-            long statusId;
-            while (this.removeQueue.TryDequeue(out statusId))
+            while (this.removeQueue.TryDequeue(out var statusId))
             {
                 if (this.RemovePostImmediately(statusId))
                     removedIds.Add(statusId);
@@ -216,9 +214,8 @@ namespace OpenTween.Models
 
                 comparison = (x, y) =>
                 {
-                    PostClass xPost, yPost;
-                    this.Posts.TryGetValue(x, out xPost);
-                    this.Posts.TryGetValue(y, out yPost);
+                    this.Posts.TryGetValue(x, out var xPost);
+                    this.Posts.TryGetValue(y, out var yPost);
 
                     var compare = sign * postComparison(xPost, yPost);
                     if (compare != 0)
@@ -322,8 +319,7 @@ namespace OpenTween.Models
         {
             get
             {
-                PostClass post;
-                if (!this.Posts.TryGetValue(this.GetStatusIdAt(index), out post))
+                if (!this.Posts.TryGetValue(this.GetStatusIdAt(index), out var post))
                     throw new ArgumentOutOfRangeException(nameof(index), "Post not exists");
 
                 return post;
@@ -422,8 +418,7 @@ namespace OpenTween.Models
 
             foreach (var index in searchIndices)
             {
-                PostClass post;
-                if (!this.Posts.TryGetValue(this.GetStatusIdAt(index), out post))
+                if (!this.Posts.TryGetValue(this.GetStatusIdAt(index), out var post))
                     continue;
 
                 if (stringComparer(post.Nickname) || stringComparer(post.TextFromApi) || stringComparer(post.ScreenName))
index 1baa521..14f1ad8 100644 (file)
@@ -814,7 +814,6 @@ namespace OpenTween
 
         public static DateTime DateTimeParse(string input)
         {
-            DateTime rslt;
             string[] format = {
                 "ddd MMM dd HH:mm:ss zzzz yyyy",
                 "ddd, d MMM yyyy HH:mm:ss zzzz",
@@ -825,7 +824,7 @@ namespace OpenTween
                                           fmt,
                                           DateTimeFormatInfo.InvariantInfo,
                                           DateTimeStyles.None,
-                                          out rslt))
+                                          out var rslt))
                 {
                     return rslt;
                 }
index d693ddc..f4ccc24 100644 (file)
@@ -482,8 +482,7 @@ namespace OpenTween
 
             EnumWindows((hWnd, lParam) =>
             {
-                uint procId;
-                GetWindowThreadProcessId(hWnd, out procId);
+                GetWindowThreadProcessId(hWnd, out var procId);
 
                 if (procId == pid)
                 {
index 479e7d9..fbdf5e7 100644 (file)
@@ -110,9 +110,8 @@ namespace OpenTween.Setting.Panel
 
         private void TextProxyPort_Validating(object sender, CancelEventArgs e)
         {
-            int port;
             if (string.IsNullOrWhiteSpace(TextProxyPort.Text)) TextProxyPort.Text = "0";
-            if (int.TryParse(TextProxyPort.Text.Trim(), out port) == false)
+            if (int.TryParse(TextProxyPort.Text.Trim(), out var port) == false)
             {
                 MessageBox.Show(Properties.Resources.TextProxyPort_ValidatingText1);
                 e.Cancel = true;
index 725b052..a08527e 100644 (file)
@@ -206,8 +206,7 @@ namespace OpenTween
                 if (!ShortUrlHosts.Contains(uri.Host) && !IsIrregularShortUrl(uri))
                     return uri;
 
-                Uri expanded;
-                if (this.urlCache.TryGetValue(uri, out expanded))
+                if (this.urlCache.TryGetValue(uri, out var expanded))
                     return expanded;
 
                 if (this.urlCache.Count > this.PurgeCount)
index 6f688b0..eaaa601 100644 (file)
@@ -103,8 +103,7 @@ namespace OpenTween.Thumbnail.Services
             }
 
             var firstRetrieveElement = thumbElement.Element("first_retrieve");
-            DateTime firstRetrieveDate;
-            if (firstRetrieveElement != null && DateTime.TryParse(firstRetrieveElement.Value, out firstRetrieveDate))
+            if (firstRetrieveElement != null && DateTime.TryParse(firstRetrieveElement.Value, out var firstRetrieveDate))
             {
                 tooltip.Append(Properties.Resources.NiconicoInfoText3);
                 tooltip.Append(firstRetrieveDate.ToString());
index c132bbe..e6cd704 100644 (file)
@@ -1392,12 +1392,9 @@ namespace OpenTween
             var listSelections = this.SaveListViewSelection();
 
             //更新確定
-            PostClass[] notifyPosts;
-            string soundFile;
             int addCount;
-            bool newMentionOrDm;
-            bool isDelete;
-            addCount = _statuses.SubmitUpdate(out soundFile, out notifyPosts, out newMentionOrDm, out isDelete);
+            addCount = _statuses.SubmitUpdate(out var soundFile, out var notifyPosts,
+                out var newMentionOrDm, out var isDelete);
 
             if (MyCommon._endingFlag) return;
 
@@ -1944,9 +1941,7 @@ namespace OpenTween
                 return;
 
             // キャッシュに含まれていないアイテムは対象外
-            ListViewItem itm;
-            PostClass post;
-            if (!listCache.TryGetValue(Index, out itm, out post))
+            if (!listCache.TryGetValue(Index, out var itm, out var post))
                 return;
 
             ChangeItemStyleRead(Read, itm, post, ((DetailsListView)_curTab.Tag));
@@ -2503,8 +2498,7 @@ namespace OpenTween
             if (!CheckAccountValid())
                 throw new WebApiException("Auth error. Check your account");
 
-            PostClass post;
-            if (!tab.Posts.TryGetValue(statusId, out post))
+            if (!tab.Posts.TryGetValue(statusId, out var post))
                 return;
 
             if (post.IsFav)
@@ -3075,8 +3069,7 @@ namespace OpenTween
 
         private async Task FavoriteChange(bool FavAdd, bool multiFavoriteChangeDialogEnable = true)
         {
-            TabModel tab;
-            if (!this._statuses.Tabs.TryGetValue(this._curTab.Text, out tab))
+            if (!this._statuses.Tabs.TryGetValue(this._curTab.Text, out var tab))
                 return;
 
             //trueでFavAdd,falseでFavRemove
@@ -3140,9 +3133,7 @@ namespace OpenTween
             var listCache = this._listItemCache;
             if (listCache != null)
             {
-                ListViewItem item;
-                PostClass post;
-                if (listCache.TryGetValue(Index, out item, out post))
+                if (listCache.TryGetValue(Index, out var item, out var post))
                     return post;
             }
 
@@ -3612,8 +3603,7 @@ namespace OpenTween
         {
             if (_curTab != null)
             {
-                TabModel tab;
-                if (!this._statuses.Tabs.TryGetValue(this._curTab.Text, out tab))
+                if (!this._statuses.Tabs.TryGetValue(this._curTab.Text, out var tab))
                     return;
 
                 switch (tab)
@@ -3654,8 +3644,7 @@ namespace OpenTween
             //ページ指定をマイナス1に
             if (_curTab != null)
             {
-                TabModel tab;
-                if (!this._statuses.Tabs.TryGetValue(this._curTab.Text, out tab))
+                if (!this._statuses.Tabs.TryGetValue(this._curTab.Text, out var tab))
                     return;
 
                 switch (tab)
@@ -4835,9 +4824,7 @@ namespace OpenTween
             var listCache = this._listItemCache;
             if (listCache?.TargetList == sender)
             {
-                ListViewItem item;
-                PostClass cacheItemPost;
-                if (listCache.TryGetValue(e.ItemIndex, out item, out cacheItemPost))
+                if (listCache.TryGetValue(e.ItemIndex, out var item, out var cacheItemPost))
                 {
                     e.Item = item;
                     return;
@@ -5044,8 +5031,7 @@ namespace OpenTween
                     rct.Height -= fontHeight;
                 }
 
-                int heightDiff;
-                int drawLineCount = Math.Max(1, Math.DivRem((int)rct.Height, fontHeight, out heightDiff));
+                int drawLineCount = Math.Max(1, Math.DivRem((int)rct.Height, fontHeight, out var heightDiff));
 
                 //if (heightDiff > fontHeight * 0.7)
                 //{
@@ -5796,8 +5782,7 @@ namespace OpenTween
                 if (e.Control || e.Shift || e.Alt)
                     this._anchorFlag = false;
 
-                Task asyncTask;
-                if (CommonKeyDown(e.KeyData, FocusedControl.ListTab, out asyncTask))
+                if (CommonKeyDown(e.KeyData, FocusedControl.ListTab, out var asyncTask))
                 {
                     e.Handled = true;
                     e.SuppressKeyPress = true;
@@ -7146,8 +7131,7 @@ namespace OpenTween
 
         private async void StatusText_KeyDown(object sender, KeyEventArgs e)
         {
-            Task asyncTask;
-            if (CommonKeyDown(e.KeyData, FocusedControl.StatusText, out asyncTask))
+            if (CommonKeyDown(e.KeyData, FocusedControl.StatusText, out var asyncTask))
             {
                 e.Handled = true;
                 e.SuppressKeyPress = true;
@@ -7339,8 +7323,7 @@ namespace OpenTween
 
         private async void OpenURLFileMenuItem_Click(object sender, EventArgs e)
         {
-            string inputText;
-            var ret = InputDialog.Show(this, Properties.Resources.OpenURL_InputText, Properties.Resources.OpenURL_Caption, out inputText);
+            var ret = InputDialog.Show(this, Properties.Resources.OpenURL_InputText, Properties.Resources.OpenURL_Caption, out var inputText);
             if (ret != DialogResult.OK)
                 return;
 
@@ -7485,8 +7468,7 @@ namespace OpenTween
 
         private void ListTab_DoubleClick(object sender, MouseEventArgs e)
         {
-            string _;
-            TabRename(this.ListTab.SelectedTab.Text, out _);
+            TabRename(this.ListTab.SelectedTab.Text, out var _);
         }
 
         private void ListTab_MouseDown(object sender, MouseEventArgs e)
@@ -7979,8 +7961,7 @@ namespace OpenTween
             if (_statuses == null) return;
             if (_statuses.Tabs == null) return;
 
-            TabModel tb;
-            if (!this._statuses.Tabs.TryGetValue(this._rclickTabName, out tb))
+            if (!this._statuses.Tabs.TryGetValue(this._rclickTabName, out var tb))
                 return;
 
             NotifyDispMenuItem.Checked = tb.Notify;
@@ -8223,9 +8204,8 @@ namespace OpenTween
                 //選択発言を元にフィルタ追加
                 foreach (int idx in _curList.SelectedIndices)
                 {
-                    string tabName;
                     //タブ選択(or追加)
-                    if (!SelectTab(out tabName)) return;
+                    if (!SelectTab(out var tabName)) return;
 
                     fltDialog.SetCurrent(tabName);
                     if (_statuses.Tabs[_curTab.Text][idx].RetweetedId == null)
@@ -8380,8 +8360,7 @@ namespace OpenTween
         public void AddFilterRuleByScreenName(params string[] screenNameArray)
         {
             //タブ選択(or追加)
-            string tabName;
-            if (!SelectTab(out tabName)) return;
+            if (!SelectTab(out var tabName)) return;
 
             var tab = (FilterTabModel)this._statuses.Tabs[tabName];
 
@@ -8418,8 +8397,7 @@ namespace OpenTween
         public void AddFilterRuleBySource(params string[] sourceArray)
         {
             // タブ選択ダイアログを表示(or追加)
-            string tabName;
-            if (!this.SelectTab(out tabName))
+            if (!this.SelectTab(out var tabName))
                 return;
 
             var filterTab = (FilterTabModel)this._statuses.Tabs[tabName];
@@ -10249,8 +10227,7 @@ namespace OpenTween
         {
             if (string.IsNullOrEmpty(_rclickTabName)) return;
 
-            string _;
-            TabRename(_rclickTabName, out _);
+            TabRename(_rclickTabName, out var _);
         }
 
         private async void BitlyToolStripMenuItem_Click(object sender, EventArgs e)
index f3f0951..720fe39 100644 (file)
@@ -313,8 +313,7 @@ namespace OpenTween
 
             using (var origImage = item.CreateImage())
             {
-                MemoryImage newImage;
-                if (alphaPNGWorkaround && this.AddAlphaChannelIfNeeded(origImage.Image, out newImage))
+                if (alphaPNGWorkaround && this.AddAlphaChannelIfNeeded(origImage.Image, out var newImage))
                 {
                     using (var newMediaItem = new MemoryImageMediaItem(newImage))
                     {
@@ -879,8 +878,7 @@ namespace OpenTween
                 var match = Twitter.StatusUrlRegex.Match(url);
                 if (match.Success)
                 {
-                    long statusId;
-                    if (long.TryParse(match.Groups["StatusId"].Value, out statusId))
+                    if (long.TryParse(match.Groups["StatusId"].Value, out var statusId))
                         yield return statusId;
                 }
             }
@@ -1077,8 +1075,7 @@ namespace OpenTween
                 .Concat(Twitter.ThirdPartyStatusUrlRegex.Matches(text).Cast<Match>());
             foreach (var _match in ma)
             {
-                Int64 _statusId;
-                if (Int64.TryParse(_match.Groups["StatusId"].Value, out _statusId))
+                if (Int64.TryParse(_match.Groups["StatusId"].Value, out var _statusId))
                 {
                     if (relPosts.ContainsKey(_statusId))
                         continue;
@@ -2029,8 +2026,7 @@ namespace OpenTween
             evt.Username = eventData.Source.ScreenName;
             evt.IsMe = evt.Username.ToLowerInvariant().Equals(this.Username.ToLowerInvariant());
 
-            MyCommon.EVENTTYPE eventType;
-            eventTable.TryGetValue(eventData.Event, out eventType);
+            eventTable.TryGetValue(eventData.Event, out var eventType);
             evt.Eventtype = eventType;
 
             TwitterStreamEvent<TwitterStatusCompat> tweetEvent;
@@ -2075,9 +2071,8 @@ namespace OpenTween
 
                     var tabinfo = TabInformations.GetInstance();
 
-                    PostClass post;
                     var statusId = tweet.Id;
-                    if (!tabinfo.Posts.TryGetValue(statusId, out post))
+                    if (!tabinfo.Posts.TryGetValue(statusId, out var post))
                         break;
 
                     if (eventData.Event == "favorite")
index 56ef6db..dd678ef 100644 (file)
@@ -327,9 +327,8 @@ namespace OpenTween
             // 自分を IInternetSecurityManager として提供
             try
             {
-                int cookie = 0;
                 profferService.ProfferService(
-                    ref WebBrowserAPI.IID_IInternetSecurityManager, this, out cookie);
+                    ref WebBrowserAPI.IID_IInternetSecurityManager, this, out var cookie);
             }
             catch (SEHException ex)
             {