ExpressionToString icon indicating copy to clipboard operation
ExpressionToString copied to clipboard

Extension method

Open AlexArchive opened this issue 10 years ago • 5 comments
trafficstars

Originally we would have written something like this:

Expression<Action> func = () => Console.WriteLine();
string result = func.ToString();

I would like for ExpressionToString to offer an extension method. The method name ToString is taken. Maybe call the extension method something like:

  • ToReadableString
  • ToAwesomeString
  • ToSafeString
  • ToStringSafe
  • ToText
  • ToString
  • Dump
  • GetString
  • AsString
  • AsString

(Naming things is hard)

I can do this if you want it.

AlexArchive avatar Mar 17 '15 11:03 AlexArchive

This is why I released this as < v1. I thought about this too =)

.ToCodeString() maybe.

JakeGinnivan avatar Mar 17 '15 11:03 JakeGinnivan

I am not particularly attached to any name (although I think the name should start with the word To for IntelliSense discoverability purposes).

Which name do you like the most? ToCodeString is fine in my opinion.

AlexArchive avatar Mar 17 '15 11:03 AlexArchive

We could also be compatible with https://github.com/jbevain/mono.linq.expressions/#api

JakeGinnivan avatar Mar 17 '15 11:03 JakeGinnivan

Ah. If I understand correctly, you want to call the extension method ToCSharpCode so users can swap out mono.linq.expressions for (the lighter) ExpressionToString with ease?

AlexArchive avatar Mar 17 '15 12:03 AlexArchive

Unsure, will have a think. Just put it here as an option..

JakeGinnivan avatar Mar 17 '15 12:03 JakeGinnivan