OSDN Git Service

読み取り専用のフィールドにreadonlyを追加する (IDE0044)
authorKimura Youichi <kim.upsilon@bucyou.net>
Wed, 28 Aug 2019 17:08:02 +0000 (02:08 +0900)
committerKimura Youichi <kim.upsilon@bucyou.net>
Wed, 28 Aug 2019 19:26:29 +0000 (04:26 +0900)
28 files changed:
OpenTween.Tests/DateTimeUtcTest.cs
OpenTween.Tests/LRUCacheDictionaryTest.cs
OpenTween.Tests/Models/TabInformationTest.cs
OpenTween.Tests/MyCommonTest.cs
OpenTween.Tests/TabsDialogTest.cs
OpenTween/Api/TwitterApiStatus.cs
OpenTween/AtIdSupplement.cs
OpenTween/FilterDialog.cs
OpenTween/HashtagManage.cs
OpenTween/HookGlobalHotkey.cs
OpenTween/ImageCache.cs
OpenTween/ImageListViewItem.cs
OpenTween/ListManage.cs
OpenTween/Models/FilterTabModel.cs
OpenTween/Models/HomeTabModel.cs
OpenTween/Models/TabInformations.cs
OpenTween/Models/TabModel.cs
OpenTween/OpenURL.cs
OpenTween/Setting/SettingBase.cs
OpenTween/Setting/SettingLocal.cs
OpenTween/ShortUrl.cs
OpenTween/Thumbnail/Services/ImgAzyobuziNet.cs
OpenTween/ToolStripLabelHistory.cs
OpenTween/Tween.cs
OpenTween/TweetFormatter.cs
OpenTween/Twitter.cs
OpenTween/WebBrowserController.cs
OpenTween/nicoms.cs

index ec22397..9ed6cd2 100644 (file)
@@ -269,7 +269,7 @@ namespace OpenTween
                 utc.ToDateTimeUnsafe());
         }
 
