mirror of
https://github.com/xoofx/markdig.git
synced 2026-02-04 05:44:50 +00:00
Use pattern matching to test for non-empty collections
This commit is contained in:
@@ -214,7 +214,7 @@ namespace Markdig.Extensions.Tables
|
||||
}
|
||||
}
|
||||
|
||||
if (currentRow != null && currentRow.Count > 0)
|
||||
if (currentRow is { Count: > 0 })
|
||||
{
|
||||
gridTable.Add(currentRow);
|
||||
}
|
||||
|
||||
@@ -588,7 +588,7 @@ namespace Markdig.Parsers
|
||||
}
|
||||
if (TrackTrivia)
|
||||
{
|
||||
if (LinesBefore != null && LinesBefore.Count > 0)
|
||||
if (LinesBefore is { Count: > 0 })
|
||||
{
|
||||
// single emptylines are significant for the syntax tree, attach
|
||||
// them to the block
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace Markdig.Parsers
|
||||
|
||||
parser.Initialize();
|
||||
parser.Index = i;
|
||||
if (parser.OpeningCharacters != null && parser.OpeningCharacters.Length != 0)
|
||||
if (parser.OpeningCharacters is { Length: > 0 })
|
||||
{
|
||||
foreach (var openingChar in parser.OpeningCharacters)
|
||||
{
|
||||
|
||||
@@ -363,7 +363,7 @@ namespace Markdig.Renderers
|
||||
Write(" id=\"").WriteEscape(attributes.Id).Write("\"");
|
||||
}
|
||||
|
||||
if (attributes.Classes != null && attributes.Classes.Count > 0)
|
||||
if (attributes.Classes is { Count: > 0 })
|
||||
{
|
||||
Write(" class=\"");
|
||||
for (int i = 0; i < attributes.Classes.Count; i++)
|
||||
@@ -378,7 +378,7 @@ namespace Markdig.Renderers
|
||||
Write("\"");
|
||||
}
|
||||
|
||||
if (attributes.Properties != null && attributes.Properties.Count > 0)
|
||||
if (attributes.Properties is { Count: > 0 })
|
||||
{
|
||||
foreach (var property in attributes.Properties)
|
||||
{
|
||||
|
||||
@@ -119,7 +119,7 @@ namespace Markdig.Syntax
|
||||
/// </returns>
|
||||
public static IEnumerable<T> Descendants<T>(this ContainerBlock block) where T : Block
|
||||
{
|
||||
if (block != null && block.Count > 0)
|
||||
if (block is { Count: > 0 })
|
||||
{
|
||||
return BlockDescendantsInternal<T>(block);
|
||||
}
|
||||
@@ -133,7 +133,7 @@ namespace Markdig.Syntax
|
||||
{
|
||||
Debug.Assert(typeof(T).IsSubclassOf(typeof(Block)));
|
||||
|
||||
Stack<Block> stack = new Stack<Block>();
|
||||
var stack = new Stack<Block>();
|
||||
|
||||
int childrenCount = block.Count;
|
||||
while (childrenCount-- > 0)
|
||||
|
||||
Reference in New Issue
Block a user