diff --git a/.github/workflows/reusable_run_tests.yml b/.github/workflows/reusable_run_tests.yml index 8e9d4758..849d82a9 100644 --- a/.github/workflows/reusable_run_tests.yml +++ b/.github/workflows/reusable_run_tests.yml @@ -15,7 +15,7 @@ jobs: strategy: matrix: dotnet: [ - { tfm: net9.0, version: '9.0.x' }, + { tfm: net10.0, version: '10.0.x' }, ] env: BUILD_CONFIG: Release @@ -34,7 +34,7 @@ jobs: uses: actions/setup-dotnet@v4 with: dotnet-version: | - 9.0.x + ${{ matrix.dotnet.version }} - name: Display dotnet version run: | diff --git a/BBCodeParser/BBCodeParser.csproj b/BBCodeParser/BBCodeParser.csproj index d87329aa..ff7fe628 100644 --- a/BBCodeParser/BBCodeParser.csproj +++ b/BBCodeParser/BBCodeParser.csproj @@ -1,6 +1,6 @@  - net9.0 + net10.0 Library enable enable diff --git a/Directory.Build.props b/Directory.Build.props index 8b70c5a1..176421f7 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -16,6 +16,11 @@ CS1591 - Missing XML comment for publicly visible type or member 'Type_or_Member' --> $(NoWarn);1591 + + + NU1903 diff --git a/Directory.Packages.props b/Directory.Packages.props index a5349d15..9a53feb8 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -1,91 +1,96 @@ true - false + true + true - - - + + + - + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + - - - + + + - + - + - + - - - - - - + + + + + + - + + + + + \ No newline at end of file diff --git a/Hikkaba.Application/Hikkaba.Application.csproj b/Hikkaba.Application/Hikkaba.Application.csproj index 480782d8..74a9b7d4 100644 --- a/Hikkaba.Application/Hikkaba.Application.csproj +++ b/Hikkaba.Application/Hikkaba.Application.csproj @@ -1,7 +1,7 @@  - net9.0 + net10.0 enable enable @@ -12,7 +12,6 @@ - diff --git a/Hikkaba.Application/Implementations/CategoryService.cs b/Hikkaba.Application/Implementations/CategoryService.cs index b39b86bd..d5e506c3 100644 --- a/Hikkaba.Application/Implementations/CategoryService.cs +++ b/Hikkaba.Application/Implementations/CategoryService.cs @@ -1,5 +1,4 @@ using Hikkaba.Application.Contracts; -using Hikkaba.Infrastructure.Models.Administration; using Hikkaba.Infrastructure.Models.Category; using Hikkaba.Infrastructure.Repositories.Contracts; diff --git a/Hikkaba.Application/Implementations/PostService.cs b/Hikkaba.Application/Implementations/PostService.cs index 0a45ec9e..6b8f52db 100644 --- a/Hikkaba.Application/Implementations/PostService.cs +++ b/Hikkaba.Application/Implementations/PostService.cs @@ -7,7 +7,6 @@ using Hikkaba.Infrastructure.Repositories.Contracts; using Hikkaba.Paging.Models; using Hikkaba.Shared.Enums; -using Hikkaba.Shared.Exceptions; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; diff --git a/Hikkaba.Application/Implementations/ThreadService.cs b/Hikkaba.Application/Implementations/ThreadService.cs index 32320571..16f479e6 100644 --- a/Hikkaba.Application/Implementations/ThreadService.cs +++ b/Hikkaba.Application/Implementations/ThreadService.cs @@ -7,7 +7,6 @@ using Hikkaba.Infrastructure.Repositories.Contracts; using Hikkaba.Paging.Models; using Hikkaba.Shared.Enums; -using Hikkaba.Shared.Exceptions; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; diff --git a/Hikkaba.Data/Hikkaba.Data.csproj b/Hikkaba.Data/Hikkaba.Data.csproj index 660412e8..6db743c0 100644 --- a/Hikkaba.Data/Hikkaba.Data.csproj +++ b/Hikkaba.Data/Hikkaba.Data.csproj @@ -1,7 +1,7 @@ - net9.0 + net10.0 Library default enable @@ -36,4 +36,5 @@ + diff --git a/Hikkaba.Infrastructure.Mappings/Hikkaba.Infrastructure.Mappings.csproj b/Hikkaba.Infrastructure.Mappings/Hikkaba.Infrastructure.Mappings.csproj index 58e1c0a4..40dd7232 100644 --- a/Hikkaba.Infrastructure.Mappings/Hikkaba.Infrastructure.Mappings.csproj +++ b/Hikkaba.Infrastructure.Mappings/Hikkaba.Infrastructure.Mappings.csproj @@ -1,7 +1,7 @@  - net9.0 + net10.0 enable enable @@ -15,4 +15,5 @@ + diff --git a/Hikkaba.Infrastructure.Models/Hikkaba.Infrastructure.Models.csproj b/Hikkaba.Infrastructure.Models/Hikkaba.Infrastructure.Models.csproj index ab471410..bbfd3223 100644 --- a/Hikkaba.Infrastructure.Models/Hikkaba.Infrastructure.Models.csproj +++ b/Hikkaba.Infrastructure.Models/Hikkaba.Infrastructure.Models.csproj @@ -1,7 +1,7 @@  - net9.0 + net10.0 enable enable @@ -16,4 +16,5 @@ + diff --git a/Hikkaba.Infrastructure.Repositories/Hikkaba.Infrastructure.Repositories.csproj b/Hikkaba.Infrastructure.Repositories/Hikkaba.Infrastructure.Repositories.csproj index 02f580fe..5e841b68 100644 --- a/Hikkaba.Infrastructure.Repositories/Hikkaba.Infrastructure.Repositories.csproj +++ b/Hikkaba.Infrastructure.Repositories/Hikkaba.Infrastructure.Repositories.csproj @@ -1,7 +1,7 @@  - net9.0 + net10.0 enable enable @@ -21,4 +21,5 @@ + diff --git a/Hikkaba.Paging.Tests.Unit/Hikkaba.Paging.Tests.Unit.csproj b/Hikkaba.Paging.Tests.Unit/Hikkaba.Paging.Tests.Unit.csproj index 3223eff2..f1103900 100644 --- a/Hikkaba.Paging.Tests.Unit/Hikkaba.Paging.Tests.Unit.csproj +++ b/Hikkaba.Paging.Tests.Unit/Hikkaba.Paging.Tests.Unit.csproj @@ -1,7 +1,7 @@ - net9.0 + net10.0 enable enable diff --git a/Hikkaba.Paging/Hikkaba.Paging.csproj b/Hikkaba.Paging/Hikkaba.Paging.csproj index e2dc14f4..2aa66f4c 100644 --- a/Hikkaba.Paging/Hikkaba.Paging.csproj +++ b/Hikkaba.Paging/Hikkaba.Paging.csproj @@ -1,7 +1,7 @@  - net9.0 + net10.0 enable enable @@ -10,4 +10,5 @@ + diff --git a/Hikkaba.Shared/Hikkaba.Shared.csproj b/Hikkaba.Shared/Hikkaba.Shared.csproj index 92b1ee5f..781382be 100644 --- a/Hikkaba.Shared/Hikkaba.Shared.csproj +++ b/Hikkaba.Shared/Hikkaba.Shared.csproj @@ -1,7 +1,7 @@ - net9.0 + net10.0 default enable @@ -10,4 +10,5 @@ + diff --git a/Hikkaba.Tests.Integration/CustomAppFactory.cs b/Hikkaba.Tests.Integration/CustomAppFactory.cs index 47fa3802..ba56e90a 100644 --- a/Hikkaba.Tests.Integration/CustomAppFactory.cs +++ b/Hikkaba.Tests.Integration/CustomAppFactory.cs @@ -1,7 +1,6 @@ using System; using System.Data.Common; using Hikkaba.Shared.Constants; -using Hikkaba.Shared.Enums; using Hikkaba.Data.Context; using Hikkaba.Data.Utils; using Hikkaba.Infrastructure.Models.Configuration; @@ -21,7 +20,6 @@ using NLog; using NLog.Config; using NLog.Web; -using ILogger = Microsoft.Extensions.Logging.ILogger; using LogLevel = Microsoft.Extensions.Logging.LogLevel; namespace Hikkaba.Tests.Integration; diff --git a/Hikkaba.Tests.Integration/Hikkaba.Tests.Integration.csproj b/Hikkaba.Tests.Integration/Hikkaba.Tests.Integration.csproj index cfa18008..f76fa847 100644 --- a/Hikkaba.Tests.Integration/Hikkaba.Tests.Integration.csproj +++ b/Hikkaba.Tests.Integration/Hikkaba.Tests.Integration.csproj @@ -1,7 +1,7 @@ - net9.0 + net10.0 enable false diff --git a/Hikkaba.Tests.Integration/Utils/TestDbUtils.cs b/Hikkaba.Tests.Integration/Utils/TestDbUtils.cs index 81448c91..127cb217 100644 --- a/Hikkaba.Tests.Integration/Utils/TestDbUtils.cs +++ b/Hikkaba.Tests.Integration/Utils/TestDbUtils.cs @@ -6,7 +6,6 @@ using Hikkaba.Tests.Integration.Services; using JetBrains.Annotations; using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Logging; namespace Hikkaba.Tests.Integration.Utils; diff --git a/Hikkaba.Tests.Unit/CustomAppFactory.cs b/Hikkaba.Tests.Unit/CustomAppFactory.cs index 41a18c9d..db650523 100644 --- a/Hikkaba.Tests.Unit/CustomAppFactory.cs +++ b/Hikkaba.Tests.Unit/CustomAppFactory.cs @@ -5,16 +5,13 @@ using Hikkaba.Data.Context; using Hikkaba.Infrastructure.Models.Configuration; using Hikkaba.Tests.Unit.Mocks; -using Hikkaba.Web.Services.Contracts; -using Hikkaba.Web.Services.Implementations; using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.DataProtection.KeyManagement; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Identity; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.Infrastructure; -using Microsoft.AspNetCore.Mvc.Routing; using Microsoft.AspNetCore.Mvc.Testing; +using Microsoft.AspNetCore.Routing; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.Extensions.Caching.Distributed; @@ -34,11 +31,8 @@ namespace Hikkaba.Tests.Unit; internal sealed class CustomAppFactory : WebApplicationFactory { - private readonly FakeUrlHelperParams _fakeUrlHelperParams; - - public CustomAppFactory(FakeUrlHelperParams fakeUrlHelperParams) + public CustomAppFactory() { - _fakeUrlHelperParams = fakeUrlHelperParams; LogManager.Configuration = new XmlLoggingConfiguration("nlog.config"); } @@ -63,10 +57,8 @@ protected override void ConfigureWebHost(IWebHostBuilder builder) services.RemoveAll(); services.RemoveAll(); - services.RemoveAll(); - services.RemoveAll(); - services.RemoveAll(); - services.RemoveAll(); + services.RemoveAll(); + services.RemoveAll(); // we will use TestContainers + Respawner for DB, Redis, RabbitMQ services.RemoveAll>(); @@ -126,10 +118,8 @@ protected override void ConfigureWebHost(IWebHostBuilder builder) services.AddSingleton(x => FakeTimeProviderFactory.Create()); - services.AddSingleton(x => new FakeUrlHelper(_fakeUrlHelperParams)); - services.AddSingleton(x => new FakeUrlHelperFactory(_fakeUrlHelperParams)); - services.AddSingleton(); - services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); }) .ConfigureLogging(logging => { diff --git a/Hikkaba.Tests.Unit/Hikkaba.Tests.Unit.csproj b/Hikkaba.Tests.Unit/Hikkaba.Tests.Unit.csproj index 8bdb9ad9..0934e201 100644 --- a/Hikkaba.Tests.Unit/Hikkaba.Tests.Unit.csproj +++ b/Hikkaba.Tests.Unit/Hikkaba.Tests.Unit.csproj @@ -1,7 +1,7 @@ - net9.0 + net10.0 enable false diff --git a/Hikkaba.Tests.Unit/Mocks/FakeActionContextAccessor.cs b/Hikkaba.Tests.Unit/Mocks/FakeActionContextAccessor.cs deleted file mode 100644 index bf5b73e7..00000000 --- a/Hikkaba.Tests.Unit/Mocks/FakeActionContextAccessor.cs +++ /dev/null @@ -1,14 +0,0 @@ -using HttpContextMoq; -using HttpContextMoq.Extensions; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.Infrastructure; - -namespace Hikkaba.Tests.Unit.Mocks; - -internal sealed class FakeActionContextAccessor : IActionContextAccessor -{ - public ActionContext? ActionContext { get; set; } = new( - new HttpContextMock().SetupUrl("https://example.com").Mock.Object, - new Microsoft.AspNetCore.Routing.RouteData(), - new Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor()); -} diff --git a/Hikkaba.Tests.Unit/Mocks/FakeHttpContextAccessor.cs b/Hikkaba.Tests.Unit/Mocks/FakeHttpContextAccessor.cs new file mode 100644 index 00000000..992e7114 --- /dev/null +++ b/Hikkaba.Tests.Unit/Mocks/FakeHttpContextAccessor.cs @@ -0,0 +1,8 @@ +using Microsoft.AspNetCore.Http; + +namespace Hikkaba.Tests.Unit.Mocks; + +internal sealed class FakeHttpContextAccessor : IHttpContextAccessor +{ + public HttpContext? HttpContext { get; set; } = new DefaultHttpContext(); +} diff --git a/Hikkaba.Tests.Unit/Mocks/FakeLinkGenerator.cs b/Hikkaba.Tests.Unit/Mocks/FakeLinkGenerator.cs new file mode 100644 index 00000000..bb521642 --- /dev/null +++ b/Hikkaba.Tests.Unit/Mocks/FakeLinkGenerator.cs @@ -0,0 +1,50 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Routing; + +namespace Hikkaba.Tests.Unit.Mocks; + +internal sealed class FakeLinkGenerator : LinkGenerator +{ + private string? _expectedPath; + private string? _expectedUri; + + public FakeLinkGenerator() + { + } + + public FakeLinkGenerator(string expectedPath, string expectedUri) + { + _expectedPath = expectedPath; + _expectedUri = expectedUri; + } + + public void SetExpectedPath(string expectedPath) + { + _expectedPath = expectedPath; + } + + public void SetExpectedUri(string expectedUri) + { + _expectedUri = expectedUri; + } + + public override string? GetPathByAddress(HttpContext httpContext, TAddress address, RouteValueDictionary values, RouteValueDictionary? ambientValues = null, PathString? pathBase = null, FragmentString fragment = new FragmentString(), LinkOptions? options = null) + { + return _expectedPath; + } + + public override string? GetPathByAddress(TAddress address, RouteValueDictionary values, PathString pathBase = new PathString(), FragmentString fragment = new FragmentString(), LinkOptions? options = null) + { + return _expectedPath; + } + + public override string? GetUriByAddress(HttpContext httpContext, TAddress address, RouteValueDictionary values, RouteValueDictionary? ambientValues = null, string? scheme = null, HostString? host = null, PathString? pathBase = null, FragmentString fragment = new FragmentString(), LinkOptions? options = null) + { + return _expectedUri; + } + + public override string? GetUriByAddress(TAddress address, RouteValueDictionary values, string scheme, HostString host, PathString pathBase = new PathString(), FragmentString fragment = new FragmentString(), LinkOptions? options = null) + { + return _expectedUri; + } +} diff --git a/Hikkaba.Tests.Unit/Mocks/FakeUrlHelper.cs b/Hikkaba.Tests.Unit/Mocks/FakeUrlHelper.cs deleted file mode 100644 index b69c4df2..00000000 --- a/Hikkaba.Tests.Unit/Mocks/FakeUrlHelper.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System; -using System.Diagnostics.CodeAnalysis; -using HttpContextMoq; -using HttpContextMoq.Extensions; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.Routing; - -namespace Hikkaba.Tests.Unit.Mocks; - -internal sealed class FakeUrlHelper : IUrlHelper -{ - private const string BaseUri = "http://localhost"; - - private readonly FakeUrlHelperParams _fakeUrlHelperParams; - - public FakeUrlHelper(FakeUrlHelperParams fakeUrlHelperParams) - { - _fakeUrlHelperParams = fakeUrlHelperParams; - } - - public string? Action(UrlActionContext actionContext) - { - return _fakeUrlHelperParams.Action; - } - - [return: NotNullIfNotNull(nameof(contentPath))] - public string? Content(string? contentPath) - { - return "FakeContent"; - } - - public bool IsLocalUrl([NotNullWhen(true)] string? url) - { - return true; - } - - public string? RouteUrl(UrlRouteContext routeContext) - { - return _fakeUrlHelperParams.RouteUrlFactory(routeContext.RouteName, routeContext.Values); - } - - public string? Link(string? routeName, object? values) - { - var uri = new Uri(_fakeUrlHelperParams.RouteUrlFactory(routeName, values)); - var result = uri.IsAbsoluteUri - ? uri - : Uri.TryCreate(new Uri(BaseUri), uri, out var absoluteUri) - ? absoluteUri - : null; - - return result?.ToString(); - } - - public ActionContext ActionContext { get; } = new( - new HttpContextMock().SetupUrl(BaseUri).Mock.Object, - new Microsoft.AspNetCore.Routing.RouteData(), - new Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor()); -} diff --git a/Hikkaba.Tests.Unit/Mocks/FakeUrlHelperFactory.cs b/Hikkaba.Tests.Unit/Mocks/FakeUrlHelperFactory.cs deleted file mode 100644 index 5be929e1..00000000 --- a/Hikkaba.Tests.Unit/Mocks/FakeUrlHelperFactory.cs +++ /dev/null @@ -1,19 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.Routing; - -namespace Hikkaba.Tests.Unit.Mocks; - -internal sealed class FakeUrlHelperFactory : IUrlHelperFactory -{ - private readonly FakeUrlHelperParams _fakeUrlHelperParams; - - public FakeUrlHelperFactory(FakeUrlHelperParams fakeUrlHelperParams) - { - _fakeUrlHelperParams = fakeUrlHelperParams; - } - - public IUrlHelper GetUrlHelper(ActionContext context) - { - return new FakeUrlHelper(_fakeUrlHelperParams); - } -} diff --git a/Hikkaba.Tests.Unit/Mocks/FakeUrlHelperParams.cs b/Hikkaba.Tests.Unit/Mocks/FakeUrlHelperParams.cs deleted file mode 100644 index b9736b78..00000000 --- a/Hikkaba.Tests.Unit/Mocks/FakeUrlHelperParams.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; - -namespace Hikkaba.Tests.Unit.Mocks; - -internal sealed class FakeUrlHelperParams -{ - public string? Action { get; set; } - - /// - /// routeName, values => routeUrl - /// - public required Func RouteUrlFactory { get; set; } -} diff --git a/Hikkaba.Tests.Unit/Tests/Services/MessageToPlainTextTests.cs b/Hikkaba.Tests.Unit/Tests/Services/MessageToPlainTextTests.cs index d7a55ec7..a19ac315 100644 --- a/Hikkaba.Tests.Unit/Tests/Services/MessageToPlainTextTests.cs +++ b/Hikkaba.Tests.Unit/Tests/Services/MessageToPlainTextTests.cs @@ -1,5 +1,3 @@ -using System; -using Hikkaba.Tests.Unit.Mocks; using Hikkaba.Web.Services.Contracts; using Microsoft.Extensions.DependencyInjection; @@ -9,15 +7,6 @@ namespace Hikkaba.Tests.Unit.Tests.Services; [Parallelizable(scope: ParallelScope.All)] internal sealed class MessageToPlainTextTests { - private const string FakeActionPath = "/b/23454362"; - private static readonly FakeUrlHelperParams FakeUrlHelperParams = new() - { - Action = FakeActionPath, - RouteUrlFactory = (routeName, values) => routeName == "ThreadDetails" - ? FakeActionPath - : throw new ArgumentException("Invalid route name", nameof(routeName)), - }; - [TestCase("SOME STRANGE TEXT, huh ^^ 延凹線艶彙")] [TestCase("S♢MΞ░STRΛNGΞ░TΞXT,░huh░^^ (延凹線艶彙)")] [TestCase("【SOME STRANGE TEXT, huh ^^】")] @@ -30,7 +19,7 @@ internal sealed class MessageToPlainTextTests [TestCase("Line 1\n\nLine 2\n\nLine 3")] public void MessageToPlainText_WhenCalledWithText_ShouldReturnTheSameText(string input) { - using var customAppFactory = new CustomAppFactory(FakeUrlHelperParams); + using var customAppFactory = new CustomAppFactory(); using var scope = customAppFactory.Services.GetRequiredService().CreateScope(); var messagePostProcessor = scope.ServiceProvider.GetRequiredService(); @@ -51,7 +40,7 @@ plain [b][i][u] """, "plain \nmix3\nmix2 mix1\nplain")] public void MessageToPlainText_WhenCalledWithTags_ShouldReturnPlainText(string input, string expectedOutput) { - using var customAppFactory = new CustomAppFactory(FakeUrlHelperParams); + using var customAppFactory = new CustomAppFactory(); using var scope = customAppFactory.Services.GetRequiredService().CreateScope(); var messagePostProcessor = scope.ServiceProvider.GetRequiredService(); diff --git a/Hikkaba.Tests.Unit/Tests/Services/MessageToSafeHtmlTests.cs b/Hikkaba.Tests.Unit/Tests/Services/MessageToSafeHtmlTests.cs index 8f3845c9..d59055e4 100644 --- a/Hikkaba.Tests.Unit/Tests/Services/MessageToSafeHtmlTests.cs +++ b/Hikkaba.Tests.Unit/Tests/Services/MessageToSafeHtmlTests.cs @@ -1,6 +1,6 @@ -using System; using Hikkaba.Tests.Unit.Mocks; using Hikkaba.Web.Services.Contracts; +using Microsoft.AspNetCore.Routing; using Microsoft.Extensions.DependencyInjection; namespace Hikkaba.Tests.Unit.Tests.Services; @@ -9,15 +9,6 @@ namespace Hikkaba.Tests.Unit.Tests.Services; [Parallelizable(scope: ParallelScope.All)] internal sealed class MessageToSafeHtmlTests { - private const string FakeActionPath = "/b/23454362"; - private static readonly FakeUrlHelperParams FakeUrlHelperParams = new() - { - Action = FakeActionPath, - RouteUrlFactory = (routeName, values) => routeName == "ThreadDetails" - ? FakeActionPath - : throw new ArgumentException("Invalid route name", nameof(routeName)), - }; - [TestCase("SOME STRANGE TEXT, huh ^^ 延凹線艶彙")] [TestCase("S♢MΞ░STRΛNGΞ░TΞXT,░huh░^^ (延凹線艶彙)")] [TestCase("【SOME STRANGE TEXT, huh ^^】")] @@ -27,7 +18,7 @@ internal sealed class MessageToSafeHtmlTests [TestCase("Some letters. 1234567890; 987 * 2 - 5 @! | [wow](!wow)[!wow][[ yoy )))) [[[ ]] ] \\ //.")] public void MessageToSafeHtml_WhenCalledWithText_ShouldReturnTheSameText(string input) { - using var customAppFactory = new CustomAppFactory(FakeUrlHelperParams); + using var customAppFactory = new CustomAppFactory(); using var scope = customAppFactory.Services.GetRequiredService().CreateScope(); var messagePostProcessor = scope.ServiceProvider.GetRequiredService(); @@ -43,7 +34,7 @@ public void MessageToSafeHtml_WhenCalledWithText_ShouldReturnTheSameText(string [TestCase("TEXT\n\rWITH LINE BREAKS", "TEXT\n\nWITH LINE BREAKS")] public void MessageToSafeHtml_WhenCalledWithLineBreaks_ShouldReturnNormalizedLineBreaks(string input, string expectedOutput) { - using var customAppFactory = new CustomAppFactory(FakeUrlHelperParams); + using var customAppFactory = new CustomAppFactory(); using var scope = customAppFactory.Services.GetRequiredService().CreateScope(); var messagePostProcessor = scope.ServiceProvider.GetRequiredService(); @@ -63,7 +54,7 @@ public void MessageToSafeHtml_WhenCalledWithLineBreaks_ShouldReturnNormalizedLin [TestCase("plain [b][i][u]mix3[/u] mix2[/i] mix1[/b] plain", "plain mix3 mix2 mix1 plain")] public void MessageToSafeHtml_WhenCalledWithBbCode_ShouldReturnHtml(string input, string expectedOutput) { - using var customAppFactory = new CustomAppFactory(FakeUrlHelperParams); + using var customAppFactory = new CustomAppFactory(); using var scope = customAppFactory.Services.GetRequiredService().CreateScope(); var messagePostProcessor = scope.ServiceProvider.GetRequiredService(); @@ -83,7 +74,7 @@ public void MessageToSafeHtml_WhenCalledWithBbCode_ShouldReturnHtml(string input [TestCase("http://example.com/\"bold\"abc", """http://example.com/"bold"abc""")] public void MessageToSafeHtml_WhenCalledWithLinks_ShouldReturnHtmlLinks(string input, string expectedOutput) { - using var customAppFactory = new CustomAppFactory(FakeUrlHelperParams); + using var customAppFactory = new CustomAppFactory(); using var scope = customAppFactory.Services.GetRequiredService().CreateScope(); var messagePostProcessor = scope.ServiceProvider.GetRequiredService(); @@ -91,14 +82,20 @@ public void MessageToSafeHtml_WhenCalledWithLinks_ShouldReturnHtmlLinks(string i Assert.That(actualOutput, Is.EqualTo(expectedOutput)); } - [TestCase(">>0", $""">>0""")] - [TestCase(">>999", $""">>999""")] - public void MessageToSafeHtml_WhenCalledWithReplyLinks_ShouldReturnHtmlLinks(string input, string expectedOutput) + [TestCase(">>0", "/a/9024389", """>>0""")] + [TestCase(">>999", "/a/9024389", """>>999""")] + public void MessageToSafeHtml_WhenCalledWithReplyLinks_ShouldReturnHtmlLinks(string input, string testPath, string expectedOutput) { - using var customAppFactory = new CustomAppFactory(FakeUrlHelperParams); + using var customAppFactory = new CustomAppFactory(); using var scope = customAppFactory.Services.GetRequiredService().CreateScope(); + var linkGenerator = scope.ServiceProvider.GetRequiredService(); var messagePostProcessor = scope.ServiceProvider.GetRequiredService(); + if (linkGenerator is FakeLinkGenerator fakeLinkGenerator) + { + fakeLinkGenerator.SetExpectedPath(testPath); + } + var actualOutput = messagePostProcessor.MessageToSafeHtml("a", 9024389, input); Assert.That(actualOutput, Is.EqualTo(expectedOutput)); } @@ -109,7 +106,7 @@ public void MessageToSafeHtml_WhenCalledWithReplyLinks_ShouldReturnHtmlLinks(str [TestCase("", "<nav>test</nav>")] public void MessageToSafeHtml_WhenCalledWithUnsafeTags_ShouldReturnHtml(string input, string expectedOutput) { - using var customAppFactory = new CustomAppFactory(FakeUrlHelperParams); + using var customAppFactory = new CustomAppFactory(); using var scope = customAppFactory.Services.GetRequiredService().CreateScope(); var messagePostProcessor = scope.ServiceProvider.GetRequiredService(); @@ -143,7 +140,7 @@ public void MessageToSafeHtml_WhenCalledWithUnsafeTags_ShouldReturnHtml(string i [TestCase("""[url="[url="javascript:alert('XSS')"][/url]"]test[/url]""", """[url=""]test""")] public void MessageToSafeHtml_WhenCalledWithMaliciousInput_ShouldSanitizeInput(string input, string expectedOutput) { - using var customAppFactory = new CustomAppFactory(FakeUrlHelperParams); + using var customAppFactory = new CustomAppFactory(); using var scope = customAppFactory.Services.GetRequiredService().CreateScope(); var messagePostProcessor = scope.ServiceProvider.GetRequiredService(); @@ -165,7 +162,7 @@ public void MessageToSafeHtml_WhenCalledWithMaliciousInput_ShouldSanitizeInput(s [TestCase("""[code="javascript:alert('XSS')"]text[/code]""", "
text
")] public void MessageToSafeHtml_WhenCalledWithPreformattedTag_ShouldReturnHtml(string input, string expectedOutput) { - using var customAppFactory = new CustomAppFactory(FakeUrlHelperParams); + using var customAppFactory = new CustomAppFactory(); using var scope = customAppFactory.Services.GetRequiredService().CreateScope(); var messagePostProcessor = scope.ServiceProvider.GetRequiredService(); diff --git a/Hikkaba.Tools.Manual.LibManOptimizer/Hikkaba.Tools.Manual.LibManOptimizer.csproj b/Hikkaba.Tools.Manual.LibManOptimizer/Hikkaba.Tools.Manual.LibManOptimizer.csproj index b43ed4ef..bd1fde52 100644 --- a/Hikkaba.Tools.Manual.LibManOptimizer/Hikkaba.Tools.Manual.LibManOptimizer.csproj +++ b/Hikkaba.Tools.Manual.LibManOptimizer/Hikkaba.Tools.Manual.LibManOptimizer.csproj @@ -2,7 +2,7 @@ Exe - net9.0 + net10.0 enable enable diff --git a/Hikkaba.Tools.Manual.Seed/Hikkaba.Tools.Manual.Seed.csproj b/Hikkaba.Tools.Manual.Seed/Hikkaba.Tools.Manual.Seed.csproj index 6935edaf..3fec6184 100644 --- a/Hikkaba.Tools.Manual.Seed/Hikkaba.Tools.Manual.Seed.csproj +++ b/Hikkaba.Tools.Manual.Seed/Hikkaba.Tools.Manual.Seed.csproj @@ -2,7 +2,7 @@ Exe - net9.0 + net10.0 enable enable diff --git a/Hikkaba.Web/Controllers/Mvc/Admin/ThreadAdminController.cs b/Hikkaba.Web/Controllers/Mvc/Admin/ThreadAdminController.cs index 4e8807de..3321e55a 100644 --- a/Hikkaba.Web/Controllers/Mvc/Admin/ThreadAdminController.cs +++ b/Hikkaba.Web/Controllers/Mvc/Admin/ThreadAdminController.cs @@ -1,9 +1,7 @@ using System.ComponentModel.DataAnnotations; -using System.Globalization; using System.Threading; using System.Threading.Tasks; using Hikkaba.Application.Contracts; -using Hikkaba.Infrastructure.Models.Thread; using Hikkaba.Shared.Constants; using Hikkaba.Web.Controllers.Mvc.Base; using Hikkaba.Web.Mappings; diff --git a/Hikkaba.Web/Controllers/Mvc/Admin/UserAdminController.cs b/Hikkaba.Web/Controllers/Mvc/Admin/UserAdminController.cs index 825a1071..77210ffe 100644 --- a/Hikkaba.Web/Controllers/Mvc/Admin/UserAdminController.cs +++ b/Hikkaba.Web/Controllers/Mvc/Admin/UserAdminController.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations; using System.Globalization; using System.Linq; using System.Threading; diff --git a/Hikkaba.Web/Controllers/Mvc/ErrorController.cs b/Hikkaba.Web/Controllers/Mvc/ErrorController.cs index df69b4fd..1839f367 100644 --- a/Hikkaba.Web/Controllers/Mvc/ErrorController.cs +++ b/Hikkaba.Web/Controllers/Mvc/ErrorController.cs @@ -5,7 +5,6 @@ using Hikkaba.Web.ViewModels.ErrorViewModels; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Diagnostics; -using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; diff --git a/Hikkaba.Web/Controllers/Mvc/PostController.cs b/Hikkaba.Web/Controllers/Mvc/PostController.cs index 79e09749..ebb1f2f4 100644 --- a/Hikkaba.Web/Controllers/Mvc/PostController.cs +++ b/Hikkaba.Web/Controllers/Mvc/PostController.cs @@ -24,7 +24,6 @@ using Hikkaba.Web.ViewModels.SearchViewModels; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; -using MyCSharp.HttpUserAgentParser; using MyCSharp.HttpUserAgentParser.AspNetCore; namespace Hikkaba.Web.Controllers.Mvc; diff --git a/Hikkaba.Web/DataAnnotations/AllowedExtensionsAttribute.cs b/Hikkaba.Web/DataAnnotations/AllowedExtensionsAttribute.cs index 54ad2e57..7356d6a5 100644 --- a/Hikkaba.Web/DataAnnotations/AllowedExtensionsAttribute.cs +++ b/Hikkaba.Web/DataAnnotations/AllowedExtensionsAttribute.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using Microsoft.AspNetCore.Http; diff --git a/Hikkaba.Web/DataAnnotations/MaxFileCountAttribute.cs b/Hikkaba.Web/DataAnnotations/MaxFileCountAttribute.cs index 66f380b7..4eefe480 100644 --- a/Hikkaba.Web/DataAnnotations/MaxFileCountAttribute.cs +++ b/Hikkaba.Web/DataAnnotations/MaxFileCountAttribute.cs @@ -1,6 +1,5 @@ using System; using System.ComponentModel.DataAnnotations; -using System.Linq; using Microsoft.AspNetCore.Http; namespace Hikkaba.Web.DataAnnotations; diff --git a/Hikkaba.Web/DataAnnotations/MinFileCountAttribute.cs b/Hikkaba.Web/DataAnnotations/MinFileCountAttribute.cs index 0a04b226..e07463c4 100644 --- a/Hikkaba.Web/DataAnnotations/MinFileCountAttribute.cs +++ b/Hikkaba.Web/DataAnnotations/MinFileCountAttribute.cs @@ -1,6 +1,5 @@ using System; using System.ComponentModel.DataAnnotations; -using System.Linq; using Microsoft.AspNetCore.Http; namespace Hikkaba.Web.DataAnnotations; diff --git a/Hikkaba.Web/Extensions/DependencyInjection.cs b/Hikkaba.Web/Extensions/DependencyInjection.cs index 1cd042c7..2754d950 100644 --- a/Hikkaba.Web/Extensions/DependencyInjection.cs +++ b/Hikkaba.Web/Extensions/DependencyInjection.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Diagnostics; using System.Globalization; using System.IO; @@ -148,8 +148,7 @@ internal static IServiceCollection AddHikkabaServices(this IServiceCollection se }); // declared in presentation layer - services.AddSingleton(); - services.AddScoped(); + services.AddScoped(); services.AddScoped(); services.AddHttpUserAgentMemoryCachedParser() diff --git a/Hikkaba.Web/Hikkaba.Web.csproj b/Hikkaba.Web/Hikkaba.Web.csproj index ba9ff94c..7793450f 100644 --- a/Hikkaba.Web/Hikkaba.Web.csproj +++ b/Hikkaba.Web/Hikkaba.Web.csproj @@ -1,7 +1,7 @@  - net9.0 + net10.0 true aspnet-Hikkaba.Web-3E363644-2AE5-4DC0-B12C-4896CBFF1BE6 Linux @@ -24,7 +24,6 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - diff --git a/Hikkaba.Web/Mappings/RoleMapper.cs b/Hikkaba.Web/Mappings/RoleMapper.cs index 52ba259c..676efa2c 100644 --- a/Hikkaba.Web/Mappings/RoleMapper.cs +++ b/Hikkaba.Web/Mappings/RoleMapper.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using System.Linq; using Hikkaba.Infrastructure.Models.Role; -using Hikkaba.Web.ViewModels.AdministrationViewModels; using Hikkaba.Web.ViewModels.RoleViewModels; using Riok.Mapperly.Abstractions; diff --git a/Hikkaba.Web/Mappings/UserMapper.cs b/Hikkaba.Web/Mappings/UserMapper.cs index 028f25be..8e385329 100644 --- a/Hikkaba.Web/Mappings/UserMapper.cs +++ b/Hikkaba.Web/Mappings/UserMapper.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; using Hikkaba.Infrastructure.Models.User; -using Hikkaba.Web.ViewModels.AdministrationViewModels; using Hikkaba.Web.ViewModels.UserViewModels; using Riok.Mapperly.Abstractions; diff --git a/Hikkaba.Web/Program.cs b/Hikkaba.Web/Program.cs index 9d5221a8..60c17557 100644 --- a/Hikkaba.Web/Program.cs +++ b/Hikkaba.Web/Program.cs @@ -10,7 +10,6 @@ using NLog; using NLog.Config; using NLog.Web; -using OpenTelemetry.Exporter; using OpenTelemetry.Logs; using OpenTelemetry.Resources; using LogLevel = Microsoft.Extensions.Logging.LogLevel; @@ -56,7 +55,7 @@ private static IHostBuilder CreateHostBuilder(string[] args, LoggingConfiguratio { logging.ClearProviders(); logging.SetMinimumLevel(LogLevel.Trace); - logging.AddNLog(loggingConfiguration); + logging.AddNLogWeb(loggingConfiguration); var hikkabaConfig = hostBuilderContext.Configuration .GetSection(nameof(HikkabaConfiguration)) diff --git a/Hikkaba.Web/Services/Contracts/ILinkBuilder.cs b/Hikkaba.Web/Services/Contracts/ILinkBuilder.cs new file mode 100644 index 00000000..d9dd3612 --- /dev/null +++ b/Hikkaba.Web/Services/Contracts/ILinkBuilder.cs @@ -0,0 +1,14 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Routing; + +namespace Hikkaba.Web.Services.Contracts; + +public interface ILinkBuilder +{ + public string? RouteUrl( + string? routeName, + object? values, + PathString? pathBase = null, + FragmentString fragment = default, + LinkOptions? options = null); +} diff --git a/Hikkaba.Web/Services/Contracts/IUrlHelperFactoryWrapper.cs b/Hikkaba.Web/Services/Contracts/IUrlHelperFactoryWrapper.cs deleted file mode 100644 index 3ceaeedc..00000000 --- a/Hikkaba.Web/Services/Contracts/IUrlHelperFactoryWrapper.cs +++ /dev/null @@ -1,8 +0,0 @@ -using Microsoft.AspNetCore.Mvc; - -namespace Hikkaba.Web.Services.Contracts; - -public interface IUrlHelperFactoryWrapper -{ - IUrlHelper GetUrlHelper(); -} diff --git a/Hikkaba.Web/Services/Implementations/LinkBuilder.cs b/Hikkaba.Web/Services/Implementations/LinkBuilder.cs new file mode 100644 index 00000000..52698026 --- /dev/null +++ b/Hikkaba.Web/Services/Implementations/LinkBuilder.cs @@ -0,0 +1,32 @@ +using System; +using Hikkaba.Web.Services.Contracts; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Routing; + +namespace Hikkaba.Web.Services.Implementations; + +public class LinkBuilder : ILinkBuilder +{ + private readonly IHttpContextAccessor _httpContextAccessor; + private readonly LinkGenerator _linkGenerator; + + public LinkBuilder( + IHttpContextAccessor httpContextAccessor, + LinkGenerator linkGenerator) + { + _httpContextAccessor = httpContextAccessor; + _linkGenerator = linkGenerator; + } + + public string? RouteUrl( + string? routeName, + object? values, + PathString? pathBase = null, + FragmentString fragment = default, + LinkOptions? options = null) + { + var httpContext = _httpContextAccessor.HttpContext + ?? throw new InvalidOperationException("HttpContext is not available."); + return _linkGenerator.GetPathByRouteValues(httpContext, routeName, values, pathBase, fragment, options); + } +} diff --git a/Hikkaba.Web/Services/Implementations/MessagePostProcessor.cs b/Hikkaba.Web/Services/Implementations/MessagePostProcessor.cs index 1c67045e..8a5cce5f 100644 --- a/Hikkaba.Web/Services/Implementations/MessagePostProcessor.cs +++ b/Hikkaba.Web/Services/Implementations/MessagePostProcessor.cs @@ -6,13 +6,12 @@ using Hikkaba.Application.Implementations; using Hikkaba.Web.Services.Contracts; using Hikkaba.Web.Telemetry; -using Microsoft.AspNetCore.Mvc; namespace Hikkaba.Web.Services.Implementations; public partial class MessagePostProcessor : IMessagePostProcessor { - private readonly IUrlHelper _urlHelper; + private readonly ILinkBuilder _linkBuilder; private readonly BBParser _bbParser = new([ new Tag("b", "", ""), @@ -45,10 +44,9 @@ public partial class MessagePostProcessor : IMessagePostProcessor private static readonly Regex ReplaceLineTerminatorsRegex = GetReplaceLineTerminatorsRegex(); private static readonly Regex LimitLineTerminatorCountRegex = GetLimitLineTerminatorCountRegex(); - public MessagePostProcessor( - IUrlHelperFactoryWrapper urlHelperFactoryWrapper) + public MessagePostProcessor(ILinkBuilder linkBuilder) { - _urlHelper = urlHelperFactoryWrapper.GetUrlHelper(); + _linkBuilder = linkBuilder; } private static string ReplaceUrisWithBbCodeUrl(string text) @@ -60,7 +58,7 @@ private static string ReplaceUrisWithBbCodeUrl(string text) private string ReplacePostLinksWithBbCodeUrl(string categoryAlias, long threadId, string text) { using var activity = WebTelemetry.MessagePostProcessorSource.StartActivity(); - var threadUri = _urlHelper.RouteUrl( + var threadUri = _linkBuilder.RouteUrl( "ThreadDetails", new { diff --git a/Hikkaba.Web/Services/Implementations/UrlHelperFactoryWrapper.cs b/Hikkaba.Web/Services/Implementations/UrlHelperFactoryWrapper.cs deleted file mode 100644 index 32c27242..00000000 --- a/Hikkaba.Web/Services/Implementations/UrlHelperFactoryWrapper.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using Hikkaba.Web.Services.Contracts; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.Infrastructure; -using Microsoft.AspNetCore.Mvc.Routing; - -namespace Hikkaba.Web.Services.Implementations; - -public class UrlHelperFactoryWrapper : IUrlHelperFactoryWrapper -{ - private readonly IUrlHelperFactory _urlHelperFactory; - private readonly IActionContextAccessor _actionContextAccessor; - - public UrlHelperFactoryWrapper( - IUrlHelperFactory urlHelperFactory, - IActionContextAccessor actionContextAccessor) - { - _urlHelperFactory = urlHelperFactory; - _actionContextAccessor = actionContextAccessor; - } - - public IUrlHelper GetUrlHelper() - { - return _urlHelperFactory.GetUrlHelper(_actionContextAccessor.ActionContext - ?? throw new InvalidOperationException("ActionContext is null")); - } -} diff --git a/Hikkaba.Web/Utils/Url/BanUrlUtils.cs b/Hikkaba.Web/Utils/Url/BanUrlUtils.cs index 55d24e1c..ab57f3bf 100644 --- a/Hikkaba.Web/Utils/Url/BanUrlUtils.cs +++ b/Hikkaba.Web/Utils/Url/BanUrlUtils.cs @@ -1,11 +1,12 @@ +using Hikkaba.Web.Services.Contracts; using Hikkaba.Web.ViewModels.BansViewModels; -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Http; namespace Hikkaba.Web.Utils.Url; public static class BanUrlUtils { - public static string? GetThreadDetailsPostUri(BanViewModel banViewModel, IUrlHelper urlHelper) + public static string? GetThreadDetailsPostUri(BanViewModel banViewModel, ILinkBuilder urlHelper) { return urlHelper.RouteUrl( "ThreadDetails", @@ -14,8 +15,6 @@ public static class BanUrlUtils categoryAlias = banViewModel.CategoryAlias, threadId = banViewModel.RelatedThreadId, }, - protocol: null, - host: null, - fragment: $"{banViewModel.RelatedPostId}"); + fragment: new FragmentString($"#{banViewModel.RelatedPostId}")); } } diff --git a/Hikkaba.Web/Utils/Url/PostUrlUtils.cs b/Hikkaba.Web/Utils/Url/PostUrlUtils.cs index f83f9561..3b3375bc 100644 --- a/Hikkaba.Web/Utils/Url/PostUrlUtils.cs +++ b/Hikkaba.Web/Utils/Url/PostUrlUtils.cs @@ -1,11 +1,12 @@ +using Hikkaba.Web.Services.Contracts; using Hikkaba.Web.ViewModels.PostsViewModels; -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Http; namespace Hikkaba.Web.Utils.Url; public static class PostUrlUtils { - public static string? GetThreadDetailsPostUri(PostDetailsViewModel postDetailsViewModel, IUrlHelper urlHelper) + public static string? GetThreadDetailsPostUri(PostDetailsViewModel postDetailsViewModel, ILinkBuilder urlHelper) { return urlHelper.RouteUrl( "ThreadDetails", @@ -14,8 +15,6 @@ public static class PostUrlUtils categoryAlias = postDetailsViewModel.CategoryAlias, threadId = postDetailsViewModel.ThreadId, }, - protocol: null, - host: null, - fragment: $"{postDetailsViewModel.Id}"); + fragment: new FragmentString($"#{postDetailsViewModel.Id}")); } } diff --git a/Hikkaba.Web/Utils/Url/ThreadUrlUtils.cs b/Hikkaba.Web/Utils/Url/ThreadUrlUtils.cs index db32bbcd..aba99e64 100644 --- a/Hikkaba.Web/Utils/Url/ThreadUrlUtils.cs +++ b/Hikkaba.Web/Utils/Url/ThreadUrlUtils.cs @@ -1,11 +1,11 @@ +using Hikkaba.Web.Services.Contracts; using Hikkaba.Web.ViewModels.ThreadsViewModels; -using Microsoft.AspNetCore.Mvc; namespace Hikkaba.Web.Utils.Url; public static class ThreadUrlUtils { - public static string? GetThreadDetailsUri(ThreadDetailsViewModel threadDetailsViewModel, IUrlHelper urlHelper) + public static string? GetThreadDetailsUri(ThreadDetailsViewModel threadDetailsViewModel, ILinkBuilder urlHelper) { return urlHelper.RouteUrl( "ThreadDetails", diff --git a/Hikkaba.Web/Views/BanAdmin/Details.cshtml b/Hikkaba.Web/Views/BanAdmin/Details.cshtml index cea13eef..1b5d301f 100644 --- a/Hikkaba.Web/Views/BanAdmin/Details.cshtml +++ b/Hikkaba.Web/Views/BanAdmin/Details.cshtml @@ -1,7 +1,9 @@ -@using Hikkaba.Web.Utils.Url +@using Hikkaba.Web.Services.Contracts +@using Hikkaba.Web.Utils.Url @using Humanizer @model Hikkaba.Web.ViewModels.BansViewModels.BanViewModel @inject TimeProvider TimeProvider +@inject ILinkBuilder LinkBuilder @{ ViewData["Title"] = "Ban details"; } @@ -55,7 +57,7 @@
@Html.DisplayFor(model => model.CategoryAlias)
@Html.DisplayNameFor(model => model.RelatedPostId)
-
@(Model.RelatedPostId == null ? "" : Model.RelatedPostId.ToString())
+
@(Model.RelatedPostId == null ? "" : Model.RelatedPostId.ToString())
@Html.DisplayNameFor(model => model.Reason)
@Html.DisplayFor(model => model.Reason)
diff --git a/Hikkaba.Web/Views/BanAdmin/DisplayTemplates/BanViewModel.cshtml b/Hikkaba.Web/Views/BanAdmin/DisplayTemplates/BanViewModel.cshtml index 9b0e1349..50cf8c5b 100644 --- a/Hikkaba.Web/Views/BanAdmin/DisplayTemplates/BanViewModel.cshtml +++ b/Hikkaba.Web/Views/BanAdmin/DisplayTemplates/BanViewModel.cshtml @@ -1,10 +1,12 @@ +@using Hikkaba.Web.Services.Contracts @using Hikkaba.Web.Utils.Url @model Hikkaba.Web.ViewModels.BansViewModels.BanViewModel +@inject ILinkBuilder LinkBuilder @Html.DisplayFor(model => model.CreatedAt) @(Model.CategoryAlias == null ? "" : "/" + Model.CategoryAlias) - @(Model?.RelatedPostId == null ? "" : Model.RelatedPostId.ToString()) + @(Model?.RelatedPostId == null ? "" : Model.RelatedPostId.ToString()) @Html.DisplayFor(model => model.BannedIpAddress) @Html.DisplayFor(model => model.BannedCidrLowerIpAddress) @Html.DisplayFor(model => model.BannedCidrUpperIpAddress) diff --git a/Hikkaba.Web/Views/Shared/DisplayTemplates/PostDetailsViewModel.cshtml b/Hikkaba.Web/Views/Shared/DisplayTemplates/PostDetailsViewModel.cshtml index 4876802a..3c94bf6d 100644 --- a/Hikkaba.Web/Views/Shared/DisplayTemplates/PostDetailsViewModel.cshtml +++ b/Hikkaba.Web/Views/Shared/DisplayTemplates/PostDetailsViewModel.cshtml @@ -1,10 +1,12 @@ @using Hikkaba.Shared.Constants @using Hikkaba.Shared.Extensions @using Hikkaba.Shared.Services.Contracts +@using Hikkaba.Web.Services.Contracts @using Hikkaba.Web.Utils.Url @using Microsoft.AspNetCore.Mvc.TagHelpers @model Hikkaba.Web.ViewModels.PostsViewModels.PostDetailsViewModel @inject IUserContext UserContext +@inject ILinkBuilder LinkBuilder
@@ -69,7 +71,7 @@ @*Post ID*@
@*no extra spaces inside a*@ - @Html.DisplayFor(model => model.Id) + @Html.DisplayFor(model => model.Id)
@*Post sequence number in thread*@ diff --git a/Hikkaba.Web/Views/Shared/DisplayTemplates/ThreadDetailsViewModel.cshtml b/Hikkaba.Web/Views/Shared/DisplayTemplates/ThreadDetailsViewModel.cshtml index 40c52fd0..498c4528 100644 --- a/Hikkaba.Web/Views/Shared/DisplayTemplates/ThreadDetailsViewModel.cshtml +++ b/Hikkaba.Web/Views/Shared/DisplayTemplates/ThreadDetailsViewModel.cshtml @@ -1,23 +1,23 @@ @using Hikkaba.Shared.Constants -@using Hikkaba.Shared.Models @using Hikkaba.Shared.Services.Contracts +@using Hikkaba.Web.Services.Contracts @using Hikkaba.Web.Utils.Url -@using Microsoft.AspNetCore.Mvc.TagHelpers @model Hikkaba.Web.ViewModels.ThreadsViewModels.ThreadDetailsViewModel @inject IUserContext UserContext +@inject ILinkBuilder LinkBuilder
- @Model.Title + @Model.Title   @Model.PostCount posts   @Html.DisplayFor(model => model.CreatedAt)   - @Model.Id + @Model.Id @if (Model.IsPinned) {   @@ -96,7 +96,7 @@ {
}