Welcome to Keen Software House Forums! Log in or Sign up to interact with the KSH community.
  1. You are currently browsing our forum as a guest. Create your own forum account to access all forum functionality.

[Suggest] Unlock VRage.Library's System.StringExtensions

Discussion in 'Programming Questions and Suggestions' started by DavidChenware, Jan 24, 2015.

Thread Status:
This last post in this thread was made more than 31 days old.
  1. DavidChenware Trainee Engineer

    Messages:
    23
    I would have liked to use the Contains extension, but it's not supported for in game programming, and I suggest that it should be allowed to be used, or moved in to some general namespace that we ARE allowed to use in game.

    It's a very simple, easy to implement bit of functionality, but why not reuse?

    VRage.Library
    Static System.StringExtensions
    Contains(this string, string, System.StringComparison)

    Makes in game programming life easier for things like:
    1) Finding tag's anywhere in the block custom name
    2) Finding blocks by name with very common standards, like "{shipname} {block name} {block number}", e.g. "The Annihilator Drill 3"

    Edit: I should add that for anyone that actually wants this functionality, using String.IndexOf(string, StringComparison) and checking the return value will get you identical functionality. https://msdn.microsoft.com/en-us/library/ms224425(v=vs.110).aspx
     
    Last edited by a moderator: Jan 24, 2015
  2. MegaMiner Junior Engineer

    Messages:
    625
    System.Text can be used for pretty much everything. And any string can access Contains() directly.

    Not sure what functionality you need...
     
  3. DavidChenware Trainee Engineer

    Messages:
    23
    I'm assuming that the string extensions will have added functionality in the future, it not having to do bad stuff like .ToUpper everywhere to ignore case.

    It's not a huge priority but does make things easier to read. You can do "anything" with "anything", but it might not make it easier to do or read.
     
  4. Phoera Senior Engineer

    Messages:
    1,713
    why not use IndexOf?
    https://msdn.microsoft.com/ru-ru/en-en/library/ms224425(v=vs.110).aspx
     
  5. DavidChenware Trainee Engineer

    Messages:
    23
    Thanks for reading the original post :(
     
  6. Phoera Senior Engineer

    Messages:
    1,713
    dont reread post before post, i write answer before update.
    sorry.
     
  7. CommanderGizmo Apprentice Engineer

    Messages:
    133
    I just wrote a couple of extension functions to parse block names and now I just write block.CheckFilter("FILTER1", "FILTER2"); If you compartmentalize your naming system you can just write the IndexOf once and be done.

    If they gave us more string functions, I'd just update the extensions and I still wouldn't write any more code each time I want to do the same task.
     
  8. Malware Master Engineer

    Messages:
    9,507
    Won't the possibility of writing extension methods be removed? They have explicitly stated somewhere that the ability to add that extra } to add extension classes etc is a bug and will be fixed.

    Or am I simply misunderstanding you?
     
  9. CommanderGizmo Apprentice Engineer

    Messages:
    133
    See here: http://forums.keenswh.com/post/show_single_post?pid=1285664369&postcount=15
     
  10. Malware Master Engineer

    Messages:
    9,507
    :rolleyes: I SOO wish I had seen that post earlier...

    Thanks a billion, this makes me able to simplify my mainframe framework severely.
     
Thread Status:
This last post in this thread was made more than 31 days old.