Skip to content

Commit

Permalink
Fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Psichorex committed Jan 30, 2024
1 parent 48ccf0a commit dbfd82a
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 15 deletions.
3 changes: 2 additions & 1 deletion Lombiq.HelpfulLibraries.AspNetCore/Mvc/JsonModelBinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace Lombiq.HelpfulLibraries.AspNetCore.Mvc;

public class JsonModelBinder : IModelBinder
{
private static readonly JsonSerializerOptions SerializeOptions = new(JsonSerializerDefaults.Web);
private readonly ILogger<JsonModelBinder> _logger;
private readonly IObjectModelValidator _validator;

Expand All @@ -28,7 +29,7 @@ public Task BindModelAsync(ModelBindingContext bindingContext)
var parsed = value is null ? null : JsonSerializer.Deserialize(
value,
bindingContext.ModelType,
new JsonSerializerOptions(JsonSerializerDefaults.Web));
SerializeOptions);

if (parsed is null)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
Expand Down Expand Up @@ -46,19 +46,19 @@ public ValueTask UpdateAsync(IDictionary<string, string> securityPolicies, HttpC
{
var any = false;

if (PermittedStyleSources.Any())
if (!PermittedStyleSources.IsEmpty)
{
any = true;
MergeValues(securityPolicies, StyleSrc, PermittedStyleSources);
}

if (PermittedScriptSources.Any())
if (!PermittedScriptSources.IsEmpty)
{
any = true;
MergeValues(securityPolicies, ScriptSrc, PermittedScriptSources);
}

if (PermittedFontSources.Any())
if (!PermittedFontSources.IsEmpty)
{
any = true;
MergeValues(securityPolicies, FontSrc, PermittedFontSources);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static class RandomNumberGeneratorExtensions
/// </remarks>
public static int Next(this RandomNumberGenerator randomNumberGenerator, int minValue, int maxValue)
{
if (minValue > maxValue) throw new ArgumentOutOfRangeException(nameof(minValue));
ArgumentOutOfRangeException.ThrowIfGreaterThan(minValue, maxValue);
if (minValue == maxValue) return minValue;

var diff = (long)maxValue - minValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public async Task InvokeAsync(HttpContext context)
.ToList();

IList<string> themes =
providers.Exists(providerInfo => providerInfo.ThemeRequirements.Any())
providers.Exists(providerInfo => providerInfo.ThemeRequirements.Count != 0)
? new[]
{
await context.RequestServices.GetRequiredService<ISiteThemeService>().GetSiteThemeAsync(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public async Task<ShapeTable> GetShapeTableAsync(string themeId)
private static void BuildDescriptors(
IShapeTableProvider bindingStrategy,
IEnumerable<ShapeAlteration> builtAlterations,
IDictionary<string, FeatureShapeDescriptor> shapeDescriptors)
Dictionary<string, FeatureShapeDescriptor> shapeDescriptors)
{
var alterationSets = builtAlterations.GroupBy(a => a.Feature.Id + a.ShapeType);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ namespace Lombiq.HelpfulLibraries.OrchardCore.Users;

public class CachingUserManager : ICachingUserManager
{
private readonly Dictionary<string, User> _userByNameCache = new();
private readonly Dictionary<string, User> _userByEmailCache = new();
private readonly Dictionary<string, User> _userByIdCache = new();
private readonly Dictionary<string, User> _userByUserIdCache = new();
private readonly Dictionary<string, User> _userByNameCache = [];
private readonly Dictionary<string, User> _userByEmailCache = [];
private readonly Dictionary<string, User> _userByIdCache = [];
private readonly Dictionary<string, User> _userByUserIdCache = [];

private readonly Lazy<UserManager<IUser>> _userManagerLazy;
private readonly Lazy<ISession> _sessionLazy;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private ValueTask NotifyAsync(LocalizedString title, IDictionary<string, string>
layout,
layout,
isResourceNotFound: false,
[.. arguments]));
arguments));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class ManualConnectingIndexServiceTests : IClassFixture<ManualConnectingI
public const string NamePrefix = "test_";

private readonly ManualConnectingIndexServiceFixture _fixture;
private static readonly int[] Numbers = [3, 6];

public ManualConnectingIndexServiceTests(ManualConnectingIndexServiceFixture fixture) => _fixture = fixture;

Expand Down Expand Up @@ -43,8 +44,7 @@ public Task AllIndexShouldRetrieveItsDocument() => _fixture.SessionAsync(async s
[Fact]
public Task MissingOrDeletedIndexShouldNotRetrieveAnyDocument() => _fixture.SessionAsync(async session =>
{
var numbers = new[] { 3, 6 };
var documents = (await session.Query<TestDocument, TestDocumentIndex>(index => index.Number.IsIn(numbers)).ListAsync()).ToList();
var documents = (await session.Query<TestDocument, TestDocumentIndex>(index => index.Number.IsIn(Numbers)).ListAsync()).ToList();
documents.ShouldBeEmpty();
});
}

0 comments on commit dbfd82a

Please sign in to comment.