diff --git a/apps/WASMDemo.Server/Pages/Error.cshtml.cs b/apps/WASMDemo.Server/Pages/Error.cshtml.cs index 56d016232..d2551f21d 100644 --- a/apps/WASMDemo.Server/Pages/Error.cshtml.cs +++ b/apps/WASMDemo.Server/Pages/Error.cshtml.cs @@ -8,13 +8,9 @@ namespace WASMDemo.Server.Pages; [IgnoreAntiforgeryToken] public class ErrorModel : PageModel { - private readonly ILogger logger; - - public ErrorModel(ILogger logger) => this.logger = logger; public string? RequestId { get; set; } public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); public void OnGet() => RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; } - diff --git a/src/Sitko.Core.App/ApplicationModuleRegistration.cs b/src/Sitko.Core.App/ApplicationModuleRegistration.cs index 6fe515d69..dec97fadd 100644 --- a/src/Sitko.Core.App/ApplicationModuleRegistration.cs +++ b/src/Sitko.Core.App/ApplicationModuleRegistration.cs @@ -128,9 +128,9 @@ public override (bool isSuccess, IEnumerable missingModules) CheckRequired private TModuleOptions CreateOptions(IApplicationContext applicationContext, bool validateOptions = false) { TModuleOptions options; - if (optionsCache.ContainsKey(applicationContext.Id)) + if (optionsCache.TryGetValue(applicationContext.Id, out var value)) { - options = optionsCache[applicationContext.Id]; + options = value; } else { diff --git a/src/Sitko.Core.App/Localization/JsonStringLocalizerFactory.cs b/src/Sitko.Core.App/Localization/JsonStringLocalizerFactory.cs index b7048df62..e9f9b701c 100644 --- a/src/Sitko.Core.App/Localization/JsonStringLocalizerFactory.cs +++ b/src/Sitko.Core.App/Localization/JsonStringLocalizerFactory.cs @@ -122,10 +122,7 @@ private static void FillData(Dictionary data, Dictionary - selector.AddTypes(startupOptions.Middlewares).AsSelfWithInterfaces().WithSingletonLifetime()); + selector.FromTypes(startupOptions.Middlewares).AsSelfWithInterfaces().WithSingletonLifetime()); } foreach (var options in startupOptions.Options) @@ -40,7 +40,7 @@ public override void ConfigureServices(IApplicationContext applicationContext, I if (startupOptions.ProcessorEntries.Any()) { var types = startupOptions.ProcessorEntries.Select(e => e.Type).Distinct().ToArray(); - services.Scan(selector => selector.AddTypes(types).AsSelfWithInterfaces().WithScopedLifetime()); + services.Scan(selector => selector.FromTypes(types).AsSelfWithInterfaces().WithScopedLifetime()); var messageTypes = startupOptions.ProcessorEntries.SelectMany(e => e.MessageTypes).Distinct().ToArray(); foreach (var messageType in messageTypes) { diff --git a/src/Sitko.Core.Repository/RepositoriesModule.cs b/src/Sitko.Core.Repository/RepositoriesModule.cs index b9d7dc1c3..37dbb751a 100644 --- a/src/Sitko.Core.Repository/RepositoriesModule.cs +++ b/src/Sitko.Core.Repository/RepositoriesModule.cs @@ -45,7 +45,7 @@ public override void ConfigureServices(IApplicationContext applicationContext, I .Select(implementedInterface => (implementedInterface.GenericTypeArguments[0], implementedInterface.GenericTypeArguments[1])).ToList(); services.Scan(s => - s.AddTypes(types.Distinct()).UsingRegistrationStrategy(RegistrationStrategy.Skip).AsSelfWithInterfaces() + s.FromTypes(types.Distinct()).UsingRegistrationStrategy(RegistrationStrategy.Skip).AsSelfWithInterfaces() .WithScopedLifetime()); foreach (var (entityType, entityPkType) in entityTypes) { diff --git a/src/Sitko.Core.Search/SearchModule.cs b/src/Sitko.Core.Search/SearchModule.cs index 2089013e1..975a7af5a 100644 --- a/src/Sitko.Core.Search/SearchModule.cs +++ b/src/Sitko.Core.Search/SearchModule.cs @@ -55,7 +55,7 @@ public static IServiceCollection RegisterSearchProvider where TEntity : class => - serviceCollection.Scan(a => a.AddType().AsSelfWithInterfaces()); + serviceCollection.Scan(a => a.FromType().AsSelfWithInterfaces()); } public abstract class SearchModuleOptions : BaseModuleOptions diff --git a/tests/Sitko.Core.ImgProxy.Tests/ImgProxyTests.cs b/tests/Sitko.Core.ImgProxy.Tests/ImgProxyTests.cs index d4ee86932..38c0a66c7 100644 --- a/tests/Sitko.Core.ImgProxy.Tests/ImgProxyTests.cs +++ b/tests/Sitko.Core.ImgProxy.Tests/ImgProxyTests.cs @@ -7,7 +7,7 @@ namespace Sitko.Core.ImgProxy.Tests; public class ImgProxyTests : BaseTest { - private static readonly string testUrl = "https://img.test.com/img/foo.png"; + private const string TestUrl = "https://img.test.com/img/foo.png"; public ImgProxyTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { @@ -19,7 +19,7 @@ public async Task Url() var scope = await GetScopeAsync(); var generator = scope.GetService(); - var generated = generator.Url(testUrl); + var generated = generator.Url(TestUrl); generated.Should() .Be( "https://imgproxy.test.com/SxQp7ZiYppbWLN0lA6-qCKCtEAafQidbWvGhObksdOg//aHR0cHM6Ly9pbWcudGVzdC5jb20vaW1nL2Zvby5wbmc"); @@ -31,7 +31,7 @@ public async Task Format() var scope = await GetScopeAsync(); var generator = scope.GetService(); - var generated = generator.Format(testUrl, "jpg"); + var generated = generator.Format(TestUrl, "jpg"); generated.Should() .Be( "https://imgproxy.test.com/UrUQdqnjooZ8VB5f2p88GAAYsxAfMRad3JDDJpIoQEI//aHR0cHM6Ly9pbWcudGVzdC5jb20vaW1nL2Zvby5wbmc.jpg"); @@ -56,7 +56,7 @@ public async Task Build() var scope = await GetScopeAsync(); var generator = scope.GetService(); - var generated = generator.Build(testUrl, builder => builder.WithFormat("jpg")); + var generated = generator.Build(TestUrl, builder => builder.WithFormat("jpg")); generated.Should() .Be( "https://imgproxy.test.com/UrUQdqnjooZ8VB5f2p88GAAYsxAfMRad3JDDJpIoQEI//aHR0cHM6Ly9pbWcudGVzdC5jb20vaW1nL2Zvby5wbmc.jpg"); @@ -68,7 +68,7 @@ public async Task Resize() var scope = await GetScopeAsync(); var generator = scope.GetService(); - var generated = generator.Resize(testUrl, 100, 100); + var generated = generator.Resize(TestUrl, 100, 100); generated.Should() .Be( "https://imgproxy.test.com/jUHPR01P3EetzCxdi8MX9cKbYJ7potdoEMO1NxZAIr4/resize:auto:100:100:0:0/aHR0cHM6Ly9pbWcudGVzdC5jb20vaW1nL2Zvby5wbmc"); diff --git a/tests/Sitko.Core.Repository.EntityFrameworkCore.Tests/Data/TPH/BaseTPHClass.cs b/tests/Sitko.Core.Repository.EntityFrameworkCore.Tests/Data/TPH/BaseTPHClass.cs index 69d8a8251..ba60761eb 100644 --- a/tests/Sitko.Core.Repository.EntityFrameworkCore.Tests/Data/TPH/BaseTPHClass.cs +++ b/tests/Sitko.Core.Repository.EntityFrameworkCore.Tests/Data/TPH/BaseTPHClass.cs @@ -1,12 +1,11 @@ using System.ComponentModel.DataAnnotations.Schema; -using Sitko.Core.Repository.Tests.Data; namespace Sitko.Core.Repository.EntityFrameworkCore.Tests.Data.TPH; public abstract class BaseTPHClass : Entity { public TPHType Type { get; set; } - public string Foo { get; set; } + public string Foo { get; set; } = ""; } public abstract class BaseTPHClass : BaseTPHClass where TConfig : class, new() diff --git a/tests/Sitko.Core.Repository.EntityFrameworkCore.Tests/Data/TPH/FirstTPHClass.cs b/tests/Sitko.Core.Repository.EntityFrameworkCore.Tests/Data/TPH/FirstTPHClass.cs index 5ec5b4367..2d27d1c9d 100644 --- a/tests/Sitko.Core.Repository.EntityFrameworkCore.Tests/Data/TPH/FirstTPHClass.cs +++ b/tests/Sitko.Core.Repository.EntityFrameworkCore.Tests/Data/TPH/FirstTPHClass.cs @@ -2,5 +2,5 @@ public class FirstTPHClass : BaseTPHClass { - public string Bar { get; set; } -} \ No newline at end of file + public string Bar { get; set; } = ""; +} diff --git a/tests/Sitko.Core.Repository.EntityFrameworkCore.Tests/Data/TPH/SecondTPHClass.cs b/tests/Sitko.Core.Repository.EntityFrameworkCore.Tests/Data/TPH/SecondTPHClass.cs index 010cdb41c..d1c7086b1 100644 --- a/tests/Sitko.Core.Repository.EntityFrameworkCore.Tests/Data/TPH/SecondTPHClass.cs +++ b/tests/Sitko.Core.Repository.EntityFrameworkCore.Tests/Data/TPH/SecondTPHClass.cs @@ -2,5 +2,5 @@ public class SecondTPHClass : BaseTPHClass { - public string Baz { get; set; } -} \ No newline at end of file + public string Baz { get; set; } = ""; +} diff --git a/tests/Sitko.Core.Repository.EntityFrameworkCore.Tests/Data/TPH/TPHDbContextsTestScope.cs b/tests/Sitko.Core.Repository.EntityFrameworkCore.Tests/Data/TPH/TPHDbContextsTestScope.cs index 977f28288..d8eb9eee2 100644 --- a/tests/Sitko.Core.Repository.EntityFrameworkCore.Tests/Data/TPH/TPHDbContextsTestScope.cs +++ b/tests/Sitko.Core.Repository.EntityFrameworkCore.Tests/Data/TPH/TPHDbContextsTestScope.cs @@ -1,5 +1,4 @@ -using Sitko.Core.Repository.Tests.Data; -using Sitko.Core.Xunit; +using Sitko.Core.Xunit; namespace Sitko.Core.Repository.EntityFrameworkCore.Tests.Data.TPH; diff --git a/tests/Sitko.Core.Repository.Remote.Tests/RemoteRepositoryTests.cs b/tests/Sitko.Core.Repository.Remote.Tests/RemoteRepositoryTests.cs index 401ff094f..94b6a9523 100644 --- a/tests/Sitko.Core.Repository.Remote.Tests/RemoteRepositoryTests.cs +++ b/tests/Sitko.Core.Repository.Remote.Tests/RemoteRepositoryTests.cs @@ -30,7 +30,7 @@ public async Task Count() var repo = scope.GetService(); var result = await repo.CountAsync(); - Assert.Equal(result, 6); + result.Should().Be(6); } [Fact] @@ -39,8 +39,7 @@ public async Task CountWithCondition() var scope = await GetScopeAsync(); var repo = scope.GetService(); var result = await repo.CountAsync(q => q.Where(t => t.FooId == 5)); - - Assert.Equal(result, 2); + result.Should().Be(2); } [Fact]