diff --git a/.editorconfig b/.editorconfig index fa05938..0f27dd6 100644 --- a/.editorconfig +++ b/.editorconfig @@ -273,6 +273,7 @@ dotnet_diagnostic.SA1122.severity = suggestion dotnet_diagnostic.SA1108.severity = silent dotnet_diagnostic.SA1012.severity = error dotnet_diagnostic.SA1500.severity = error +dotnet_diagnostic.SA1316.severity = error [*.{cs,vb}] dotnet_style_operator_placement_when_wrapping = beginning_of_line diff --git a/.github/workflows/dotnet-core-desktop.yml b/.github/workflows/dotnet-core-desktop.yml index 8d08838..6202abd 100644 --- a/.github/workflows/dotnet-core-desktop.yml +++ b/.github/workflows/dotnet-core-desktop.yml @@ -29,13 +29,13 @@ jobs: # Install the .NET Core workload - name: Install .NET Core - uses: actions/setup-dotnet@v3.0.3 + uses: actions/setup-dotnet@v3.2.0 with: - dotnet-version: 7.0.x + dotnet-version: 8.0.x # Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild - name: Setup MSBuild.exe - uses: microsoft/setup-msbuild@v1.1.3 + uses: microsoft/setup-msbuild@v1.3.1 # Restore the application to populate the obj folder with RuntimeIdentifiers - name: Restore the application diff --git a/Analogy.LogViewer.Github.UnitTests/Analogy.LogViewer.Github.UnitTests.csproj b/Analogy.LogViewer.Github.UnitTests/Analogy.LogViewer.Github.UnitTests.csproj index 4c404d8..bf797f7 100644 --- a/Analogy.LogViewer.Github.UnitTests/Analogy.LogViewer.Github.UnitTests.csproj +++ b/Analogy.LogViewer.Github.UnitTests/Analogy.LogViewer.Github.UnitTests.csproj @@ -7,9 +7,9 @@ - - - + + + diff --git a/Analogy.LogViewer.Github.UnitTests/UnitTest1.cs b/Analogy.LogViewer.Github.UnitTests/UnitTest1.cs index b948e06..7699709 100644 --- a/Analogy.LogViewer.Github.UnitTests/UnitTest1.cs +++ b/Analogy.LogViewer.Github.UnitTests/UnitTest1.cs @@ -1,9 +1,9 @@ +using Analogy.CommonUtilities.Github; using Analogy.Interfaces; using Analogy.LogViewer.Github.DataTypes; using Microsoft.VisualStudio.TestTools.UnitTesting; using Newtonsoft.Json; using System.Threading.Tasks; -using Analogy.CommonUtilities.Github; namespace Analogy.LogViewer.Github.UnitTests { @@ -28,4 +28,4 @@ public async Task TestMethod1() //var r = JsonConvert.DeserializeObject(releases); } } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Github.UnitTests/Utils.cs b/Analogy.LogViewer.Github.UnitTests/Utils.cs index b6e7c53..cb6b93e 100644 --- a/Analogy.LogViewer.Github.UnitTests/Utils.cs +++ b/Analogy.LogViewer.Github.UnitTests/Utils.cs @@ -32,4 +32,4 @@ public static async Task GetAsync(string uri) //} } } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Github.sln b/Analogy.LogViewer.Github.sln index a70d5b4..2bbc4bd 100644 --- a/Analogy.LogViewer.Github.sln +++ b/Analogy.LogViewer.Github.sln @@ -1,11 +1,19 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29926.136 +# Visual Studio Version 17 +VisualStudioVersion = 17.8.34309.116 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Analogy.LogViewer.Github", "Analogy.LogViewer.Github\Analogy.LogViewer.Github.csproj", "{6F9F6F8D-E943-4BC1-8E74-9D853F0E6BB2}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Analogy.LogViewer.Github.UnitTests", "Analogy.LogViewer.Github.UnitTests\Analogy.LogViewer.Github.UnitTests.csproj", "{E20C1B88-D4E1-4BCC-AF45-686F3CB988FA}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Analogy.LogViewer.Github.UnitTests", "Analogy.LogViewer.Github.UnitTests\Analogy.LogViewer.Github.UnitTests.csproj", "{E20C1B88-D4E1-4BCC-AF45-686F3CB988FA}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{5BAA8DAD-6A8B-4AB1-A51D-C2D1423F7B31}" + ProjectSection(SolutionItems) = preProject + .editorconfig = .editorconfig + Directory.Build.props = Directory.Build.props + .github\workflows\dotnet-core-desktop.yml = .github\workflows\dotnet-core-desktop.yml + nuget.config = nuget.config + EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/Analogy.LogViewer.Github/Analogy.LogViewer.Github.csproj b/Analogy.LogViewer.Github/Analogy.LogViewer.Github.csproj index 6ad5e32..fa32065 100644 --- a/Analogy.LogViewer.Github/Analogy.LogViewer.Github.csproj +++ b/Analogy.LogViewer.Github/Analogy.LogViewer.Github.csproj @@ -2,45 +2,25 @@ Library - net7.0-windows;net6.0-windows;net48;net471 - true - true - true - snupkg - true - true + net8.0-windows;net7.0-windows;net6.0-windows;net48;net471 + 6.0.0 + Lior Banai Extension for Analogy Log Viewer that shows Git Histroy in searchable UI - Lior Banai @ 2020-2023 - MIT + Lior Banai @ 2020-2024 https://github.com/Analogy-LogViewer/Analogy.LogViewer.Github https://github.com/Analogy-LogViewer/Analogy.LogViewer.Github - git Analogy.GitHistoryBanner.png - true - 5.0.3.2 - - enable - latest - true Analogy.LogViewer - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - + + + - + @@ -64,13 +44,4 @@ - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - diff --git a/Analogy.LogViewer.Github/DataTypes/RepositorySettings.cs b/Analogy.LogViewer.Github/DataTypes/RepositorySettings.cs index a523294..aae65c7 100644 --- a/Analogy.LogViewer.Github/DataTypes/RepositorySettings.cs +++ b/Analogy.LogViewer.Github/DataTypes/RepositorySettings.cs @@ -27,4 +27,4 @@ public override string ToString() return $"{nameof(RepoName)}: {RepoName}"; } } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Github/GitHubActions/GitFetchAction.cs b/Analogy.LogViewer.Github/GitHubActions/GitFetchAction.cs index dbe591b..eabcb91 100644 --- a/Analogy.LogViewer.Github/GitHubActions/GitFetchAction.cs +++ b/Analogy.LogViewer.Github/GitHubActions/GitFetchAction.cs @@ -1,7 +1,7 @@ -using System.Drawing; -using System.Windows.Forms; -using Analogy.Interfaces; +using Analogy.Interfaces; using Analogy.Interfaces.DataTypes; +using System.Drawing; +using System.Windows.Forms; namespace Analogy.LogViewer.Github.GitHubActions { @@ -20,4 +20,4 @@ public class GitFetchAction : IAnalogyCustomAction public AnalogyCustomActionType Type { get; } = AnalogyCustomActionType.BelongsToProvider; public AnalogyToolTip? ToolTip { get; set; } } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Github/GitOperationsForm.cs b/Analogy.LogViewer.Github/GitOperationsForm.cs index 3c2b85c..3c2a321 100644 --- a/Analogy.LogViewer.Github/GitOperationsForm.cs +++ b/Analogy.LogViewer.Github/GitOperationsForm.cs @@ -9,4 +9,4 @@ public GitOperationsForm() InitializeComponent(); } } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Github/GitRepositoriesSettings.cs b/Analogy.LogViewer.Github/GitRepositoriesSettings.cs index d819d2e..0c1fc2c 100644 --- a/Analogy.LogViewer.Github/GitRepositoriesSettings.cs +++ b/Analogy.LogViewer.Github/GitRepositoriesSettings.cs @@ -15,7 +15,6 @@ private void GitRepositoriesSettings_Load(object sender, EventArgs e) { RefreshList(); txtbLocalToken.Text = UserSettingsManager.UserSettings.GithubSettings.GitHubToken; - } private void RefreshList() @@ -47,4 +46,4 @@ private void btnLocalToken_Click(object sender, EventArgs e) UserSettingsManager.UserSettings.GithubSettings.LocalGitHubToken = txtbLocalToken.Text; } } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Github/GithubSettings.cs b/Analogy.LogViewer.Github/GithubSettings.cs index ed02cf0..7270887 100644 --- a/Analogy.LogViewer.Github/GithubSettings.cs +++ b/Analogy.LogViewer.Github/GithubSettings.cs @@ -3,7 +3,6 @@ namespace Analogy.LogViewer.Github { - public class GithubSettings { public string RegistryGitHubToken { get; set; } = Environment.GetEnvironmentVariable("Analogy.LogViewer.Github_Token"); @@ -33,7 +32,5 @@ public void DeleteRepository(RepositorySettings repository) Repositories.Remove(repository); } } - - } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Github/IAnalogy/DownloadInformation.cs b/Analogy.LogViewer.Github/IAnalogy/DownloadInformation.cs index 245f66f..b88764f 100644 --- a/Analogy.LogViewer.Github/IAnalogy/DownloadInformation.cs +++ b/Analogy.LogViewer.Github/IAnalogy/DownloadInformation.cs @@ -28,4 +28,4 @@ public override string InstalledVersionNumber } } } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Github/IAnalogy/GitHubDataProviderSettings.cs b/Analogy.LogViewer.Github/IAnalogy/GitHubDataProviderSettings.cs index b6f7dce..376fa60 100644 --- a/Analogy.LogViewer.Github/IAnalogy/GitHubDataProviderSettings.cs +++ b/Analogy.LogViewer.Github/IAnalogy/GitHubDataProviderSettings.cs @@ -1,8 +1,8 @@ -using Analogy.LogViewer.Github.Managers; +using Analogy.Interfaces; +using Analogy.LogViewer.Github.Managers; +using Microsoft.Extensions.Logging; using System.Drawing; using System.Windows.Forms; -using Analogy.Interfaces; -using Microsoft.Extensions.Logging; namespace Analogy.LogViewer.Github.IAnalogy { @@ -26,4 +26,4 @@ public override Task SaveSettingsAsync() return Task.CompletedTask; } } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Github/IAnalogy/GitHubIssuesTrackerFactory.cs b/Analogy.LogViewer.Github/IAnalogy/GitHubIssuesTrackerFactory.cs index 2b87def..969bd5c 100644 --- a/Analogy.LogViewer.Github/IAnalogy/GitHubIssuesTrackerFactory.cs +++ b/Analogy.LogViewer.Github/IAnalogy/GitHubIssuesTrackerFactory.cs @@ -8,11 +8,9 @@ public class GitHubIssuesTrackerFactory : Template.DataProvidersFactory public override string Title { get; set; } = "Repositories Releases"; public override IEnumerable DataProviders { get; set; } = GenerateDataProviders(); - private static IEnumerable GenerateDataProviders() { yield return new IssuesTracker(); } } - -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Github/IAnalogy/GitHubRepositoriesReleasesFactory.cs b/Analogy.LogViewer.Github/IAnalogy/GitHubRepositoriesReleasesFactory.cs index 1ad11df..453995d 100644 --- a/Analogy.LogViewer.Github/IAnalogy/GitHubRepositoriesReleasesFactory.cs +++ b/Analogy.LogViewer.Github/IAnalogy/GitHubRepositoriesReleasesFactory.cs @@ -9,7 +9,6 @@ public class GitHubRepositoriesReleasesFactory : Template.DataProvidersFactory public override string Title { get; set; } = "Repositories Releases"; public override IEnumerable DataProviders { get; set; } = GenerateDataProviders(); - private static IEnumerable GenerateDataProviders() { foreach (var repo in UserSettingsManager.UserSettings.GithubSettings.Repositories.Select(rs => @@ -19,5 +18,4 @@ private static IEnumerable GenerateDataProviders() } } } - -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Github/IAnalogy/GitRepositoryLoader.cs b/Analogy.LogViewer.Github/IAnalogy/GitRepositoryLoader.cs index 5ff03b8..235c609 100644 --- a/Analogy.LogViewer.Github/IAnalogy/GitRepositoryLoader.cs +++ b/Analogy.LogViewer.Github/IAnalogy/GitRepositoryLoader.cs @@ -1,17 +1,16 @@ -using Analogy.Interfaces; -using Analogy.LogViewer.Github.Managers; -using System.Drawing; -using System.Threading; -using Analogy.CommonUtilities.Github; +using Analogy.CommonUtilities.Github; +using Analogy.Interfaces; using Analogy.LogViewer.Github.DataTypes; +using Analogy.LogViewer.Github.Managers; using Microsoft.Extensions.Logging; using Octokit; +using System.Drawing; +using System.Threading; namespace Analogy.LogViewer.Github { public class GitRepositoryLoader : Template.OnlineDataProvider { - public override Guid Id { get; set; } = new Guid("B92CA79D-3621-416E-ADA7-52EEAF243759"); public override Image? ConnectedLargeImage { get; set; } @@ -26,10 +25,10 @@ public class GitRepositoryLoader : Template.OnlineDataProvider private RepositorySettings Repository { get; } public override bool UseCustomColors { get; set; } - public override IEnumerable<(string originalHeader, string replacementHeader)> GetReplacementHeaders() - => new List<(string originalHeader, string replacementHeader)> { ("Module", "Downloads"), ("User", "Type"), ("Category", "URL") }; + public override IEnumerable<(string OriginalHeader, string ReplacementHeader)> GetReplacementHeaders() + => new List<(string OriginalHeader, string ReplacementHeader)> { ("Module", "Downloads"), ("User", "Type"), ("Category", "URL") }; - public override (Color backgroundColor, Color foregroundColor) GetColorForMessage(IAnalogyLogMessage logMessage) + public override (Color BackgroundColor, Color ForegroundColor) GetColorForMessage(IAnalogyLogMessage logMessage) => (Color.Empty, Color.Empty); private GitHubClient? Client { get; set; } @@ -39,10 +38,8 @@ public GitRepositoryLoader(RepositorySettings repo) { Repository = repo; OptionalTitle = "Release for: " + Repository.DisplayName; - } - public override Task StartReceiving() { Client = new GitHubClient(new ProductHeaderValue("Analogy.LogViewer.Github")); @@ -78,11 +75,10 @@ private async void Fetch(object? state) Date = entry.PublishedAt?.DateTime ?? DateTime.MinValue, FileName = entry.Url, User = "Release", - Module = entry.Assets.Sum(a => a.DownloadCount).ToString() + Module = entry.Assets.Sum(a => a.DownloadCount).ToString(), }; m.AddOrReplaceAdditionalProperty("Category", entry.HtmlUrl); MessageReady(this, new AnalogyLogMessageArgs(m, Repository.DisplayName, "Github", Id)); - } int total = releases.SelectMany(e => e.Assets).Sum(a => a.DownloadCount); AnalogyLogMessage d = new AnalogyLogMessage @@ -93,10 +89,9 @@ private async void Fetch(object? state) Date = DateTime.Now, FileName = "", User = "Release", - Module = total.ToString() + Module = total.ToString(), }; MessageReady(this, new AnalogyLogMessageArgs(d, Repository.DisplayName, "Github", Id)); - } catch (Exception e) { @@ -107,14 +102,11 @@ private async void Fetch(object? state) Module = Repository.DisplayName, Text = $"Error: {e}", Level = AnalogyLogLevel.Error, - Class = AnalogyLogClass.General + Class = AnalogyLogClass.General, }; MessageReady(this, new AnalogyLogMessageArgs(m, "", "", Id)); } - } public override Task ShutDown() => Task.CompletedTask; - - } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Github/IAnalogy/IssuesTracker.cs b/Analogy.LogViewer.Github/IAnalogy/IssuesTracker.cs index 0c44925..af2d91f 100644 --- a/Analogy.LogViewer.Github/IAnalogy/IssuesTracker.cs +++ b/Analogy.LogViewer.Github/IAnalogy/IssuesTracker.cs @@ -10,7 +10,6 @@ namespace Analogy.LogViewer.Github.IAnalogy { public class IssuesTracker : Template.OnlineDataProvider { - public override Guid Id { get; set; } = new Guid("a6f0882d-c39a-4c38-9f9d-267d5d012db3"); public override Image? ConnectedLargeImage { get; set; } @@ -23,10 +22,10 @@ public class IssuesTracker : Template.OnlineDataProvider public override IAnalogyOfflineDataProvider? FileOperationsHandler { get; set; } public override bool UseCustomColors { get; set; } - public override IEnumerable<(string originalHeader, string replacementHeader)> GetReplacementHeaders() - => new List<(string originalHeader, string replacementHeader)> { ("Module", "Comments"), ("User", "Id"), ("User", "Type"), ("Category", "URL") }; + public override IEnumerable<(string OriginalHeader, string ReplacementHeader)> GetReplacementHeaders() + => new List<(string OriginalHeader, string ReplacementHeader)> { ("Module", "Comments"), ("User", "Id"), ("User", "Type"), ("Category", "URL") }; - public override (Color backgroundColor, Color foregroundColor) GetColorForMessage(IAnalogyLogMessage logMessage) + public override (Color BackgroundColor, Color ForegroundColor) GetColorForMessage(IAnalogyLogMessage logMessage) => (Color.Empty, Color.Empty); public List Repositories => UserSettingsManager.UserSettings.GithubSettings.Repositories; private UserSettingsManager Settings => UserSettingsManager.UserSettings; @@ -38,7 +37,6 @@ public IssuesTracker() { } - public override Task StartReceiving() { Client = new GitHubClient(new ProductHeaderValue("Analogy.LogViewer.Github")); @@ -56,7 +54,6 @@ public override Task StopReceiving() private async void Fetch(object? state) { - foreach (RepositorySettings repo in Repositories) { try @@ -64,7 +61,6 @@ private async void Fetch(object? state) var issues = await Client.Issue.GetAllForRepository(repo.Owner, repo.RepoName); foreach (var entry in issues) { - AnalogyLogMessage m = new AnalogyLogMessage { Text = $"{entry.Title}{Environment.NewLine}URL: {entry.HtmlUrl}{Environment.NewLine}Body: {entry.Body}{Environment.NewLine}", @@ -73,7 +69,7 @@ private async void Fetch(object? state) Date = entry.UpdatedAt?.DateTime ?? DateTime.MinValue, FileName = entry.Url, User = "Issue", - Module = $"Comments: {entry.Comments} ({ entry.CommentsUrl })" + Module = $"Comments: {entry.Comments} ({entry.CommentsUrl})", }; m.AddOrReplaceAdditionalProperty("Category", entry.HtmlUrl); @@ -95,7 +91,6 @@ private async void Fetch(object? state) } MessageReady(this, new AnalogyLogMessageArgs(m, repo.DisplayName, "Github", Id)); - } } catch (Exception e) @@ -108,14 +103,12 @@ private async void Fetch(object? state) Module = repo.DisplayName, Text = $"Error: {e}", Level = AnalogyLogLevel.Error, - Class = AnalogyLogClass.General + Class = AnalogyLogClass.General, }; MessageReady(this, new AnalogyLogMessageArgs(m, "", "", Id)); } - } } public override Task ShutDown() => Task.CompletedTask; - } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Github/IAnalogy/PrimaryFactory.cs b/Analogy.LogViewer.Github/IAnalogy/PrimaryFactory.cs index 1c4e219..1d8eac2 100644 --- a/Analogy.LogViewer.Github/IAnalogy/PrimaryFactory.cs +++ b/Analogy.LogViewer.Github/IAnalogy/PrimaryFactory.cs @@ -11,12 +11,11 @@ public class PrimaryFactory : Template.PrimaryFactory public override string Title { get; set; } = "GitHub"; public override IEnumerable ChangeLog { get; set; } = new List { - new AnalogyChangeLog("Initial version",AnalogChangeLogType.None, "Lior Banai",new DateTime(2020, 04, 14), "") + new AnalogyChangeLog("Initial version", AnalogChangeLogType.None, "Lior Banai", new DateTime(2020, 04, 14), ""), }; public override IEnumerable Contributors { get; set; } = new List { "Lior Banai" }; public override string About { get; set; } = "Github Info"; public override Image? SmallImage { get; set; } = Resources.Git_icon_16x16; public override Image? LargeImage { get; set; } = Resources.Git_icon_32x32; - } -} +} \ No newline at end of file diff --git a/Analogy.LogViewer.Github/Managers/UserSettingsManager.cs b/Analogy.LogViewer.Github/Managers/UserSettingsManager.cs index 627e271..82dfbe0 100644 --- a/Analogy.LogViewer.Github/Managers/UserSettingsManager.cs +++ b/Analogy.LogViewer.Github/Managers/UserSettingsManager.cs @@ -21,7 +21,6 @@ public UserSettingsManager() { string data = File.ReadAllText(RepositoriesSettingFile); GithubSettings = JsonConvert.DeserializeObject(data); - } catch (Exception ex) { @@ -39,10 +38,7 @@ public void Save() catch (Exception ex) { Template.Managers.LogManager.Instance.LogCritical($"Unable to save file {RepositoriesSettingFile}: {ex}", ""); - } - - } } -} +} \ No newline at end of file diff --git a/BannedSymbols.txt b/BannedSymbols.txt new file mode 100644 index 0000000..26002bb --- /dev/null +++ b/BannedSymbols.txt @@ -0,0 +1,9 @@ +#https://github.com/dotnet/csharplang/blob/main/spec/documentation-comments.md#id-string-format + +M:System.String.ToLower;Use ToLowerInvariant instead +M:System.String.ToUpper;Use ToUpperInvariant instead + +F:System.StringComparison.CurrentCulture;Consider using Ordinal +F:System.StringComparison.CurrentCultureIgnoreCase;Consider using OrdinalIgnoreCase +F:System.StringComparison.InvariantCurrent;Consider using Ordinal +F:System.StringComparison.InvariantCurrentIgnoreCase;Consider using OrdinalIgnoreCase diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000..92e4444 --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,61 @@ + + + true + true + True + snupkg + true + true + true + MIT + true + False + git + portable + + + enable + latest + + + $(DefineContants);DEBUG + false + + + true + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + \ No newline at end of file