Skip to content

Commit

Permalink
Merge pull request #416 from microsoft/staging
Browse files Browse the repository at this point in the history
Release - 7/16/24
  • Loading branch information
EricJohnson327 authored Jul 15, 2024
2 parents 11fb693 + fa3fbed commit 9b013b6
Show file tree
Hide file tree
Showing 66 changed files with 651 additions and 611 deletions.
39 changes: 32 additions & 7 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ csharp_space_between_method_declaration_parameter_list_parentheses = false

#Formatting - wrapping options

#leave code block on separate lines
#allow code blocks on single lines
csharp_preserve_single_line_blocks = true

#Style - Code block preferences
Expand Down Expand Up @@ -87,16 +87,13 @@ csharp_style_var_elsewhere = true:suggestion
csharp_style_var_for_built_in_types = true:suggestion
#prefer var when the type is already mentioned on the right-hand side of a declaration expression
csharp_style_var_when_type_is_apparent = true:suggestion
csharp_style_implicit_object_creation_when_type_is_apparent = true:warning

#Style - language keyword and framework type options

#prefer the language keyword for local variables, method parameters, and class members, instead of the type name, for types that have a keyword to represent them
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion

#Style - Language rules
csharp_style_implicit_object_creation_when_type_is_apparent = true:warning
csharp_style_var_for_built_in_types = true:warning

#Style - modifier options

#prefer accessibility modifiers to be declared except for public interface members. This will currently not differ from always and will act as future proofing for if C# adds default interface methods.
Expand Down Expand Up @@ -146,7 +143,6 @@ dotnet_style_collection_initializer = true:suggestion
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
dotnet_style_prefer_conditional_expression_over_return = true:silent
[*.{cs,vb}]

#Style - Unnecessary code rules
csharp_style_unused_value_assignment_preference = discard_variable:warning
Expand Down Expand Up @@ -203,6 +199,35 @@ dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_compound_assignment = true:warning
dotnet_style_prefer_simplified_interpolation = true:suggestion

# Define what we will treat as private fields.
dotnet_naming_symbols.private_fields.applicable_kinds = field
dotnet_naming_symbols.private_fields.applicable_accessibilities = private

dotnet_naming_symbols.const_private_fields.applicable_kinds = field
dotnet_naming_symbols.const_private_fields.applicable_accessibilities = private
dotnet_naming_symbols.const_private_fields.required_modifiers = const

# Define rule that something must begin with an underscore and be in camel case.
dotnet_naming_style.require_underscore_prefix_and_camel_case.required_prefix = _
dotnet_naming_style.require_underscore_prefix_and_camel_case.capitalization = camel_case

dotnet_naming_style.requre_no_prefix_and_pascal_case.required_prefix =
dotnet_naming_style.requre_no_prefix_and_pascal_case.capitalization = pascal_case

# Appy our rule to private fields.
dotnet_naming_rule.private_fields_must_begin_with_underscore_and_be_in_camel_case.symbols = private_fields
dotnet_naming_rule.private_fields_must_begin_with_underscore_and_be_in_camel_case.style = require_underscore_prefix_and_camel_case
dotnet_naming_rule.private_fields_must_begin_with_underscore_and_be_in_camel_case.severity = warning

dotnet_naming_rule.const_fields_must_begin_with_no_prefix_and_be_in_pascal_case.symbols = const_private_fields
dotnet_naming_rule.const_fields_must_begin_with_no_prefix_and_be_in_pascal_case.style = requre_no_prefix_and_pascal_case
dotnet_naming_rule.const_fields_must_begin_with_no_prefix_and_be_in_pascal_case.severity = warning
# Spelling

spelling_exclusion_path = .\exclusion.dic
spelling_exclusion_path = .\exclusion.dic

# Diagnostic configuration

# CS8305: Type is for evaluation purposes only and is subject to change or removal in future updates.
dotnet_diagnostic.CS8305.severity = suggestion

