/// <summary> /// Find LongName argument from the OptionAttribute. /// </summary> /// <param name="attributeSyntax"></param> /// <returns> /// name: the LongName value. /// location: the syntax tree location of the LongName argument value. /// </returns> private (string? name, Location? location) AnalyzeOptionAttributeArguments(AttributeSyntax attributeSyntax) { var argumentList = attributeSyntax.ChildNodes().OfType<AttributeArgumentListSyntax>().FirstOrDefault(); if (argumentList != null) { var attributeArguments = argumentList.ChildNodes().OfType<AttributeArgumentSyntax>(); foreach (var attributeArgument in attributeArguments) { var expressionSyntax = attributeArgument.Expression; var expression = expressionSyntax.ToString(); var nameEqualsExists = attributeArgument.ChildNodes().OfType<NameEqualsSyntax>().Any(); var longNameEqualsExists = attributeArgument.ChildNodes().OfType<NameEqualsSyntax>().Any(x => x.Name.ToString() == "LongName"); var mayBeLongName = !nameEqualsExists || longNameEqualsExists; if (expression != null && expression.StartsWith("\"", StringComparison.OrdinalIgnoreCase) && expression.EndsWith("\"", StringComparison.OrdinalIgnoreCase) && mayBeLongName) { var value = expression.Substring(1, expression.Length - 2); if (value.Length >= 2) { var isPascalCase = NamingHelper.CheckIsPascalCase(value); if (!isPascalCase) { return (value, expressionSyntax.GetLocation()); } } break; } } } return (null, null); }