From e24ecf47a99e4f8bb3af1249d5ba0d39ae98b2fc Mon Sep 17 00:00:00 2001 From: Mark Cilia Vincenti Date: Tue, 16 Dec 2025 15:17:17 +0100 Subject: [PATCH 1/2] Modernization, cleaning and minor optimization --- .../CacheOGP.ApiService.csproj | 59 +++++++++---------- CacheOGP.ApiService/Program.cs | 24 ++++---- CacheOGP.AppHost/CacheOGP.AppHost.csproj | 9 +-- .../CacheOGP.ServiceDefaults.csproj | 19 +++--- CacheOGP.sln | 36 ----------- CacheOGP.slnx | 9 +++ Directory.Build.props | 8 +++ Directory.Packages.props | 30 ++++++++++ 8 files changed, 96 insertions(+), 98 deletions(-) delete mode 100644 CacheOGP.sln create mode 100644 CacheOGP.slnx create mode 100644 Directory.Build.props create mode 100644 Directory.Packages.props diff --git a/CacheOGP.ApiService/CacheOGP.ApiService.csproj b/CacheOGP.ApiService/CacheOGP.ApiService.csproj index 8387496..f228fd2 100644 --- a/CacheOGP.ApiService/CacheOGP.ApiService.csproj +++ b/CacheOGP.ApiService/CacheOGP.ApiService.csproj @@ -1,37 +1,32 @@ - - net9.0 - enable - enable - - - - - - - - - - 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 + + + + + + + + + - - - + + + diff --git a/CacheOGP.ApiService/Program.cs b/CacheOGP.ApiService/Program.cs index 5c27615..d3ecb7c 100644 --- a/CacheOGP.ApiService/Program.cs +++ b/CacheOGP.ApiService/Program.cs @@ -1,18 +1,16 @@ -using System.Globalization; -using System.Net; -using System.Net.Mime; -using System.Reflection; -using System.Text; -using CacheOGP.ApiService; +using CacheOGP.ApiService; +using DeterministicGuids; using HtmlAgilityPack; using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.OutputCaching; using Microsoft.EntityFrameworkCore; using Microsoft.IO; using OpenGraphNet; using PuppeteerSharp; using SkiaSharp; -using UUIDNext; +using System.Net; +using System.Net.Mime; +using System.Reflection; +using System.Text; Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); var builder = WebApplication.CreateBuilder(args); @@ -236,12 +234,12 @@ static async Task GetImage(OgpDbContext db, HttpClient client, IBrowser var ogp = await GetOgpInfo(url, db, client); var ns = new Guid("95DDE42A-79E7-46C6-A9DC-25C8ED7CFF73"); - var id = Uuid.NewNameBased(ns, ogp.Url.ToString()); - id = Uuid.NewNameBased(id, style.ToString()); - id = Uuid.NewNameBased(id, scale.ToString()); + var id = DeterministicGuid.Create(ns, ogp.Url.ToString()); + id = DeterministicGuid.Create(id, style.ToString()); + id = DeterministicGuid.Create(id, scale.ToString()); if (css is not null) { - id = Uuid.NewNameBased(id, css); + id = DeterministicGuid.Create(id, css); } #if DEBUG OgpImage? image = null; @@ -492,7 +490,7 @@ static class Extensions public static async Task SetOgpThumb(this OgpDbContext db, HttpClient client, Uri originUrl) { - var id = Uuid.NewNameBased(ThumbNamespace, originUrl.ToString()); + var id = DeterministicGuid.Create(ThumbNamespace, originUrl.ToString()); var image = await db.FindAsync(id); if (image?.ExpiresAt > DateTime.UtcNow) { diff --git a/CacheOGP.AppHost/CacheOGP.AppHost.csproj b/CacheOGP.AppHost/CacheOGP.AppHost.csproj index fc07aa9..33a8f97 100644 --- a/CacheOGP.AppHost/CacheOGP.AppHost.csproj +++ b/CacheOGP.AppHost/CacheOGP.AppHost.csproj @@ -3,9 +3,6 @@ Exe - net9.0 - enable - enable true 86f40f6e-0956-4790-9e91-8cacd8153778 @@ -15,9 +12,9 @@ - - - + + + diff --git a/CacheOGP.ServiceDefaults/CacheOGP.ServiceDefaults.csproj b/CacheOGP.ServiceDefaults/CacheOGP.ServiceDefaults.csproj index 09ec7d1..09320e5 100644 --- a/CacheOGP.ServiceDefaults/CacheOGP.ServiceDefaults.csproj +++ b/CacheOGP.ServiceDefaults/CacheOGP.ServiceDefaults.csproj @@ -1,23 +1,20 @@ - net9.0 - enable - enable true - - - - - - - - + + + + + + + + diff --git a/CacheOGP.sln b/CacheOGP.sln deleted file mode 100644 index 75b16ad..0000000 --- a/CacheOGP.sln +++ /dev/null @@ -1,36 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.8.0.0 -MinimumVisualStudioVersion = 17.8.0.0 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CacheOGP.AppHost", "CacheOGP.AppHost\CacheOGP.AppHost.csproj", "{C72E279A-2C1B-4240-A781-61C2B3D4B692}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CacheOGP.ServiceDefaults", "CacheOGP.ServiceDefaults\CacheOGP.ServiceDefaults.csproj", "{F352C58A-761C-4D96-8E2A-789BF484E6D6}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CacheOGP.ApiService", "CacheOGP.ApiService\CacheOGP.ApiService.csproj", "{C8DBDABA-EB97-4B9A-9891-D078AC4BDC5D}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {C72E279A-2C1B-4240-A781-61C2B3D4B692}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C72E279A-2C1B-4240-A781-61C2B3D4B692}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C72E279A-2C1B-4240-A781-61C2B3D4B692}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C72E279A-2C1B-4240-A781-61C2B3D4B692}.Release|Any CPU.Build.0 = Release|Any CPU - {F352C58A-761C-4D96-8E2A-789BF484E6D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F352C58A-761C-4D96-8E2A-789BF484E6D6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F352C58A-761C-4D96-8E2A-789BF484E6D6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F352C58A-761C-4D96-8E2A-789BF484E6D6}.Release|Any CPU.Build.0 = Release|Any CPU - {C8DBDABA-EB97-4B9A-9891-D078AC4BDC5D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C8DBDABA-EB97-4B9A-9891-D078AC4BDC5D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C8DBDABA-EB97-4B9A-9891-D078AC4BDC5D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C8DBDABA-EB97-4B9A-9891-D078AC4BDC5D}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {1B1C3BDE-AD4A-492D-BA33-17CCF30BBC23} - EndGlobalSection -EndGlobal diff --git a/CacheOGP.slnx b/CacheOGP.slnx new file mode 100644 index 0000000..6147281 --- /dev/null +++ b/CacheOGP.slnx @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000..b8b56d5 --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,8 @@ + + + latest + net9.0 + enable + enable + + \ No newline at end of file diff --git a/Directory.Packages.props b/Directory.Packages.props new file mode 100644 index 0000000..4177b3d --- /dev/null +++ b/Directory.Packages.props @@ -0,0 +1,30 @@ + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 2fab55f8ba919473dc5603f45a3f17c6dd74cee0 Mon Sep 17 00:00:00 2001 From: Mark Cilia Vincenti Date: Wed, 17 Dec 2025 13:59:01 +0100 Subject: [PATCH 2/2] Update DeterministicGuids package version to 1.0.7 --- Directory.Packages.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 4177b3d..b87ba74 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -9,7 +9,7 @@ - + @@ -27,4 +27,4 @@ - \ No newline at end of file +