diff --git a/src/Markdig/Parsers/MarkdownParser.cs b/src/Markdig/Parsers/MarkdownParser.cs index 07c24c1b..80372f56 100644 --- a/src/Markdig/Parsers/MarkdownParser.cs +++ b/src/Markdig/Parsers/MarkdownParser.cs @@ -2,6 +2,8 @@ // This file is licensed under the BSD-Clause 2 license. // See the license.txt file in the project root for more information. +#nullable enable + using System; using System.Collections.Generic; using Markdig.Helpers; @@ -39,7 +41,7 @@ namespace Markdig.Parsers /// A parser context used for the parsing. /// /// - private MarkdownParser(string text, MarkdownPipeline pipeline, MarkdownParserContext context) + private MarkdownParser(string text, MarkdownPipeline pipeline, MarkdownParserContext? context) { if (text == null) ThrowHelper.ArgumentNullException_text(); if (pipeline == null) ThrowHelper.ArgumentNullException(nameof(pipeline)); @@ -73,7 +75,7 @@ namespace Markdig.Parsers /// A parser context used for the parsing. /// An AST Markdown document /// if reader variable is null - public static MarkdownDocument Parse(string text, MarkdownPipeline pipeline = null, MarkdownParserContext context = null) + public static MarkdownDocument Parse(string text, MarkdownPipeline? pipeline = null, MarkdownParserContext? context = null) { if (text == null) ThrowHelper.ArgumentNullException_text(); pipeline ??= new MarkdownPipelineBuilder().Build(); diff --git a/src/Markdig/Syntax/MarkdownObject.cs b/src/Markdig/Syntax/MarkdownObject.cs index fd8d90db..c4765c46 100644 --- a/src/Markdig/Syntax/MarkdownObject.cs +++ b/src/Markdig/Syntax/MarkdownObject.cs @@ -2,8 +2,10 @@ // This file is licensed under the BSD-Clause 2 license. // See the license.txt file in the project root for more information. -using Markdig.Helpers; +#nullable enable + using System; +using Markdig.Helpers; namespace Markdig.Syntax { @@ -22,7 +24,7 @@ namespace Markdig.Syntax /// as we expect less than 5~10 entries, usually typically 1 (HtmlAttributes) /// so it will gives faster access than a Dictionary, and lower memory occupation /// - private DataEntries _attachedDatas; + private DataEntries? _attachedDatas; /// /// Gets or sets the text column this instance was declared (zero-based). @@ -70,7 +72,7 @@ namespace Markdig.Syntax /// The key. /// The associated data or null if none /// if key is null - public object GetData(object key) => _attachedDatas?.GetData(key); + public object? GetData(object key) => _attachedDatas?.GetData(key); /// /// Removes the associated data for the specified key. @@ -128,9 +130,9 @@ namespace Markdig.Syntax _count++; } - public object GetData(object key) + public object? GetData(object key) { - if (key == null) ThrowHelper.ArgumentNullException_key(); + if (key is null) ThrowHelper.ArgumentNullException_key(); DataEntry[] entries = _entries; int count = _count; @@ -149,7 +151,7 @@ namespace Markdig.Syntax public bool ContainsData(object key) { - if (key == null) ThrowHelper.ArgumentNullException_key(); + if (key is null) ThrowHelper.ArgumentNullException_key(); DataEntry[] entries = _entries; int count = _count; @@ -167,7 +169,7 @@ namespace Markdig.Syntax public bool RemoveData(object key) { - if (key == null) ThrowHelper.ArgumentNullException_key(); + if (key is null) ThrowHelper.ArgumentNullException_key(); DataEntry[] entries = _entries; int count = _count;