Refactor via regex help (c style to c# style)
I'm converting some C code to C#, and all is going well, however i'd like to jiggle things around so that:
Util.SetStart(someObject, somePoint);
...gets refactored to:
开发者_运维技巧someObject.StartPoint = somePoint;
I think this is more than resharper can handle, and it seems the perfect candidate for regex replacement, however my regex knowledge is limited. If i'm mistaken, and this can be done in Resharper, i'd love to know!
As a side note, if I could use LINQ in place of regex that'd be awesome.
As you don't make clear how should be handled Util
, SetStart
and StartPoint
, I handcoded them:
var pattern = @"Util.SetStart\(([^,\s]+)\s*,\s*([^,\s]+)\);";
var text = "Util.SetStart(someObject, somePoint);";
var a = Regex.Replace(text, pattern, m => m.Groups[1] + ".StartPoint = " + m.Groups[2]);
It shouldn't be too hard to include those 3 functions in the regex, but I don't know what is the pattern I should follow when renaming, for example, SetStart
to StartPoint
.
精彩评论