Skip to content

Commit 7106cf7

Browse files
committed
Enable NRT. Drop support for .NET Standard.
The library will target .NET 8.0 only.
1 parent 6a46b1b commit 7106cf7

16 files changed

+727
-810
lines changed

MwParserFromScratch/MwParserFromScratch.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netstandard2.0;net8.0</TargetFrameworks>
4+
<TargetFrameworks>net8.0</TargetFrameworks>
55
<LangVersion>latest</LangVersion>
6+
<Nullable>enable</Nullable>
7+
<ImplicitUsings>enable</ImplicitUsings>
68
<GenerateDocumentationFile>true</GenerateDocumentationFile>
79

810
<AssemblyName>MwParserFromScratch</AssemblyName>

MwParserFromScratch/MwParserUtility.cs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
1+
using System.Diagnostics.CodeAnalysis;
62
using MwParserFromScratch.Nodes;
73

84
namespace MwParserFromScratch;
@@ -15,7 +11,8 @@ public static class MwParserUtility
1511

1612
/// <inheritdoc cref="NormalizeTemplateArgumentName(string)"/>
1713
/// <param name="argumentName">The argument name to be normalized. The node will be converted into its string representation.</param>
18-
public static string NormalizeTemplateArgumentName(Node argumentName)
14+
[return: NotNullIfNotNull(nameof(argumentName))]
15+
public static string? NormalizeTemplateArgumentName(Node? argumentName)
1916
{
2017
if (argumentName == null) return null;
2118
return NormalizeTemplateArgumentName(argumentName.ToString());
@@ -27,18 +24,20 @@ public static string NormalizeTemplateArgumentName(Node argumentName)
2724
/// <param name="argumentName">The argument name to be normalized.</param>
2825
/// <returns>The normalized argument name, with leading and trailing whitespace removed,
2926
/// or <c>null</c> if <paramref name="argumentName"/> is <c>null</c>.</returns>
30-
public static string NormalizeTemplateArgumentName(string argumentName)
27+
[return: NotNullIfNotNull(nameof(argumentName))]
28+
public static string? NormalizeTemplateArgumentName(string? argumentName)
3129
{
3230
if (string.IsNullOrEmpty(argumentName)) return argumentName;
3331
return argumentName.Trim();
3432
}
3533

3634
/// <inheritdoc cref="NormalizeImageLinkArgumentName(string)"/>
3735
/// <param name="argumentName">The argument name to be normalized. The node will be converted into its string representation.</param>
38-
public static string NormalizeImageLinkArgumentName(Node argumentName)
36+
[return: NotNullIfNotNull(nameof(argumentName))]
37+
public static string? NormalizeImageLinkArgumentName(Node? argumentName)
3938
{
4039
if (argumentName == null) return null;
41-
return NormalizeImageLinkArgumentName(argumentName.ToString());
40+
return NormalizeImageLinkArgumentName(argumentName.ToString()!);
4241
}
4342

4443
/// <summary>
@@ -47,7 +46,8 @@ public static string NormalizeImageLinkArgumentName(Node argumentName)
4746
/// <param name="argumentName">The argument name to be normalized.</param>
4847
/// <returns>The normalized argument name, with leading and trailing whitespace removed, and first letter converted into lowercase
4948
/// or <c>null</c> if <paramref name="argumentName"/> is <c>null</c>.</returns>
50-
public static string NormalizeImageLinkArgumentName(string argumentName)
49+
[return: NotNullIfNotNull(nameof(argumentName))]
50+
public static string? NormalizeImageLinkArgumentName(string? argumentName)
5151
{
5252
if (string.IsNullOrEmpty(argumentName)) return argumentName;
5353
argumentName = argumentName.Trim();
@@ -61,7 +61,7 @@ public static string NormalizeImageLinkArgumentName(string argumentName)
6161

6262
/// <inheritdoc cref="NormalizeTitle(string)"/>
6363
/// <param name="title">The title to be normalized. The node will be converted into its string representation.</param>
64-
public static string NormalizeTitle(Node title)
64+
public static string? NormalizeTitle(Node? title)
6565
{
6666
if (title == null) return null;
6767
return NormalizeTitle(title.ToString());
@@ -77,12 +77,13 @@ public static string NormalizeTitle(Node title)
7777
/// <returns>The normalized argument name, with leading and trailing whitespace removed,
7878
/// underscore replaced with space, starting with an upper-case letter.
7979
/// Or <c>null</c> if <paramref name="title"/> is <c>null</c>.</returns>
80-
public static string NormalizeTitle(string title)
80+
public static string? NormalizeTitle(string? title)
8181
{
8282
if (string.IsNullOrEmpty(title)) return title;
83-
var parts = title.Split(new[] {':'}, 2);
83+
var parts = title.Split([':'], 2);
8484
for (int i = 0; i < parts.Length; i++)
8585
parts[i] = Utility.NormalizeTitlePart(parts[i], false);
8686
return string.Join(":", parts);
8787
}
88+
8889
}

0 commit comments

Comments
 (0)