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

Commit 49b6610

Browse files
authored
Merge branch 'master' into feature/submodule-changes-progress-on-statusbar
2 parents a209e5f + 2464cf6 commit 49b6610

File tree

22 files changed

+95
-119
lines changed

22 files changed

+95
-119
lines changed

ISSUE_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Hello! Please read the contributing guidelines before submitting an issue regarding the GitHub Extension for Visual Studio.
22

3-
- GitHub Extension for Visual Studio version:
3+
- GitHub Extension for Visual Studio version:
44
- Visual Studio version:
55

66
__What happened__ (with steps, logs and screenshots, if possible)

src/GitHub.App/Api/ApiClient.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,8 @@ public IObservable<PullRequest> GetPullRequestsForRepository(string owner, strin
242242
Guard.ArgumentNotEmptyString(name, nameof(name));
243243

244244
return gitHubClient.PullRequest.GetAllForRepository(owner, name,
245-
new PullRequestRequest {
245+
new PullRequestRequest
246+
{
246247
State = ItemStateFilter.All,
247248
SortProperty = PullRequestSort.Updated,
248249
SortDirection = SortDirection.Descending
@@ -268,7 +269,7 @@ public IObservable<Branch> GetBranches(string owner, string repo)
268269
Guard.ArgumentNotEmptyString(owner, nameof(owner));
269270
Guard.ArgumentNotEmptyString(repo, nameof(repo));
270271

271-
#pragma warning disable CS0618
272+
#pragma warning disable 618
272273
// GetAllBranches is obsolete, but don't want to introduce the change to fix the
273274
// warning in the PR, so disabling for now.
274275
return gitHubClient.Repository.GetAllBranches(owner, repo);

src/GitHub.InlineReviews/Services/PullRequestSessionManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ async Task StatusChanged()
236236
}
237237

238238
CurrentSession = session;
239-
initialized.SetResult(null);
239+
initialized.TrySetResult(null);
240240
}
241241
catch (Exception e)
242242
{

src/GitHub.Logging/Logging/LogManager.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.IO;
3+
using System.Diagnostics.CodeAnalysis;
34
using GitHub.Info;
45
using Serilog;
56
using Serilog.Core;
@@ -33,10 +34,8 @@ static Logger CreateLogger()
3334

3435
static Lazy<Logger> Logger { get; } = new Lazy<Logger>(CreateLogger);
3536

36-
//Violates CA1004 - Generic methods should provide type parameter
37-
#pragma warning disable CA1004
37+
[SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter")]
3838
public static ILogger ForContext<T>() => ForContext(typeof(T));
39-
#pragma warning restore CA1004
4039

4140
public static ILogger ForContext(Type type) => Logger.Value.ForContext(type).ForContext("ShortSourceContext", type.Name);
4241
}

src/GitHub.UI/Helpers/SharedDictionaryManager.cs

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class SharedDictionaryManager : ResourceDictionary
1111
CachingFactory factory;
1212
Uri source;
1313

14-
public SharedDictionaryManager() : this(GetCurrentDomainCachingFactory())
14+
public SharedDictionaryManager() : this(CachingFactory.GetInstanceForDomain())
1515
{
1616
}
1717

@@ -41,37 +41,38 @@ public SharedDictionaryManager(CachingFactory factory)
4141
}
4242
}
4343

44-
public static CachingFactory GetCurrentDomainCachingFactory()
45-
{
46-
var dataName = typeof(CachingFactory).FullName;
47-
var data = AppDomain.CurrentDomain.GetData(dataName);
48-
49-
var cachingFactory = data as CachingFactory;
50-
if (cachingFactory != null)
51-
{
52-
return cachingFactory;
53-
}
54-
55-
var disposable = data as IDisposable;
56-
if (disposable != null)
57-
{
58-
disposable.Dispose();
59-
}
60-
61-
cachingFactory = new CachingFactory();
62-
AppDomain.CurrentDomain.SetData(dataName, cachingFactory);
63-
return cachingFactory;
64-
}
65-
6644
public class CachingFactory : IDisposable
6745
{
46+
internal static string DataName = typeof(CachingFactory).FullName;
47+
6848
IDictionary<Uri, ResourceDictionary> sharedDictionaries;
6949
ISet<IDisposable> disposables;
7050

7151
public CachingFactory()
7252
{
7353
sharedDictionaries = new Dictionary<Uri, ResourceDictionary>();
7454
disposables = new HashSet<IDisposable>();
55+
56+
AppDomain.CurrentDomain.SetData(DataName, this);
57+
}
58+
59+
public static CachingFactory GetInstanceForDomain()
60+
{
61+
var data = AppDomain.CurrentDomain.GetData(DataName);
62+
63+
var cachingFactory = data as CachingFactory;
64+
if (cachingFactory != null)
65+
{
66+
return cachingFactory;
67+
}
68+
69+
var disposable = data as IDisposable;
70+
if (disposable != null)
71+
{
72+
disposable.Dispose();
73+
}
74+
75+
return new CachingFactory();
7576
}
7677

7778
public ResourceDictionary GetOrCreateResourceDictionary(ResourceDictionary owner, Uri uri)
@@ -118,6 +119,8 @@ void Dispose(bool disposing)
118119
disposables.Clear();
119120
sharedDictionaries.Clear();
120121
}
122+
123+
AppDomain.CurrentDomain.SetData(DataName, null);
121124
}
122125

