//
//  AttributeListSyntaxExtensions.cs
//
//  Copyright (c) František Boháček. All rights reserved.
//  Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System.Text.RegularExpressions;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
namespace NosSmooth.PacketSerializersGenerator.Extensions;
/// 
/// Extension methods for .
/// 
public static class AttributeListSyntaxExtensions
{
    /// 
    /// Whether the attribute list contains the attribute with the given full name.
    /// 
    /// The list of the attributes.
    /// The semantic model.
    /// The full name of the attribute.
    /// Whether the attribute is present.
    public static bool ContainsAttribute(this AttributeListSyntax attributeList, SemanticModel semanticModel, string attributeFullName)
    {
        var first = semanticModel.GetTypeInfo(attributeList.Attributes[0]).Type?.ToString()!;
        return attributeList.Attributes.Any(x => Regex.IsMatch(semanticModel.GetTypeInfo(x).Type?.ToString()!, attributeFullName));
    }
}