Merge pull request #522 from carbon/master

Enable nullability
This commit is contained in:
Alexandre Mutel
2021-03-09 07:13:18 +01:00
committed by GitHub
8 changed files with 123 additions and 57 deletions

View File

@@ -1,7 +1,9 @@
// Copyright (c) Alexandre Mutel. All rights reserved.
// Copyright (c) Alexandre Mutel. All rights reserved.
// 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.Collections.Generic;
namespace Markdig.Helpers
@@ -18,9 +20,9 @@ namespace Markdig.Helpers
/// </summary>
/// <param name="c">The input char.</param>
/// <returns>The simple ASCII string or null if the char itself cannot be simplified</returns>
public static string ConvertToAscii(char c)
public static string? ConvertToAscii(char c)
{
return CodeToAscii.TryGetValue(c, out string str) ? str : null;
return CodeToAscii.TryGetValue(c, out string? str) ? str : null;
}
static CharNormalizer()

View File

@@ -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.Text;
@@ -30,7 +32,8 @@ namespace Markdig.Helpers
}
}
}
public static string EscapeUrlCharacter(char c)
public static string? EscapeUrlCharacter(char c)
{
return c < 128 ? EscapeUrlsForAscii[c] : null;
}
@@ -431,7 +434,7 @@ namespace Markdig.Helpers
/// <param name="text">The string data that will be changed by unescaping any punctuation or symbol characters.</param>
/// <param name="removeBackSlash">if set to <c>true</c> [remove back slash].</param>
/// <returns></returns>
public static string Unescape(string text, bool removeBackSlash = true)
public static string Unescape(string? text, bool removeBackSlash = true)
{
// Credits: code from CommonMark.NET
// Copyright (c) 2014, Kārlis Gaņģis All rights reserved.
@@ -446,9 +449,9 @@ namespace Markdig.Helpers
int lastPos = 0;
char c;
char[] search = removeBackSlash ? SearchBackAndAmp : SearchAmp;
StringBuilder sb = null;
StringBuilder? sb = null;
while ((searchPos = text.IndexOfAny(search, searchPos)) != -1)
while ((searchPos = text!.IndexOfAny(search, searchPos)) != -1)
{
sb ??= StringBuilderCache.Local();
c = text[searchPos];

View File

@@ -2,7 +2,9 @@
// This file is licensed under the BSD-Clause 2 license.
// See the license.txt file in the project root for more information.
using System;
#nullable enable
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using System.Text;
using Markdig.Syntax;
@@ -14,7 +16,7 @@ namespace Markdig.Helpers
/// </summary>
public static class LinkHelper
{
public static bool TryParseAutolink(StringSlice text, out string link, out bool isEmail)
public static bool TryParseAutolink(StringSlice text, [NotNullWhen(true)] out string? link, out bool isEmail)
{
return TryParseAutolink(ref text, out link, out isEmail);
}
@@ -118,7 +120,7 @@ namespace Markdig.Helpers
return c == '_' || c == '-' || c == '.';
}
public static bool TryParseAutolink(ref StringSlice text, out string link, out bool isEmail)
public static bool TryParseAutolink(ref StringSlice text, [NotNullWhen(true)] out string? link, out bool isEmail)
{
link = null;
isEmail = false;
@@ -322,22 +324,22 @@ namespace Markdig.Helpers
return false;
}
public static bool TryParseInlineLink(StringSlice text, out string link, out string title)
public static bool TryParseInlineLink(StringSlice text, out string? link, out string? title)
{
return TryParseInlineLink(ref text, out link, out title, out _, out _);
}
public static bool TryParseInlineLink(StringSlice text, out string link, out string title, out SourceSpan linkSpan, out SourceSpan titleSpan)
public static bool TryParseInlineLink(StringSlice text, out string? link, out string? title, out SourceSpan linkSpan, out SourceSpan titleSpan)
{
return TryParseInlineLink(ref text, out link, out title, out linkSpan, out titleSpan);
}
public static bool TryParseInlineLink(ref StringSlice text, out string link, out string title)
public static bool TryParseInlineLink(ref StringSlice text, out string? link, out string? title)
{
return TryParseInlineLink(ref text, out link, out title, out SourceSpan linkSpan, out SourceSpan titleSpan);
}
public static bool TryParseInlineLink(ref StringSlice text, out string link, out string title, out SourceSpan linkSpan, out SourceSpan titleSpan)
public static bool TryParseInlineLink(ref StringSlice text, out string? link, out string? title, out SourceSpan linkSpan, out SourceSpan titleSpan)
{
// 1. An inline link consists of a link text followed immediately by a left parenthesis (,
// 2. optional whitespace, TODO: specs: is it whitespace or multiple whitespaces?
@@ -417,9 +419,9 @@ namespace Markdig.Helpers
public static bool TryParseInlineLinkTrivia(
ref StringSlice text,
out string link,
out string? link,
out SourceSpan unescapedLink,
out string title,
out string? title,
out SourceSpan unescapedTitle,
out char titleEnclosingCharacter,
out SourceSpan linkSpan,
@@ -521,12 +523,12 @@ namespace Markdig.Helpers
return isValid;
}
public static bool TryParseTitle<T>(T text, out string title) where T : ICharIterator
public static bool TryParseTitle<T>(T text, out string? title) where T : ICharIterator
{
return TryParseTitle(ref text, out title, out _);
}
public static bool TryParseTitle<T>(ref T text, out string title, out char enclosingCharacter) where T : ICharIterator
public static bool TryParseTitle<T>(ref T text, out string? title, out char enclosingCharacter) where T : ICharIterator
{
bool isValid = false;
var buffer = StringBuilderCache.Local();
@@ -620,7 +622,7 @@ namespace Markdig.Helpers
return isValid;
}
public static bool TryParseTitleTrivia<T>(ref T text, out string title, out char enclosingCharacter) where T : ICharIterator
public static bool TryParseTitleTrivia<T>(ref T text, out string? title, out char enclosingCharacter) where T : ICharIterator
{
bool isValid = false;
var buffer = StringBuilderCache.Local();
@@ -714,12 +716,12 @@ namespace Markdig.Helpers
return isValid;
}
public static bool TryParseUrl<T>(T text, out string link) where T : ICharIterator
public static bool TryParseUrl<T>(T text, out string? link) where T : ICharIterator
{
return TryParseUrl(ref text, out link, out _);
}
public static bool TryParseUrl<T>(ref T text, out string link, out bool hasPointyBrackets, bool isAutoLink = false) where T : ICharIterator
public static bool TryParseUrl<T>(ref T text, out string? link, out bool hasPointyBrackets, bool isAutoLink = false) where T : ICharIterator
{
bool isValid = false;
hasPointyBrackets = false;
@@ -859,7 +861,7 @@ namespace Markdig.Helpers
return isValid;
}
public static bool TryParseUrlTrivia<T>(ref T text, out string link, out bool hasPointyBrackets, bool isAutoLink = false) where T : ICharIterator
public static bool TryParseUrlTrivia<T>(ref T text, out string? link, out bool hasPointyBrackets, bool isAutoLink = false) where T : ICharIterator
{
bool isValid = false;
hasPointyBrackets = false;
@@ -1069,7 +1071,7 @@ namespace Markdig.Helpers
segmentCount - lastUnderscoreSegment >= 2; // No underscores are present in the last two segments of the domain
}
public static bool TryParseLinkReferenceDefinition<T>(ref T text, out string label, out string url, out string title, out SourceSpan labelSpan, out SourceSpan urlSpan, out SourceSpan titleSpan) where T : ICharIterator
public static bool TryParseLinkReferenceDefinition<T>(ref T text, out string? label, out string? url, out string? title, out SourceSpan labelSpan, out SourceSpan urlSpan, out SourceSpan titleSpan) where T : ICharIterator
{
url = null;
title = null;
@@ -1158,14 +1160,14 @@ namespace Markdig.Helpers
public static bool TryParseLinkReferenceDefinitionTrivia<T>(
ref T text,
out SourceSpan triviaBeforeLabel,
out string label,
out string? label,
out SourceSpan labelWithTrivia,
out SourceSpan triviaBeforeUrl, // can contain newline
out string url,
out string? url,
out SourceSpan unescapedUrl,
out bool urlHasPointyBrackets,
out SourceSpan triviaBeforeTitle, // can contain newline
out string title, // can contain non-consecutive newlines
out string? title, // can contain non-consecutive newlines
out SourceSpan unescapedTitle,
out char titleEnclosingCharacter,
out NewLine newLine,
@@ -1303,32 +1305,32 @@ namespace Markdig.Helpers
return true;
}
public static bool TryParseLabel<T>(T lines, out string label) where T : ICharIterator
public static bool TryParseLabel<T>(T lines, out string? label) where T : ICharIterator
{
return TryParseLabel(ref lines, false, out label, out SourceSpan labelSpan);
}
public static bool TryParseLabel<T>(T lines, out string label, out SourceSpan labelSpan) where T : ICharIterator
public static bool TryParseLabel<T>(T lines, out string? label, out SourceSpan labelSpan) where T : ICharIterator
{
return TryParseLabel(ref lines, false, out label, out labelSpan);
}
public static bool TryParseLabel<T>(ref T lines, out string label) where T : ICharIterator
public static bool TryParseLabel<T>(ref T lines, out string? label) where T : ICharIterator
{
return TryParseLabel(ref lines, false, out label, out SourceSpan labelSpan);
}
public static bool TryParseLabel<T>(ref T lines, out string label, out SourceSpan labelSpan) where T : ICharIterator
public static bool TryParseLabel<T>(ref T lines, out string? label, out SourceSpan labelSpan) where T : ICharIterator
{
return TryParseLabel(ref lines, false, out label, out labelSpan);
}
public static bool TryParseLabelTrivia<T>(ref T lines, out string label, out SourceSpan labelSpan) where T : ICharIterator
public static bool TryParseLabelTrivia<T>(ref T lines, out string? label, out SourceSpan labelSpan) where T : ICharIterator
{
return TryParseLabelTrivia(ref lines, false, out label, out labelSpan);
}
public static bool TryParseLabel<T>(ref T lines, bool allowEmpty, out string label, out SourceSpan labelSpan) where T : ICharIterator
public static bool TryParseLabel<T>(ref T lines, bool allowEmpty, out string? label, out SourceSpan labelSpan) where T : ICharIterator
{
label = null;
char c = lines.CurrentChar;
@@ -1443,7 +1445,7 @@ namespace Markdig.Helpers
return isValid;
}
public static bool TryParseLabelTrivia<T>(ref T lines, bool allowEmpty, out string label, out SourceSpan labelSpan) where T : ICharIterator
public static bool TryParseLabelTrivia<T>(ref T lines, bool allowEmpty, out string? label, out SourceSpan labelSpan) where T : ICharIterator
{
label = null;
char c = lines.CurrentChar;

View File

@@ -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;
using System.Collections.Generic;
@@ -30,6 +32,7 @@ namespace Markdig.Helpers
Lines = _pool.Rent(capacity);
Count = 0;
}
internal StringLineGroup(int capacity, bool willRelease)
{
if (capacity <= 0) ThrowHelper.ArgumentOutOfRangeException(nameof(capacity));
@@ -116,7 +119,7 @@ namespace Markdig.Helpers
/// </summary>
/// <param name="lineOffsets">The position of the `\n` line offsets from the beginning of the returned slice.</param>
/// <returns>A single slice concatenating the lines of this instance</returns>
public readonly StringSlice ToSlice(List<LineOffset> lineOffsets = null)
public readonly StringSlice ToSlice(List<LineOffset>? lineOffsets = null)
{
// Optimization case for a single line.
if (Count == 1)
@@ -201,7 +204,7 @@ namespace Markdig.Helpers
{
Array.Clear(Lines, 0, Count);
_pool.Return(Lines);
Lines = null;
Lines = null!;
Count = -1;
}

View File

@@ -15,24 +15,52 @@ namespace Markdig.Helpers
[ExcludeFromCodeCoverage]
internal static class ThrowHelper
{
[DoesNotReturn]
public static void ArgumentNullException(string paramName) => throw new ArgumentNullException(paramName);
[DoesNotReturn]
public static void ArgumentNullException_item() => throw new ArgumentNullException("item");
[DoesNotReturn]
public static void ArgumentNullException_text() => throw new ArgumentNullException("text");
[DoesNotReturn]
public static void ArgumentNullException_label() => throw new ArgumentNullException("label");
[DoesNotReturn]
public static void ArgumentNullException_key() => throw new ArgumentNullException("key");
[DoesNotReturn]
public static void ArgumentNullException_name() => throw new ArgumentNullException("name");
[DoesNotReturn]
public static void ArgumentNullException_markdown() => throw new ArgumentNullException("markdown");
[DoesNotReturn]
public static void ArgumentNullException_writer() => throw new ArgumentNullException("writer");
[DoesNotReturn]
public static void ArgumentNullException_leafBlock() => throw new ArgumentNullException("leafBlock");
[DoesNotReturn]
public static void ArgumentNullException_markdownObject() => throw new ArgumentNullException("markdownObject");
[DoesNotReturn]
public static void ArgumentException(string message) => throw new ArgumentException(message);
[DoesNotReturn]
public static void ArgumentException(string message, string paramName) => throw new ArgumentException(message, paramName);
[DoesNotReturn]
public static void ArgumentOutOfRangeException(string paramName) => throw new ArgumentOutOfRangeException(paramName);
[DoesNotReturn]
public static void ArgumentOutOfRangeException(string message, string paramName) => throw new ArgumentOutOfRangeException(message, paramName);
[DoesNotReturn]
public static void ArgumentOutOfRangeException_index() => throw new ArgumentOutOfRangeException("index");
[DoesNotReturn]
public static void InvalidOperationException(string message) => throw new InvalidOperationException(message);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -57,21 +85,25 @@ namespace Markdig.Helpers
static void DepthLimitExceeded() => throw new ArgumentException("Markdown elements in the input are too deeply nested - depth limit exceeded. Input is most likely not sensible or is a very large table.");
}
[DoesNotReturn]
public static void ThrowArgumentNullException(ExceptionArgument argument)
{
throw new ArgumentNullException(argument.ToString());
}
[DoesNotReturn]
public static void ThrowArgumentException(ExceptionArgument argument, ExceptionReason reason)
{
throw new ArgumentException(argument.ToString(), GetExceptionReason(reason));
}
[DoesNotReturn]
public static void ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionReason reason)
{
throw new ArgumentOutOfRangeException(argument.ToString(), GetExceptionReason(reason));
}
[DoesNotReturn]
public static void ThrowIndexOutOfRangeException()
{
throw new IndexOutOfRangeException();

View File

@@ -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.IO;
using System.Reflection;
@@ -29,7 +31,7 @@ namespace Markdig
/// <param name="pipeline">The pipeline.</param>
/// <param name="context">A parser context used for the parsing.</param>
/// <returns>A normalized markdown text.</returns>
public static string Normalize(string markdown, NormalizeOptions options = null, MarkdownPipeline pipeline = null, MarkdownParserContext context = null)
public static string Normalize(string markdown, NormalizeOptions? options = null, MarkdownPipeline? pipeline = null, MarkdownParserContext? context = null)
{
var writer = new StringWriter();
Normalize(markdown, writer, options, pipeline, context);
@@ -45,7 +47,7 @@ namespace Markdig
/// <param name="pipeline">The pipeline.</param>
/// <param name="context">A parser context used for the parsing.</param>
/// <returns>A normalized markdown text.</returns>
public static MarkdownDocument Normalize(string markdown, TextWriter writer, NormalizeOptions options = null, MarkdownPipeline pipeline = null, MarkdownParserContext context = null)
public static MarkdownDocument Normalize(string markdown, TextWriter writer, NormalizeOptions? options = null, MarkdownPipeline? pipeline = null, MarkdownParserContext? context = null)
{
pipeline ??= new MarkdownPipelineBuilder().Build();
pipeline = CheckForSelfPipeline(pipeline, markdown);
@@ -69,9 +71,9 @@ namespace Markdig
/// <param name="context">A parser context used for the parsing.</param>
/// <returns>The result of the conversion</returns>
/// <exception cref="ArgumentNullException">if markdown variable is null</exception>
public static string ToHtml(string markdown, MarkdownPipeline pipeline = null, MarkdownParserContext context = null)
public static string ToHtml(string markdown, MarkdownPipeline? pipeline = null, MarkdownParserContext? context = null)
{
if (markdown == null) ThrowHelper.ArgumentNullException_markdown();
if (markdown is null) ThrowHelper.ArgumentNullException_markdown();
pipeline ??= new MarkdownPipelineBuilder().Build();
pipeline = CheckForSelfPipeline(pipeline, markdown);
@@ -81,7 +83,7 @@ namespace Markdig
renderer.Render(document);
renderer.Writer.Flush();
string html = renderer.Writer.ToString();
string html = renderer.Writer.ToString()!;
pipeline.ReleaseCacheableHtmlRenderer(renderer);
return html;
}
@@ -95,10 +97,10 @@ namespace Markdig
/// <param name="context">A parser context used for the parsing.</param>
/// <returns>The Markdown document that has been parsed</returns>
/// <exception cref="ArgumentNullException">if reader or writer variable are null</exception>
public static MarkdownDocument ToHtml(string markdown, TextWriter writer, MarkdownPipeline pipeline = null, MarkdownParserContext context = null)
public static MarkdownDocument ToHtml(string markdown, TextWriter writer, MarkdownPipeline? pipeline = null, MarkdownParserContext? context = null)
{
if (markdown == null) ThrowHelper.ArgumentNullException_markdown();
if (writer == null) ThrowHelper.ArgumentNullException_writer();
if (markdown is null) ThrowHelper.ArgumentNullException_markdown();
if (writer is null) ThrowHelper.ArgumentNullException_writer();
pipeline ??= new MarkdownPipelineBuilder().Build();
pipeline = CheckForSelfPipeline(pipeline, markdown);
@@ -121,10 +123,10 @@ namespace Markdig
/// <param name="pipeline">The pipeline used for the conversion.</param>
/// <param name="context">A parser context used for the parsing.</param>
/// <exception cref="ArgumentNullException">if markdown or writer variable are null</exception>
public static object Convert(string markdown, IMarkdownRenderer renderer, MarkdownPipeline pipeline = null, MarkdownParserContext context = null)
public static object Convert(string markdown, IMarkdownRenderer renderer, MarkdownPipeline? pipeline = null, MarkdownParserContext? context = null)
{
if (markdown == null) ThrowHelper.ArgumentNullException_markdown();
if (renderer == null) ThrowHelper.ArgumentNullException(nameof(renderer));
if (markdown is null) ThrowHelper.ArgumentNullException_markdown();
if (renderer is null) ThrowHelper.ArgumentNullException(nameof(renderer));
pipeline ??= new MarkdownPipelineBuilder().Build();
pipeline = CheckForSelfPipeline(pipeline, markdown);
@@ -141,9 +143,9 @@ namespace Markdig
/// <exception cref="ArgumentNullException">if markdown variable is null</exception>
public static MarkdownDocument Parse(string markdown, bool trackTrivia = false)
{
if (markdown == null) ThrowHelper.ArgumentNullException_markdown();
if (markdown is null) ThrowHelper.ArgumentNullException_markdown();
MarkdownPipeline pipeline = trackTrivia ? new MarkdownPipelineBuilder()
MarkdownPipeline? pipeline = trackTrivia ? new MarkdownPipelineBuilder()
.EnableTrackTrivia()
.Build() : null;
@@ -158,9 +160,9 @@ namespace Markdig
/// <param name="context">A parser context used for the parsing.</param>
/// <returns>An AST Markdown document</returns>
/// <exception cref="ArgumentNullException">if markdown variable is null</exception>
public static MarkdownDocument Parse(string markdown, MarkdownPipeline pipeline, MarkdownParserContext context = null)
public static MarkdownDocument Parse(string markdown, MarkdownPipeline? pipeline, MarkdownParserContext? context = null)
{
if (markdown == null) ThrowHelper.ArgumentNullException_markdown();
if (markdown is null) ThrowHelper.ArgumentNullException_markdown();
pipeline ??= new MarkdownPipelineBuilder().Build();
pipeline = CheckForSelfPipeline(pipeline, markdown);
@@ -186,7 +188,7 @@ namespace Markdig
/// <param name="context">A parser context used for the parsing.</param>
/// <returns>The Markdown document that has been parsed</returns>
/// <exception cref="ArgumentNullException">if reader or writer variable are null</exception>
public static MarkdownDocument ToPlainText(string markdown, TextWriter writer, MarkdownPipeline pipeline = null, MarkdownParserContext context = null)
public static MarkdownDocument ToPlainText(string markdown, TextWriter writer, MarkdownPipeline? pipeline = null, MarkdownParserContext? context = null)
{
if (markdown == null) ThrowHelper.ArgumentNullException_markdown();
if (writer == null) ThrowHelper.ArgumentNullException_writer();
@@ -217,7 +219,7 @@ namespace Markdig
/// <param name="context">A parser context used for the parsing.</param>
/// <returns>The result of the conversion</returns>
/// <exception cref="ArgumentNullException">if markdown variable is null</exception>
public static string ToPlainText(string markdown, MarkdownPipeline pipeline = null, MarkdownParserContext context = null)
public static string ToPlainText(string markdown, MarkdownPipeline? pipeline = null, MarkdownParserContext? context = null)
{
if (markdown == null) ThrowHelper.ArgumentNullException_markdown();
var writer = new StringWriter();

View File

@@ -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 Markdig.Extensions.Abbreviations;
using Markdig.Extensions.AutoIdentifiers;
@@ -101,7 +103,7 @@ namespace Markdig
/// <param name="pipeline">The pipeline.</param>
/// <param name="options">The options.</param>
/// <returns>The modified pipeline</returns>
public static MarkdownPipelineBuilder UseAutoLinks(this MarkdownPipelineBuilder pipeline, AutoLinkOptions options = null)
public static MarkdownPipelineBuilder UseAutoLinks(this MarkdownPipelineBuilder pipeline, AutoLinkOptions? options = null)
{
pipeline.Extensions.ReplaceOrAdd<AutoLinkExtension>(new AutoLinkExtension(options));
return pipeline;
@@ -136,7 +138,7 @@ namespace Markdig
/// <param name="defaultTag">The default tag to use to match the self pipeline configuration. By default, <see cref="SelfPipelineExtension.DefaultTag"/>, meaning that the HTML tag will be &lt;--markdig:extensions--&gt;</param>
/// <param name="defaultExtensions">The default extensions to configure if no pipeline setup was found from the Markdown document</param>
/// <returns>The modified pipeline</returns>
public static MarkdownPipelineBuilder UseSelfPipeline(this MarkdownPipelineBuilder pipeline, string defaultTag = SelfPipelineExtension.DefaultTag, string defaultExtensions = null)
public static MarkdownPipelineBuilder UseSelfPipeline(this MarkdownPipelineBuilder pipeline, string defaultTag = SelfPipelineExtension.DefaultTag, string? defaultExtensions = null)
{
if (pipeline.Extensions.Count != 0)
{
@@ -210,7 +212,7 @@ namespace Markdig
/// <returns>
/// The modified pipeline
/// </returns>
public static MarkdownPipelineBuilder UseMediaLinks(this MarkdownPipelineBuilder pipeline, MediaOptions options = null)
public static MarkdownPipelineBuilder UseMediaLinks(this MarkdownPipelineBuilder pipeline, MediaOptions? options = null)
{
if (!pipeline.Extensions.Contains<MediaLinkExtension>())
{
@@ -244,7 +246,7 @@ namespace Markdig
/// <returns>
/// The modified pipeline
/// </returns>
public static MarkdownPipelineBuilder UseSmartyPants(this MarkdownPipelineBuilder pipeline, SmartyPantOptions options = null)
public static MarkdownPipelineBuilder UseSmartyPants(this MarkdownPipelineBuilder pipeline, SmartyPantOptions? options = null)
{
if (!pipeline.Extensions.Contains<SmartyPantsExtension>())
{
@@ -316,7 +318,7 @@ namespace Markdig
/// <returns>
/// The modified pipeline
/// </returns>
public static MarkdownPipelineBuilder UsePipeTables(this MarkdownPipelineBuilder pipeline, PipeTableOptions options = null)
public static MarkdownPipelineBuilder UsePipeTables(this MarkdownPipelineBuilder pipeline, PipeTableOptions? options = null)
{
if (!pipeline.Extensions.Contains<PipeTableExtension>())
{

View File

@@ -0,0 +1,20 @@
// Based on code at located at https://github.com/dotnet/runtime/blob/79ae74f5ca5c8a6fe3a48935e85bd7374959c570/src/libraries/System.Private.CoreLib/src/System/Diagnostics/CodeAnalysis/NullableAttributes.cs
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace System.Diagnostics.CodeAnalysis
{
#if !NETCORE || NETCOREAPP2_1
internal sealed class DoesNotReturnAttribute : Attribute { }
[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
internal sealed class NotNullWhenAttribute : Attribute
{
public NotNullWhenAttribute(bool returnValue) => ReturnValue = returnValue;
public bool ReturnValue { get; }
}
#endif
}