mirror of
https://github.com/xoofx/markdig.git
synced 2026-11-17 18:00:55 +00:00
Bump .NET framework target to net462
This commit is contained in:
@@ -2,6 +2,7 @@ using NUnit.Framework;
|
||||
using Markdig.Helpers;
|
||||
using Markdig.Syntax;
|
||||
using Markdig.Syntax.Inlines;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -32,9 +33,9 @@ namespace Markdig.Tests
|
||||
|
||||
foreach (LiteralInline literalInline in syntaxTree.Descendants<LiteralInline>())
|
||||
{
|
||||
Assert.AreSame(ArrayHelper.Empty<ListBlock>(), literalInline.Descendants<ListBlock>());
|
||||
Assert.AreSame(ArrayHelper.Empty<ParagraphBlock>(), literalInline.Descendants<ParagraphBlock>());
|
||||
Assert.AreSame(ArrayHelper.Empty<ContainerInline>(), literalInline.Descendants<ContainerInline>());
|
||||
Assert.AreSame(Array.Empty<ListBlock>(), literalInline.Descendants<ListBlock>());
|
||||
Assert.AreSame(Array.Empty<ParagraphBlock>(), literalInline.Descendants<ParagraphBlock>());
|
||||
Assert.AreSame(Array.Empty<ContainerInline>(), literalInline.Descendants<ContainerInline>());
|
||||
}
|
||||
|
||||
foreach (ContainerInline containerInline in syntaxTree.Descendants<ContainerInline>())
|
||||
@@ -49,13 +50,13 @@ namespace Markdig.Tests
|
||||
|
||||
if (containerInline.FirstChild is null)
|
||||
{
|
||||
Assert.AreSame(ArrayHelper.Empty<LiteralInline>(), containerInline.Descendants<LiteralInline>());
|
||||
Assert.AreSame(ArrayHelper.Empty<LiteralInline>(), containerInline.FindDescendants<LiteralInline>());
|
||||
Assert.AreSame(ArrayHelper.Empty<LiteralInline>(), (containerInline as MarkdownObject).Descendants<LiteralInline>());
|
||||
Assert.AreSame(Array.Empty<LiteralInline>(), containerInline.Descendants<LiteralInline>());
|
||||
Assert.AreSame(Array.Empty<LiteralInline>(), containerInline.FindDescendants<LiteralInline>());
|
||||
Assert.AreSame(Array.Empty<LiteralInline>(), (containerInline as MarkdownObject).Descendants<LiteralInline>());
|
||||
}
|
||||
|
||||
Assert.AreSame(ArrayHelper.Empty<ListBlock>(), containerInline.Descendants<ListBlock>());
|
||||
Assert.AreSame(ArrayHelper.Empty<ParagraphBlock>(), containerInline.Descendants<ParagraphBlock>());
|
||||
Assert.AreSame(Array.Empty<ListBlock>(), containerInline.Descendants<ListBlock>());
|
||||
Assert.AreSame(Array.Empty<ParagraphBlock>(), containerInline.Descendants<ParagraphBlock>());
|
||||
}
|
||||
|
||||
foreach (ParagraphBlock paragraphBlock in syntaxTree.Descendants<ParagraphBlock>())
|
||||
@@ -64,7 +65,7 @@ namespace Markdig.Tests
|
||||
(paragraphBlock as MarkdownObject).Descendants<LiteralInline>(),
|
||||
paragraphBlock.Descendants<LiteralInline>());
|
||||
|
||||
Assert.AreSame(ArrayHelper.Empty<ParagraphBlock>(), paragraphBlock.Descendants<ParagraphBlock>());
|
||||
Assert.AreSame(Array.Empty<ParagraphBlock>(), paragraphBlock.Descendants<ParagraphBlock>());
|
||||
}
|
||||
|
||||
foreach (ContainerBlock containerBlock in syntaxTree.Descendants<ContainerBlock>())
|
||||
|
||||
@@ -12,15 +12,6 @@ namespace Markdig.Helpers
|
||||
/// <summary>
|
||||
/// An empty array.
|
||||
/// </summary>
|
||||
#if NET452
|
||||
public static T[] Empty<T>() => EmptyArray<T>.Value;
|
||||
|
||||
private static class EmptyArray<T>
|
||||
{
|
||||
public static readonly T[] Value = new T[0];
|
||||
}
|
||||
#else
|
||||
public static T[] Empty<T>() => System.Array.Empty<T>();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -8,19 +8,12 @@ using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Markdig.Helpers
|
||||
{
|
||||
internal sealed class FastStringWriter : TextWriter
|
||||
{
|
||||
#if NET452
|
||||
private static Task CompletedTask => Task.FromResult(0);
|
||||
#else
|
||||
private static Task CompletedTask => Task.CompletedTask;
|
||||
#endif
|
||||
|
||||
public override Encoding Encoding => Encoding.Unicode;
|
||||
|
||||
private char[] _chars;
|
||||
@@ -66,13 +59,13 @@ namespace Markdig.Helpers
|
||||
public override Task WriteAsync(char value)
|
||||
{
|
||||
Write(value);
|
||||
return CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public override Task WriteLineAsync(char value)
|
||||
{
|
||||
WriteLine(value);
|
||||
return CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
@@ -100,13 +93,13 @@ namespace Markdig.Helpers
|
||||
public override Task WriteAsync(string? value)
|
||||
{
|
||||
Write(value);
|
||||
return CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public override Task WriteLineAsync(string? value)
|
||||
{
|
||||
WriteLine(value);
|
||||
return CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
@@ -156,16 +149,16 @@ namespace Markdig.Helpers
|
||||
public override Task WriteAsync(char[] buffer, int index, int count)
|
||||
{
|
||||
Write(buffer, index, count);
|
||||
return CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public override Task WriteLineAsync(char[] buffer, int index, int count)
|
||||
{
|
||||
WriteLine(buffer, index, count);
|
||||
return CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
#if !(NET452 || NETSTANDARD2_0)
|
||||
#if !(NETFRAMEWORK || NETSTANDARD2_0)
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public override void Write(ReadOnlySpan<char> value)
|
||||
{
|
||||
@@ -188,17 +181,17 @@ namespace Markdig.Helpers
|
||||
public override Task WriteAsync(ReadOnlyMemory<char> buffer, CancellationToken cancellationToken = default)
|
||||
{
|
||||
Write(buffer.Span);
|
||||
return CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public override Task WriteLineAsync(ReadOnlyMemory<char> buffer, CancellationToken cancellationToken = default)
|
||||
{
|
||||
WriteLine(buffer.Span);
|
||||
return CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !(NET452 || NETSTANDARD2_0 || NETSTANDARD2_1)
|
||||
#if !(NETFRAMEWORK || NETSTANDARD2_0 || NETSTANDARD2_1)
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public override void Write(StringBuilder? value)
|
||||
{
|
||||
@@ -225,13 +218,13 @@ namespace Markdig.Helpers
|
||||
public override Task WriteAsync(StringBuilder? value, CancellationToken cancellationToken = default)
|
||||
{
|
||||
Write(value);
|
||||
return CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public override Task WriteLineAsync(StringBuilder? value, CancellationToken cancellationToken = default)
|
||||
{
|
||||
WriteLine(value);
|
||||
return CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -247,7 +240,7 @@ namespace Markdig.Helpers
|
||||
public override Task WriteLineAsync()
|
||||
{
|
||||
WriteLine();
|
||||
return CompletedTask;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
|
||||
@@ -273,9 +266,9 @@ namespace Markdig.Helpers
|
||||
|
||||
public override void Close() { }
|
||||
|
||||
public override Task FlushAsync() => CompletedTask;
|
||||
public override Task FlushAsync() => Task.CompletedTask;
|
||||
|
||||
#if !(NET452 || NETSTANDARD2_0)
|
||||
#if !(NETFRAMEWORK || NETSTANDARD2_0)
|
||||
public override ValueTask DisposeAsync() => default;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -5,9 +5,7 @@
|
||||
<Copyright>Alexandre Mutel</Copyright>
|
||||
<NeutralLanguage>en-US</NeutralLanguage>
|
||||
<Authors>Alexandre Mutel</Authors>
|
||||
<!-- Markdig.Wpf still supports net452, a target still supported by by Microsoft until January 10, 2023 -->
|
||||
<!-- see: https://github.com/xoofx/markdig/pull/466 -->
|
||||
<TargetFrameworks>net452;netstandard2.0;netstandard2.1;net6.0</TargetFrameworks>
|
||||
<TargetFrameworks>net462;netstandard2.0;netstandard2.1;net6.0</TargetFrameworks>
|
||||
<CheckEolTargetFramework>false</CheckEolTargetFramework>
|
||||
<PackageTags>Markdown CommonMark md html md2html</PackageTags>
|
||||
<PackageReleaseNotes>https://github.com/lunet-io/markdig/blob/master/changelog.md</PackageReleaseNotes>
|
||||
@@ -26,7 +24,7 @@
|
||||
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition=" '$(TargetFramework)' == 'net452' ">
|
||||
<ItemGroup Condition=" '$(TargetFramework)' == 'net462' ">
|
||||
<PackageReference Include="System.Memory" Version="4.5.4" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// This file is licensed under the BSD-Clause 2 license.
|
||||
// See the license.txt file in the project root for more information.
|
||||
|
||||
#if NET452 || NETSTANDARD2_0
|
||||
#if NETFRAMEWORK || NETSTANDARD2_0
|
||||
namespace System.Collections.Concurrent
|
||||
{
|
||||
internal static class ConcurrentQueueExtensions
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Markdig.Syntax
|
||||
/// <param name="parser">The parser used to create this block.</param>
|
||||
protected ContainerBlock(BlockParser? parser) : base(parser)
|
||||
{
|
||||
_children = ArrayHelper.Empty<BlockWrapper>();
|
||||
_children = Array.Empty<BlockWrapper>();
|
||||
SetTypeKind(isInline: false, isContainer: true);
|
||||
}
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ namespace Markdig.Syntax.Inlines
|
||||
{
|
||||
if (FirstChild is null)
|
||||
{
|
||||
return ArrayHelper.Empty<T>();
|
||||
return Array.Empty<T>();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Markdig.Syntax
|
||||
/// <seealso cref="ContainerBlock" />
|
||||
public class LinkReferenceDefinitionGroup : ContainerBlock
|
||||
{
|
||||
#if NET452
|
||||
#if NETFRAMEWORK
|
||||
private static readonly StringComparer _unicodeIgnoreCaseComparer = StringComparer.InvariantCultureIgnoreCase;
|
||||
#else
|
||||
private static readonly StringComparer _unicodeIgnoreCaseComparer = CultureInfo.InvariantCulture.CompareInfo.GetStringComparer(CompareOptions.IgnoreCase | CompareOptions.IgnoreNonSpace);
|
||||
|
||||
@@ -23,8 +23,8 @@ namespace Markdig.Syntax
|
||||
/// <returns>An iteration over the descendant elements</returns>
|
||||
public static IEnumerable<MarkdownObject> Descendants(this MarkdownObject markdownObject)
|
||||
{
|
||||
Stack<MarkdownObject> stack = new Stack<MarkdownObject>();
|
||||
Stack<bool> pushStack = new Stack<bool>();
|
||||
var stack = new Stack<MarkdownObject>();
|
||||
var pushStack = new Stack<bool>();
|
||||
|
||||
stack.Push(markdownObject);
|
||||
pushStack.Push(false);
|
||||
@@ -95,7 +95,7 @@ namespace Markdig.Syntax
|
||||
}
|
||||
}
|
||||
|
||||
return ArrayHelper.Empty<T>();
|
||||
return Array.Empty<T>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -125,7 +125,7 @@ namespace Markdig.Syntax
|
||||
}
|
||||
else
|
||||
{
|
||||
return ArrayHelper.Empty<T>();
|
||||
return Array.Empty<T>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user