123126
public void Dispose()

test/GitHub.InlineReviews.UnitTests/GitHub.InlineReviews.UnitTests.csproj

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="..\..\packages\NUnit3TestAdapter.3.9.0\build\net35\NUnit3TestAdapter.props" Condition="Exists('..\..\packages\NUnit3TestAdapter.3.9.0\build\net35\NUnit3TestAdapter.props')" />
34
<PropertyGroup>
45
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
56
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -110,22 +111,6 @@
110111
<Reference Include="Microsoft.CSharp" />
111112
<Reference Include="System.Data" />
112113
<Reference Include="System.Xml" />
113-
<Reference Include="nunit.core, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
114-
<HintPath>..\..\packages\NUnitTestAdapter.2.0.0\lib\nunit.core.dll</HintPath>
115-
<Private>False</Private>
116-
</Reference>
117-
<Reference Include="nunit.core.interfaces, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
118-
<HintPath>..\..\packages\NUnitTestAdapter.2.0.0\lib\nunit.core.interfaces.dll</HintPath>
119-
<Private>False</Private>
120-
</Reference>
121-
<Reference Include="nunit.util, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
122-
<HintPath>..\..\packages\NUnitTestAdapter.2.0.0\lib\nunit.util.dll</HintPath>
123-
<Private>False</Private>
124-
</Reference>
125-
<Reference Include="NUnit.VisualStudio.TestAdapter, Version=2.0.0.0, Culture=neutral, PublicKeyToken=4cb40d35494691ac, processorArchitecture=MSIL">
126-
<HintPath>..\..\packages\NUnitTestAdapter.2.0.0\lib\NUnit.VisualStudio.TestAdapter.dll</HintPath>
127-
<Private>False</Private>
128-
</Reference>
129114
</ItemGroup>
130115
<ItemGroup>
131116
<Compile Include="Models\DiffUtilitiesTests.cs" />
@@ -197,6 +182,7 @@
197182
<PropertyGroup>
198183
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
199184
</PropertyGroup>
185+
<Error Condition="!Exists('..\..\packages\NUnit3TestAdapter.3.9.0\build\net35\NUnit3TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\NUnit3TestAdapter.3.9.0\build\net35\NUnit3TestAdapter.props'))" />
200186
</Target>
201187
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
202188
Other similar extension points exist, see Microsoft.Common.targets.

test/GitHub.InlineReviews.UnitTests/TestDoubles/FakeDiffService.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ public string AddFile(string path, string contents)
3939
var directory = Path.GetDirectoryName(fullPath);
4040
Directory.CreateDirectory(directory);
4141
File.WriteAllText(fullPath, contents);
42+
#pragma warning disable 618 // Type or member is obsolete
4243
repository.Stage(path);
44+
#pragma warning restore 618 // Type or member is obsolete
4345
repository.Commit("Added " + path, signature, signature);
4446
return repository.Head.Tip.Sha;
4547
}
@@ -106,7 +108,9 @@ static IRepository CreateRepository()
106108
var signature = new Signature("user", "user@user", DateTimeOffset.Now);
107109

108110
File.WriteAllText(Path.Combine(tempPath, ".gitattributes"), "* text=auto");
111+
#pragma warning disable 618 // Type or member is obsolete
109112
result.Stage("*");
113+
#pragma warning restore 618 // Type or member is obsolete
110114
result.Commit("Initial commit", signature, signature);
111115

112116
return result;

