Skip to content

Commit

Permalink
Merge branch 'develop' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
upsilon committed Sep 2, 2022
2 parents 056b345 + 341e11e commit aca0e34
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 39 deletions.
5 changes: 5 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
[*.csproj]
indent_style = space
indent_size = 2
tab_width = 2

[*.cs]
indent_style = space
tab_width = 4
Expand Down
1 change: 1 addition & 0 deletions OpenTween.Tests/OpenTween.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Xunit.StaFact" Version="1.1.11" />
</ItemGroup>
<ItemGroup>
<None Update="Resources\re.gif">
Expand Down
22 changes: 7 additions & 15 deletions OpenTween.Tests/TweetThumbnailTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private void MyCommonSetup()
MyCommon.EntryAssembly = mockAssembly.Object;
}

[Fact]
[WinFormsFact]
public void CreatePictureBoxTest()
{
using var thumbBox = new TweetThumbnail();
Expand All @@ -121,7 +121,7 @@ public void CreatePictureBoxTest()
picbox.Dispose();
}

[Fact]
[WinFormsFact]
public async Task CancelAsyncTest()
{
var post = new PostClass
Expand All @@ -138,7 +138,6 @@ public async Task CancelAsyncTest()

using var tokenSource = new CancellationTokenSource();

SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
var task = thumbbox.ShowThumbnailAsync(post, tokenSource.Token);

tokenSource.Cancel();
Expand All @@ -147,7 +146,7 @@ public async Task CancelAsyncTest()
Assert.True(task.IsCanceled);
}

[Theory]
[WinFormsTheory]
[InlineData(0)]
[InlineData(1)]
[InlineData(2)]
Expand Down Expand Up @@ -178,7 +177,7 @@ public void SetThumbnailCountTest(int count)
Assert.Equal(count - 1, thumbbox.scrollBar.Maximum);
}

[Fact]
[WinFormsFact]
public async Task ShowThumbnailAsyncTest()
{
var post = new PostClass
Expand All @@ -193,7 +192,6 @@ public async Task ShowThumbnailAsyncTest()
using var thumbbox = new TweetThumbnail();
thumbbox.Initialize(this.CreateThumbnailGenerator());

SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
await thumbbox.ShowThumbnailAsync(post);

Assert.Equal(0, thumbbox.scrollBar.Maximum);
Expand All @@ -211,7 +209,7 @@ public async Task ShowThumbnailAsyncTest()
Assert.Equal("", thumbbox.toolTip.GetToolTip(thumbbox.PictureBox[0]));
}

[Fact]
[WinFormsFact]
public async Task ShowThumbnailAsyncTest2()
{
var post = new PostClass
Expand All @@ -227,7 +225,6 @@ public async Task ShowThumbnailAsyncTest2()
using var thumbbox = new TweetThumbnail();
thumbbox.Initialize(this.CreateThumbnailGenerator());

SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
await thumbbox.ShowThumbnailAsync(post);

Assert.Equal(1, thumbbox.scrollBar.Maximum);
Expand All @@ -253,14 +250,12 @@ public async Task ShowThumbnailAsyncTest2()
Assert.Equal("efgh", thumbbox.toolTip.GetToolTip(thumbbox.PictureBox[1]));
}

[Fact]
[WinFormsFact]
public async Task ThumbnailLoadingEventTest()
{
using var thumbbox = new TweetThumbnail();
thumbbox.Initialize(this.CreateThumbnailGenerator());

SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());

var post = new PostClass
{
TextFromApi = "てすと",
Expand All @@ -274,8 +269,6 @@ await TestUtils.NotRaisesAsync<EventArgs>(
() => thumbbox.ShowThumbnailAsync(post)
);

SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());

var post2 = new PostClass
{
TextFromApi = "てすと http://foo.example.com/abcd",
Expand All @@ -292,7 +285,7 @@ await Assert.RaisesAsync<EventArgs>(
);
}

