8000 Merge branch 'refactor/connections-master' into refactor/connections/… · github/VisualStudio@8f6d218 · GitHub
[go: up one dir, main page]

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

Commit 8f6d218

Browse files
committed
Merge branch 'refactor/connections-master' into refactor/connections/local-repositories
Conflicts: src/GitHub.VisualStudio/Services/ConnectionManager.cs
2 parents 01aad33 + e45d0c6 commit 8f6d218

File tree

92 files changed

+660
-501
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+660
-501
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<ProjectConfiguration>
2+
<Settings>
3+
<PreviouslyBuiltSuccessfully>True</PreviouslyBuiltSuccessfully>
4+
</Settings>
5+
</ProjectConfiguration>

GitHubVS.sln

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitHub.InlineReviews", "src
104104
EndProject
105105
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitHub.InlineReviews.UnitTests", "test\GitHub.InlineReviews.UnitTests\GitHub.InlineReviews.UnitTests.csproj", "{17EB676B-BB91-48B5-AA59-C67695C647C2}"
106106
EndProject
107+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitHub.Logging", "src\GitHub.Logging\GitHub.Logging.csproj", "{8D73575A-A89F-47CC-B153-B47DD06837F0}"
108+
EndProject
107109
Global
108110
GlobalSection(SolutionConfigurationPlatforms) = preSolution
109111
Debug|Any CPU = Debug|Any CPU
@@ -403,6 +405,16 @@ Global
403405
{17EB676B-BB91-48B5-AA59-C67695C647C2}.Release|Any CPU.Build.0 = Release|Any CPU
404406
{17EB676B-BB91-48B5-AA59-C67695C647C2}.ReleaseWithoutVsix|Any CPU.ActiveCfg = Release|Any CPU
405407
{17EB676B-BB91-48B5-AA59-C67695C647C2}.ReleaseWithoutVsix|Any CPU.Build.0 = Release|Any CPU
408+
{8D73575A-A89F-47CC-B153-B47DD06837F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
409+
{8D73575A-A89F-47CC-B153-B47DD06837F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
410+
{8D73575A-A89F-47CC-B153-B47DD06837F0}.DebugCodeAnalysis|Any CPU.ActiveCfg = DebugCodeAnalysis|Any CPU
411+
{8D73575A-A89F-47CC-B153-B47DD06837F0}.DebugCodeAnalysis|Any CPU.Build.0 = DebugCodeAnalysis|Any CPU
412+
{8D73575A-A89F-47CC-B153-B47DD06837F0}.DebugWithoutVsix|Any CPU.ActiveCfg = Debug|Any CPU
413+
{8D73575A-A89F-47CC-B153-B47DD06837F0}.DebugWithoutVsix|Any CPU.Build.0 = Debug|Any CPU
414+
{8D73575A-A89F-47CC-B153-B47DD06837F0}.Release|Any CPU.ActiveCfg = Release|Any CPU
415+
{8D73575A-A89F-47CC-B153-B47DD06837F0}.Release|Any CPU.Build.0 = Release|Any CPU
416+
{8D73575A-A89F-47CC-B153-B47DD06837F0}.ReleaseWithoutVsix|Any CPU.ActiveCfg = Release|Any CPU
417+
{8D73575A-A89F-47CC-B153-B47DD06837F0}.ReleaseWithoutVsix|Any CPU.Build.0 = Release|Any CPU
406418
EndGlobalSection
407419
GlobalSection(SolutionProperties) = preSolution
408420
HideSolutionNode = FALSE

src/GitHub.Api/GitHub.Api.csproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
</Compile>
6464
<Compile Include="ApiClientConfiguration_User.cs" Condition="$(Buildtype) != 'Internal'" />
6565
<Compile Include="IKeychain.cs" />
66-
<Compile Include="ILoginCache.cs" />
6766
<Compile Include="ILoginManager.cs" />
6867
<Compile Include="ITwoFactorChallengeHandler.cs" />
6968
<Compile Include="LoginManager.cs" />
@@ -95,6 +94,10 @@
9594
<Project>{6afe2e2d-6db0-4430-a2ea-f5f5388d2f78}</Project>
9695
<Name>GitHub.Extensions</Name>
9796
</ProjectReference>
97+
<ProjectReference Include="..\GitHub.Logging\GitHub.Logging.csproj">
98+
<Project>{8d73575a-a89f-47cc-b153-b47dd06837f0}</Project>
99+
<Name>GitHub.Logging</Name>
100+
</ProjectReference>
98101
</ItemGroup>
99102
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
100103
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

src/GitHub.App/Api/ApiClient.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using System.Security.Cryptography;
99
using System.Text;
1010
using GitHub.Primitives;
11-
using NLog;
1211
using Octokit;
1312
using Octokit.Reactive;
1413
using ReactiveUI;
@@ -18,14 +17,16 @@
1817
using System.Collections.Generic;
1918
using GitHub.Models;
2019
using GitHub.Extensions;
20+
using GitHub.Logging;
21+
using Serilog;
2122

2223
namespace GitHub.Api
2324
{
2425
public partial class ApiClient : IApiClient
2526
{
2627
const string ScopesHeader = "X-OAuth-Scopes";
2728
const string ProductName = Info.ApplicationInfo.ApplicationDescription;
28-
static readonly Logger log = LogManager.GetCurrentClassLogger();
29+
static readonly ILogger log = LogManager.ForContext<ApiClient>();
2930

3031
readonly IObservableGitHubClient gitHubClient;
3132
// There are two sets of authorization scopes, old and new:
@@ -187,7 +188,7 @@ static string GetSha256Hash(string input)
187188
}
188189
catch (Exception e)
189190
{
190-
log.Error("IMPOSSIBLE! Generating Sha256 hash caused an exception.", e);
191+
log.Error(e, "IMPOSSIBLE! Generating Sha256 hash caused an exception");
191192
return null;
192193
}
193194
}
@@ -205,14 +206,14 @@ static string GetMachineNameSafe()
205206
}
206207
catch (Exception e)
207208
{
208-
log.Info("Failed to retrieve host name using `DNS.GetHostName`.", e);
209+
log.Information(e, "Failed to retrieve host name using `DNS.GetHostName`");
209210
try
210211
{
211212
return Environment.MachineName;
212213
}
213214
catch (Exception ex)
214215
{
215-
log.Info("Failed to retrieve host name using `Environment.MachineName`.", ex);
216+
log.Warning(ex, "Failed to retrieve host name using `Environment.MachineName`");
216217
return "(unknown)";
217218
}
218219
}
@@ -233,7 +234,7 @@ static string GetMachineIdentifier()
233234
}
234235
catch (Exception e)
235236
{
236-
log.Info("Could not retrieve MAC address. Fallback to using machine name.", e);
237+
log.Warning(e, "Could not retrieve MAC address. Fallback to using machine name");
237238
return GetMachineNameSafe();
238239
}
239240
}