test/GitHub.InlineReviews.UnitTests/packages.config

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@
1010
<package id="Microsoft.Win32.Primitives" version="4.0.1" targetFramework="net461" />
1111
<package id="NSubstitute" version="2.0.3" targetFramework="net461" />
1212
<package id="NUnit" version="3.9.0" targetFramework="net461" />
13-
<package id="NUnit.Extension.NUnitV2Driver" version="3.7.0" targetFramework="net461" />
14-
<package id="NUnit.Extension.NUnitV2ResultWriter" version="3.6.0" targetFramework="net461" />
15-
<package id="NUnit.Runners" version="2.6.4" targetFramework="net452" />
16-
<package id="NUnitTestAdapter" version="2.0.0" targetFramework="net452" />
13+
<package id="NUnit3TestAdapter" version="3.9.0" targetFramework="net461" />
1714
<package id="Rx-Core" version="2.2.5-custom" targetFramework="net461" />
1815
<package id="Rx-Interfaces" version="2.2.5-custom" targetFramework="net461" />
1916
<package id="Rx-Linq" version="2.2.5-custom" targetFramework="net461" />

test/GitHub.UI.UnitTests/GitHub.UI.UnitTests.csproj

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="..\..\packages\NUnit3TestAdapter.3.9.0\build\net35\NUnit3TestAdapter.props" Condition="Exists('..\..\packages\NUnit3TestAdapter.3.9.0\build\net35\NUnit3TestAdapter.props')" />
34
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
45
<PropertyGroup>
56
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -12,6 +13,8 @@
1213
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
1314
<FileAlignment>512</FileAlignment>
1415
<TargetFrameworkProfile />
16+
<NuGetPackageImportStamp>
17+
</NuGetPackageImportStamp>
1518
</PropertyGroup>
1619
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1720
<DebugSymbols>true</DebugSymbols>
@@ -110,6 +113,12 @@
110113
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
111114
</ItemGroup>
112115
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
116+
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
117+
<PropertyGroup>
118+
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
119+
</PropertyGroup>
120+
<Error Condition="!Exists('..\..\packages\NUnit3TestAdapter.3.9.0\build\net35\NUnit3TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\NUnit3TestAdapter.3.9.0\build\net35\NUnit3TestAdapter.props'))" />
121+
</Target>
113122
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
114123
Other similar extension points exist, see Microsoft.Common.targets.
115124
<Target Name="BeforeBuild">

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

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,12 @@ public class TheGetCurrentDomainCachingFactoryMethod
8181
[Test]
8282
public void CalledTwice_DisposeNotCalled()
8383
{
84-
using (var factory = SharedDictionaryManager.GetCurrentDomainCachingFactory())
84+
using (var factory = SharedDictionaryManager.CachingFactory.GetInstanceForDomain())
8585
{
8686
var disposable = Substitute.For<IDisposable>();
8787
factory.TryAddDisposable(disposable);
8888

89-
using (SharedDictionaryManager.GetCurrentDomainCachingFactory())
89+
using (SharedDictionaryManager.CachingFactory.GetInstanceForDomain())
9090
{
9191
disposable.Received(0).Dispose();
9292
}
@@ -96,20 +96,16 @@ public void CalledTwice_DisposeNotCalled()
9696
[Test]
9797
public void InvokeMethodOnNewAssembly_DisposeCalled()
9898
{
99-
// HACK: Why does this need to be in app domain?
100-
AppDomainContext.Invoke(new AppDomainSetup { ApplicationBase = AppDomain.CurrentDomain.BaseDirectory }, () =>
99+
using (var factory = SharedDictionaryManager.CachingFactory.GetInstanceForDomain())
101100
{
102-
using (var factory = SharedDictionaryManager.GetCurrentDomainCachingFactory())
103-
{
104-
var disposable = Substitute.For<IDisposable>();
105-
factory.TryAddDisposable(disposable);
101+
var disposable = Substitute.For<IDisposable>();
102+
factory.TryAddDisposable(disposable);
106103

107-
using (InvokeMethodOnNewAssembly(SharedDictionaryManager.GetCurrentDomainCachingFactory))
108-
{
109-
disposable.Received(1).Dispose();
110-
}
104+
using (InvokeMethodOnNewAssembly(SharedDictionaryManager.CachingFactory.GetInstanceForDomain))
105+
{
106+
disposable.Received(1).Dispose();
111107
}
112-
});
108+
}
113109
}
114110

115111
static IDisposable InvokeMethodOnNewAssembly<T>(Func<T> func)
@@ -144,7 +140,7 @@ public class TheSourceProperty
144140
[TestCase(Urls.Test_SharedDictionary_PackUrl)]
145141
public void IsEqualToSet(string url)
146142
{
147-
using (SharedDictionaryManager.GetCurrentDomainCachingFactory())
143+
using (SharedDictionaryManager.CachingFactory.GetInstanceForDomain())
148144
{
149145
var uri = ResourceDictionaryUtilities.ToPackUri(url);
150146
var target = new SharedDictionaryManager();

0 commit comments

Comments
 (0)