diff --git a/.editorconfig b/.editorconfig index 557eb2e..b4c13cf 100644 --- a/.editorconfig +++ b/.editorconfig @@ -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 @@ -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. @@ -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 @@ -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 \ No newline at end of file +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 + diff --git a/build/azure-pipelines.yml b/build/azure-pipelines.yml index 1a5365b..f30f388 100644 --- a/build/azure-pipelines.yml +++ b/build/azure-pipelines.yml @@ -20,7 +20,7 @@ parameters: - release variables: - MSIXVersion: '0.1500' + MSIXVersion: '0.1600' solution: '**/GitHubExtension.sln' appxPackageDir: 'AppxPackages' testOutputArtifactDir: 'TestResults' diff --git a/build/scripts/CreateBuildInfo.ps1 b/build/scripts/CreateBuildInfo.ps1 index 07ac422..02d7de1 100644 --- a/build/scripts/CreateBuildInfo.ps1 +++ b/build/scripts/CreateBuildInfo.ps1 @@ -5,7 +5,7 @@ Param( ) $Major = "0" -$Minor = "15" +$Minor = "16" $Patch = "99" # default to 99 for local builds $versionSplit = $Version.Split("."); diff --git a/exclusion.dic b/exclusion.dic index 3569188..4b71916 100644 --- a/exclusion.dic +++ b/exclusion.dic @@ -13,3 +13,9 @@ riid Impl microsoft octokit +Octokit +Dependabot +Stringify +riid +impl +dhlog diff --git a/src/GitHubExtension/Client/GithubClientProvider.cs b/src/GitHubExtension/Client/GithubClientProvider.cs index 3d05ee9..13b1722 100644 --- a/src/GitHubExtension/Client/GithubClientProvider.cs +++ b/src/GitHubExtension/Client/GithubClientProvider.cs @@ -10,13 +10,13 @@ namespace GitHubExtension.Client; public class GitHubClientProvider { - private static readonly Lazy _log = new(() => Serilog.Log.ForContext("SourceContext", nameof(GitHubClientProvider))); + private static readonly Lazy _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; @@ -26,7 +26,7 @@ public static GitHubClientProvider Instance { if (_instance == null) { - lock (InstanceLock) + lock (_instanceLock) { _instance = new GitHubClientProvider(); } @@ -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) @@ -52,7 +52,7 @@ 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; @@ -60,7 +60,7 @@ public GitHubClient GetClient(string url) public GitHubClient GetClient() { - return publicRepoClient; + return _publicRepoClient; } public async Task GetClientForLoggedInDeveloper(bool logRateLimit = false) @@ -70,18 +70,18 @@ public async Task 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!; } @@ -90,11 +90,11 @@ public async Task 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."); } } diff --git a/src/GitHubExtension/Client/Validation.cs b/src/GitHubExtension/Client/Validation.cs index 99da1c8..b57963f 100644 --- a/src/GitHubExtension/Client/Validation.cs +++ b/src/GitHubExtension/Client/Validation.cs @@ -9,9 +9,9 @@ namespace GitHubExtension.Client; // Validation layer to help parsing GitHub URL. public static class Validation { - private static readonly Lazy _log = new(() => Serilog.Log.ForContext("SourceContext", nameof(Validation))); + private static readonly Lazy _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) { @@ -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; } @@ -43,7 +43,7 @@ public static bool IsValidGitHubEnterpriseServerURL(Uri server) // https://docs.github.com/en/enterprise-server@3.10/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; } @@ -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; } @@ -231,13 +231,13 @@ public static async Task 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; } diff --git a/src/GitHubExtension/DataManager/DataUpdater.cs b/src/GitHubExtension/DataManager/DataUpdater.cs index 35c6a4f..721208f 100644 --- a/src/GitHubExtension/DataManager/DataUpdater.cs +++ b/src/GitHubExtension/DataManager/DataUpdater.cs @@ -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; @@ -28,7 +28,7 @@ public DataUpdater(TimeSpan interval, Func action) } public DataUpdater(Func action) - : this(TimerUpdateInterval, action) + : this(_timerUpdateInterval, action) { } @@ -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."); @@ -75,7 +75,7 @@ protected virtual void Dispose(bool disposing) _timer.Dispose(); } - disposed = true; + _disposed = true; } } diff --git a/src/GitHubExtension/DataManager/GitHubDataManager.cs b/src/GitHubExtension/DataManager/GitHubDataManager.cs index 6883728..5562a1c 100644 --- a/src/GitHubExtension/DataManager/GitHubDataManager.cs +++ b/src/GitHubExtension/DataManager/GitHubDataManager.cs @@ -12,26 +12,26 @@ namespace GitHubExtension; public partial class GitHubDataManager : IGitHubDataManager, IDisposable { - private static readonly Lazy _log = new(() => Serilog.Log.ForContext("SourceContext", nameof(GitHubDataManager))); + private static readonly Lazy _logger = new(() => Serilog.Log.ForContext("SourceContext", nameof(GitHubDataManager))); - private static readonly ILogger Log = _log.Value; + private static readonly ILogger _log = _logger.Value; public static event DataManagerUpdateEventHandler? OnUpdate; - private static readonly string LastUpdatedKeyName = "LastUpdated"; - private static readonly TimeSpan NotificationRetentionTime = TimeSpan.FromDays(7); - private static readonly TimeSpan SearchRetentionTime = TimeSpan.FromDays(7); - private static readonly TimeSpan PullRequestStaleTime = TimeSpan.FromDays(1); - private static readonly TimeSpan ReviewStaleTime = TimeSpan.FromDays(7); - private static readonly TimeSpan ReleaseRetentionTime = TimeSpan.FromDays(7); + private const string LastUpdatedKeyName = "LastUpdated"; + private static readonly TimeSpan _notificationRetentionTime = TimeSpan.FromDays(7); + private static readonly TimeSpan _searchRetentionTime = TimeSpan.FromDays(7); + private static readonly TimeSpan _pullRequestStaleTime = TimeSpan.FromDays(1); + private static readonly TimeSpan _reviewStaleTime = TimeSpan.FromDays(7); + private static readonly TimeSpan _releaseRetentionTime = TimeSpan.FromDays(7); // It is possible different widgets have queries which touch the same pull requests. // We want to keep this window large enough that we don't delete data being used by // other clients which simply haven't been updated yet but will in the near future. // This is a conservative time period to check for pruning and give time for other // consumers using the data to update its freshness before we remove it. - private static readonly TimeSpan LastObservedDeleteSpan = TimeSpan.FromMinutes(6); - private static readonly long CheckSuiteIdDependabot = 29110; + private static readonly TimeSpan _lastObservedDeleteSpan = TimeSpan.FromMinutes(6); + private const long CheckSuiteIdDependabot = 29110; private DataStore DataStore { get; set; } @@ -47,7 +47,7 @@ public partial class GitHubDataManager : IGitHubDataManager, IDisposable } catch (Exception e) { - Log.Error(e, "Failed creating GitHubDataManager"); + _log.Error(e, "Failed creating GitHubDataManager"); Environment.FailFast(e.Message, e); return null; } @@ -253,7 +253,7 @@ private async Task UpdateDataStoreAsync(DataStoreOperationParameters parameters, } catch (Exception ex) { - Log.Error(ex, $"Failed Updating DataStore for: {parameters}"); + _log.Error(ex, $"Failed Updating DataStore for: {parameters}"); tx.Rollback(); // Rethrow so clients can catch/display an error UX. @@ -261,7 +261,7 @@ private async Task UpdateDataStoreAsync(DataStoreOperationParameters parameters, } tx.Commit(); - Log.Information($"Updated datastore: {parameters}"); + _log.Information($"Updated datastore: {parameters}"); } // Wrapper for the targeted repository update pattern. @@ -301,22 +301,22 @@ private async Task UpdateDataForRepositoryAsync(DataStoreOperationParameters par { case Octokit.NotFoundException: // A private repository will come back as "not found" by the GitHub API when an unauthorized account cannot even view it. - Log.Debug($"DeveloperId {devId.LoginId} did not find {parameters.Owner}/{parameters.RepositoryName}"); + _log.Debug($"DeveloperId {devId.LoginId} did not find {parameters.Owner}/{parameters.RepositoryName}"); continue; case Octokit.RateLimitExceededException: - Log.Debug($"DeveloperId {devId.LoginId} rate limit exceeded."); + _log.Debug($"DeveloperId {devId.LoginId} rate limit exceeded."); throw; case Octokit.ForbiddenException: // This can happen most commonly with SAML-enabled organizations. // The user may have access but the org blocked the application. - Log.Debug($"DeveloperId {devId.LoginId} was forbidden access to {parameters.Owner}/{parameters.RepositoryName}"); + _log.Debug($"DeveloperId {devId.LoginId} was forbidden access to {parameters.Owner}/{parameters.RepositoryName}"); throw; default: // If it's some other error like abuse detection, abort and do not continue. - Log.Debug($"Unhandled Octokit API error for {devId.LoginId} and {parameters.Owner} / {parameters.RepositoryName}"); + _log.Debug($"Unhandled Octokit API error for {devId.LoginId} and {parameters.Owner} / {parameters.RepositoryName}"); throw; } } @@ -334,13 +334,13 @@ private async Task UpdateDataForRepositoryAsync(DataStoreOperationParameters par catch (Exception ex) { // This is for catching any other unexpected error as well as any we throw. - Log.Error(ex, $"Failed trying update data for repository: {parameters.Owner}/{parameters.RepositoryName}"); + _log.Error(ex, $"Failed trying update data for repository: {parameters.Owner}/{parameters.RepositoryName}"); tx.Rollback(); throw; } tx.Commit(); - Log.Information($"Updated datastore: {parameters}"); + _log.Information($"Updated datastore: {parameters}"); } // Find all pull requests the developer, and update them. @@ -351,7 +351,7 @@ private async Task UpdatePullRequestsForLoggedInDeveloperIdsAsync(DataStoreOpera if (devIds is null || !devIds.Any()) { // This may not be an error if the user has not yet logged in with a DevId. - Log.Information("Called to update all pull requests for a user with no logged in developer."); + _log.Information("Called to update all pull requests for a user with no logged in developer."); return; } @@ -408,7 +408,7 @@ private async Task UpdatePullRequestsForLoggedInDeveloperIdsAsync(DataStoreOpera // the UI to query it to attempt to resolve any issues discovered in the main // app UX, such as via a user prompt that tells them not all of their data // could be accessed. - Log.Warning($"Forbidden exception while trying to query repository {repoFullName}: {ex.Message}"); + _log.Warning($"Forbidden exception while trying to query repository {repoFullName}: {ex.Message}"); continue; } @@ -448,7 +448,7 @@ private async Task UpdatePullRequestsForLoggedInDeveloperIdsAsync(DataStoreOpera continue; } - Log.Verbose($"Suite: {suite.App.Name} - {suite.App.Id} - {suite.App.Owner.Login} Conclusion: {suite.Conclusion} Status: {suite.Status}"); + _log.Verbose($"Suite: {suite.App.Name} - {suite.App.Id} - {suite.App.Owner.Login} Conclusion: {suite.Conclusion} Status: {suite.Status}"); CheckSuite.GetOrCreateByOctokitCheckSuite(DataStore, suite); } } @@ -457,10 +457,10 @@ private async Task UpdatePullRequestsForLoggedInDeveloperIdsAsync(DataStoreOpera // Octokit can sometimes fail unexpectedly or have bugs. Should that occur here, we // will not stop processing all pull requests and instead skip over getting the PR // checks information for this particular pull request. - Log.Error($"Error updating Check Status for Pull Request #{octoPull.Number}: {e.Message}"); + _log.Error($"Error updating Check Status for Pull Request #{octoPull.Number}: {e.Message}"); // Put the full stack trace in debug if this occurs to reduce log spam. - Log.Debug(e, $"Error updating Check Status for Pull Request #{octoPull.Number}."); + _log.Debug(e, $"Error updating Check Status for Pull Request #{octoPull.Number}."); } var commitCombinedStatus = await devId.GitHubClient.Repository.Status.GetCombined(dsRepository.InternalId, dsPullRequest.HeadSha); @@ -483,19 +483,19 @@ private async Task UpdatePullRequestsForLoggedInDeveloperIdsAsync(DataStoreOpera // Octokit can sometimes fail unexpectedly or have bugs. Should that occur here, we // will not stop processing all pull requests and instead skip over getting the PR // review information for this particular pull request. - Log.Error($"Error updating Reviews for Pull Request #{octoPull.Number}: {e.Message}"); + _log.Error($"Error updating Reviews for Pull Request #{octoPull.Number}: {e.Message}"); // Put the full stack trace in debug if this occurs to reduce log spam. - Log.Debug(e, $"Error updating Reviews for Pull Request #{octoPull.Number}."); + _log.Debug(e, $"Error updating Reviews for Pull Request #{octoPull.Number}."); } } - Log.Debug($"Updated developer pull requests for {repoFullName}."); + _log.Debug($"Updated developer pull requests for {repoFullName}."); } // After we update for this developer, remove all pull requests for this developer that // were not observed recently. - PullRequest.DeleteAllByDeveloperLoginAndLastObservedBefore(DataStore, devId.LoginId, DateTime.UtcNow - LastObservedDeleteSpan); + PullRequest.DeleteAllByDeveloperLoginAndLastObservedBefore(DataStore, devId.LoginId, DateTime.UtcNow - _lastObservedDeleteSpan); } } @@ -504,7 +504,7 @@ private async Task UpdatePullRequestsForLoggedInDeveloperIdsAsync(DataStoreOpera private async Task UpdateRepositoryAsync(string owner, string repositoryName, Octokit.GitHubClient? client = null) { client ??= await GitHubClientProvider.Instance.GetClientForLoggedInDeveloper(true); - Log.Information($"Updating repository: {owner}/{repositoryName}"); + _log.Information($"Updating repository: {owner}/{repositoryName}"); var octokitRepository = await client.Repository.Get(owner, repositoryName); return Repository.GetOrCreateByOctokitRepository(DataStore, octokitRepository); } @@ -516,7 +516,7 @@ private async Task UpdatePullRequestsAsync(Repository repository, Octokit.GitHub options ??= RequestOptions.RequestOptionsDefault(); client ??= await GitHubClientProvider.Instance.GetClientForLoggedInDeveloper(true); var user = await client.User.Current(); - Log.Information($"Updating pull requests for: {repository.FullName} and user: {user.Login}"); + _log.Information($"Updating pull requests for: {repository.FullName} and user: {user.Login}"); var octoPulls = await client.PullRequest.GetAllForRepository(repository.InternalId, options.PullRequestRequest, options.ApiOptions); foreach (var pull in octoPulls) { @@ -539,7 +539,7 @@ private async Task UpdatePullRequestsAsync(Repository repository, Octokit.GitHub continue; } - Log.Verbose($"Suite: {suite.App.Name} - {suite.App.Id} - {suite.App.Owner.Login} Conclusion: {suite.Conclusion} Status: {suite.Status}"); + _log.Verbose($"Suite: {suite.App.Name} - {suite.App.Id} - {suite.App.Owner.Login} Conclusion: {suite.Conclusion} Status: {suite.Status}"); CheckSuite.GetOrCreateByOctokitCheckSuite(DataStore, suite); } } @@ -548,10 +548,10 @@ private async Task UpdatePullRequestsAsync(Repository repository, Octokit.GitHub // Octokit can sometimes fail unexpectedly or have bugs. Should that occur here, we // will not stop processing all pull requests and instead skip over getting the PR // checks information for this particular pull request. - Log.Error($"Error updating Check Status for Pull Request #{pull.Number}: {e.Message}"); + _log.Error($"Error updating Check Status for Pull Request #{pull.Number}: {e.Message}"); // Put the full stack trace in debug if this occurs to reduce log spam. - Log.Debug(e, $"Error updating Check Status for Pull Request #{pull.Number}."); + _log.Debug(e, $"Error updating Check Status for Pull Request #{pull.Number}."); } var commitCombinedStatus = await client.Repository.Status.GetCombined(repository.InternalId, dsPullRequest.HeadSha); @@ -561,13 +561,13 @@ private async Task UpdatePullRequestsAsync(Repository repository, Octokit.GitHub } // Remove unobserved pull requests from this repository. - PullRequest.DeleteLastObservedBefore(DataStore, repository.Id, DateTime.UtcNow - LastObservedDeleteSpan); + PullRequest.DeleteLastObservedBefore(DataStore, repository.Id, DateTime.UtcNow - _lastObservedDeleteSpan); } private void ProcessReview(PullRequest pullRequest, Octokit.PullRequestReview octoReview) { // Skip reviews that are stale. - if ((DateTime.Now - octoReview.SubmittedAt) > ReviewStaleTime) + if ((DateTime.Now - octoReview.SubmittedAt) > _reviewStaleTime) { return; } @@ -581,7 +581,7 @@ private void ProcessReview(PullRequest pullRequest, Octokit.PullRequestReview oc // Ignore comments or pending state. if (string.IsNullOrEmpty(newReview.State) || newReview.State == "Commented") { - Log.Debug($"Ignoring review for {pullRequest}. State: {newReview.State}"); + _log.Debug($"Ignoring review for {pullRequest}. State: {newReview.State}"); return; } @@ -589,7 +589,7 @@ private void ProcessReview(PullRequest pullRequest, Octokit.PullRequestReview oc if (existingReview == null || (existingReview.State != newReview.State)) { // We assume that the logged in developer created this pull request. - Log.Information($"Creating NewReview Notification for {pullRequest}. State: {newReview.State}"); + _log.Information($"Creating NewReview Notification for {pullRequest}. State: {newReview.State}"); Notification.Create(DataStore, newReview, NotificationType.NewReview); } } @@ -604,13 +604,13 @@ private void CreatePullRequestStatus(PullRequest pullRequest) if (ShouldCreateCheckFailureNotification(curStatus, prevStatus)) { - Log.Information($"Creating CheckRunFailure Notification for {curStatus}"); + _log.Information($"Creating CheckRunFailure Notification for {curStatus}"); Notification.Create(DataStore, curStatus, NotificationType.CheckRunFailed); } if (ShouldCreateCheckSucceededNotification(curStatus, prevStatus)) { - Log.Debug($"Creating CheckRunSuccess Notification for {curStatus}"); + _log.Debug($"Creating CheckRunSuccess Notification for {curStatus}"); Notification.Create(DataStore, curStatus, NotificationType.CheckRunSucceeded); } } @@ -618,7 +618,7 @@ private void CreatePullRequestStatus(PullRequest pullRequest) public bool ShouldCreateCheckFailureNotification(PullRequestStatus curStatus, PullRequestStatus? prevStatus) { // If the pull request is not recent, do not create a notification for it. - if ((DateTime.Now - curStatus.PullRequest.UpdatedAt) > PullRequestStaleTime) + if ((DateTime.Now - curStatus.PullRequest.UpdatedAt) > _pullRequestStaleTime) { return false; } @@ -654,7 +654,7 @@ public bool ShouldCreateCheckFailureNotification(PullRequestStatus curStatus, Pu public bool ShouldCreateCheckSucceededNotification(PullRequestStatus curStatus, PullRequestStatus? prevStatus) { // If the pull request is not recent, do not create a notification for it. - if ((DateTime.Now - curStatus.PullRequest.UpdatedAt) > PullRequestStaleTime) + if ((DateTime.Now - curStatus.PullRequest.UpdatedAt) > _pullRequestStaleTime) { return false; } @@ -687,7 +687,7 @@ private async Task UpdateIssuesAsync(Repository repository, Octokit.GitHubClient { options ??= RequestOptions.RequestOptionsDefault(); client ??= await GitHubClientProvider.Instance.GetClientForLoggedInDeveloper(true); - Log.Information($"Updating issues for: {repository.FullName}"); + _log.Information($"Updating issues for: {repository.FullName}"); // Since we are only interested in issues and for a specific repository, we will override // these two properties. All other properties the caller can specify however they see fit. @@ -697,7 +697,7 @@ private async Task UpdateIssuesAsync(Repository repository, Octokit.GitHubClient var issuesResult = await client.Search.SearchIssues(options.SearchIssuesRequest); if (issuesResult == null) { - Log.Debug($"No issues found."); + _log.Debug($"No issues found."); return; } @@ -705,11 +705,11 @@ private async Task UpdateIssuesAsync(Repository repository, Octokit.GitHubClient Search? search = null; if (!string.IsNullOrEmpty(options.SearchIssuesRequest.Term)) { - Log.Debug($"Term = {options.SearchIssuesRequest.Term}"); + _log.Debug($"Term = {options.SearchIssuesRequest.Term}"); search = Search.GetOrCreate(DataStore, options.SearchIssuesRequest.Term, repository.Id); } - Log.Debug($"Results contain {issuesResult.Items.Count} issues."); + _log.Debug($"Results contain {issuesResult.Items.Count} issues."); foreach (var issue in issuesResult.Items) { var dsIssue = Issue.GetOrCreateByOctokitIssue(DataStore, issue, repository.Id); @@ -727,7 +727,7 @@ private async Task UpdateIssuesAsync(Repository repository, Octokit.GitHubClient } // Remove issues from this repository that were not observed recently. - Issue.DeleteLastObservedBefore(DataStore, repository.Id, DateTime.UtcNow - LastObservedDeleteSpan); + Issue.DeleteLastObservedBefore(DataStore, repository.Id, DateTime.UtcNow - _lastObservedDeleteSpan); } // Internal method to update releases. Assumes Repository has already been populated and created. @@ -741,16 +741,16 @@ private async Task UpdateReleasesAsync(Repository repository, Octokit.GitHubClie options.ApiOptions.PageSize = 10; client ??= await GitHubClientProvider.Instance.GetClientForLoggedInDeveloper(true); - Log.Information($"Updating releases for: {repository.FullName}"); + _log.Information($"Updating releases for: {repository.FullName}"); var releasesResult = await client.Repository.Release.GetAll(repository.InternalId, options.ApiOptions); if (releasesResult == null) { - Log.Debug($"No releases found."); + _log.Debug($"No releases found."); return; } - Log.Debug($"Results contain {releasesResult.Count} releases."); + _log.Debug($"Results contain {releasesResult.Count} releases."); foreach (var release in releasesResult) { if (release.Draft) @@ -762,7 +762,7 @@ private async Task UpdateReleasesAsync(Repository repository, Octokit.GitHubClie } // Remove releases from this repository that were not observed recently. - Release.DeleteLastObservedBefore(DataStore, repository.Id, DateTime.UtcNow - LastObservedDeleteSpan); + Release.DeleteLastObservedBefore(DataStore, repository.Id, DateTime.UtcNow - _lastObservedDeleteSpan); } // Removes unused data from the datastore. @@ -772,11 +772,11 @@ private void PruneObsoleteData() CheckSuite.DeleteUnreferenced(DataStore); CommitCombinedStatus.DeleteUnreferenced(DataStore); PullRequestStatus.DeleteUnreferenced(DataStore); - Notification.DeleteBefore(DataStore, DateTime.Now - NotificationRetentionTime); - Search.DeleteBefore(DataStore, DateTime.Now - SearchRetentionTime); + Notification.DeleteBefore(DataStore, DateTime.Now - _notificationRetentionTime); + Search.DeleteBefore(DataStore, DateTime.Now - _searchRetentionTime); SearchIssue.DeleteUnreferenced(DataStore); Review.DeleteUnreferenced(DataStore); - Release.DeleteBefore(DataStore, DateTime.Now - ReleaseRetentionTime); + Release.DeleteBefore(DataStore, DateTime.Now - _releaseRetentionTime); } // Sets a last-updated in the MetaData. @@ -791,7 +791,7 @@ private string[] GetOwnerAndRepositoryNameFromFullName(string fullName) var nameSplit = fullName.Split(new[] { '/' }); if (nameSplit.Length != 2 || string.IsNullOrEmpty(nameSplit[0]) || string.IsNullOrEmpty(nameSplit[1])) { - Log.Error($"Invalid repository full name: {fullName}"); + _log.Error($"Invalid repository full name: {fullName}"); throw new ArgumentException($"Invalid repository full name: {fullName}"); } @@ -826,9 +826,9 @@ private void ValidateDataStore() // Making the default options a singleton to avoid repeatedly calling the storage APIs and // creating a new GitHubDataStoreSchema when not necessary. - private static readonly Lazy LazyDataStoreOptions = new(DefaultOptionsInit); + private static readonly Lazy _lazyDataStoreOptions = new(DefaultOptionsInit); - private static DataStoreOptions DefaultOptions => LazyDataStoreOptions.Value; + private static DataStoreOptions DefaultOptions => _lazyDataStoreOptions.Value; private static DataStoreOptions DefaultOptionsInit() { @@ -841,13 +841,13 @@ private static DataStoreOptions DefaultOptionsInit() public override string ToString() => "GitHubDataManager"; - private bool disposed; // To detect redundant calls. + private bool _disposed; // To detect redundant calls. protected virtual void Dispose(bool disposing) { - if (!disposed) + if (!_disposed) { - Log.Debug("Disposing of all Disposable resources."); + _log.Debug("Disposing of all Disposable resources."); if (disposing) { @@ -863,7 +863,7 @@ protected virtual void Dispose(bool disposing) } } - disposed = true; + _disposed = true; } } diff --git a/src/GitHubExtension/DataManager/GitHubDataManagerUpdate.cs b/src/GitHubExtension/DataManager/GitHubDataManagerUpdate.cs index f493d04..c3944fe 100644 --- a/src/GitHubExtension/DataManager/GitHubDataManagerUpdate.cs +++ b/src/GitHubExtension/DataManager/GitHubDataManagerUpdate.cs @@ -9,14 +9,14 @@ namespace GitHubExtension; public partial class GitHubDataManager { // This is how frequently the DataStore update occurs. - private static readonly TimeSpan UpdateInterval = TimeSpan.FromMinutes(5); - private static DateTime lastUpdateTime = DateTime.MinValue; + private static readonly TimeSpan _updateInterval = TimeSpan.FromMinutes(5); + private static DateTime _lastUpdateTime = DateTime.MinValue; public static async Task Update() { // Only update per the update interval. // This is intended to be dynamic in the future. - if (DateTime.Now - lastUpdateTime < UpdateInterval) + if (DateTime.Now - _lastUpdateTime < _updateInterval) { return; } @@ -27,15 +27,15 @@ public static async Task Update() } catch (Exception ex) { - Log.Error(ex, "Update failed unexpectedly."); + _log.Error(ex, "Update failed unexpectedly."); } - lastUpdateTime = DateTime.Now; + _lastUpdateTime = DateTime.Now; } private static async Task UpdateDeveloperPullRequests() { - Log.Debug($"Executing UpdateDeveloperPullRequests"); + _log.Debug($"Executing UpdateDeveloperPullRequests"); using var dataManager = CreateInstance() ?? throw new DataStoreInaccessibleException("GitHubDataManager is null."); await dataManager.UpdatePullRequestsForLoggedInDeveloperIdsAsync(); @@ -73,7 +73,7 @@ private static void SendUpdateEvent(object? source, DataManagerUpdateKind kind, { info ??= string.Empty; context ??= Array.Empty(); - Log.Information($"Sending Update Event: {kind} Info: {info} Context: {string.Join(",", context)}"); + _log.Information($"Sending Update Event: {kind} Info: {info} Context: {string.Join(",", context)}"); OnUpdate.Invoke(source, new DataManagerUpdateEventArgs(kind, info, context)); } } diff --git a/src/GitHubExtension/DataManager/GitHubSearchManager.cs b/src/GitHubExtension/DataManager/GitHubSearchManager.cs index 300c50b..4026dac 100644 --- a/src/GitHubExtension/DataManager/GitHubSearchManager.cs +++ b/src/GitHubExtension/DataManager/GitHubSearchManager.cs @@ -12,11 +12,11 @@ namespace GitHubExtension; public partial class GitHubSearchManager : IGitHubSearchManager, IDisposable { - private static readonly Lazy _log = new(() => Serilog.Log.ForContext("SourceContext", nameof(GitHubSearchManager))); + private static readonly Lazy _logger = new(() => Serilog.Log.ForContext("SourceContext", nameof(GitHubSearchManager))); - private static readonly ILogger Log = _log.Value; + private static readonly ILogger _log = _logger.Value; - private static readonly string Name = nameof(GitHubSearchManager); + private static readonly string _name = nameof(GitHubSearchManager); public static event SearchManagerResultsAvailableEventHandler? OnResultsAvailable; @@ -32,7 +32,7 @@ public GitHubSearchManager() } catch (Exception e) { - Log.Error(e, "Failed creating GitHubSearchManager"); + _log.Error(e, "Failed creating GitHubSearchManager"); Environment.FailFast(e.Message, e); return null; } @@ -54,7 +54,7 @@ public async Task SearchForGitHubIssuesOrPRs(Octokit.SearchIssuesRequest request private async Task SearchForGitHubIssuesOrPRs(Octokit.SearchIssuesRequest request, string initiator, SearchCategory category, Octokit.GitHubClient client, RequestOptions? options = null) { - Log.Information(Name, $"Searching for issues or pull requests for widget {initiator}"); + _log.Information(_name, $"Searching for issues or pull requests for widget {initiator}"); request.State = Octokit.ItemState.Open; request.Archived = false; request.PerPage = 10; @@ -75,12 +75,12 @@ private async Task SearchForGitHubIssuesOrPRs(Octokit.SearchIssuesRequest reques var octokitResult = await client.Search.SearchIssues(request); if (octokitResult == null) { - Log.Debug($"No issues or PRs found."); + _log.Debug($"No issues or PRs found."); SendResultsAvailable(new List(), initiator); } else { - Log.Debug($"Results contain {octokitResult.Items.Count} items."); + _log.Debug($"Results contain {octokitResult.Items.Count} items."); SendResultsAvailable(octokitResult.Items, initiator); } } @@ -89,7 +89,7 @@ private void SendResultsAvailable(IEnumerable results, string ini { if (OnResultsAvailable != null) { - Log.Information(Name, $"Sending search results available Event, of type: {initiator}"); + _log.Information(_name, $"Sending search results available Event, of type: {initiator}"); OnResultsAvailable.Invoke(results, initiator); } } diff --git a/src/GitHubExtension/DataModel/DataObjects/CheckRun.cs b/src/GitHubExtension/DataModel/DataObjects/CheckRun.cs index fdbb8cd..9b1793d 100644 --- a/src/GitHubExtension/DataModel/DataObjects/CheckRun.cs +++ b/src/GitHubExtension/DataModel/DataObjects/CheckRun.cs @@ -12,9 +12,9 @@ namespace GitHubExtension.DataModel; [Table("CheckRun")] public class CheckRun { - private static readonly Lazy _log = new(() => Serilog.Log.ForContext("SourceContext", $"DataModel/{nameof(CheckRun)}")); + private static readonly Lazy _logger = new(() => Serilog.Log.ForContext("SourceContext", $"DataModel/{nameof(CheckRun)}")); - private static readonly ILogger Log = _log.Value; + private static readonly ILogger _log = _logger.Value; [Key] public long Id { get; set; } = DataStore.NoForeignKey; @@ -134,7 +134,7 @@ private static CheckConclusion GetCheckRunConclusion(StringEnum oct catch (Exception) { // This error means a programming error or Octokit added to or changed their enum. - Log.Error($"Found Unknown CheckStatus value: {octoCheckStatus.Value}"); + _log.Error($"Found Unknown CheckStatus value: {octoCheckStatus.Value}"); return CheckStatus.Unknown; } @@ -210,7 +210,7 @@ public static IEnumerable GetFailedCheckRunsForPullRequest(DataStore d MaxConclusion = (long)CheckConclusion.ActionRequired, }; - Log.Verbose(DataStore.GetSqlLogMessage(sql, param)); + _log.Verbose(DataStore.GetSqlLogMessage(sql, param)); return dataStore.Connection!.Query(sql, param, null) ?? Enumerable.Empty(); } @@ -225,7 +225,7 @@ public static CheckStatus GetCheckRunStatusForPullRequest(DataStore datastore, P pullRequest.HeadSha, }; - Log.Verbose(DataStore.GetSqlLogMessage(sql, param)); + _log.Verbose(DataStore.GetSqlLogMessage(sql, param)); // Query results in NULL if there are no entries, and QueryFirstOrDefault will throw trying // to assign null to an integer. In this instance we catch it and return the None type. @@ -255,7 +255,7 @@ public static CheckConclusion GetCheckRunConclusionForPullRequest(DataStore data StatusId = (long)CheckStatus.Completed, }; - Log.Verbose(DataStore.GetSqlLogMessage(sql, param)); + _log.Verbose(DataStore.GetSqlLogMessage(sql, param)); // Query results in NULL if there are no entries, and QueryFirstOrDefault will throw trying // to assign null to an integer. In this instance we catch it and return the None type. @@ -275,9 +275,9 @@ public static void DeleteUnreferenced(DataStore dataStore) var sql = @"DELETE FROM CheckRun WHERE HeadSha NOT IN (SELECT HeadSha FROM PullRequest)"; var command = dataStore.Connection!.CreateCommand(); command.CommandText = sql; - Log.Verbose(DataStore.GetCommandLogMessage(sql, command)); + _log.Verbose(DataStore.GetCommandLogMessage(sql, command)); var rowsDeleted = command.ExecuteNonQuery(); - Log.Verbose(DataStore.GetDeletedLogMessage(rowsDeleted)); + _log.Verbose(DataStore.GetDeletedLogMessage(rowsDeleted)); } public static void DeleteAllForPullRequest(DataStore dataStore, PullRequest pullRequest) @@ -287,8 +287,8 @@ public static void DeleteAllForPullRequest(DataStore dataStore, PullRequest pull var command = dataStore.Connection!.CreateCommand(); command.CommandText = sql; command.Parameters.AddWithValue("$HeadSha", pullRequest.HeadSha); - Log.Verbose(DataStore.GetCommandLogMessage(sql, command)); + _log.Verbose(DataStore.GetCommandLogMessage(sql, command)); var rowsDeleted = command.ExecuteNonQuery(); - Log.Verbose(DataStore.GetDeletedLogMessage(rowsDeleted)); + _log.Verbose(DataStore.GetDeletedLogMessage(rowsDeleted)); } } diff --git a/src/GitHubExtension/DataModel/DataObjects/CheckSuite.cs b/src/GitHubExtension/DataModel/DataObjects/CheckSuite.cs index e7df7ea..3c9c05d 100644 --- a/src/GitHubExtension/DataModel/DataObjects/CheckSuite.cs +++ b/src/GitHubExtension/DataModel/DataObjects/CheckSuite.cs @@ -11,9 +11,9 @@ namespace GitHubExtension.DataModel; [Table("CheckSuite")] public class CheckSuite { - private static readonly Lazy _log = new(() => Serilog.Log.ForContext("SourceContext", $"DataModel/{nameof(CheckSuite)}")); + private static readonly Lazy _logger = new(() => Serilog.Log.ForContext("SourceContext", $"DataModel/{nameof(CheckSuite)}")); - private static readonly ILogger Log = _log.Value; + private static readonly ILogger _log = _logger.Value; [Key] public long Id { get; set; } = DataStore.NoForeignKey; @@ -111,7 +111,7 @@ private static CheckConclusion GetCheckConclusion(StringEnum octoCh catch (Exception) { // This error means a programming error or Octokit added to or changed their enum. - Log.Error($"Found Unknown CheckStatus value: {octoCheckStatus.Value}"); + _log.Error($"Found Unknown CheckStatus value: {octoCheckStatus.Value}"); return CheckStatus.Unknown; } @@ -184,7 +184,7 @@ public static CheckStatus GetCheckStatusForPullRequest(DataStore datastore, Pull pullRequest.HeadSha, }; - Log.Verbose(DataStore.GetSqlLogMessage(sql, param)); + _log.Verbose(DataStore.GetSqlLogMessage(sql, param)); // Query results in NULL if there are no entries, and QueryFirstOrDefault will throw trying // to assign null to an integer. In this instance we catch it and return the None type. @@ -214,7 +214,7 @@ public static CheckConclusion GetCheckConclusionForPullRequest(DataStore datasto StatusId = (long)CheckStatus.Completed, }; - Log.Verbose(DataStore.GetSqlLogMessage(sql, param)); + _log.Verbose(DataStore.GetSqlLogMessage(sql, param)); // Query results in NULL if there are no entries, and QueryFirstOrDefault will throw trying // to assign null to an integer. In this instance we catch it and return the None type. @@ -235,9 +235,9 @@ public static void DeleteAllForPullRequest(DataStore dataStore, PullRequest pull var command = dataStore.Connection!.CreateCommand(); command.CommandText = sql; command.Parameters.AddWithValue("$HeadSha", pullRequest.HeadSha); - Log.Verbose(DataStore.GetCommandLogMessage(sql, command)); + _log.Verbose(DataStore.GetCommandLogMessage(sql, command)); var rowsDeleted = command.ExecuteNonQuery(); - Log.Verbose(DataStore.GetDeletedLogMessage(rowsDeleted)); + _log.Verbose(DataStore.GetDeletedLogMessage(rowsDeleted)); } public static void DeleteUnreferenced(DataStore dataStore) @@ -246,7 +246,7 @@ public static void DeleteUnreferenced(DataStore dataStore) var sql = @"DELETE FROM CheckSuite WHERE HeadSha NOT IN (SELECT HeadSha FROM PullRequest)"; var command = dataStore.Connection!.CreateCommand(); command.CommandText = sql; - Log.Verbose(DataStore.GetCommandLogMessage(sql, command)); + _log.Verbose(DataStore.GetCommandLogMessage(sql, command)); command.ExecuteNonQuery(); } } diff --git a/src/GitHubExtension/DataModel/DataObjects/CommitCombinedStatus.cs b/src/GitHubExtension/DataModel/DataObjects/CommitCombinedStatus.cs index 3531b15..2d6c7fa 100644 --- a/src/GitHubExtension/DataModel/DataObjects/CommitCombinedStatus.cs +++ b/src/GitHubExtension/DataModel/DataObjects/CommitCombinedStatus.cs @@ -10,9 +10,9 @@ namespace GitHubExtension.DataModel; [Table("CommitCombinedStatus")] public class CommitCombinedStatus { - private static readonly Lazy _log = new(() => Serilog.Log.ForContext("SourceContext", $"DataModel/{nameof(CommitCombinedStatus)}")); + private static readonly Lazy _logger = new(() => Serilog.Log.ForContext("SourceContext", $"DataModel/{nameof(CommitCombinedStatus)}")); - private static readonly ILogger Log = _log.Value; + private static readonly ILogger _log = _logger.Value; [Key] public long Id { get; set; } = DataStore.NoForeignKey; @@ -76,7 +76,7 @@ private static CommitState GetCommitState(Octokit.StringEnum _log = new(() => Serilog.Log.ForContext("SourceContext", $"DataModel/{nameof(Issue)}")); + private static readonly Lazy _logger = new(() => Serilog.Log.ForContext("SourceContext", $"DataModel/{nameof(Issue)}")); - private static readonly ILogger Log = _log.Value; + private static readonly ILogger _log = _logger.Value; [Key] public long Id { get; set; } = DataStore.NoForeignKey; @@ -191,7 +191,7 @@ private static Issue CreateFromOctokitIssue(DataStore dataStore, Octokit.Issue o issue.AssigneeIds = string.Join(",", assignees); - // Owner is a rowid in the User table + // Owner is a row id in the User table var author = User.GetOrCreateByOctokitUser(dataStore, okitIssue.User); issue.AuthorId = author.Id; @@ -291,7 +291,7 @@ public static IEnumerable GetAllForRepository(DataStore dataStore, Reposi RepositoryId = repository.Id, }; - Log.Verbose(DataStore.GetSqlLogMessage(sql, param)); + _log.Verbose(DataStore.GetSqlLogMessage(sql, param)); var issues = dataStore.Connection!.Query(sql, param, null) ?? Enumerable.Empty(); foreach (var issue in issues) { @@ -315,7 +315,7 @@ public static IEnumerable GetForSearch(DataStore dataStore, Search search SearchId = search.Id, }; - Log.Verbose(DataStore.GetSqlLogMessage(sql, param)); + _log.Verbose(DataStore.GetSqlLogMessage(sql, param)); var issues = dataStore.Connection!.Query(sql, param, null) ?? Enumerable.Empty(); foreach (var issue in issues) { @@ -370,8 +370,8 @@ public static void DeleteLastObservedBefore(DataStore dataStore, long repository command.CommandText = sql; command.Parameters.AddWithValue("$Time", date.ToDataStoreInteger()); command.Parameters.AddWithValue("$RepositoryId", repositoryId); - Log.Verbose(DataStore.GetCommandLogMessage(sql, command)); + _log.Verbose(DataStore.GetCommandLogMessage(sql, command)); var rowsDeleted = command.ExecuteNonQuery(); - Log.Verbose(DataStore.GetDeletedLogMessage(rowsDeleted)); + _log.Verbose(DataStore.GetDeletedLogMessage(rowsDeleted)); } } diff --git a/src/GitHubExtension/DataModel/DataObjects/IssueAssign.cs b/src/GitHubExtension/DataModel/DataObjects/IssueAssign.cs index 2bbc9d8..6cb5ad8 100644 --- a/src/GitHubExtension/DataModel/DataObjects/IssueAssign.cs +++ b/src/GitHubExtension/DataModel/DataObjects/IssueAssign.cs @@ -10,9 +10,9 @@ namespace GitHubExtension.DataModel; [Table("IssueAssign")] public class IssueAssign { - private static readonly Lazy _log = new(() => Serilog.Log.ForContext("SourceContext", $"DataModel/{nameof(IssueAssign)}")); + private static readonly Lazy _logger = new(() => Serilog.Log.ForContext("SourceContext", $"DataModel/{nameof(IssueAssign)}")); - private static readonly ILogger Log = _log.Value; + private static readonly ILogger _log = _logger.Value; [Key] public long Id { get; set; } = DataStore.NoForeignKey; @@ -60,7 +60,7 @@ public static IEnumerable GetUsersForIssue(DataStore dataStore, Issue issu IssueId = issue.Id, }; - Log.Verbose(DataStore.GetSqlLogMessage(sql, param)); + _log.Verbose(DataStore.GetSqlLogMessage(sql, param)); return dataStore.Connection!.Query(sql, param, null) ?? Enumerable.Empty(); } diff --git a/src/GitHubExtension/DataModel/DataObjects/IssueLabel.cs b/src/GitHubExtension/DataModel/DataObjects/IssueLabel.cs index 86e3f92..89839eb 100644 --- a/src/GitHubExtension/DataModel/DataObjects/IssueLabel.cs +++ b/src/GitHubExtension/DataModel/DataObjects/IssueLabel.cs @@ -10,9 +10,9 @@ namespace GitHubExtension.DataModel; [Table("IssueLabel")] public class IssueLabel { - private static readonly Lazy _log = new(() => Serilog.Log.ForContext("SourceContext", $"DataModel/{nameof(IssueLabel)}")); + private static readonly Lazy _logger = new(() => Serilog.Log.ForContext("SourceContext", $"DataModel/{nameof(IssueLabel)}")); - private static readonly ILogger Log = _log.Value; + private static readonly ILogger _log = _logger.Value; [Key] public long Id { get; set; } = DataStore.NoForeignKey; @@ -60,7 +60,7 @@ public static IEnumerable