WalkerCodeRanger/semver

Add implicit conversion from SemVersion to String

Closed this issue · 1 comments

semver is heavily used in build scripts, where devs often need to craft/parse an initial SemVersion which then is passed as argument to different tools in the build pipeline - with these tools usually expecting the argument as a string, which means build scripts end up having to call .ToString() everywhere.

Happy to send a PR.

As discussed in PR#25 it was decided not to include an implicit conversion from SemVersion to string. Reasons for this include:

  • consistency with .NET Framework types (see in particular Uri and Version) (esp. important since this is a library most people will interact with only a few times)
  • The .ToString() is easy to make use of in string format operations and not that big of an issue when occasionally converting to string
  • Implicit conversion to string will cause confusing behavior if someone writes a string comparison like version >= "1.0". Currently, that relies on a conversion from string to SemVersion. However, that is going to be removed. If there were implicit conversion from SemVersion to string then that comparison would be a lexicographical comparison which is probably not what the developer intended.

Unless there is new MS guidance on this or something not discussed in PR#25 or here, I plan to stick with the current approach of not having an implicit conversion from SemVersion to string.