From: Kimura Youichi Date: Mon, 23 Sep 2019 19:12:08 +0000 (+0900) Subject: string.IsNullOrEmpty の nullable annotation あり版のメソッドを追加 X-Git-Tag: OpenTween_v2.4.1~3^2~2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=03835b2189cd3a42bd2c9e3413b4161e3786b455;hp=f615a20532df9fe963254c4ec5a36412563e1d4c;p=opentween%2Fopen-tween.git string.IsNullOrEmpty の nullable annotation あり版のメソッドを追加 VS16.3 に同梱されているRoslynから string.IsNullOrEmpty などのメソッドに対する アノテーションがハードコードされなくなったため、独自に代替のメソッドを用意する必要がある --- diff --git a/OpenTween/Api/BitlyApi.cs b/OpenTween/Api/BitlyApi.cs index 92b8ccb9..133d4946 100644 --- a/OpenTween/Api/BitlyApi.cs +++ b/OpenTween/Api/BitlyApi.cs @@ -64,7 +64,7 @@ namespace OpenTween.Api ["longUrl"] = srcUri.OriginalString, }; - if (!string.IsNullOrEmpty(domain)) + if (!MyCommon.IsNullOrEmpty(domain)) query["domain"] = domain; var uri = new Uri("/v3/shorten", UriKind.Relative); @@ -138,7 +138,7 @@ namespace OpenTween.Api private IEnumerable> CreateAccessTokenParams() { - if (string.IsNullOrEmpty(this.EndUserAccessToken)) + if (MyCommon.IsNullOrEmpty(this.EndUserAccessToken)) { return new[] { diff --git a/OpenTween/Api/MicrosoftTranslatorApi.cs b/OpenTween/Api/MicrosoftTranslatorApi.cs index 51e8abb2..b55835ee 100644 --- a/OpenTween/Api/MicrosoftTranslatorApi.cs +++ b/OpenTween/Api/MicrosoftTranslatorApi.cs @@ -97,7 +97,7 @@ namespace OpenTween.Api public async Task UpdateAccessTokenIfExpired() { - if (!string.IsNullOrEmpty(this.AccessToken) && this.RefreshAccessTokenAt > DateTimeUtc.Now) + if (!MyCommon.IsNullOrEmpty(this.AccessToken) && this.RefreshAccessTokenAt > DateTimeUtc.Now) return; var (accessToken, expiresIn) = await this.GetAccessTokenAsync() diff --git a/OpenTween/Api/TwitterApi.cs b/OpenTween/Api/TwitterApi.cs index e8127985..f651b8a2 100644 --- a/OpenTween/Api/TwitterApi.cs +++ b/OpenTween/Api/TwitterApi.cs @@ -775,9 +775,9 @@ namespace OpenTween.Api var endpoint = new Uri("https://userstream.twitter.com/1.1/user.json"); var param = new Dictionary(); - if (!string.IsNullOrEmpty(replies)) + if (!MyCommon.IsNullOrEmpty(replies)) param["replies"] = replies; - if (!string.IsNullOrEmpty(track)) + if (!MyCommon.IsNullOrEmpty(track)) param["track"] = track; Task openStream() diff --git a/OpenTween/Api/TwitterApiStatus.cs b/OpenTween/Api/TwitterApiStatus.cs index c26815f1..56475412 100644 --- a/OpenTween/Api/TwitterApiStatus.cs +++ b/OpenTween/Api/TwitterApiStatus.cs @@ -80,7 +80,7 @@ namespace OpenTween.Api return null; // たまに出てくる空文字列は無視する - if (string.IsNullOrEmpty(header[headerName])) + if (MyCommon.IsNullOrEmpty(header[headerName])) return null; switch (header[headerName]) diff --git a/OpenTween/Api/TwitterStreamObservable.cs b/OpenTween/Api/TwitterStreamObservable.cs index a7e945a1..d9c83fb5 100644 --- a/OpenTween/Api/TwitterStreamObservable.cs +++ b/OpenTween/Api/TwitterStreamObservable.cs @@ -79,7 +79,7 @@ namespace OpenTween.Api public static ITwitterStreamMessage ParseLine(string line) { - if (string.IsNullOrEmpty(line)) + if (MyCommon.IsNullOrEmpty(line)) return new StreamMessageKeepAlive(); if (line.First() != '{' || line.Last() != '}') diff --git a/OpenTween/AppendSettingDialog.cs b/OpenTween/AppendSettingDialog.cs index 13f93edf..70838a62 100644 --- a/OpenTween/AppendSettingDialog.cs +++ b/OpenTween/AppendSettingDialog.cs @@ -284,7 +284,7 @@ namespace OpenTween var pinPageUrl = TwitterApiConnection.GetAuthorizeUri(requestToken); var pin = AuthDialog.DoAuth(this, pinPageUrl); - if (string.IsNullOrEmpty(pin)) + if (MyCommon.IsNullOrEmpty(pin)) return null; // キャンセルされた場合 var accessTokenResponse = await TwitterApiConnection.GetAccessTokenAsync(requestToken, pin); @@ -320,7 +320,7 @@ namespace OpenTween var path = this.ActionPanel.BrowserPathText.Text; try { - if (!string.IsNullOrEmpty(path)) + if (!MyCommon.IsNullOrEmpty(path)) { if (path.StartsWith("\"", StringComparison.Ordinal) && path.Length > 2 && path.IndexOf("\"", 2, StringComparison.Ordinal) > -1) { diff --git a/OpenTween/ApplicationEvents.cs b/OpenTween/ApplicationEvents.cs index f384c04d..afd8f5eb 100644 --- a/OpenTween/ApplicationEvents.cs +++ b/OpenTween/ApplicationEvents.cs @@ -284,7 +284,7 @@ namespace OpenTween private static bool SetConfigDirectoryPath() { - if (StartupOptions.TryGetValue("configDir", out var configDir) && !string.IsNullOrEmpty(configDir)) + if (StartupOptions.TryGetValue("configDir", out var configDir) && !MyCommon.IsNullOrEmpty(configDir)) { // 起動オプション /configDir で設定ファイルの参照先を変更できます if (!Directory.Exists(configDir)) diff --git a/OpenTween/AtIdSupplement.cs b/OpenTween/AtIdSupplement.cs index 49116d67..032f35bb 100644 --- a/OpenTween/AtIdSupplement.cs +++ b/OpenTween/AtIdSupplement.cs @@ -88,7 +88,7 @@ namespace OpenTween private void TextId_KeyDown(object sender, KeyEventArgs e) { - if (e.KeyCode == Keys.Back && string.IsNullOrEmpty(this.TextId.Text)) + if (e.KeyCode == Keys.Back && MyCommon.IsNullOrEmpty(this.TextId.Text)) { inputText = ""; isBack = true; @@ -102,7 +102,7 @@ namespace OpenTween } else if (e.Control && e.KeyCode == Keys.Delete) { - if (!string.IsNullOrEmpty(this.TextId.Text)) + if (!MyCommon.IsNullOrEmpty(this.TextId.Text)) { var idx = this.TextId.AutoCompleteCustomSource.IndexOf(this.TextId.Text); if (idx > -1) @@ -126,7 +126,7 @@ namespace OpenTween private void AtIdSupplement_Shown(object sender, EventArgs e) { TextId.Text = startChar; - if (!string.IsNullOrEmpty(this.StartsWith)) + if (!MyCommon.IsNullOrEmpty(this.StartsWith)) { TextId.Text += this.StartsWith.Substring(0, this.StartsWith.Length); } diff --git a/OpenTween/Connection/Networking.cs b/OpenTween/Connection/Networking.cs index 78fb59a3..1ae37f0f 100644 --- a/OpenTween/Connection/Networking.cs +++ b/OpenTween/Connection/Networking.cs @@ -124,7 +124,7 @@ namespace OpenTween.Connection break; case ProxyType.Specified: proxy = new WebProxy(proxyAddress, proxyPort); - if (!string.IsNullOrEmpty(proxyUser) || !string.IsNullOrEmpty(proxyPassword)) + if (!MyCommon.IsNullOrEmpty(proxyUser) || !MyCommon.IsNullOrEmpty(proxyPassword)) proxy.Credentials = new NetworkCredential(proxyUser, proxyPassword); break; case ProxyType.IE: diff --git a/OpenTween/Connection/OAuthUtility.cs b/OpenTween/Connection/OAuthUtility.cs index 885aa9ed..8d451069 100644 --- a/OpenTween/Connection/OAuthUtility.cs +++ b/OpenTween/Connection/OAuthUtility.cs @@ -96,7 +96,7 @@ namespace OpenTween.Connection ["oauth_nonce"] = NonceRandom.Next(123400, 9999999).ToString(), ["oauth_version"] = "1.0", }; - if (!string.IsNullOrEmpty(token)) + if (!MyCommon.IsNullOrEmpty(token)) parameter.Add("oauth_token", token); // トークンがあれば追加 return parameter; } @@ -121,7 +121,7 @@ namespace OpenTween.Connection var signatureBase = string.Format("{0}&{1}&{2}", method, MyCommon.UrlEncode(url), MyCommon.UrlEncode(paramString)); // 署名鍵の文字列をコンシューマー秘密鍵とアクセストークン秘密鍵から生成(&区切り。アクセストークン秘密鍵なくても&残すこと) var key = MyCommon.UrlEncode(consumerSecret) + "&"; - if (!string.IsNullOrEmpty(tokenSecret)) + if (!MyCommon.IsNullOrEmpty(tokenSecret)) key += MyCommon.UrlEncode(tokenSecret); // 鍵生成&署名生成 using var hmac = new HMACSHA1(Encoding.ASCII.GetBytes(key)); diff --git a/OpenTween/Connection/TwitterPhoto.cs b/OpenTween/Connection/TwitterPhoto.cs index c22afcee..ee1350b3 100644 --- a/OpenTween/Connection/TwitterPhoto.cs +++ b/OpenTween/Connection/TwitterPhoto.cs @@ -142,7 +142,7 @@ namespace OpenTween.Connection var mediaId = await this.tw.UploadMedia(media, category) .ConfigureAwait(false); - if (!string.IsNullOrEmpty(media.AltText)) + if (!MyCommon.IsNullOrEmpty(media.AltText)) { await this.tw.Api.MediaMetadataCreate(mediaId, media.AltText) .ConfigureAwait(false); diff --git a/OpenTween/EventViewerDialog.cs b/OpenTween/EventViewerDialog.cs index 2cab1954..bf572581 100644 --- a/OpenTween/EventViewerDialog.cs +++ b/OpenTween/EventViewerDialog.cs @@ -131,7 +131,7 @@ namespace OpenTween private bool IsFilterMatch(Twitter.FormattedEvent x) { - if (!CheckBoxFilter.Checked || string.IsNullOrEmpty(TextBoxKeyword.Text)) + if (!CheckBoxFilter.Checked || MyCommon.IsNullOrEmpty(TextBoxKeyword.Text)) { return true; } diff --git a/OpenTween/FilterDialog.cs b/OpenTween/FilterDialog.cs index 82c6bcd0..a32303d6 100644 --- a/OpenTween/FilterDialog.cs +++ b/OpenTween/FilterDialog.cs @@ -667,7 +667,7 @@ namespace OpenTween else { ft.FilterBody = bdy.Split(' ', ' ') - .Where(x => !string.IsNullOrEmpty(x)) + .Where(x => !MyCommon.IsNullOrEmpty(x)) .ToArray(); } @@ -699,7 +699,7 @@ namespace OpenTween else { ft.ExFilterBody = bdy.Split(' ', ' ') - .Where(x => !string.IsNullOrEmpty(x)) + .Where(x => !MyCommon.IsNullOrEmpty(x)) .ToArray(); } @@ -755,7 +755,7 @@ namespace OpenTween isBlank = false; if (RadioAND.Checked) { - if (string.IsNullOrEmpty(UID.Text) && string.IsNullOrEmpty(MSG1.Text) && string.IsNullOrEmpty(TextSource.Text) && CheckRetweet.Checked == false) + if (MyCommon.IsNullOrEmpty(UID.Text) && MyCommon.IsNullOrEmpty(MSG1.Text) && MyCommon.IsNullOrEmpty(TextSource.Text) && CheckRetweet.Checked == false) { isBlank = true; return true; @@ -785,7 +785,7 @@ namespace OpenTween } else { - if (string.IsNullOrEmpty(MSG2.Text) && string.IsNullOrEmpty(TextSource.Text) && CheckRetweet.Checked == false) + if (MyCommon.IsNullOrEmpty(MSG2.Text) && MyCommon.IsNullOrEmpty(TextSource.Text) && CheckRetweet.Checked == false) { isBlank = true; return true; @@ -812,7 +812,7 @@ namespace OpenTween isBlank = false; if (RadioExAnd.Checked) { - if (string.IsNullOrEmpty(ExUID.Text) && string.IsNullOrEmpty(ExMSG1.Text) && string.IsNullOrEmpty(TextExSource.Text) && CheckExRetweet.Checked == false) + if (MyCommon.IsNullOrEmpty(ExUID.Text) && MyCommon.IsNullOrEmpty(ExMSG1.Text) && MyCommon.IsNullOrEmpty(TextExSource.Text) && CheckExRetweet.Checked == false) { isBlank = true; return true; @@ -842,7 +842,7 @@ namespace OpenTween } else { - if (string.IsNullOrEmpty(ExMSG2.Text) && string.IsNullOrEmpty(TextExSource.Text) && CheckExRetweet.Checked == false) + if (MyCommon.IsNullOrEmpty(ExMSG2.Text) && MyCommon.IsNullOrEmpty(TextExSource.Text) && CheckExRetweet.Checked == false) { isBlank = true; return true; @@ -971,7 +971,7 @@ namespace OpenTween tabName = inputName.TabName; tabType = inputName.Usage; } - if (!string.IsNullOrEmpty(tabName)) + if (!MyCommon.IsNullOrEmpty(tabName)) { //List対応 ListElement? list = null; diff --git a/OpenTween/Growl.cs b/OpenTween/Growl.cs index 21dcf8ab..fe0f1047 100644 --- a/OpenTween/Growl.cs +++ b/OpenTween/Growl.cs @@ -268,7 +268,7 @@ namespace OpenTween }; object? n; - if (icon != null || !string.IsNullOrEmpty(url)) + if (icon != null || !MyCommon.IsNullOrEmpty(url)) { var gCore = _core!.GetType("Growl.CoreLibrary.Resource"); object? res; diff --git a/OpenTween/HashtagManage.cs b/OpenTween/HashtagManage.cs index 7a5b4192..01d8b336 100644 --- a/OpenTween/HashtagManage.cs +++ b/OpenTween/HashtagManage.cs @@ -125,14 +125,14 @@ namespace OpenTween private int GetIndexOf(ListBox.ObjectCollection list, string value) { - if (string.IsNullOrEmpty(value)) return -1; + if (MyCommon.IsNullOrEmpty(value)) return -1; var idx = 0; foreach (var l in list) { var src = (string)l; - if (string.IsNullOrEmpty(src)) + if (MyCommon.IsNullOrEmpty(src)) { idx += 1; continue; @@ -151,7 +151,7 @@ namespace OpenTween public void AddHashToHistory(string hash, bool isIgnorePermanent) { hash = hash.Trim(); - if (!string.IsNullOrEmpty(hash)) + if (!MyCommon.IsNullOrEmpty(hash)) { if (isIgnorePermanent || !this.IsPermanent) { @@ -231,7 +231,7 @@ namespace OpenTween if (e.KeyChar == '#') { _hashSupl.ShowDialog(); - if (!string.IsNullOrEmpty(_hashSupl.inputText)) + if (!MyCommon.IsNullOrEmpty(_hashSupl.inputText)) { var fHalf = ""; var eHalf = ""; @@ -256,7 +256,7 @@ namespace OpenTween public void ToggleHash() { - if (string.IsNullOrEmpty(this.UseHash)) + if (MyCommon.IsNullOrEmpty(this.UseHash)) { if (this.HistoryHashList.Items.Count > 0) this.UseHash = this.HistoryHashList.Items[0].ToString(); @@ -344,7 +344,7 @@ namespace OpenTween { //ハッシュタグの整形 hashtag = hashtag.Trim(); - if (string.IsNullOrEmpty(hashtag)) + if (MyCommon.IsNullOrEmpty(hashtag)) { if (isShowWarn) MessageBox.Show("emply hashtag.", "Hashtag warning", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return false; @@ -382,7 +382,7 @@ namespace OpenTween hash += hs + " "; } hash = hash.Trim(); - if (!string.IsNullOrEmpty(hash)) + if (!MyCommon.IsNullOrEmpty(hash)) { this.AddHashToHistory(hash, true); this.IsPermanent = this.CheckPermanent.Checked; diff --git a/OpenTween/ImageListViewItem.cs b/OpenTween/ImageListViewItem.cs index 05840951..b109e174 100644 --- a/OpenTween/ImageListViewItem.cs +++ b/OpenTween/ImageListViewItem.cs @@ -88,7 +88,7 @@ namespace OpenTween private async Task GetImageAsyncInternal(bool force) { - if (string.IsNullOrEmpty(this.imageUrl) || this.imageCache == null) + if (MyCommon.IsNullOrEmpty(this.imageUrl) || this.imageCache == null) return; if (!force && this.imageReference.Target != null) diff --git a/OpenTween/ListManage.cs b/OpenTween/ListManage.cs index fbbe78d9..60b86be2 100644 --- a/OpenTween/ListManage.cs +++ b/OpenTween/ListManage.cs @@ -136,7 +136,7 @@ namespace OpenTween { var listItem = (ListElement)this.ListsList.SelectedItem; - if (string.IsNullOrEmpty(this.NameTextBox.Text)) + if (MyCommon.IsNullOrEmpty(this.NameTextBox.Text)) { MessageBox.Show(Properties.Resources.ListManageOKButton1); return; @@ -322,7 +322,7 @@ namespace OpenTween this.UserFollowerNum.Text = user.FollowersCount.ToString("#,###,##0"); this.UserPostsNum.Text = user.StatusesCount.ToString("#,###,##0"); this.UserProfile.Text = user.Description; - if (!string.IsNullOrEmpty(user.RecentPost)) + if (!MyCommon.IsNullOrEmpty(user.RecentPost)) { this.UserTweetDateTime.Text = user.PostCreatedAt.ToLocalTimeString("yy/MM/dd HH:mm"); this.UserTweet.Text = user.RecentPost; diff --git a/OpenTween/MediaSelector.cs b/OpenTween/MediaSelector.cs index 5eec3e01..570dabcf 100644 --- a/OpenTween/MediaSelector.cs +++ b/OpenTween/MediaSelector.cs @@ -77,7 +77,7 @@ namespace OpenTween get { var serviceName = this.ServiceName; - if (string.IsNullOrEmpty(serviceName)) + if (MyCommon.IsNullOrEmpty(serviceName)) return null; return this.pictureService.TryGetValue(serviceName, out var service) @@ -200,7 +200,7 @@ namespace OpenTween /// private bool IsUploadable(string serviceName, string ext, long? size) { - if (!string.IsNullOrEmpty(serviceName)) + if (!MyCommon.IsNullOrEmpty(serviceName)) { var imageService = this.pictureService[serviceName]; if (imageService.CheckFileExtension(ext)) @@ -394,7 +394,7 @@ namespace OpenTween private IMediaItem? CreateFileMediaItem(string path, bool noMsgBox) { - if (string.IsNullOrEmpty(path)) return null; + if (MyCommon.IsNullOrEmpty(path)) return null; try { @@ -491,7 +491,7 @@ namespace OpenTween if (isSelectedPage) this.ClearImageSelectedPicture(); - if (item == null || string.IsNullOrEmpty(item.Path)) return; + if (item == null || MyCommon.IsNullOrEmpty(item.Path)) return; try { @@ -563,11 +563,11 @@ namespace OpenTween var text = string.Join(", ", ImageServiceCombo.Items.Cast() .Where(serviceName => - !string.IsNullOrEmpty(serviceName) && + !MyCommon.IsNullOrEmpty(serviceName) && this.pictureService[serviceName].CheckFileExtension(ext) && this.pictureService[serviceName].CheckFileSize(ext, fileSize))); - if (string.IsNullOrEmpty(text)) + if (MyCommon.IsNullOrEmpty(text)) return Properties.Resources.PostPictureWarn6; return text; @@ -631,7 +631,7 @@ namespace OpenTween private void SelectImageServiceComboItem(string svc, int? index = null) { int idx; - if (string.IsNullOrEmpty(svc)) + if (MyCommon.IsNullOrEmpty(svc)) { idx = index ?? 0; } diff --git a/OpenTween/Models/MediaInfo.cs b/OpenTween/Models/MediaInfo.cs index 51fa8a58..2390e15d 100644 --- a/OpenTween/Models/MediaInfo.cs +++ b/OpenTween/Models/MediaInfo.cs @@ -44,7 +44,7 @@ namespace OpenTween.Models { this.Url = url; this.AltText = altText; - this.VideoUrl = !string.IsNullOrEmpty(videoUrl) ? videoUrl : null; + this.VideoUrl = !MyCommon.IsNullOrEmpty(videoUrl) ? videoUrl : null; } public override bool Equals(object? obj) diff --git a/OpenTween/Models/PostFilterRule.cs b/OpenTween/Models/PostFilterRule.cs index c8ad53ea..2a1df999 100644 --- a/OpenTween/Models/PostFilterRule.cs +++ b/OpenTween/Models/PostFilterRule.cs @@ -331,7 +331,7 @@ namespace OpenTween.Models { var filterExprs = new List(); - if (useNameField && !string.IsNullOrEmpty(filterName)) + if (useNameField && !MyCommon.IsNullOrEmpty(filterName)) { filterExprs.Add(Expression.OrElse( this.MakeGenericFilter(postParam, "ScreenName", filterName, useRegex, caseSensitive, exactMatch: true), @@ -339,7 +339,7 @@ namespace OpenTween.Models } foreach (var body in filterBody) { - if (string.IsNullOrEmpty(body)) + if (MyCommon.IsNullOrEmpty(body)) continue; Expression bodyExpr; @@ -378,7 +378,7 @@ namespace OpenTween.Models filterExprs.Add(bodyExpr); } - if (!string.IsNullOrEmpty(filterSource)) + if (!MyCommon.IsNullOrEmpty(filterSource)) { if (filterByUrl) filterExprs.Add(this.MakeGenericFilter(postParam, "SourceHtml", filterSource, useRegex, caseSensitive)); @@ -544,7 +544,7 @@ namespace OpenTween.Models { if (this.UseNameField) { - if (!string.IsNullOrEmpty(this.FilterName)) + if (!MyCommon.IsNullOrEmpty(this.FilterName)) { fs.AppendFormat(Properties.Resources.SetFiltersText1, this.FilterName); } @@ -593,7 +593,7 @@ namespace OpenTween.Models { fs.Append("LambdaExp/"); } - if (!string.IsNullOrEmpty(this.FilterSource)) + if (!MyCommon.IsNullOrEmpty(this.FilterSource)) { fs.AppendFormat("Src…{0}/", this.FilterSource); } @@ -606,7 +606,7 @@ namespace OpenTween.Models fs.Append(Properties.Resources.SetFiltersText12); if (this.ExUseNameField) { - if (!string.IsNullOrEmpty(this.ExFilterName)) + if (!MyCommon.IsNullOrEmpty(this.ExFilterName)) { fs.AppendFormat(Properties.Resources.SetFiltersText1, this.ExFilterName); } @@ -655,7 +655,7 @@ namespace OpenTween.Models { fs.Append("LambdaExp/"); } - if (!string.IsNullOrEmpty(this.ExFilterSource)) + if (!MyCommon.IsNullOrEmpty(this.ExFilterSource)) { fs.AppendFormat("Src…{0}/", this.ExFilterSource); } @@ -691,18 +691,18 @@ namespace OpenTween.Models /// この振り分けルールにマッチ条件が含まれているかを返します /// public bool HasMatchConditions() - => !string.IsNullOrEmpty(this.FilterName) || - this.FilterBody.Any(x => !string.IsNullOrEmpty(x)) || - !string.IsNullOrEmpty(this.FilterSource) || + => !MyCommon.IsNullOrEmpty(this.FilterName) || + this.FilterBody.Any(x => !MyCommon.IsNullOrEmpty(x)) || + !MyCommon.IsNullOrEmpty(this.FilterSource) || this.FilterRt; /// /// この振り分けルールに除外条件が含まれているかを返します /// public bool HasExcludeConditions() - => !string.IsNullOrEmpty(this.ExFilterName) || - this.ExFilterBody.Any(x => !string.IsNullOrEmpty(x)) || - !string.IsNullOrEmpty(this.ExFilterSource) || + => !MyCommon.IsNullOrEmpty(this.ExFilterName) || + this.ExFilterBody.Any(x => !MyCommon.IsNullOrEmpty(x)) || + !MyCommon.IsNullOrEmpty(this.ExFilterSource) || this.ExFilterRt; public override bool Equals(object? obj) diff --git a/OpenTween/Models/PublicSearchTabModel.cs b/OpenTween/Models/PublicSearchTabModel.cs index 8e8fd8c2..e4c5dadb 100644 --- a/OpenTween/Models/PublicSearchTabModel.cs +++ b/OpenTween/Models/PublicSearchTabModel.cs @@ -70,7 +70,7 @@ namespace OpenTween.Models public override async Task RefreshAsync(Twitter tw, bool backward, bool startup, IProgress progress) { - if (string.IsNullOrEmpty(this.SearchWords)) + if (MyCommon.IsNullOrEmpty(this.SearchWords)) return; bool read; diff --git a/OpenTween/Models/TabInformations.cs b/OpenTween/Models/TabInformations.cs index c6badd04..53a764a5 100644 --- a/OpenTween/Models/TabInformations.cs +++ b/OpenTween/Models/TabInformations.cs @@ -370,7 +370,7 @@ namespace OpenTween.Models // 通知サウンドは TabClass.Notify の値に関わらず鳴らす // SettingCommon.PlaySound が false であれば TweenMain 側で無効化される - if (!string.IsNullOrEmpty(tab.SoundFile)) + if (!MyCommon.IsNullOrEmpty(tab.SoundFile)) { if (!this.notifyPriorityByTabType.TryGetValue(tab.TabType, out var notifyPriority)) notifyPriority = 0; diff --git a/OpenTween/Models/UserTimelineTabModel.cs b/OpenTween/Models/UserTimelineTabModel.cs index f658754e..07110ca8 100644 --- a/OpenTween/Models/UserTimelineTabModel.cs +++ b/OpenTween/Models/UserTimelineTabModel.cs @@ -51,7 +51,7 @@ namespace OpenTween.Models public override async Task RefreshAsync(Twitter tw, bool backward, bool startup, IProgress progress) { - if (string.IsNullOrEmpty(this.ScreenName)) + if (MyCommon.IsNullOrEmpty(this.ScreenName)) return; bool read; diff --git a/OpenTween/MyCommon.cs b/OpenTween/MyCommon.cs index 22a624ca..8f8d6ee9 100644 --- a/OpenTween/MyCommon.cs +++ b/OpenTween/MyCommon.cs @@ -51,6 +51,7 @@ using System.Runtime.InteropServices; using OpenTween.Api; using OpenTween.Models; using OpenTween.Setting; +using System.Diagnostics.CodeAnalysis; namespace OpenTween { @@ -535,7 +536,7 @@ namespace OpenTween public static string EncryptString(string str) { - if (string.IsNullOrEmpty(str)) return ""; + if (MyCommon.IsNullOrEmpty(str)) return ""; //文字列をバイト型配列にする var bytesIn = Encoding.UTF8.GetBytes(str); @@ -587,7 +588,7 @@ namespace OpenTween public static string DecryptString(string str) { - if (string.IsNullOrEmpty(str)) return ""; + if (MyCommon.IsNullOrEmpty(str)) return ""; //DESCryptoServiceProviderオブジェクトの作成 using var des = new DESCryptoServiceProvider(); @@ -994,5 +995,8 @@ namespace OpenTween } return sb.ToString(); } + + public static bool IsNullOrEmpty([NotNullWhen(false)] string? value) + => string.IsNullOrEmpty(value); } } diff --git a/OpenTween/NativeMethods.cs b/OpenTween/NativeMethods.cs index c318452a..209824ff 100644 --- a/OpenTween/NativeMethods.cs +++ b/OpenTween/NativeMethods.cs @@ -330,7 +330,7 @@ namespace OpenTween InternetProxyInfo ipi; // Filling in structure - if (!string.IsNullOrEmpty(strProxy)) + if (!MyCommon.IsNullOrEmpty(strProxy)) { ipi = new InternetProxyInfo { diff --git a/OpenTween/SearchWordDialog.cs b/OpenTween/SearchWordDialog.cs index 58df0005..f8eab67f 100644 --- a/OpenTween/SearchWordDialog.cs +++ b/OpenTween/SearchWordDialog.cs @@ -152,7 +152,7 @@ namespace OpenTween private void buttonSearchTimeline_Click(object sender, EventArgs e) { - if (string.IsNullOrEmpty(this.textSearchTimeline.Text)) + if (MyCommon.IsNullOrEmpty(this.textSearchTimeline.Text)) { this.DialogResult = DialogResult.Cancel; return; @@ -171,7 +171,7 @@ namespace OpenTween private void buttonSearchTimelineNew_Click(object sender, EventArgs e) { - if (string.IsNullOrEmpty(this.textSearchTimeline.Text)) + if (MyCommon.IsNullOrEmpty(this.textSearchTimeline.Text)) { this.DialogResult = DialogResult.Cancel; return; @@ -190,7 +190,7 @@ namespace OpenTween private void buttonSearchPublic_Click(object sender, EventArgs e) { - if (string.IsNullOrEmpty(this.textSearchPublic.Text)) + if (MyCommon.IsNullOrEmpty(this.textSearchPublic.Text)) { this.DialogResult = DialogResult.Cancel; return; diff --git a/OpenTween/Setting/Panel/CooperatePanel.cs b/OpenTween/Setting/Panel/CooperatePanel.cs index a4f9f3e8..1a958694 100644 --- a/OpenTween/Setting/Panel/CooperatePanel.cs +++ b/OpenTween/Setting/Panel/CooperatePanel.cs @@ -71,7 +71,7 @@ namespace OpenTween.Setting.Panel private void UserAppointUrlText_Validating(object sender, CancelEventArgs e) { - if (!UserAppointUrlText.Text.StartsWith("http", StringComparison.Ordinal) && !string.IsNullOrEmpty(UserAppointUrlText.Text)) + if (!UserAppointUrlText.Text.StartsWith("http", StringComparison.Ordinal) && !MyCommon.IsNullOrEmpty(UserAppointUrlText.Text)) { MessageBox.Show("Text Error:正しいURLではありません"); } diff --git a/OpenTween/Setting/SettingCommon.cs b/OpenTween/Setting/SettingCommon.cs index dd1f3592..e5d8dfa7 100644 --- a/OpenTween/Setting/SettingCommon.cs +++ b/OpenTween/Setting/SettingCommon.cs @@ -66,7 +66,7 @@ namespace OpenTween private string Encrypt(string password) { - if (string.IsNullOrEmpty(password)) password = ""; + if (MyCommon.IsNullOrEmpty(password)) password = ""; if (password.Length > 0) { try @@ -85,7 +85,7 @@ namespace OpenTween } private string Decrypt(string password) { - if (string.IsNullOrEmpty(password)) password = ""; + if (MyCommon.IsNullOrEmpty(password)) password = ""; if (password.Length > 0) { try @@ -249,7 +249,7 @@ namespace OpenTween [XmlIgnore] public Version? SkipUpdateVersion { - get => string.IsNullOrEmpty(this.SkipUpdateVersionStr) ? null : Version.Parse(this.SkipUpdateVersionStr); + get => MyCommon.IsNullOrEmpty(this.SkipUpdateVersionStr) ? null : Version.Parse(this.SkipUpdateVersionStr); set => this.SkipUpdateVersionStr = value == null ? "" : value.ToString(); } @@ -271,7 +271,7 @@ namespace OpenTween } private string Encrypt(string password) { - if (string.IsNullOrEmpty(password)) password = ""; + if (MyCommon.IsNullOrEmpty(password)) password = ""; if (password.Length > 0) { try @@ -290,7 +290,7 @@ namespace OpenTween } private string Decrypt(string password) { - if (string.IsNullOrEmpty(password)) password = ""; + if (MyCommon.IsNullOrEmpty(password)) password = ""; if (password.Length > 0) { try diff --git a/OpenTween/Setting/SettingLocal.cs b/OpenTween/Setting/SettingLocal.cs index eb4a6080..2e9e6e7c 100644 --- a/OpenTween/Setting/SettingLocal.cs +++ b/OpenTween/Setting/SettingLocal.cs @@ -276,7 +276,7 @@ namespace OpenTween get { var pwd = ProxyPassword; - if (string.IsNullOrEmpty(pwd)) pwd = ""; + if (MyCommon.IsNullOrEmpty(pwd)) pwd = ""; if (pwd.Length > 0) { try @@ -296,7 +296,7 @@ namespace OpenTween set { var pwd = value; - if (string.IsNullOrEmpty(pwd)) pwd = ""; + if (MyCommon.IsNullOrEmpty(pwd)) pwd = ""; if (pwd.Length > 0) { try diff --git a/OpenTween/Setting/SettingManager.cs b/OpenTween/Setting/SettingManager.cs index 7da155cb..12ee07dd 100644 --- a/OpenTween/Setting/SettingManager.cs +++ b/OpenTween/Setting/SettingManager.cs @@ -54,7 +54,7 @@ namespace OpenTween.Setting if (settings.UserAccounts == null || settings.UserAccounts.Count == 0) { settings.UserAccounts = new List(); - if (!string.IsNullOrEmpty(settings.UserName)) + if (!MyCommon.IsNullOrEmpty(settings.UserName)) { var account = new UserAccount { diff --git a/OpenTween/ShortUrl.cs b/OpenTween/ShortUrl.cs index be314dcf..2f601214 100644 --- a/OpenTween/ShortUrl.cs +++ b/OpenTween/ShortUrl.cs @@ -402,7 +402,7 @@ namespace OpenTween return srcUri; // OAuth2 アクセストークンまたは API キー (旧方式) のいずれも設定されていなければ短縮しない - if (string.IsNullOrEmpty(this.BitlyAccessToken) && (string.IsNullOrEmpty(this.BitlyId) || string.IsNullOrEmpty(this.BitlyKey))) + if (MyCommon.IsNullOrEmpty(this.BitlyAccessToken) && (MyCommon.IsNullOrEmpty(this.BitlyId) || MyCommon.IsNullOrEmpty(this.BitlyKey))) return srcUri; var bitly = new BitlyApi diff --git a/OpenTween/Thumbnail/Services/MetaThumbnailService.cs b/OpenTween/Thumbnail/Services/MetaThumbnailService.cs index 14f908ad..d364f9a6 100644 --- a/OpenTween/Thumbnail/Services/MetaThumbnailService.cs +++ b/OpenTween/Thumbnail/Services/MetaThumbnailService.cs @@ -88,7 +88,7 @@ namespace OpenTween.Thumbnail.Services .ConfigureAwait(false); var thumbnailUrl = this.GetThumbnailUrl(content); - if (string.IsNullOrEmpty(thumbnailUrl)) return null; + if (MyCommon.IsNullOrEmpty(thumbnailUrl)) return null; return new ThumbnailInfo { diff --git a/OpenTween/ToolStripAPIGauge.cs b/OpenTween/ToolStripAPIGauge.cs index 992bf623..8143ebca 100644 --- a/OpenTween/ToolStripAPIGauge.cs +++ b/OpenTween/ToolStripAPIGauge.cs @@ -92,7 +92,7 @@ namespace OpenTween get => this._ApiEndpoint; set { - if (string.IsNullOrEmpty(value)) + if (MyCommon.IsNullOrEmpty(value)) { // リセット this._ApiEndpoint = null; @@ -222,7 +222,7 @@ namespace OpenTween minuteText = Math.Ceiling(this.remainMinutes).ToString(); } - var endpointText = string.IsNullOrEmpty(this._ApiEndpoint) ? "unknown" : this._ApiEndpoint; + var endpointText = MyCommon.IsNullOrEmpty(this._ApiEndpoint) ? "unknown" : this._ApiEndpoint; var textFormat = "API {0}/{1}"; this.Text = string.Format(textFormat, remainCountText, maxCountText); diff --git a/OpenTween/Tween.cs b/OpenTween/Tween.cs index 6a202831..db2a31f2 100644 --- a/OpenTween/Tween.cs +++ b/OpenTween/Tween.cs @@ -874,7 +874,7 @@ namespace OpenTween this.tw = new Twitter(this.twitterApi); //認証関連 - if (string.IsNullOrEmpty(SettingManager.Common.Token)) SettingManager.Common.UserName = ""; + if (MyCommon.IsNullOrEmpty(SettingManager.Common.Token)) SettingManager.Common.UserName = ""; tw.Initialize(SettingManager.Common.Token, SettingManager.Common.TokenSecret, SettingManager.Common.UserName, SettingManager.Common.UserId); _initial = true; @@ -885,14 +885,14 @@ namespace OpenTween var firstRun = false; //ユーザー名、パスワードが未設定なら設定画面を表示(初回起動時など) - if (string.IsNullOrEmpty(tw.Username)) + if (MyCommon.IsNullOrEmpty(tw.Username)) { saveRequired = true; firstRun = true; //設定せずにキャンセルされたか、設定されたが依然ユーザー名が未設定ならプログラム終了 if (ShowSettingDialog(showTaskbarIcon: true) != DialogResult.OK || - string.IsNullOrEmpty(tw.Username)) + MyCommon.IsNullOrEmpty(tw.Username)) { Application.Exit(); //強制終了 return; @@ -911,7 +911,7 @@ namespace OpenTween tw.RestrictFavCheck = SettingManager.Common.RestrictFavCheck; tw.ReadOwnPost = SettingManager.Common.ReadOwnPost; tw.TrackWord = SettingManager.Common.TrackWord; - TrackToolStripMenuItem.Checked = !string.IsNullOrEmpty(tw.TrackWord); + TrackToolStripMenuItem.Checked = !MyCommon.IsNullOrEmpty(tw.TrackWord); tw.AllAtReply = SettingManager.Common.AllAtReply; AllrepliesToolStripMenuItem.Checked = tw.AllAtReply; ShortUrl.Instance.DisableExpanding = !SettingManager.Common.TinyUrlResolve; @@ -953,7 +953,7 @@ namespace OpenTween SettingManager.Common.HashIsPermanent, SettingManager.Common.HashIsHead, SettingManager.Common.HashIsNotAddToAtReply); - if (!string.IsNullOrEmpty(HashMgr.UseHash) && HashMgr.IsPermanent) HashStripSplitButton.Text = HashMgr.UseHash; + if (!MyCommon.IsNullOrEmpty(HashMgr.UseHash) && HashMgr.IsPermanent) HashStripSplitButton.Text = HashMgr.UseHash; //アイコンリスト作成 this.IconCache = new ImageCache(); @@ -1838,7 +1838,7 @@ namespace OpenTween nt = GrowlHelper.NotifyType.Notify; } var bText = sb.ToString(); - if (string.IsNullOrEmpty(bText)) return; + if (MyCommon.IsNullOrEmpty(bText)) return; var image = this.IconCache.TryGetFromCache(post.ImageUrl); gh.Notify(nt, post.StatusId.ToString(), title.ToString(), bText, image?.Image, post.ImageUrl); @@ -1897,7 +1897,7 @@ namespace OpenTween title.AppendFormat(Properties.Resources.RefreshTimeline_NotifyText, addCount); } var bText = sb.ToString(); - if (string.IsNullOrEmpty(bText)) return; + if (MyCommon.IsNullOrEmpty(bText)) return; NotifyIcon1.BalloonTipTitle = title.ToString(); NotifyIcon1.BalloonTipText = bText; @@ -1908,7 +1908,7 @@ namespace OpenTween } //サウンド再生 - if (!_initial && SettingManager.Common.PlaySound && !string.IsNullOrEmpty(soundFile)) + if (!_initial && SettingManager.Common.PlaySound && !MyCommon.IsNullOrEmpty(soundFile)) { try { @@ -2669,7 +2669,7 @@ namespace OpenTween if (ct.IsCancellationRequested) return; - if (!string.IsNullOrEmpty(errMsg) && + if (!MyCommon.IsNullOrEmpty(errMsg) && !errMsg.StartsWith("OK:", StringComparison.Ordinal) && !errMsg.StartsWith("Warn:", StringComparison.Ordinal)) { @@ -2706,7 +2706,7 @@ namespace OpenTween this._postTimestamps.RemoveAt(i); } - if (!this.HashMgr.IsPermanent && !string.IsNullOrEmpty(this.HashMgr.UseHash)) + if (!this.HashMgr.IsPermanent && !MyCommon.IsNullOrEmpty(this.HashMgr.UseHash)) { this.HashMgr.ClearHashtag(); this.HashStripSplitButton.Text = "#[-]"; @@ -3291,7 +3291,7 @@ namespace OpenTween { RepliedStatusOpenMenuItem.Enabled = true; } - if (!this.ExistCurrentPost || post == null || string.IsNullOrEmpty(post.RetweetedBy)) + if (!this.ExistCurrentPost || post == null || MyCommon.IsNullOrEmpty(post.RetweetedBy)) { MoveToRTHomeMenuItem.Enabled = false; } @@ -3864,7 +3864,7 @@ namespace OpenTween //同一検索条件のタブが既に存在すれば、そのタブアクティブにして終了 foreach (var tb in _statuses.GetTabsByType()) { - if (tb.SearchWords == searchWord && string.IsNullOrEmpty(tb.SearchLang)) + if (tb.SearchWords == searchWord && MyCommon.IsNullOrEmpty(tb.SearchLang)) { var tabIndex = this._statuses.Tabs.IndexOf(tb); this.ListTab.SelectedIndex = tabIndex; @@ -4076,7 +4076,7 @@ namespace OpenTween btn.TabIndex = 3; btn.Click += SearchButton_Click; - if (!string.IsNullOrEmpty(searchTab.SearchWords)) + if (!MyCommon.IsNullOrEmpty(searchTab.SearchWords)) { cmb.Items.Add(searchTab.SearchWords); cmb.Text = searchTab.SearchWords; @@ -4284,7 +4284,7 @@ namespace OpenTween tn = this.CurrentTabName; } - if (string.IsNullOrEmpty(tn)) return; + if (MyCommon.IsNullOrEmpty(tn)) return; var tabIndex = this._statuses.Tabs.IndexOf(tn); if (tabIndex != -1) @@ -4404,7 +4404,7 @@ namespace OpenTween var eHalf = ""; if (dialog.DialogResult == DialogResult.OK) { - if (!string.IsNullOrEmpty(dialog.inputText)) + if (!MyCommon.IsNullOrEmpty(dialog.inputText)) { if (selStart > 0) { @@ -4484,7 +4484,7 @@ namespace OpenTween this.StatusText.AccessibleDescription = string.Format(Properties.Resources.StatusText_AccessibleDescription, pLen); - if (string.IsNullOrEmpty(StatusText.Text)) + if (MyCommon.IsNullOrEmpty(StatusText.Text)) { this.inReplyTo = null; } @@ -4640,7 +4640,7 @@ namespace OpenTween var footer = ""; var hashtag = this.HashMgr.UseHash; - if (!string.IsNullOrEmpty(hashtag) && !(this.HashMgr.IsNotAddToAtReply && this.inReplyTo != null)) + if (!MyCommon.IsNullOrEmpty(hashtag) && !(this.HashMgr.IsNotAddToAtReply && this.inReplyTo != null)) { if (HashMgr.IsHead) header = HashMgr.UseHash + " "; @@ -4655,7 +4655,7 @@ namespace OpenTween // 推奨ステータスを使用する footer += this.recommendedStatusFooter; } - else if (!string.IsNullOrEmpty(SettingManager.Local.StatusText)) + else if (!MyCommon.IsNullOrEmpty(SettingManager.Local.StatusText)) { // テキストボックスに入力されている文字列を使用する footer += " " + SettingManager.Local.StatusText.Trim(); @@ -6484,7 +6484,7 @@ namespace OpenTween if (post.ScreenName == _anchorPost.ScreenName || post.RetweetedBy == _anchorPost.ScreenName || post.ScreenName == _anchorPost.RetweetedBy || - (!string.IsNullOrEmpty(post.RetweetedBy) && post.RetweetedBy == _anchorPost.RetweetedBy) || + (!MyCommon.IsNullOrEmpty(post.RetweetedBy) && post.RetweetedBy == _anchorPost.RetweetedBy) || _anchorPost.ReplyToList.Any(x => x.UserId == post.UserId) || _anchorPost.ReplyToList.Any(x => x.UserId == post.RetweetedByUserId) || post.ReplyToList.Any(x => x.UserId == _anchorPost.UserId) || @@ -7241,7 +7241,7 @@ namespace OpenTween newTabName = inputName.TabName; } this.TopMost = SettingManager.Common.AlwaysTop; - if (!string.IsNullOrEmpty(newTabName)) + if (!MyCommon.IsNullOrEmpty(newTabName)) { //新タブ名存在チェック if (this._statuses.ContainsTab(newTabName)) @@ -7344,7 +7344,7 @@ namespace OpenTween } //タブのないところにドロップ->最後尾へ移動 - if (string.IsNullOrEmpty(tn)) + if (MyCommon.IsNullOrEmpty(tn)) { var lastTab = this._statuses.Tabs.Last(); tn = lastTab.TabName; @@ -7420,7 +7420,7 @@ namespace OpenTween StatusText.Focus(); return; } - if (string.IsNullOrEmpty(StatusText.Text)) + if (MyCommon.IsNullOrEmpty(StatusText.Text)) { //空の場合 var inReplyToStatusId = post.RetweetedId ?? post.StatusId; @@ -7593,7 +7593,7 @@ namespace OpenTween ids += "@" + screenName + " "; } } - if (!string.IsNullOrEmpty(post.RetweetedBy)) + if (!MyCommon.IsNullOrEmpty(post.RetweetedBy)) { if (!ids.Contains("@" + post.RetweetedBy + " ") && post.RetweetedByUserId != tw.UserId) { @@ -7601,7 +7601,7 @@ namespace OpenTween } } if (ids.Length == 0) return; - if (string.IsNullOrEmpty(StatusText.Text)) + if (MyCommon.IsNullOrEmpty(StatusText.Text)) { //未入力の場合のみ返信先付加 var inReplyToStatusId = post.RetweetedId ?? post.StatusId; @@ -7709,7 +7709,7 @@ namespace OpenTween private void ContextMenuTabProperty_Opening(object sender, CancelEventArgs e) { //右クリックの場合はタブ名が設定済。アプリケーションキーの場合は現在のタブを対象とする - if (string.IsNullOrEmpty(_rclickTabName) || sender != ContextMenuTabProperty) + if (MyCommon.IsNullOrEmpty(_rclickTabName) || sender != ContextMenuTabProperty) _rclickTabName = this.CurrentTabName; if (_statuses == null) return; @@ -7793,7 +7793,7 @@ namespace OpenTween this.DeleteTabMenuItem.Enabled = !checkState; this.DeleteTbMenuItem.Enabled = !checkState; - if (string.IsNullOrEmpty(_rclickTabName)) return; + if (MyCommon.IsNullOrEmpty(_rclickTabName)) return; _statuses.Tabs[_rclickTabName].Protected = checkState; SaveConfigsTabs(); @@ -7804,7 +7804,7 @@ namespace OpenTween UreadManageMenuItem.Checked = ((ToolStripMenuItem)sender).Checked; this.UnreadMngTbMenuItem.Checked = UreadManageMenuItem.Checked; - if (string.IsNullOrEmpty(_rclickTabName)) return; + if (MyCommon.IsNullOrEmpty(_rclickTabName)) return; ChangeTabUnreadManage(_rclickTabName, UreadManageMenuItem.Checked); SaveConfigsTabs(); @@ -7844,7 +7844,7 @@ namespace OpenTween NotifyDispMenuItem.Checked = ((ToolStripMenuItem)sender).Checked; this.NotifyTbMenuItem.Checked = NotifyDispMenuItem.Checked; - if (string.IsNullOrEmpty(_rclickTabName)) return; + if (MyCommon.IsNullOrEmpty(_rclickTabName)) return; _statuses.Tabs[_rclickTabName].Notify = NotifyDispMenuItem.Checked; @@ -7853,7 +7853,7 @@ namespace OpenTween private void SoundFileComboBox_SelectedIndexChanged(object sender, EventArgs e) { - if (soundfileListup || string.IsNullOrEmpty(_rclickTabName)) return; + if (soundfileListup || MyCommon.IsNullOrEmpty(_rclickTabName)) return; _statuses.Tabs[_rclickTabName].SoundFile = (string)((ToolStripComboBox)sender).SelectedItem; @@ -7862,7 +7862,7 @@ namespace OpenTween private void DeleteTabMenuItem_Click(object sender, EventArgs e) { - if (string.IsNullOrEmpty(_rclickTabName) || sender == this.DeleteTbMenuItem) + if (MyCommon.IsNullOrEmpty(_rclickTabName) || sender == this.DeleteTbMenuItem) _rclickTabName = this.CurrentTabName; RemoveSpecifiedTab(_rclickTabName, true); @@ -7871,7 +7871,7 @@ namespace OpenTween private void FilterEditMenuItem_Click(object sender, EventArgs e) { - if (string.IsNullOrEmpty(_rclickTabName)) _rclickTabName = _statuses.HomeTab.TabName; + if (MyCommon.IsNullOrEmpty(_rclickTabName)) _rclickTabName = _statuses.HomeTab.TabName; using (var fltDialog = new FilterDialog()) { @@ -7899,7 +7899,7 @@ namespace OpenTween tabUsage = inputName.Usage; } this.TopMost = SettingManager.Common.AlwaysTop; - if (!string.IsNullOrEmpty(tabName)) + if (!MyCommon.IsNullOrEmpty(tabName)) { //List対応 ListElement? list = null; @@ -8221,7 +8221,7 @@ namespace OpenTween tabName = inputName.TabName; } this.TopMost = SettingManager.Common.AlwaysTop; - if (!string.IsNullOrEmpty(tabName)) + if (!MyCommon.IsNullOrEmpty(tabName)) { var newTab = new FilterTabModel(tabName); if (!_statuses.AddTab(newTab) || !AddNewTab(newTab, startup: false)) @@ -8336,7 +8336,7 @@ namespace OpenTween var href = linkElm.GetAttribute("href"); var linkedText = linkElm.InnerText; - if (string.IsNullOrEmpty(displayUrl)) + if (MyCommon.IsNullOrEmpty(displayUrl)) displayUrl = href; links.Add(new OpenUrlItem(linkedText, displayUrl, href)); @@ -8379,7 +8379,7 @@ namespace OpenTween private void ClearTabMenuItem_Click(object sender, EventArgs e) { - if (string.IsNullOrEmpty(_rclickTabName)) return; + if (MyCommon.IsNullOrEmpty(_rclickTabName)) return; ClearTab(_rclickTabName, true); } @@ -8639,11 +8639,11 @@ namespace OpenTween HashSupl.AddItem("#" + hm.Result("$3")); } } - if (!string.IsNullOrEmpty(HashMgr.UseHash) && !hstr.Contains(HashMgr.UseHash + " ")) + if (!MyCommon.IsNullOrEmpty(HashMgr.UseHash) && !hstr.Contains(HashMgr.UseHash + " ")) { hstr += HashMgr.UseHash; } - if (!string.IsNullOrEmpty(hstr)) HashMgr.AddHashToHistory(hstr.Trim(), false); + if (!MyCommon.IsNullOrEmpty(hstr)) HashMgr.AddHashToHistory(hstr.Trim(), false); // 本当にリプライ先指定すべきかどうかの判定 m = Regex.Matches(StatusText, "(^|[ -/:-@[-^`{-~])(?@[a-zA-Z0-9_]+)"); @@ -8867,8 +8867,8 @@ namespace OpenTween if (Converter_Type == MyCommon.UrlConverter.Bitly || Converter_Type == MyCommon.UrlConverter.Jmp) { // OAuth2 アクセストークンまたは API キー (旧方式) のいずれも設定されていなければ短縮しない - if (string.IsNullOrEmpty(SettingManager.Common.BitlyAccessToken) && - (string.IsNullOrEmpty(SettingManager.Common.BilyUser) || string.IsNullOrEmpty(SettingManager.Common.BitlyPwd))) + if (MyCommon.IsNullOrEmpty(SettingManager.Common.BitlyAccessToken) && + (MyCommon.IsNullOrEmpty(SettingManager.Common.BilyUser) || MyCommon.IsNullOrEmpty(SettingManager.Common.BitlyPwd))) { MessageBox.Show(this, Properties.Resources.UrlConvert_BitlyAuthRequired, ApplicationSettings.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Warning); return false; @@ -8921,7 +8921,7 @@ namespace OpenTween return true; } - if (!string.IsNullOrEmpty(result)) + if (!MyCommon.IsNullOrEmpty(result)) { var undotmp = new urlUndo(); @@ -9006,7 +9006,7 @@ namespace OpenTween continue; } - if (!string.IsNullOrEmpty(result)) + if (!MyCommon.IsNullOrEmpty(result)) { // 短縮 URL が生成されるまでの間に投稿欄から元の URL が削除されていたら中断する var origUrlIndex = this.StatusText.Text.IndexOf(mt.Result("${url}"), StringComparison.Ordinal); @@ -9452,7 +9452,7 @@ namespace OpenTween try { var configBrowserPath = SettingManager.Local.BrowserPath; - if (!string.IsNullOrEmpty(configBrowserPath)) + if (!MyCommon.IsNullOrEmpty(configBrowserPath)) { if (configBrowserPath.StartsWith("\"", StringComparison.Ordinal) && configBrowserPath.Length > 2 && configBrowserPath.IndexOf("\"", 2, StringComparison.Ordinal) > -1) { @@ -9879,7 +9879,7 @@ namespace OpenTween private void TabRenameMenuItem_Click(object sender, EventArgs e) { - if (string.IsNullOrEmpty(_rclickTabName)) return; + if (MyCommon.IsNullOrEmpty(_rclickTabName)) return; _ = TabRename(_rclickTabName, out _); } @@ -10259,7 +10259,7 @@ namespace OpenTween tb.SearchWords = cmb.Text; tb.SearchLang = cmbLang.Text; - if (string.IsNullOrEmpty(cmb.Text)) + if (MyCommon.IsNullOrEmpty(cmb.Text)) { listView.Focus(); SaveConfigsTabs(); @@ -10440,7 +10440,7 @@ namespace OpenTween } this.TopMost = SettingManager.Common.AlwaysTop; if (rslt == DialogResult.Cancel) return; - if (!string.IsNullOrEmpty(HashMgr.UseHash)) + if (!MyCommon.IsNullOrEmpty(HashMgr.UseHash)) { HashStripSplitButton.Text = HashMgr.UseHash; HashTogglePullDownMenuItem.Checked = true; @@ -10460,7 +10460,7 @@ namespace OpenTween private void HashToggleMenuItem_Click(object sender, EventArgs e) { HashMgr.ToggleHash(); - if (!string.IsNullOrEmpty(HashMgr.UseHash)) + if (!MyCommon.IsNullOrEmpty(HashMgr.UseHash)) { HashStripSplitButton.Text = HashMgr.UseHash; HashToggleMenuItem.Checked = true; @@ -10577,7 +10577,7 @@ namespace OpenTween { OpenRepSourceOpMenuItem.Enabled = true; } - if (!this.ExistCurrentPost || post == null || string.IsNullOrEmpty(post.RetweetedBy)) + if (!this.ExistCurrentPost || post == null || MyCommon.IsNullOrEmpty(post.RetweetedBy)) { OpenRterHomeMenuItem.Enabled = false; } @@ -11204,13 +11204,13 @@ namespace OpenTween title.Append(" ["); title.Append(ev.Event.ToUpper(CultureInfo.CurrentCulture)); title.Append("] by "); - if (!string.IsNullOrEmpty(ev.Username)) + if (!MyCommon.IsNullOrEmpty(ev.Username)) { title.Append(ev.Username); } string text; - if (!string.IsNullOrEmpty(ev.Target)) + if (!MyCommon.IsNullOrEmpty(ev.Target)) text = ev.Target; else text = " "; @@ -11231,7 +11231,7 @@ namespace OpenTween //サウンド再生 var snd = SettingManager.Common.EventSoundFile; - if (!_initial && SettingManager.Common.PlaySound && !string.IsNullOrEmpty(snd)) + if (!_initial && SettingManager.Common.PlaySound && !MyCommon.IsNullOrEmpty(snd)) { if ((ev.Eventtype & SettingManager.Common.EventNotifyFlag) != 0 && IsMyEventNotityAsEventType(ev)) { @@ -11292,7 +11292,7 @@ namespace OpenTween { tw.TrackWord = inputTrack; this.MarkSettingCommonModified(); - TrackToolStripMenuItem.Checked = !string.IsNullOrEmpty(inputTrack); + TrackToolStripMenuItem.Checked = !MyCommon.IsNullOrEmpty(inputTrack); tw.ReconnectUserStream(); } } @@ -11379,7 +11379,7 @@ namespace OpenTween inputName.TabName = id; if (inputName.ShowDialog() == DialogResult.OK && - !string.IsNullOrEmpty(inputName.TabName.Trim())) + !MyCommon.IsNullOrEmpty(inputName.TabName.Trim())) { id = inputName.TabName.Trim(); } @@ -11393,7 +11393,7 @@ namespace OpenTween private async void UserTimelineToolStripMenuItem_Click(object sender, EventArgs e) { var id = GetUserIdFromCurPostOrInput("Show UserTimeline"); - if (!string.IsNullOrEmpty(id)) + if (!MyCommon.IsNullOrEmpty(id)) { await this.AddNewTabForUserTimeline(id); } @@ -11582,7 +11582,7 @@ namespace OpenTween private void tweetDetailsView_StatusChanged(object sender, TweetDetailsViewStatusChengedEventArgs e) { - if (!string.IsNullOrEmpty(e.StatusText)) + if (!MyCommon.IsNullOrEmpty(e.StatusText)) { this.StatusLabelUrl.Text = e.StatusText; } diff --git a/OpenTween/TweetDetailsView.cs b/OpenTween/TweetDetailsView.cs index 1b56aa35..b005bcbe 100644 --- a/OpenTween/TweetDetailsView.cs +++ b/OpenTween/TweetDetailsView.cs @@ -233,7 +233,7 @@ namespace OpenTween private async Task SetUserPictureAsync(string imageUrl, bool force = false) { - if (string.IsNullOrEmpty(imageUrl)) + if (MyCommon.IsNullOrEmpty(imageUrl)) return; if (this.IconCache == null) @@ -364,7 +364,7 @@ namespace OpenTween private async Task DoTranslation(string str) { - if (string.IsNullOrEmpty(str)) + if (MyCommon.IsNullOrEmpty(str)) return; var bing = new Bing(); @@ -504,7 +504,7 @@ namespace OpenTween { this.RaiseStatusChanged(this.PostBrowser.StatusText.Replace("&", "&&")); } - if (string.IsNullOrEmpty(PostBrowser.StatusText)) + if (MyCommon.IsNullOrEmpty(PostBrowser.StatusText)) { this.RaiseStatusChanged(statusText: ""); } @@ -545,7 +545,7 @@ namespace OpenTween if (this.CurrentPost != null) { var name = this.CurrentPost.ImageUrl; - if (!string.IsNullOrEmpty(name)) + if (!MyCommon.IsNullOrEmpty(name)) { var idx = name.LastIndexOf('/'); if (idx != -1) @@ -692,7 +692,7 @@ namespace OpenTween private async void IconNameToolStripMenuItem_Click(object sender, EventArgs e) { var imageUrl = this.CurrentPost?.ImageUrl; - if (string.IsNullOrEmpty(imageUrl)) + if (MyCommon.IsNullOrEmpty(imageUrl)) return; await this.Owner.OpenUriInBrowserAsync(imageUrl.Remove(imageUrl.LastIndexOf("_normal", StringComparison.Ordinal), 7)); // "_normal".Length @@ -701,7 +701,7 @@ namespace OpenTween private async void ReloadIconToolStripMenuItem_Click(object sender, EventArgs e) { var imageUrl = this.CurrentPost?.ImageUrl; - if (string.IsNullOrEmpty(imageUrl)) + if (MyCommon.IsNullOrEmpty(imageUrl)) return; await this.SetUserPictureAsync(imageUrl, force: true); @@ -710,7 +710,7 @@ namespace OpenTween private void SaveIconPictureToolStripMenuItem_Click(object sender, EventArgs e) { var imageUrl = this.CurrentPost?.ImageUrl; - if (string.IsNullOrEmpty(imageUrl)) + if (MyCommon.IsNullOrEmpty(imageUrl)) return; var memoryImage = this.IconCache.TryGetFromCache(imageUrl); @@ -885,7 +885,7 @@ namespace OpenTween if (link.GetAttribute("href") == this._postBrowserStatusText) { var linkStr = link.GetAttribute("title"); - if (string.IsNullOrEmpty(linkStr)) + if (MyCommon.IsNullOrEmpty(linkStr)) linkStr = link.GetAttribute("href"); Clipboard.SetDataObject(linkStr, false, 5, 100); diff --git a/OpenTween/TweetFormatter.cs b/OpenTween/TweetFormatter.cs index 91865cb4..a881dee4 100644 --- a/OpenTween/TweetFormatter.cs +++ b/OpenTween/TweetFormatter.cs @@ -168,7 +168,7 @@ namespace OpenTween if (!SettingManager.Local.UseTwemoji) return t(e(targetText)); - if (string.IsNullOrEmpty(entity.Url)) + if (MyCommon.IsNullOrEmpty(entity.Url)) return ""; return "\"""; diff --git a/OpenTween/TweetThumbnail.cs b/OpenTween/TweetThumbnail.cs index 4f02655f..b4df43f8 100644 --- a/OpenTween/TweetThumbnail.cs +++ b/OpenTween/TweetThumbnail.cs @@ -93,7 +93,7 @@ namespace OpenTween loadTasks.Add(loadTask); var tooltipText = thumb.TooltipText; - if (!string.IsNullOrEmpty(tooltipText)) + if (!MyCommon.IsNullOrEmpty(tooltipText)) { this.toolTip.SetToolTip(picbox, tooltipText); picbox.AccessibleDescription = tooltipText; diff --git a/OpenTween/Twitter.cs b/OpenTween/Twitter.cs index e184c27e..64a46ecc 100644 --- a/OpenTween/Twitter.cs +++ b/OpenTween/Twitter.cs @@ -216,7 +216,7 @@ namespace OpenTween public void Initialize(string token, string tokenSecret, string username, long userId) { //OAuth認証 - if (string.IsNullOrEmpty(token) || string.IsNullOrEmpty(tokenSecret) || string.IsNullOrEmpty(username)) + if (MyCommon.IsNullOrEmpty(token) || MyCommon.IsNullOrEmpty(tokenSecret) || MyCommon.IsNullOrEmpty(username)) { Twitter.AccountState = MyCommon.ACCOUNT_STATE.Invalid; } @@ -579,10 +579,10 @@ namespace OpenTween var count = GetApiResultCount(MyCommon.WORKERTYPE.UserTimeline, more, false); TwitterStatus[] statuses; - if (string.IsNullOrEmpty(userName)) + if (MyCommon.IsNullOrEmpty(userName)) { var target = tab.ScreenName; - if (string.IsNullOrEmpty(target)) return; + if (MyCommon.IsNullOrEmpty(target)) return; userName = target; statuses = await this.Api.StatusesUserTimeline(userName, count) .ConfigureAwait(false); @@ -1397,14 +1397,14 @@ namespace OpenTween { foreach (var m in entities.Urls) { - if (!string.IsNullOrEmpty(m.DisplayUrl)) text = text.Replace(m.Url, m.DisplayUrl); + if (!MyCommon.IsNullOrEmpty(m.DisplayUrl)) text = text.Replace(m.Url, m.DisplayUrl); } } if (entities.Media != null) { foreach (var m in entities.Media) { - if (!string.IsNullOrEmpty(m.DisplayUrl)) text = text.Replace(m.Url, m.DisplayUrl); + if (!MyCommon.IsNullOrEmpty(m.DisplayUrl)) text = text.Replace(m.Url, m.DisplayUrl); } } } @@ -1435,7 +1435,7 @@ namespace OpenTween } } - if (!string.IsNullOrEmpty(entity.DisplayUrl)) + if (!MyCommon.IsNullOrEmpty(entity.DisplayUrl)) text = text.Replace(entity.Url, entity.DisplayUrl); } } @@ -1444,11 +1444,11 @@ namespace OpenTween { foreach (var entity in entities.Media) { - if (!string.IsNullOrEmpty(entity.AltText)) + if (!MyCommon.IsNullOrEmpty(entity.AltText)) { text = text.Replace(entity.Url, string.Format(Properties.Resources.ImageAltText, entity.AltText)); } - else if (!string.IsNullOrEmpty(entity.DisplayUrl)) + else if (!MyCommon.IsNullOrEmpty(entity.DisplayUrl)) { text = text.Replace(entity.Url, entity.DisplayUrl); } @@ -1670,7 +1670,7 @@ namespace OpenTween /// internal static (string SourceText, Uri? SourceUri) ParseSource(string? sourceHtml) { - if (string.IsNullOrEmpty(sourceHtml)) + if (MyCommon.IsNullOrEmpty(sourceHtml)) return ("", null); string sourceText;