Skip to content

Commit c2fee01

Browse files
committed
Added a few bits
1 parent 1b9a0b0 commit c2fee01

27 files changed

+185
-76
lines changed

Directory.Packages.props

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66
<Nullable>enable</Nullable>
77
</PropertyGroup>
88
<ItemGroup>
9+
<PackageVersion Include="Blazor.LocalStorage" Version="8.0.0" />
910
<PackageVersion Include="coverlet.collector" Version="6.0.2" PrivateAssets="all" IncludeAssets="runtime;build;native;contentfiles;analyzers;buildtransitive" />
1011
<PackageVersion Include="GitHub.Actions.Core" Version="8.0.16" />
1112
<PackageVersion Include="GitHub.Actions.Octokit" Version="8.0.16" />
1213
<PackageVersion Include="GitHubActionsTestLogger" Version="2.3.3" PrivateAssets="all" IncludeAssets="runtime;build;native;contentfiles;analyzers;buildtransitive" />
1314
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="8.0.7" />
1415
<PackageVersion Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="8.0.7" />
1516
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="8.0.0" />
17+
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
1618
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.1" />
1719
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
1820
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
@@ -23,7 +25,7 @@
2325
<PackageVersion Include="MSTest.Analyzers" Version="3.5.0" PrivateAssets="all" IncludeAssets="runtime;build;native;contentfiles;analyzers;buildtransitive" />
2426
<PackageVersion Include="Nito.AsyncEx.Coordination" Version="5.1.2" />
2527
<PackageVersion Include="Pathological.Globbing" Version="8.0.4" />
26-
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.6.2" />
28+
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.7.0" />
2729
<PackageVersion Include="Markdig" Version="0.37.0" />
2830
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.7" />
2931
<PackageVersion Include="Microsoft.AspNetCore.SignalR.Client" Version="8.0.7" />

src/ProfanityFilter.Services/Data/ProfaneContentReader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) David Pine. All rights reserved.
22
// Licensed under the MIT License.
33

4-
namespace ProfanityFilter.Services;
4+
namespace ProfanityFilter.Services.Data;
55

66
internal sealed class ProfaneContentReader
77
{

src/ProfanityFilter.Services/DefaultProfaneContentFilterService.cs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44
namespace ProfanityFilter.Services;
55

6-
internal sealed class DefaultProfaneContentFilterService(IMemoryCache cache) : IProfaneContentFilterService
6+
internal sealed class DefaultProfaneContentFilterService(
7+
IMemoryCache cache,
8+
ILogger<DefaultProfaneContentFilterService> logger) : IProfaneContentFilterService
79
{
810
private const string ProfaneListKey = nameof(ProfaneListKey);
911

@@ -15,20 +17,21 @@ public async Task<Dictionary<string, ProfaneSourceFilter>> ReadAllProfaneWordsAs
1517
{
1618
var fileNames = ProfaneContentReader.GetFileNames();
1719

18-
Console.WriteLine("Source word list for profane content:");
20+
logger.LogInformation("Source word list for profane content:");
1921

20-
foreach (var fileName in fileNames)
22+
foreach (var (index, fileName) in fileNames.Select((f, i) => (i, f)))
2123
{
22-
Console.WriteLine(fileName);
24+
logger.LogInformation("{index} {file}", index + 1, fileName);
2325
}
2426

2527
ConcurrentDictionary<string, List<string>> allWords = new(
2628
fileNames.Select(
2729
static fileName => new KeyValuePair<string, List<string>>(fileName, [])));
2830

29-
await Parallel.ForEachAsync(fileNames,
30-
cancellationToken,
31-
async (fileName, cancellationToken) =>
31+
await Parallel.ForEachAsync(
32+
source: fileNames,
33+
cancellationToken: cancellationToken,
34+
body: async (fileName, cancellationToken) =>
3235
{
3336
var content = await ProfaneContentReader.ReadAsync(
3437
fileName, cancellationToken);
@@ -61,11 +64,12 @@ await Parallel.ForEachAsync(fileNames,
6164

6265
/// <inheritdoc />
6366
public async ValueTask<FilterResult> FilterProfanityAsync(
64-
string content,
67+
string? content,
6568
FilterParameters parameters,
6669
CancellationToken cancellationToken)
6770
{
6871
var (strategy, target) = parameters;
72+
6973
FilterResult result = new(content, parameters);
7074

7175
if (string.IsNullOrWhiteSpace(content))

src/ProfanityFilter.Services/Extensions/ServiceCollectionExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) David Pine. All rights reserved.
22
// Licensed under the MIT License.
33

4-
namespace ProfanityFilter.Services.Extensions;
4+
namespace Microsoft.Extensions.DependencyInjection;
55

66
/// <summary>
77
/// Provides extension methods for configuring services related to profanity filtering.

src/ProfanityFilter.Services/Filters/Emoji.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) David Pine. All rights reserved.
22
// Licensed under the MIT License.
33

4-
namespace ProfanityFilter.Services;
4+
namespace ProfanityFilter.Services.Filters;
55

66
/// <summary>
77
/// Provides a collection of hand-selected emoji replacements for profanity words.

src/ProfanityFilter.Services/Filters/FilterTarget.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) David Pine. All rights reserved.
22
// Licensed under the MIT License.
33

4-
namespace ProfanityFilter.Services;
4+
namespace ProfanityFilter.Services.Filters;
55

66
/// <summary>
77
/// Represents the filter target, meaning whether the filter is

src/ProfanityFilter.Services/Filters/ProfaneSourceFilter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) David Pine. All rights reserved.
22
// Licensed under the MIT License.
33

4-
namespace ProfanityFilter.Services;
4+
namespace ProfanityFilter.Services.Filters;
55

66
/// <summary>
77
/// Represents a filter source that is used as an additive to the existing profane definitions.

src/ProfanityFilter.Services/Filters/ReplacementStrategy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) David Pine. All rights reserved.
22
// Licensed under the MIT License.
33

4-
namespace ProfanityFilter.Services;
4+
namespace ProfanityFilter.Services.Filters;
55

66
/// <summary>
77
/// Specifies the strategy to use when replacing a profane word.

src/ProfanityFilter.Services/GlobalUsings.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,20 @@
55
global using System.Collections.Frozen;
66
global using System.Diagnostics.CodeAnalysis;
77
global using System.Text;
8-
global using System.Text.RegularExpressions;
98
global using System.Text.Json.Serialization;
9+
global using System.Text.RegularExpressions;
1010

1111
global using Microsoft.Extensions.Caching.Memory;
12-
global using Microsoft.Extensions.DependencyInjection;
12+
global using Microsoft.Extensions.Logging;
1313

1414
global using Pathological.Globbing.Extensions;
1515
global using Pathological.Globbing.Options;
1616

17+
global using ProfanityFilter.Services;
18+
global using ProfanityFilter.Services.Data;
1719
global using ProfanityFilter.Services.Extensions;
1820
global using ProfanityFilter.Services.Filters;
21+
global using ProfanityFilter.Services.Internals;
1922
global using ProfanityFilter.Services.Results;
2023

2124
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo(

src/ProfanityFilter.Services/IProfaneContentFilterService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public interface IProfaneContentFilterService
1717
/// <returns>A <see cref="ValueTask{TResult}"/> representing the asynchronous
1818
/// operation, containing the filtered content.</returns>
1919
ValueTask<FilterResult> FilterProfanityAsync(
20-
string content,
20+
string? content,
2121
FilterParameters parameters,
2222
CancellationToken cancellationToken = default);
2323

0 commit comments

Comments
 (0)