-        public static TheoryData<string, DateTimeUtc> Parse_Test_Fixtures = new TheoryData<string, DateTimeUtc>
+        public static readonly TheoryData<string, DateTimeUtc> Parse_Test_Fixtures = new TheoryData<string, DateTimeUtc>
         {
             { "2018-05-06T11:22:33.111", new DateTimeUtc(2018, 5, 6, 11, 22, 33, 111) },
             { "2018-05-06T11:22:33.111+00:00", new DateTimeUtc(2018, 5, 6, 11, 22, 33, 111) },
@@ -285,7 +285,7 @@ namespace OpenTween
         public void Parse_ErrorTest()
             => Assert.Throws<FormatException>(() => DateTimeUtc.Parse("### INVALID ###", DateTimeFormatInfo.InvariantInfo));
 
-        public static TheoryData<string, bool, DateTimeUtc> TryParse_Test_Fixtures = new TheoryData<string, bool, DateTimeUtc>
+        public static readonly TheoryData<string, bool, DateTimeUtc> TryParse_Test_Fixtures = new TheoryData<string, bool, DateTimeUtc>
         {
             { "2018-05-06T11:22:33.111", true, new DateTimeUtc(2018, 5, 6, 11, 22, 33, 111) },
             { "2018-05-06T11:22:33.111+00:00", true, new DateTimeUtc(2018, 5, 6, 11, 22, 33, 111) },
@@ -303,7 +303,7 @@ namespace OpenTween
             Assert.Equal(expectedResult, result);
         }
 
-        public static TheoryData<string, string, bool, DateTimeUtc> TryParseExact_Test_Fixtures = new TheoryData<string, string, bool, DateTimeUtc>
+        public static readonly TheoryData<string, string, bool, DateTimeUtc> TryParseExact_Test_Fixtures = new TheoryData<string, string, bool, DateTimeUtc>
         {
             { "2018-05-06 11:22:33.111", "yyyy-MM-dd HH:mm:ss.fff", true, new DateTimeUtc(2018, 5, 6, 11, 22, 33, 111) },
             { "2018-05-06 11:22:33.111 +00:00", "yyyy-MM-dd HH:mm:ss.fff zzz", true, new DateTimeUtc(2018, 5, 6, 11, 22, 33, 111) },
index 3c7f354..8582107 100644 (file)
@@ -31,7 +31,7 @@ namespace OpenTween
 {
     public class LRUCacheDictionaryTest
     {
-        private static AnyOrderComparer<string> collComparer = AnyOrderComparer<string>.Instance;
+        private static readonly AnyOrderComparer<string> collComparer = AnyOrderComparer<string>.Instance;
 
         [Fact]
         public void InnerListTest()
index cd64b22..598855b 100644 (file)
@@ -31,7 +31,7 @@ namespace OpenTween.Models
 {
     public class TabInformationTest
     {
-        private TabInformations tabinfo;
+        private readonly TabInformations tabinfo;
 
         public TabInformationTest()
         {
index ced990d..4194662 100644 (file)
@@ -114,7 +114,7 @@ namespace OpenTween
             Assert.Equal(expected, MyCommon.IsAnimatedGif(filename));
         }
 
-        public static TheoryData<string, DateTimeUtc> DateTimeParse_TestCase = new TheoryData<string, DateTimeUtc>
+        public static readonly TheoryData<string, DateTimeUtc> DateTimeParse_TestCase = new TheoryData<string, DateTimeUtc>
         {
             { "Sun Nov 25 06:10:00 +00:00 2012", new DateTimeUtc(2012, 11, 25, 6, 10, 0) },
             { "Sun, 25 Nov 2012 06:10:00 +00:00", new DateTimeUtc(2012, 11, 25, 6, 10, 0) },
index 1b7d4c8..12331db 100644 (file)
@@ -33,7 +33,7 @@ namespace OpenTween
 {
     public class TabsDialogTest
     {
-        private TabInformations tabinfo;
+        private readonly TabInformations tabinfo;
 
         public TabsDialogTest()
         {
index fc73729..adf488d 100644 (file)
@@ -151,7 +151,8 @@ namespace OpenTween.Api
         {
             public TwitterApiStatus Owner { get; }
 
-            private ConcurrentDictionary<string, ApiLimit> innerDict = new ConcurrentDictionary<string, ApiLimit>();
+            private readonly ConcurrentDictionary<string, ApiLimit> innerDict
+                = new ConcurrentDictionary<string, ApiLimit>();
 
             public EndpointLimits(TwitterApiStatus owner)
                 => this.Owner = owner;
index d87967d..3179b32 100644 (file)
@@ -41,7 +41,7 @@ namespace OpenTween
 
         public string inputText = "";
         public bool isBack = false;
-        private string startChar = "";
+        private readonly string startChar = "";
 
         public void AddItem(string id)
         {
index dc9a66b..848dae2 100644 (file)
@@ -45,12 +45,12 @@ namespace OpenTween
         private EDITMODE _mode;
         private bool _directAdd;
         private MultiSelectionState _multiSelState = MultiSelectionState.None;
-        private TabInformations _sts;
+        private readonly TabInformations _sts;
 
         private List<TabModel> tabs = new List<TabModel>();
         private int selectedTabIndex = -1;
 
-        private List<string> idlist = new List<string>();
+        private readonly List<string> idlist = new List<string>();
 
         private enum EDITMODE
         {
index d6b93ae..81d790e 100644 (file)
@@ -49,7 +49,7 @@ namespace OpenTween
         public bool RunSilent { get; set; }
 
         //入力補助画面
-        private AtIdSupplement _hashSupl;
+        private readonly AtIdSupplement _hashSupl;
 
         //編集モード
         private bool _isAdd = false;
index ee05a07..6a07ee3 100644 (file)
@@ -34,7 +34,7 @@ namespace OpenTween
 {
     public class HookGlobalHotkey : NativeWindow, IDisposable
     {
-        private Form _targetForm;
+        private readonly Form _targetForm;
         private class KeyEventValue
         {
             public KeyEventArgs KeyEvent { get; }
@@ -47,7 +47,7 @@ namespace OpenTween
             }
         }
 
-        private Dictionary<int, KeyEventValue> _hotkeyID;
+        private readonly Dictionary<int, KeyEventValue> _hotkeyID;
 
         [Flags]
         public enum ModKeys
index 8d7f19a..846170b 100644 (file)
@@ -47,7 +47,7 @@ namespace OpenTween
         /// <summary>
         /// innerDictionary の排他制御のためのロックオブジェクト
         /// </summary>
-        private object lockObject = new object();
+        private readonly object lockObject = new object();
 
         /// <summary>
         /// オブジェクトが破棄された否か
index c243379..a006f15 100644 (file)
@@ -46,7 +46,7 @@ namespace OpenTween
         /// </remarks>
         public int StateIndex { get; set; }
 
-        private WeakReference imageReference = new WeakReference(null);
+        private readonly WeakReference imageReference = new WeakReference(null);
         private Task imageTask = null;
 
         public event EventHandler ImageDownloaded;
index 648f685..0f922e1 100644 (file)
@@ -40,7 +40,7 @@ namespace OpenTween
 {
     public partial class ListManage : OTBaseForm
     {
-        private Twitter tw;
+        private readonly Twitter tw;
 
         public ListManage(Twitter tw)
         {
index 6345a62..dc2b479 100644 (file)
@@ -41,8 +41,8 @@ namespace OpenTween.Models
 
         public bool FilterModified { get; set; }
 
-        private List<PostFilterRule> _filters = new List<PostFilterRule>();
-        private object lockObjFilters = new object();
+        private readonly List<PostFilterRule> _filters = new List<PostFilterRule>();
+        private readonly object lockObjFilters = new object();
 
         public FilterTabModel(string tabName) : base(tabName)
         {
index 627fa9c..98680df 100644 (file)
@@ -45,7 +45,7 @@ namespace OpenTween.Models
 
         // 流速計測用
         private int tweetsPerHour = 0;
-        private ConcurrentDictionary<DateTimeUtc, int> tweetsTimestamps = new ConcurrentDictionary<DateTimeUtc, int>();
+        private readonly ConcurrentDictionary<DateTimeUtc, int> tweetsTimestamps = new ConcurrentDictionary<DateTimeUtc, int>();
 
         public HomeTabModel() : this(MyCommon.DEFAULTTAB.RECENT)
         {
index 121695f..83a9039 100644 (file)
@@ -47,8 +47,8 @@ namespace OpenTween.Models
 
         public ConcurrentDictionary<long, PostClass> Posts { get; } = new ConcurrentDictionary<long, PostClass>();
 
-        private Dictionary<long, PostClass> _quotes = new Dictionary<long, PostClass>();
-        private ConcurrentDictionary<long, int> retweetsCount = new ConcurrentDictionary<long, int>();
+        private readonly Dictionary<long, PostClass> _quotes = new Dictionary<long, PostClass>();
+        private readonly ConcurrentDictionary<long, int> retweetsCount = new ConcurrentDictionary<long, int>();
 
         public Stack<TabModel> RemovedTab { get; } = new Stack<TabModel>();
 
@@ -59,10 +59,10 @@ namespace OpenTween.Models
         //AddPost(複数回) -> DistributePosts          -> SubmitUpdate
 
         private readonly TabCollection tabs = new TabCollection();
-        private ConcurrentQueue<long> addQueue = new ConcurrentQueue<long>();
+        private readonly ConcurrentQueue<long> addQueue = new ConcurrentQueue<long>();
 
         /// <summary>通知サウンドを再生する優先順位</summary>
-        private Dictionary<MyCommon.TabUsageType, int> notifyPriorityByTabType = new Dictionary<MyCommon.TabUsageType, int>
+        private readonly Dictionary<MyCommon.TabUsageType, int> notifyPriorityByTabType = new Dictionary<MyCommon.TabUsageType, int>
         {
             [MyCommon.TabUsageType.DirectMessage] = 100,
             [MyCommon.TabUsageType.Mentions] = 90,
@@ -74,7 +74,7 @@ namespace OpenTween.Models
         //トランザクション用
         private readonly object LockObj = new object();
 
-        private static TabInformations _instance = new TabInformations();
+        private static readonly TabInformations _instance = new TabInformations();
 
         //List
         private List<ListElement> _lists = new List<ListElement>();
index ce9b973..6f1c076 100644 (file)
@@ -92,7 +92,7 @@ namespace OpenTween.Models
 
         private IndexedSortedSet<long> _ids = new IndexedSortedSet<long>();
         private ConcurrentQueue<TemporaryId> addQueue = new ConcurrentQueue<TemporaryId>();
-        private ConcurrentQueue<long> removeQueue = new ConcurrentQueue<long>();
+        private readonly ConcurrentQueue<long> removeQueue = new ConcurrentQueue<long>();
         private SortedSet<long> unreadIds = new SortedSet<long>();
         private List<long> selectedStatusIds = new List<long>();
 
index 8631c67..6d1dc95 100644 (file)
@@ -121,7 +121,7 @@ namespace OpenTween
 
     public class OpenUrlItem
     {
-        private string _linkText;
+        private readonly string _linkText;
 
         public OpenUrlItem(string linkText, string url, string href)
         {
index 9a5ff71..6297f23 100644 (file)
@@ -48,7 +48,7 @@ namespace OpenTween
         [XmlAnyElement]
         public XmlElement[] ExtraElements;
 
-        private static object lockObj = new object();
+        private static readonly object lockObj = new object();
 
         protected static T LoadSettings(string FileId)
         {
index 2a980f9..dc949fd 100644 (file)
@@ -316,7 +316,7 @@ namespace OpenTween
         public bool UseTwemoji = true;
 
         [XmlIgnore]
-        private FontConverter fontConverter = new FontConverter();
+        private readonly FontConverter fontConverter = new FontConverter();
 
         protected string FontToString(Font font)
             => font != null ? this.fontConverter.ConvertToString(font) : null;
@@ -325,7 +325,7 @@ namespace OpenTween
             => str != null ? (Font)this.fontConverter.ConvertFromString(str) : null;
 
         [XmlIgnore]
-        private ColorConverter colorConverter = new ColorConverter();
+        private readonly ColorConverter colorConverter = new ColorConverter();
 
         protected string ColorToString(Color color)
             => this.colorConverter.ConvertToString(color);
index c9ea049..8230665 100644 (file)
@@ -45,7 +45,7 @@ namespace OpenTween
     /// </summary>
     public class ShortUrl
     {
-        private static Lazy<ShortUrl> _instance;
+        private static readonly Lazy<ShortUrl> _instance;
 
         /// <summary>
         /// ShortUrl のインスタンスを取得します
@@ -68,7 +68,7 @@ namespace OpenTween
         public string BitlyKey { get; set; }
 
         private HttpClient http;
-        private ConcurrentDictionary<Uri, Uri> urlCache = new ConcurrentDictionary<Uri, Uri>();
+        private readonly ConcurrentDictionary<Uri, Uri> urlCache = new ConcurrentDictionary<Uri, Uri>();
 
         private static readonly Regex HtmlLinkPattern = new Regex(@"(<a href="")(.+?)("")");
 
index d35afb8..34d37db 100644 (file)
@@ -58,7 +58,7 @@ namespace OpenTween.Thumbnail.Services
 
         private readonly HttpClient localHttpClient;
 
-        private object LockObj = new object();
+        private readonly object LockObj = new object();
 
         public ImgAzyobuziNet(bool autoupdate)
             : this(null, autoupdate)
index c757167..f72ca45 100644 (file)
@@ -69,7 +69,7 @@ namespace OpenTween.OpenTweenCustomControl
                 => Timestamp.ToLocalTime().ToString("T") + ": " + Summary;
         }
 
-        LinkedList<LogEntry> _logs;
+        readonly LinkedList<LogEntry> _logs;
 
         const int MAXCNT = 20;
 
index 5e66ed2..4314102 100644 (file)
@@ -113,15 +113,15 @@ namespace OpenTween
         private FormWindowState _formWindowState = FormWindowState.Normal; // フォームの状態保存用 通知領域からアイコンをクリックして復帰した際に使用する
 
         //twitter解析部
-        private TwitterApi twitterApi = new TwitterApi();
+        private readonly TwitterApi twitterApi = new TwitterApi();
         private Twitter tw;
 
         //Growl呼び出し部
-        private GrowlHelper gh = new GrowlHelper(ApplicationSettings.ApplicationName);
+        private readonly GrowlHelper gh = new GrowlHelper(ApplicationSettings.ApplicationName);
 
         //サブ画面インスタンス
         internal SearchWordDialog SearchDialog = new SearchWordDialog();     //検索画面インスタンス
-        private OpenURL UrlDialog = new OpenURL();
+        private readonly OpenURL UrlDialog = new OpenURL();
         public AtIdSupplement AtIdSupl;     //@id補助
         public AtIdSupplement HashSupl;    //Hashtag補助
         public HashtagManage HashMgr;
@@ -135,7 +135,7 @@ namespace OpenTween
         private Color _clFav;               //Fav用文字色
         private Color _clOWL;               //片思い用文字色
         private Color _clRetweet;               //Retweet用文字色
-        private Color _clHighLight = Color.FromKnownColor(KnownColor.HighlightText);         //選択中の行用文字色
+        private readonly Color _clHighLight = Color.FromKnownColor(KnownColor.HighlightText);         //選択中の行用文字色
         private Font _fntDetail;            //発言詳細部用フォント
         private Color _clDetail;              //発言詳細部用色
         private Color _clDetailLink;          //発言詳細部用リンク文字色
@@ -160,23 +160,23 @@ namespace OpenTween
         private Icon ReplyIcon;               //5g
         private Icon ReplyIconBlink;          //6g
 
-        private ImageList _listViewImageList = new ImageList();    //ListViewItemの高さ変更用
+        private readonly ImageList _listViewImageList = new ImageList();    //ListViewItemの高さ変更用
 
         private PostClass _anchorPost;
         private bool _anchorFlag;        //true:関連発言移動中(関連移動以外のオペレーションをするとfalseへ。trueだとリスト背景色をアンカー発言選択中として描画)
 
-        private List<StatusTextHistory> _history = new List<StatusTextHistory>();   //発言履歴
+        private readonly List<StatusTextHistory> _history = new List<StatusTextHistory>();   //発言履歴
         private int _hisIdx;                  //発言履歴カレントインデックス
 
         //発言投稿時のAPI引数(発言編集時に設定。手書きreplyでは設定されない)
         private (long StatusId, string ScreenName)? inReplyTo = null; // リプライ先のステータスID・スクリーン名
 
         //時速表示用
-        private List<DateTimeUtc> _postTimestamps = new List<DateTimeUtc>();
-        private List<DateTimeUtc> _favTimestamps = new List<DateTimeUtc>();
+        private readonly List<DateTimeUtc> _postTimestamps = new List<DateTimeUtc>();
+        private readonly List<DateTimeUtc> _favTimestamps = new List<DateTimeUtc>();
 
         // 以下DrawItem関連
-        private SolidBrush _brsHighLight = new SolidBrush(Color.FromKnownColor(KnownColor.Highlight));
+        private readonly SolidBrush _brsHighLight = new SolidBrush(Color.FromKnownColor(KnownColor.Highlight));
         private SolidBrush _brsBackColorMine;
         private SolidBrush _brsBackColorAt;
         private SolidBrush _brsBackColorYou;
@@ -184,8 +184,8 @@ namespace OpenTween
         private SolidBrush _brsBackColorAtFromTarget;
         private SolidBrush _brsBackColorAtTo;
         private SolidBrush _brsBackColorNone;
-        private SolidBrush _brsDeactiveSelection = new SolidBrush(Color.FromKnownColor(KnownColor.ButtonFace)); //Listにフォーカスないときの選択行の背景色
-        private StringFormat sfTab = new StringFormat();
+        private readonly SolidBrush _brsDeactiveSelection = new SolidBrush(Color.FromKnownColor(KnownColor.ButtonFace)); //Listにフォーカスないときの選択行の背景色
+        private readonly StringFormat sfTab = new StringFormat();
 
         //////////////////////////////////////////////////////////////////////////////////////////////////////////
         private TabInformations _statuses;
@@ -249,15 +249,15 @@ namespace OpenTween
         private bool _isColumnChanged = false;
 
         private const int MAX_WORKER_THREADS = 20;
-        private SemaphoreSlim workerSemaphore = new SemaphoreSlim(MAX_WORKER_THREADS);
-        private CancellationTokenSource workerCts = new CancellationTokenSource();
-        private IProgress<string> workerProgress;
+        private readonly SemaphoreSlim workerSemaphore = new SemaphoreSlim(MAX_WORKER_THREADS);
+        private readonly CancellationTokenSource workerCts = new CancellationTokenSource();
+        private readonly IProgress<string> workerProgress;
 
         private int UnreadCounter = -1;
         private int UnreadAtCounter = -1;
 
-        private string[] ColumnOrgText = new string[9];
-        private string[] ColumnText = new string[9];
+        private readonly string[] ColumnOrgText = new string[9];
+        private readonly string[] ColumnText = new string[9];
 
         private bool _DoFavRetweetFlags = false;
 
@@ -297,7 +297,7 @@ namespace OpenTween
         }
 
         private Stack<ReplyChain> replyChains; //[, ]でのリプライ移動の履歴
-        private Stack<(TabModel, PostClass)> selectPostChains = new Stack<(TabModel, PostClass)>(); //ポスト選択履歴
+        private readonly Stack<(TabModel, PostClass)> selectPostChains = new Stack<(TabModel, PostClass)>(); //ポスト選択履歴
 
         public TabModel CurrentTab
             => this._statuses.SelectedTab;
@@ -10939,7 +10939,7 @@ namespace OpenTween
             MessageBox.Show(status.RetweetCount + Properties.Resources.RtCountText1);
         }
 
-        private HookGlobalHotkey _hookGlobalHotkey;
+        private readonly HookGlobalHotkey _hookGlobalHotkey;
         public TweenMain()
         {
             _hookGlobalHotkey = new HookGlobalHotkey(this);
index 9969c3a..aaf700d 100644 (file)
@@ -173,9 +173,9 @@ namespace OpenTween
         }
 
         // 長いのでエイリアスとして e(...), eu(...), t(...) でエスケープできるようにする
-        private static Func<string, string> e = EscapeHtml;
-        private static Func<string, string> eu = Uri.EscapeDataString;
-        private static Func<string, string> t = FilterText;
+        private static readonly Func<string, string> e = EscapeHtml;
+        private static readonly Func<string, string> eu = Uri.EscapeDataString;
+        private static readonly Func<string, string> t = FilterText;
 
         private static string EscapeHtml(string text)
         {
index f0217b7..4c4c1e1 100644 (file)
@@ -162,7 +162,7 @@ namespace OpenTween
         private long[] noRTId = Array.Empty<long>();
 
         //プロパティからアクセスされる共通情報
-        private List<string> _hashList = new List<string>();
+        private readonly List<string> _hashList = new List<string>();
 
         private string nextCursorDirectMessage = null;
 
index 3c77077..c2c750e 100644 (file)
@@ -280,10 +280,10 @@ namespace OpenTween
             ALLOW_SCRIPT = 0x2,
         }
 
-        private object ocx = new object();
-        private WebBrowserAPI.IServiceProvider ocxServiceProvider;
-        private IntPtr profferServicePtr = new IntPtr();
-        private WebBrowserAPI.IProfferService profferService;
+        private readonly object ocx = new object();
+        private readonly WebBrowserAPI.IServiceProvider ocxServiceProvider;
+        private readonly IntPtr profferServicePtr = new IntPtr();
+        private readonly WebBrowserAPI.IProfferService profferService;
 
         public POLICY SecurityPolicy { get; set; } = 0;
 
index 9c25431..55b60a2 100644 (file)
@@ -30,7 +30,7 @@ namespace OpenTween
 {
     public static class nicoms
     {
-        private static string[] _nicovideo =
+        private static readonly string[] _nicovideo =
         {
             "www.nicovideo.jp/watch/",
             "live.nicovideo.jp/watch/",