2 changes: 1 addition & 1 deletion build/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ parameters:
- release

variables:
MSIXVersion: '0.1500'
MSIXVersion: '0.1600'
solution: '**/GitHubExtension.sln'
appxPackageDir: 'AppxPackages'
testOutputArtifactDir: 'TestResults'
Expand Down
2 changes: 1 addition & 1 deletion build/scripts/CreateBuildInfo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Param(
)

$Major = "0"
$Minor = "15"
$Minor = "16"
$Patch = "99" # default to 99 for local builds

$versionSplit = $Version.Split(".");
Expand Down
6 changes: 6 additions & 0 deletions exclusion.dic
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ riid
Impl
microsoft
octokit
Octokit
Dependabot
Stringify
riid
impl
dhlog
26 changes: 13 additions & 13 deletions src/GitHubExtension/Client/GithubClientProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ namespace GitHubExtension.Client;

public class GitHubClientProvider
{
private static readonly Lazy<ILogger> _log = new(() => Serilog.Log.ForContext("SourceContext", nameof(GitHubClientProvider)));
private static readonly Lazy<ILogger> _logger = new(() => Serilog.Log.ForContext("SourceContext", nameof(GitHubClientProvider)));

private static readonly ILogger Log = _log.Value;
private static readonly ILogger _log = _logger.Value;

private readonly GitHubClient publicRepoClient;
private readonly GitHubClient _publicRepoClient;

private static readonly object InstanceLock = new();
private static readonly object _instanceLock = new();

private static GitHubClientProvider? _instance;

Expand All @@ -26,7 +26,7 @@ public static GitHubClientProvider Instance
{
if (_instance == null)
{
lock (InstanceLock)
lock (_instanceLock)
{
_instance = new GitHubClientProvider();
}
Expand All @@ -38,7 +38,7 @@ public static GitHubClientProvider Instance

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

public GitHubClient? GetClient(IDeveloperId devId)
Expand All @@ -52,15 +52,15 @@ 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 _publicRepoClient;
}

return devIdInternal.GitHubClient;
}

public GitHubClient GetClient()
{
return publicRepoClient;
return _publicRepoClient;
}

public async Task<GitHubClient> GetClientForLoggedInDeveloper(bool logRateLimit = false)
Expand All @@ -70,18 +70,18 @@ public async Task<GitHubClient> GetClientForLoggedInDeveloper(bool logRateLimit
GitHubClient client;
if (devIds == null || !devIds.Any())
{
Log.Information($"No logged in developer, using public GitHub client.");
_log.Information($"No logged in developer, using public GitHub client.");
client = Instance.GetClient();
}
else
{
Log.Information($"Using authenticated user: {devIds.First().LoginId}");
_log.Information($"Using authenticated user: {devIds.First().LoginId}");
client = devIds.First().GitHubClient;
}

if (client == null)
{
Log.Error($"Failed creating GitHubClient.");
_log.Error($"Failed creating GitHubClient.");
return client!;
}

Expand All @@ -90,11 +90,11 @@ public async Task<GitHubClient> GetClientForLoggedInDeveloper(bool logRateLimit
try
{
var miscRateLimit = await client.RateLimit.GetRateLimits();
Log.Information($"Rate Limit: Remaining: {miscRateLimit.Resources.Core.Remaining} Total: {miscRateLimit.Resources.Core.Limit} Resets: {miscRateLimit.Resources.Core.Reset}");
_log.Information($"Rate Limit: Remaining: {miscRateLimit.Resources.Core.Remaining} Total: {miscRateLimit.Resources.Core.Limit} Resets: {miscRateLimit.Resources.Core.Reset}");
}
catch (Exception ex)
{
Log.Error(ex, $"Rate limiting not enabled for server.");
_log.Error(ex, $"Rate limiting not enabled for server.");
}
}

Expand Down
14 changes: 7 additions & 7 deletions src/GitHubExtension/Client/Validation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ namespace GitHubExtension.Client;
// Validation layer to help parsing GitHub URL.
public static class Validation
{
private static readonly Lazy<ILogger> _log = new(() => Serilog.Log.ForContext("SourceContext", nameof(Validation)));
private static readonly Lazy<ILogger> _logger = new(() => Serilog.Log.ForContext("SourceContext", nameof(Validation)));

private static readonly ILogger Log = _log.Value;
private static readonly ILogger _log = _logger.Value;

private static bool IsValidHttpUri(string uriString, out Uri? uri)
{
Expand All @@ -29,7 +29,7 @@ public static bool IsValidGitHubComURL(Uri uri)
// Valid GitHub URL has three segments. The first is '/'.
if (uri.Segments.Length < 3 || (!uri.Host.Equals("github.com", StringComparison.OrdinalIgnoreCase) && !uri.Host.Equals("www.github.com", StringComparison.OrdinalIgnoreCase)))
{
Log.Debug($"{uri.OriginalString} is not a valid GitHub uri");
_log.Debug($"{uri.OriginalString} is not a valid GitHub uri");
return false;
}

Expand All @@ -43,7 +43,7 @@ public static bool IsValidGitHubEnterpriseServerURL(Uri server)
// https://docs.github.com/en/[email protected]/admin/configuration/configuring-network-settings/configuring-the-hostname-for-your-instance
if (server.Segments.Length < 3)
{
Log.Debug($"{server.OriginalString} is not a valid GHES repo uri");
_log.Debug($"{server.OriginalString} is not a valid GHES repo uri");
return false;
}

Expand All @@ -60,7 +60,7 @@ public static bool IsValidGitHubURL(string url)
// Above link shows a work around.
if (!IsValidHttpUri(url, out parsedUri) || url == null || parsedUri == null)
{
Log.Debug($"{url} is not a valid http uri");
_log.Debug($"{url} is not a valid http uri");
return false;
}

Expand Down Expand Up @@ -231,13 +231,13 @@ public static async Task<bool> IsReachableGitHubEnterpriseServerURL(Uri server)
var probeResult = await new EnterpriseProbe(new ProductHeaderValue(Constants.DEV_HOME_APPLICATION_NAME)).Probe(server);
if (probeResult != EnterpriseProbeResult.Ok)
{
Log.Error($"EnterpriseServer {server.AbsoluteUri} is not reachable");
_log.Error($"EnterpriseServer {server.AbsoluteUri} is not reachable");
return false;
}
}
catch (Exception ex)
{
Log.Error(ex, $"EnterpriseServer {server.AbsoluteUri} could not be probed.");
_log.Error(ex, $"EnterpriseServer {server.AbsoluteUri} could not be probed.");
return false;
}

Expand Down
10 changes: 5 additions & 5 deletions src/GitHubExtension/DataManager/DataUpdater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ 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.
private static readonly TimeSpan TimerUpdateInterval = TimeSpan.FromSeconds(5);
private static readonly TimeSpan _timerUpdateInterval = TimeSpan.FromSeconds(5);

private readonly ILogger _logger;
private readonly PeriodicTimer _timer;
Expand All @@ -28,7 +28,7 @@ public DataUpdater(TimeSpan interval, Func<Task> action)
}

public DataUpdater(Func<Task> action)
: this(TimerUpdateInterval, action)
: this(_timerUpdateInterval, action)
{
}

Expand Down Expand Up @@ -62,11 +62,11 @@ public void Stop()

public override string ToString() => "DataUpdater";

private bool disposed; // To detect redundant calls.
private bool _disposed; // To detect redundant calls.

protected virtual void Dispose(bool disposing)
{
if (!disposed)
if (!_disposed)
{
_logger.Debug("Disposing of all updater resources.");

Expand All @@ -75,7 +75,7 @@ protected virtual void Dispose(bool disposing)
_timer.Dispose();
}

disposed = true;
_disposed = true;
}
}

Expand Down
Loading

0 comments on commit 9b013b6

Please sign in to comment.