コード例 #1
0
        private static string GetRegisteredName(IFieldSymbol symbol, string invocation)
        {
            var arguments = symbol.GetInvocationArgumentsFrom(invocation);

            if (arguments.Count > 0)
            {
                switch (arguments[0].Expression)
                {
                case LiteralExpressionSyntax s:
                    return(s.Token.ValueText);

                case InvocationExpressionSyntax s:
                    return(s.ArgumentList.Arguments.FirstOrDefault()?.ToString());
                }
            }

            return(null);
        }