public static EntityName FromCode(SyntaxElement element) { switch (element) { case NameDeclaration nameDeclaration: return(new EntityName(nameDeclaration.Name.SimpleName)); case TokenName tokenName: return(new EntityName(tokenName.Name.Text)); case LiteralExpression literal: return(new EntityName((string)literal.LiteralValue)); case BracketedName bracketedName: return(new EntityName((string)bracketedName.Name.LiteralValue)); default: return(new EntityName(element.ToString())); } }