wip as fuck

This commit is contained in:
Tyrrrz
2024-09-13 02:00:39 +03:00
parent 0fc88a42ba
commit 8546c54c23
8 changed files with 383 additions and 4 deletions

View File

@@ -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;
}
}
}

View 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);
}

View File

@@ -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);
}