[Fact]
[WinFormsFact]
public async Task ScrollTest()
{
var post = new PostClass
Expand All @@ -308,7 +301,6 @@ public async Task ScrollTest()
using var thumbbox = new TweetThumbnail();
thumbbox.Initialize(this.CreateThumbnailGenerator());

SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
await thumbbox.ShowThumbnailAsync(post);

Assert.Equal(0, thumbbox.scrollBar.Minimum);
Expand Down
3 changes: 2 additions & 1 deletion OpenTween/Api/MicrosoftTranslatorApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ public async Task UpdateAccessTokenIfExpired()
using var response = await this.Http.SendAsync(request)
.ConfigureAwait(false);

response.EnsureSuccessStatusCode();
if (!response.IsSuccessStatusCode)
throw new WebApiException(response.StatusCode.ToString());

var accessToken = await response.Content.ReadAsStringAsync()
.ConfigureAwait(false);
Expand Down
22 changes: 9 additions & 13 deletions OpenTween/ImageCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,25 +91,21 @@ public Task<MemoryImage> DownloadImageAsync(string address, bool force = false)

return Task.Run(() =>
{
Task<MemoryImage>? cachedImageTask;
lock (this.lockObject)
{
this.InnerDictionary.TryGetValue(address, out var cachedImageTask);
this.InnerDictionary.TryGetValue(address, out cachedImageTask);

if (cachedImageTask != null)
{
if (force)
this.InnerDictionary.Remove(address);
else
return cachedImageTask;
}
if (cachedImageTask != null && !force)
return cachedImageTask;

cancelToken.ThrowIfCancellationRequested();
cancelToken.ThrowIfCancellationRequested();

var imageTask = this.FetchImageAsync(address, cancelToken);
var imageTask = this.FetchImageAsync(address, cancelToken);

lock (this.lockObject)
this.InnerDictionary[address] = imageTask;

return imageTask;
}
return imageTask;
},
cancelToken);
}
Expand Down
2 changes: 1 addition & 1 deletion OpenTween/OTPictureBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public async Task SetImageFromTask(Func<Task<MemoryImage>> imageTask, bool useSt
if (useStatusImage)
this.ShowInitialImage();

var image = await imageTask();
var image = await Task.Run(imageTask);

if (id == this.currentImageTaskId)
this.Image = image;
Expand Down
2 changes: 1 addition & 1 deletion OpenTween/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
// 次の GUID は、このプロジェクトが COM に公開される場合の、typelib の ID です
[assembly: Guid("2d0ae0ba-adac-49a2-9b10-26fd69e695bf")]

[assembly: AssemblyVersion("2.7.0.0")]
[assembly: AssemblyVersion("2.7.1.0")]

[assembly: InternalsVisibleTo("OpenTween.Tests")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] // for Moq
10 changes: 5 additions & 5 deletions OpenTween/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions OpenTween/Resources/ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
更新履歴

==== Ver 2.7.1(2022/09/03)
* FIX: 発言一覧の選択位置を移動した際にデッドロックが発生する場合がある不具合を修正 (thx @Kazuki_Ashiya!)
* FIX: 発言本文の翻訳時に発生したエラーが適切に処理されない不具合を修正

==== Ver 2.7.0(2022/07/30)
* NEW: 発言詳細部の日時ラベルをクリックするとWebブラウザを起動してツイートを表示する機能を追加
* NEW: 設定画面に「Twitter API v2 の使用を有効にする」のチェックボックスを追加
Expand Down
4 changes: 2 additions & 2 deletions OpenTween/TweetThumbnail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ private string GetImageSearchUriGoogle(string image_uri)
private string GetImageSearchUriSauceNao(string imageUri)
=> @"https://saucenao.com/search.php?url=" + Uri.EscapeDataString(imageUri);

protected virtual Task<IEnumerable<ThumbnailInfo>> GetThumbailInfoAsync(PostClass post, CancellationToken token)
=> this.ThumbGenerator.GetThumbnailsAsync(post, token);
protected async virtual Task<IEnumerable<ThumbnailInfo>> GetThumbailInfoAsync(PostClass post, CancellationToken token)
=> await Task.Run(() => this.ThumbGenerator.GetThumbnailsAsync(post, token));

/// <summary>
/// 表示するサムネイルの数を設定する
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: 2.6.0.{build}
version: 2.7.0.{build}

os: Visual Studio 2022

Expand Down

0 comments on commit aca0e34

Please sign in to comment.