mirror of
https://github.com/Tyrrrz/CliFx.git
synced 2025-10-25 15:19:17 +00:00
asd
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using Microsoft.CodeAnalysis;
|
||||
|
||||
namespace CliFx.SourceGeneration.Utils.Extensions;
|
||||
@@ -13,6 +16,22 @@ internal static class RoslynExtensions
|
||||
StringComparison.Ordinal
|
||||
);
|
||||
|
||||
public static T GetNamedArgumentValue<T>(
|
||||
this AttributeData attribute,
|
||||
string name,
|
||||
T defaultValue = default
|
||||
) =>
|
||||
attribute.NamedArguments.FirstOrDefault(i => i.Key == name).Value.Value is T valueAsT
|
||||
? valueAsT
|
||||
: defaultValue;
|
||||
|
||||
public static IReadOnlyList<T> GetNamedArgumentValues<T>(
|
||||
this AttributeData attribute,
|
||||
string name
|
||||
)
|
||||
where T : class =>
|
||||
attribute.NamedArguments.FirstOrDefault(i => i.Key == name).Value.Values.CastArray<T>();
|
||||
|
||||
public static IncrementalValuesProvider<T> WhereNotNull<T>(
|
||||
this IncrementalValuesProvider<T?> values
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user