Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 802c54d

Browse files
authored
Merge pull request #1093 from github/fixes/1092-dont-set-ResourceAssembly
Don't explicitly set Application.ResourceAssembly
2 parents b157b5a + ede6262 commit 802c54d

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

src/GitHub.App/Services/AvatarProvider.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
using System;
2+
using System.IO.Packaging;
23
using System.ComponentModel.Composition;
34
using System.Diagnostics;
45
using System.Reactive;
56
using System.Reactive.Linq;
6-
using System.Windows;
77
using System.Windows.Media.Imaging;
88
using Akavache;
99
using GitHub.Caches;
1010
using GitHub.Extensions;
1111
using GitHub.Models;
12+
using System.Windows;
1213

1314
namespace GitHub.Services
1415
{
@@ -24,13 +25,9 @@ public class AvatarProvider : IAvatarProvider
2425

2526
static AvatarProvider()
2627
{
27-
// NB: If this isn't explicitly set, WPF will try to guess it via
28-
// GetEntryAssembly, which in a unit test runner will be null
29-
// This is needed for the pack:// URL format to be understood.
30-
if (Application.ResourceAssembly == null)
31-
{
32-
Application.ResourceAssembly = typeof(AvatarProvider).Assembly;
33-
}
28+
// Calling `Application.Current` will install pack URI scheme via Application.cctor.
29+
// This is needed when unit testing for the pack:// URL format to be understood.
30+
if (Application.Current != null) { }
3431
}
3532

3633
[ImportingConstructor]
@@ -71,7 +68,7 @@ public IObservable<BitmapSource> GetAvatar(IAvatarContainer apiAccount)
7168
return imageCache.GetImage(avatarUrl)
7269
.Catch<BitmapSource, Exception>(_ => Observable.Return(DefaultAvatar(apiAccount)));
7370
}
74-
71+
7572
public IObservable<Unit> InvalidateAvatar(IAvatarContainer apiAccount)
7673
{
7774
return String.IsNullOrWhiteSpace(apiAccount?.Login)
@@ -87,7 +84,7 @@ BitmapImage DefaultAvatar(IAvatarContainer apiAccount)
8784
}
8885

8986
protected virtual void Dispose(bool disposing)
90-
{}
87+
{ }
9188

9289
public void Dispose()
9390
{

test/GitHub.UI.UnitTests/Helpers/ResourceDictionaryUtilities.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
using System;
22
using System.IO;
3+
using System.IO.Packaging;
34
using System.Windows;
45

56
namespace GitHub.UI.Helpers.UnitTests
67
{
78
class ResourceDictionaryUtilities
89
{
10+
public static string PackUriScheme { get; private set; }
11+
912
public static Uri ToPackUri(string url)
1013
{
11-
if (!UriParser.IsKnownScheme("pack"))
12-
{
13-
// Register the pack scheme.
14-
new Application();
15-
}
14+
// Calling `Application.Current` will install pack URI scheme via Application.cctor.
15+
// This is needed when unit testing for the pack:// URL format to be understood.
16+
if (Application.Current != null) { }
1617

1718
return new Uri(url);
1819
}

0 commit comments

Comments
 (0)