Skip to content

Commit

Permalink
Correct file headers (#340)
Browse files Browse the repository at this point in the history
  • Loading branch information
krschau authored Feb 6, 2024
1 parent e3e9d91 commit 77f2eb5
Show file tree
Hide file tree
Showing 158 changed files with 1,350 additions and 1,265 deletions.
2 changes: 2 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

[*.cs]

file_header_template = Copyright (c) Microsoft Corporation.\r\nLicensed under the MIT License.

#Core editorconfig formatting - indentation

#use soft tabs (spaces) for indentation
Expand Down
6 changes: 6 additions & 0 deletions GitHubExtension.sln
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scripts", "scripts", "{E4D6
test\scripts\CleanWidgets.ps1 = test\scripts\CleanWidgets.ps1
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{864DD9CD-9F45-47E8-847F-B72ED182626B}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
exclusion.dic = exclusion.dic
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down
2 changes: 1 addition & 1 deletion build/scripts/Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ $StartTime = Get-Date

if ($Help) {
Write-Host @"
Copyright (c) Microsoft Corporation and Contributors.
Copyright (c) Microsoft Corporation.
Licensed under the MIT License.
Syntax:
Expand Down
2 changes: 1 addition & 1 deletion build/scripts/Test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ $StartTime = Get-Date

if ($Help) {
Write-Host @"
Copyright (c) Microsoft Corporation and Contributors.
Copyright (c) Microsoft Corporation.
Licensed under the MIT License.
Syntax:
Expand Down
12 changes: 6 additions & 6 deletions codeAnalysis/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) Microsoft Corporation and Contributors
// Licensed under the MIT license.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
Expand All @@ -13,10 +13,10 @@
[assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1101:PrefixLocalCallsWithThis", Justification = "We follow the C# Core Coding Style which avoids using `this` unless absolutely necessary.")]

[assembly: SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1200:UsingDirectivesMustBePlacedWithinNamespace", Justification = "We follow the C# Core Coding Style which puts using statements outside the namespace.")]
[assembly: SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1201:ElementsMustAppearInTheCorrectOrder", Justification = "It is not a priority and have hight impact in code changes.")]
[assembly: SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1202:ElementsMustBeOrderedByAccess", Justification = "It is not a priority and have hight impact in code changes.")]
[assembly: SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1203:ConstantsMustAppearBeforeFields", Justification = "It is not a priority and have hight impact in code changes.")]
[assembly: SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1204:StaticElementsMustAppearBeforeInstanceElements", Justification = "It is not a priority and have hight impact in code changes.")]
[assembly: SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1201:ElementsMustAppearInTheCorrectOrder", Justification = "It is not a priority and has high impact in code changes.")]
[assembly: SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1202:ElementsMustBeOrderedByAccess", Justification = "It is not a priority and has high impact in code changes.")]
[assembly: SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1203:ConstantsMustAppearBeforeFields", Justification = "It is not a priority and has high impact in code changes.")]
[assembly: SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1204:StaticElementsMustAppearBeforeInstanceElements", Justification = "It is not a priority and has high impact in code changes.")]

[assembly: SuppressMessage("StyleCop.CSharp.NamingRules", "SA1309:FieldNamesMustNotBeginWithUnderscore", Justification = "We follow the C# Core Coding Style which uses underscores as prefixes rather than using `this.`.")]

Expand Down
2 changes: 1 addition & 1 deletion codeAnalysis/StyleCop.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"settings": {
"documentationRules": {
"companyName": "Microsoft Corporation",
"copyrightText": "Copyright (c) Microsoft Corporation and Contributors\r\nLicensed under the MIT license.",
"copyrightText": "Copyright (c) Microsoft Corporation.\r\nLicensed under the MIT License.",
"xmlHeader": false,
"headerDecoration": "",
"fileNamingConvention": "metadata",
Expand Down
13 changes: 13 additions & 0 deletions exclusion.dic
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
devhome
enums
Octokit
advapi
Urls
Dependabot
github.com
inlines
abcd
Doggos
Stringify
riid
Impl
microsoft
7 changes: 4 additions & 3 deletions src/GitHubExtension/Client/Exceptions.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Copyright (c) Microsoft Corporation and Contributors
// Licensed under the MIT license.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

namespace GitHubExtension.Client;

namespace GitHubExtension.Client;
public class InvalidUrlException : Exception
{
public InvalidUrlException()
Expand Down
180 changes: 90 additions & 90 deletions src/GitHubExtension/Client/GithubClientProvider.cs
Original file line number Diff line number Diff line change
@@ -1,99 +1,99 @@
// Copyright (c) Microsoft Corporation and Contributors
// Licensed under the MIT license.

using DevHome.Logging.Helpers;
using GitHubExtension.DeveloperId;
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using DevHome.Logging.Helpers;
using GitHubExtension.DeveloperId;
using Microsoft.Windows.DevHome.SDK;
using Octokit;

namespace GitHubExtension.Client;

public class GitHubClientProvider
{
private readonly GitHubClient publicRepoClient;

private static readonly object InstanceLock = new ();

private static GitHubClientProvider? _instance;

public static GitHubClientProvider Instance
{
get
{
if (_instance == null)
{
lock (InstanceLock)
{
_instance = new GitHubClientProvider();
}
}

return _instance;
}
}

public GitHubClientProvider()
{
publicRepoClient = new GitHubClient(new ProductHeaderValue(Constants.DEV_HOME_APPLICATION_NAME));
}

public GitHubClient? GetClient(IDeveloperId devId)
{
var devIdInternal = DeveloperIdProvider.GetInstance().GetDeveloperIdInternal(devId) ?? throw new ArgumentException(devId.LoginId);
return devIdInternal.GitHubClient;
}

public GitHubClient GetClient(string url)
{
var devIdInternal = DeveloperIdProvider.GetInstance().GetLoggedInDeveloperIdsInternal().Where(i => i.Url.Equals(url, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
if (devIdInternal == null)
{
return publicRepoClient;
}

return devIdInternal.GitHubClient;
}

public GitHubClient GetClient()
{
return publicRepoClient;
}

public async Task<GitHubClient> GetClientForLoggedInDeveloper(bool logRateLimit = false)
{
var authProvider = DeveloperIdProvider.GetInstance();
var devIds = authProvider.GetLoggedInDeveloperIdsInternal();
GitHubClient client;
if (devIds == null || !devIds.Any())
{
Log.Logger()?.ReportInfo($"No logged in developer, using public GitHub client.");
client = Instance.GetClient();
}
else
{
Log.Logger()?.ReportInfo($"Using authenticated user: {devIds.First().LoginId}");
client = devIds.First().GitHubClient;
}

if (client == null)
{
Log.Logger()?.ReportError($"Failed creating GitHubClient.");
return client!;
}

if (logRateLimit)
using Octokit;

namespace GitHubExtension.Client;

public class GitHubClientProvider
{
private readonly GitHubClient publicRepoClient;

private static readonly object InstanceLock = new ();

private static GitHubClientProvider? _instance;

public static GitHubClientProvider Instance
{
get
{
if (_instance == null)
{
lock (InstanceLock)
{
_instance = new GitHubClientProvider();
}
}

return _instance;
}
}

public GitHubClientProvider()
{
publicRepoClient = new GitHubClient(new ProductHeaderValue(Constants.DEV_HOME_APPLICATION_NAME));
}

public GitHubClient? GetClient(IDeveloperId devId)
{
var devIdInternal = DeveloperIdProvider.GetInstance().GetDeveloperIdInternal(devId) ?? throw new ArgumentException(devId.LoginId);
return devIdInternal.GitHubClient;
}

public GitHubClient GetClient(string url)
{
var devIdInternal = DeveloperIdProvider.GetInstance().GetLoggedInDeveloperIdsInternal().Where(i => i.Url.Equals(url, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
if (devIdInternal == null)
{
return publicRepoClient;
}

return devIdInternal.GitHubClient;
}

public GitHubClient GetClient()
{
return publicRepoClient;
}

public async Task<GitHubClient> GetClientForLoggedInDeveloper(bool logRateLimit = false)
{
var authProvider = DeveloperIdProvider.GetInstance();
var devIds = authProvider.GetLoggedInDeveloperIdsInternal();
GitHubClient client;
if (devIds == null || !devIds.Any())
{
Log.Logger()?.ReportInfo($"No logged in developer, using public GitHub client.");
client = Instance.GetClient();
}
else
{
Log.Logger()?.ReportInfo($"Using authenticated user: {devIds.First().LoginId}");
client = devIds.First().GitHubClient;
}

if (client == null)
{
Log.Logger()?.ReportError($"Failed creating GitHubClient.");
return client!;
}

if (logRateLimit)
{
try
{
var miscRateLimit = await client.RateLimit.GetRateLimits();
Log.Logger()?.ReportInfo($"Rate Limit: Remaining: {miscRateLimit.Resources.Core.Remaining} Total: {miscRateLimit.Resources.Core.Limit} Resets: {miscRateLimit.Resources.Core.Reset.ToStringInvariant()}");
}
}
catch (Exception ex)
{
Log.Logger()?.ReportError($"Rate limiting not enabled for server.", ex);
}
}

return client;
}
}
}
}

return client;
}
}
5 changes: 3 additions & 2 deletions src/GitHubExtension/Client/Validation.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright (c) Microsoft Corporation and Contributors
// Licensed under the MIT license.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using GitHubExtension.DataModel;
using Octokit;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Copyright (c) Microsoft Corporation and Contributors
// Licensed under the MIT license.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

namespace GitHubExtension;

internal static class DeveloperOAuthConfiguration
{
//// Follow this link https://docs.github.com/en/developers/apps/building-oauth-apps/creating-an-oauth-app
Expand Down
5 changes: 3 additions & 2 deletions src/GitHubExtension/Configuration/OAuthConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Copyright (c) Microsoft Corporation and Contributors
// Licensed under the MIT license.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

namespace GitHubExtension;

internal static class OauthConfiguration
{
// This redirect url has to be configured into the OAuth app. This package has "devhome://"
Expand Down
5 changes: 3 additions & 2 deletions src/GitHubExtension/Constants.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Copyright (c) Microsoft Corporation and Contributors
// Licensed under the MIT license.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

namespace GitHubExtension;

internal class Constants
{
#pragma warning disable SA1310 // Field names should not contain underscore
Expand Down
4 changes: 2 additions & 2 deletions src/GitHubExtension/DataManager/DataManagerUpdateEventArgs.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) Microsoft Corporation and Contributors
// Licensed under the MIT license.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

namespace GitHubExtension.DataManager;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) Microsoft Corporation and Contributors
// Licensed under the MIT license.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using Microsoft.Windows.DevHome.SDK;

Expand Down
5 changes: 3 additions & 2 deletions src/GitHubExtension/DataManager/DataUpdater.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Copyright (c) Microsoft Corporation and Contributors
// Licensed under the MIT license.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

namespace GitHubExtension.DataManager;

public class DataUpdater : IDisposable
{
// This is the default interval the timer will run. It is not the interval that we necessarily do work.
Expand Down
4 changes: 2 additions & 2 deletions src/GitHubExtension/DataManager/Enums/SearchCategory.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) Microsoft Corporation and Contributors
// Licensed under the MIT license.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

namespace GitHubExtension.DataManager;

Expand Down
5 changes: 3 additions & 2 deletions src/GitHubExtension/DataManager/Exceptions.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Copyright (c) Microsoft Corporation and Contributors
// Licensed under the MIT license.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

namespace GitHubExtension;

public class RepositoryNotFoundException : ApplicationException
{
public RepositoryNotFoundException()
Expand Down
5 changes: 3 additions & 2 deletions src/GitHubExtension/DataManager/GitHubDataManager.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) Microsoft Corporation and Contributors
// Licensed under the MIT license.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using GitHubExtension.Client;
using GitHubExtension.DataManager;
Expand All @@ -8,6 +8,7 @@
using Windows.Storage;

namespace GitHubExtension;

public partial class GitHubDataManager : IGitHubDataManager, IDisposable
{
public static event DataManagerUpdateEventHandler? OnUpdate;
Expand Down
Loading

0 comments on commit 77f2eb5

Please sign in to comment.