src/GitHub.App/Caches/ImageCache.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,18 @@
1111
using GitHub.Extensions;
1212
using GitHub.Extensions.Reactive;
1313
using GitHub.Factories;
14+
using GitHub.Logging;
1415
using GitHub.Services;
1516
using Rothko;
17+
using Serilog;
1618

1719
namespace GitHub.Caches
1820
{
1921
[Export(typeof(IImageCache))]
2022
[PartCreationPolicy(CreationPolicy.Shared)]
2123
public sealed class ImageCache : IImageCache
2224
{
23-
static readonly NLog.Logger log = NLog.LogManager.GetCurrentClassLogger();
25+
static readonly ILogger log = LogManager.ForContext<ImageCache>();
2426

2527
public const string ImageCacheFileName = "images.cache.db";
2628
readonly IObservable<IBlobCache> cacheFactory;
@@ -159,7 +161,7 @@ static IObservable<Unit> VacuumIfNecessary(IBlobCache blobCache, bool force = fa
159161
.SelectMany(Observable.Defer(() => blobCache.Insert(key, new byte[] { 1 })))
160162
.Catch<Unit, Exception>(ex =>
161163
{
162-
log.Error("Could not vacuum image cache", ex);
164+
log.Error(ex, "Could not vacuum image cache");
163165
return Observable.Return(Unit.Default);
164166
})
165167
.AsCompletion();

src/GitHub.App/Caches/SharedCache.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
using System.Reactive;
55
using System.Reactive.Linq;
66
using Akavache;
7-
using NLog;
7+
using GitHub.Logging;
8+
using Serilog;
89

910
namespace GitHub.Caches
1011
{
@@ -16,7 +17,7 @@ namespace GitHub.Caches
1617
public class SharedCache : ISharedCache
1718
{
1819
const string enterpriseHostApiBaseUriCacheKey = "enterprise-host-api-base-uri";
19-
static readonly Logger log = LogManager.GetCurrentClassLogger();
20+
static readonly ILogger log = LogManager.ForContext<SharedCache>();
2021

2122
static SharedCache()
2223
{
@@ -26,7 +27,7 @@ static SharedCache()
2627
}
2728
catch (Exception e)
2829
{
29-
log.Error("Error while running the static inializer for SharedCache", e);
30+
log.Error(e, "Error while running the static inializer for SharedCache");
3031
}
3132
}
3233

@@ -87,7 +88,7 @@ static IBlobCache GetBlobCacheWithFallback(Func<IBlobCache> blobCacheFunc, strin
8788
}
8889
catch (Exception e)
8990
{
90-
log.Error(string.Format(CultureInfo.InvariantCulture, "Failed to set the {0} cache.", cacheName), e);
91+
log.Error(e, "Failed to set the {CacheName} cache", cacheName);
9192
return new InMemoryBlobCache();
9293
}
9394
}

src/GitHub.App/Controllers/UIController.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using System.Reactive.Linq;
1616
using System.Reactive.Subjects;
1717
using System.Windows;
18+
using GitHub.Logging;
1819

1920
namespace GitHub.Controllers
2021
{
@@ -166,12 +167,12 @@ public UIController(IGitHubServiceProvider gitHubServiceProvider,
166167
var waitDispatcher = RxApp.MainThreadScheduler as WaitForDispatcherScheduler;
167168
if (waitDispatcher != null)
168169
{
169-
Debug.Assert(DispatcherScheduler.Current.Dispatcher == Application.Current.Dispatcher,
170+
Log.Assert(DispatcherScheduler.Current.Dispatcher == Application.Current.Dispatcher,
170171
"DispatcherScheduler is set correctly");
171172
}
172173
else
173174
{
174-
Debug.Assert(((DispatcherScheduler)RxApp.MainThreadScheduler).Dispatcher == Application.Current.Dispatcher,
175+
Log.Assert(((DispatcherScheduler)RxApp.MainThreadScheduler).Dispatcher == Application.Current.Dispatcher,
175176
"The MainThreadScheduler is using the wrong dispatcher");
176177
}
177178
}
@@ -217,7 +218,7 @@ public void Start()
217218
if (selectedFlow != UIControllerFlow.Authentication)
218219
gitHubServiceProvider.AddService(this, connection);
219220
else // sanity check: it makes zero sense to pass a connection in when calling the auth flow
220-
Debug.Assert(false, "Calling the auth flow with a connection makes no sense!");
221+
Log.Assert(false, "Calling the auth flow with a connection makes no sense!");
221222

222223
connection.Login()
223224
.ObserveOn(RxApp.MainThreadScheduler)

src/GitHub.App/Factories/ApiClientFactory.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,10 @@ public class ApiClientFactory : IApiClientFactory
1818
readonly ProductHeaderValue productHeader;
1919

2020
[ImportingConstructor]
21-
public ApiClientFactory(IKeychain keychain, IProgram program, ILoggingConfiguration config)
21+
public ApiClientFactory(IKeychain keychain, IProgram program)
2222
{
2323
Keychain = keychain;
2424
productHeader = program.ProductHeader;
25-
config.Configure();
2625
}
2726

2827
public Task<IGitHubClient> CreateGitHubClient(HostAddress hostAddress)

src/GitHub.App/Factories/SqlitePersistentBlobCacheFactory.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
using Akavache;
22
using Akavache.Sqlite3;
3-
using NLog;
43
using System;
54
using System.Collections.Generic;
65
using System.ComponentModel.Composition;
76
using System.Reactive.Linq;
87
using System.Threading.Tasks;
98
using GitHub.Extensions;
9+
using GitHub.Logging;
10+
using Serilog;
1011

1112
namespace GitHub.Factories
1213
{
1314
[Export(typeof(IBlobCacheFactory))]
1415
[PartCreationPolicy(CreationPolicy.Shared)]
1516
public class SqlitePersistentBlobCacheFactory : IBlobCacheFactory
1617
{
17-
static readonly Logger log = LogManager.GetCurrentClassLogger();
18+
static readonly ILogger log = LogManager.ForContext<SqlitePersistentBlobCacheFactory>();
1819
Dictionary<string, IBlobCache> cache = new Dictionary<string, IBlobCache>();
1920

2021
public IBlobCache CreateBlobCache(string path)
@@ -31,7 +32,7 @@ public IBlobCache CreateBlobCache(string path)
3132
}
3233
catch(Exception ex)
3334
{
34-
log.Error("Error while creating SQLitePersistentBlobCache for {0}. {1}", path, ex);
35+
log.Error(ex, "Error while creating SQLitePersistentBlobCache for {Path}", path);
3536
return new InMemoryBlobCache();
3637
}
3738
}

src/GitHub.App/GitHub.App.csproj

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,12 @@
7777
<HintPath>..\..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
7878
<Private>False</Private>
7979
</Reference>
80-
<Reference Include="NLog">
81-
<HintPath>..\..\packages\NLog.3.1.0.0\lib\net45\NLog.dll</HintPath>
82-
</Reference>
8380
<Reference Include="PresentationCore" />
8481
<Reference Include="PresentationFramework" />
82+
<Reference Include="Serilog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL">
83+
<HintPath>..\..\packages\Serilog.2.5.0\lib\net46\Serilog.dll</HintPath>
84+
<Private>True</Private>
85+
</Reference>
8586
<Reference Include="rothko, Version=0.0.2.0, Culture=neutral, PublicKeyToken=9f664c41f503810a, processorArchitecture=MSIL">
8687
<HintPath>..\..\packages\Rothko.0.0.2-ghfvs\lib\net45\rothko.dll</HintPath>
8788
<Private>True</Private>
@@ -140,7 +141,6 @@
140141
<Compile Include="Extensions\EnvironmentExtensions.cs" />
141142
<Compile Include="Factories\UIFactory.cs" />
142143
<Compile Include="GlobalSuppressions.cs" />
143-
<Compile Include="Infrastructure\LoggingConfiguration.cs" />
144144
<Compile Include="Models\PullRequestFileModel.cs" />
145145
<Compile Include="Models\PullRequestModel.cs" />
146146
<Compile Include="Resources.Designer.cs">
@@ -190,7 +190,6 @@
190190
<Compile Include="SampleData\SampleViewModels.cs" />
191191
<Compile Include="Api\ApiClient.cs" />
192192
<Compile Include="Factories\ApiClientFactory.cs" />
193-
<None Include="Services\Browser.cs" />
194193
<Compile Include="Services\EnterpriseProbe.cs" />
195194
<Compile Include="Services\ErrorMap.cs" />
196195
<Compile Include="Services\ErrorMessage.cs" />
@@ -294,6 +293,10 @@
294293
<Project>{6afe2e2d-6db0-4430-a2ea-f5f5388d2f78}</Project>
295294
<Name>GitHub.Extensions</Name>
296295
</ProjectReference>
296+
<ProjectReference Include="..\GitHub.Logging\GitHub.Logging.csproj">
297+
<Project>{8d73575a-a89f-47cc-b153-b47dd06837f0}</Project>
298+
<Name>GitHub.Logging</Name>
299+
</ProjectReference>
297300
<ProjectReference Include="..\GitHub.UI.Reactive\GitHub.UI.Reactive.csproj">
298301
<Project>{158b05e8-fdbc-4d71-b871-c96e28d5adf5}</Project>
299302
<Name>GitHub.UI.Reactive</Name>
@@ -305,6 +308,9 @@
305308
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
306309
</EmbeddedResource>
307310
</ItemGroup>
311+
<ItemGroup>
312+
<Analyzer Include="..\..\packages\SerilogAnalyzer.0.12.0.0\analyzers\dotnet\cs\SerilogAnalyzer.dll" />
313+
</ItemGroup>
308314
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
309315
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
310316
<PropertyGroup>

src/GitHub.App/Infrastructure/LoggingConfiguration.cs

Lines changed: 0 additions & 65 deletions
This file was deleted.

0 commit comments

Comments
 (0)
0