File tree Expand file tree Collapse file tree 2 files changed +39
-1
lines changed Expand file tree Collapse file tree 2 files changed +39
-1
lines changed Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using System . Collections . Generic ;
3
+ using System . Text ;
4
+ using System . Threading . Tasks ;
5
+ using Microsoft . Git . CredentialManager . Diagnostics ;
6
+
7
+ namespace GitHub . Diagnostics
8
+ {
9
+ public class GitHubApiDiagnostic : Diagnostic
10
+ {
11
+ private readonly IGitHubRestApi _api ;
12
+
13
+ public GitHubApiDiagnostic ( IGitHubRestApi api )
14
+ : base ( "GitHub API" )
15
+ {
16
+ _api = api ;
17
+ }
18
+
19
+ protected override async Task < bool > RunInternalAsync ( StringBuilder log , IList < string > additionalFiles )
20
+ {
21
+ var targetUri = new Uri ( "https://github.com" ) ;
22
+ log . AppendLine ( $ "Using '{ targetUri } ' as API target.") ;
23
+
24
+ log . Append ( "Querying '/meta' endpoint..." ) ;
25
+ GitHubMetaInfo metaInfo = await _api . GetMetaInfoAsync ( targetUri ) ;
26
+ log . AppendLine ( " OK" ) ;
27
+
28
+ return true ;
29
+ }
30
+ }
31
+ }
Original file line number Diff line number Diff line change 2
2
using System . Collections . Generic ;
3
3
using System . Net . Http ;
4
4
using System . Threading . Tasks ;
5
+ using GitHub . Diagnostics ;
5
6
using Microsoft . Git . CredentialManager ;
6
7
using Microsoft . Git . CredentialManager . Authentication . OAuth ;
8
+ using Microsoft . Git . CredentialManager . Diagnostics ;
7
9
8
10
namespace GitHub
9
11
{
10
- public class GitHubHostProvider : HostProvider
12
+ public class GitHubHostProvider : HostProvider , IDiagnosticProvider
11
13
{
12
14
private static readonly string [ ] GitHubOAuthScopes =
13
15
{
@@ -295,6 +297,11 @@ protected override void ReleaseManagedResources()
295
297
base . ReleaseManagedResources ( ) ;
296
298
}
297
299
300
+ public IEnumerable < IDiagnostic > GetDiagnostics ( )
301
+ {
302
+ yield return new GitHubApiDiagnostic ( _gitHubApi ) ;
303
+ }
304
+
298
305
#region Private Methods
299
306
300
307
public static bool IsGitHubDotCom ( string targetUrl )
You can’t perform that action at this time.
0 commit comments