Skip to content

Commit fd59e29

Browse files
committed
Fix nullable issues
1 parent c2fee01 commit fd59e29

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

src/ProfanityFilter.Action/Extensions/SummaryExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ internal static Summary AddFilterResultSection(this Summary summary, string sect
5353
]),
5454
];
5555

56-
static string ReplaceNewLinesWithHtmlBreaks(string content)
56+
static string ReplaceNewLinesWithHtmlBreaks(string? content)
5757
{
58-
return NewLineRegex().Replace(content, "<br>");
58+
return NewLineRegex().Replace(content ?? "", "<br>");
5959
}
6060

6161
foreach (var step in result.Steps ?? [])

src/ProfanityFilter.Action/Models/FilterationResult.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ internal readonly record struct FiltrationResult(
3838
/// Gets the final output of the title.
3939
/// </summary>
4040
internal string Title => IsTitleFiltered
41-
? TitleResult.FinalOutput ?? TitleResult.Input
41+
? TitleResult.FinalOutput ?? TitleResult.Input ?? "N/A"
4242
: "";
4343

4444
/// <summary>
4545
/// Gets the final output of the body.
4646
/// </summary>
4747
internal string Body => IsBodyFiltered
48-
? BodyResult.FinalOutput ?? BodyResult.Input
48+
? BodyResult.FinalOutput ?? BodyResult.Input ?? "N/A"
4949
: "";
5050
}

tests/ProfanityFilter.Services.Tests/DefaultProfaneContentFilterServiceTests.cs

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

4+
using Microsoft.Extensions.Logging.Abstractions;
45
using ProfanityFilter.Services.Filters;
56

67
namespace ProfanityFilter.Services.Tests;
@@ -11,7 +12,8 @@ public class DefaultProfaneContentFilterServiceTests
1112
private readonly IProfaneContentFilterService _sut;
1213

1314
public DefaultProfaneContentFilterServiceTests() => _sut = new DefaultProfaneContentFilterService(
14-
new MemoryCache(Options.Create<MemoryCacheOptions>(new())));
15+
cache: new MemoryCache(Options.Create<MemoryCacheOptions>(new())),
16+
logger: NullLogger<DefaultProfaneContentFilterService>.Instance);
1517

1618
[TestMethod]
1719
[DataRow(null, null)]

0 commit comments

Comments
 (0)