From bd42109ef3d83ebebc66cc9e02cf000e4d9c230f Mon Sep 17 00:00:00 2001 From: data-miner00 Date: Wed, 3 Jan 2024 23:12:22 +0800 Subject: [PATCH] chore: Fix debugger project --- src/Linker.Debugger/App.config | 2 +- src/Linker.Debugger/GlobalSuppressions.cs | 10 +++ src/Linker.Debugger/Program.cs | 77 ++++++++++++++++++----- 3 files changed, 71 insertions(+), 18 deletions(-) create mode 100644 src/Linker.Debugger/GlobalSuppressions.cs diff --git a/src/Linker.Debugger/App.config b/src/Linker.Debugger/App.config index 203fe6d..7e02e3d 100644 --- a/src/Linker.Debugger/App.config +++ b/src/Linker.Debugger/App.config @@ -1,6 +1,6 @@  - + \ No newline at end of file diff --git a/src/Linker.Debugger/GlobalSuppressions.cs b/src/Linker.Debugger/GlobalSuppressions.cs new file mode 100644 index 0000000..5e82f64 --- /dev/null +++ b/src/Linker.Debugger/GlobalSuppressions.cs @@ -0,0 +1,10 @@ +// This file is used by Code Analysis to maintain SuppressMessage +// attributes that are applied to this project. +// Project-level suppressions either have no target or are given +// a specific target and scoped to a namespace, type, member, etc. + +using System.Diagnostics.CodeAnalysis; + +[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "This is a debugging project")] +[assembly: SuppressMessage("Minor Code Smell", "S1481:Unused local variables should be removed", Justification = "This is a debugging project")] +[assembly: SuppressMessage("Style", "IDE0059:Unnecessary assignment of a value", Justification = "This is a debugging project")] diff --git a/src/Linker.Debugger/Program.cs b/src/Linker.Debugger/Program.cs index 80ccbf3..58da0dc 100644 --- a/src/Linker.Debugger/Program.cs +++ b/src/Linker.Debugger/Program.cs @@ -1,38 +1,81 @@ namespace Linker.Debugger { + using System; using System.Configuration; + using System.Data; using System.Data.SQLite; + using System.Runtime.CompilerServices; + using System.Threading.Tasks; + using System.Timers; + using Dapper; using Linker.Core.Models; using Linker.Data.SQLite; - internal class Program + internal static class Program { - static void Main(string[] args) + public static void Main(string[] args) { using (var connection = new SQLiteConnection(LoadConnectionString())) { - var websiteRepo = new WebsiteRepository(connection); + var tagRepo = new TagRepository(connection); + goto some; + some: + var tags = tagRepo.GetAllAsync().GetAwaiter().GetResult(); - var website = new Website + Console.WriteLine(tags); + } + } + + public static async Task AddArticle(IDbConnection connection) + { + var articleRepo = new ArticleRepository(connection); + + await articleRepo.AddAsync( + new Article { - Id = "new", - Url = "sample.com", + Id = Guid.NewGuid().ToString(), + Url = "sample.com/article.htm", Category = Category.Finance, - Description = "no desc", - Tags = new List { "tag1", "tag2" }, + Description = "long desc", + Tags = new List { "tag1", "tag2", "new TAG!!!" }, Language = Language.Japanese, LastVisitAt = DateTime.Now, CreatedAt = DateTime.Now, ModifiedAt = DateTime.Now, - Name = "noname", - Domain = "doamin.com", - Aesthetics = Aesthetics.Clean, - IsSubdomain = false, - IsMultilingual = false, - }; - - websiteRepo.Add(website); - } + Title = "Crummy title", + Author = "Jim Cramer", + Year = 2014, + WatchLater = true, + Domain = "www.google.com", + Grammar = Grammar.Average, + }, + CancellationToken.None); + + await articleRepo.GetAllAsync(CancellationToken.None); + } + + public static async Task AddYoutube(IDbConnection connection) + { + var youtubeRepo = new YoutubeRepository(connection); + await youtubeRepo.UpdateAsync( + new Youtube + { + Id = "ae58d402-b7a4-4e69-97d6-30ebcad741c5", + Url = "youtube.com/dahuhffd", + Category = Category.Finance, + Description = "A C# professional guru", + Tags = new List { "c#", "unity", "f#" }, + Language = Language.English, + LastVisitAt = new DateTime(1994, 4, 5, 0, 0, 0, DateTimeKind.Utc), + CreatedAt = new DateTime(2022, 4, 5, 0, 0, 0, DateTimeKind.Utc), + ModifiedAt = DateTime.Now, + Name = "Brackeys", + Youtuber = "Johnson", + Country = "Canada", + }, + CancellationToken.None); + + var all = await youtubeRepo.GetAllAsync(CancellationToken.None); } private static string LoadConnectionString(string id = "Default")