mirror of
https://github.com/Tyrrrz/CliFx.git
synced 2025-10-25 15:19:17 +00:00
wip as fuck
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace CliFx.SourceGeneration.Utils.Extensions;
|
||||
|
||||
internal static class CollectionExtensions
|
||||
{
|
||||
public static IEnumerable<T> WhereNotNull<T>(this IEnumerable<T?> source)
|
||||
where T : class
|
||||
{
|
||||
foreach (var i in source)
|
||||
{
|
||||
if (i is not null)
|
||||
yield return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
20
CliFx.SourceGeneration/Utils/Extensions/RoslynExtensions.cs
Normal file
20
CliFx.SourceGeneration/Utils/Extensions/RoslynExtensions.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using Microsoft.CodeAnalysis;
|
||||
|
||||
namespace CliFx.SourceGeneration.Utils.Extensions;
|
||||
|
||||
internal static class RoslynExtensions
|
||||
{
|
||||
public static bool DisplayNameMatches(this ISymbol symbol, string name) =>
|
||||
string.Equals(
|
||||
// Fully qualified name, without `global::`
|
||||
symbol.ToDisplayString(SymbolDisplayFormat.CSharpErrorMessageFormat),
|
||||
name,
|
||||
StringComparison.Ordinal
|
||||
);
|
||||
|
||||
public static IncrementalValuesProvider<T> WhereNotNull<T>(
|
||||
this IncrementalValuesProvider<T?> values
|
||||
)
|
||||
where T : class => values.Where(i => i is not null);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace CliFx.SourceGeneration.Utils.Extensions;
|
||||
|
||||
internal static class StringExtensions
|
||||
{
|
||||
public static string JoinToString<T>(this IEnumerable<T> source, string separator) =>
|
||||
string.Join(separator, source);
|
||||
}
|
||||
Reference in New Issue
Block a user