\r\n
-
Reflector showed me this 'gem' in a contractors project:
string cBRK = Convert.ToChar(int.Parse("13")).ToString() + Convert.ToChar(int.Parse("10")).ToString();
this.ReportStatus("93101Bytes" + cBRK + BytesRecieved.ToString() + cBRK + fileSize.ToString() + cBRK);
kind regards, JoFli
Come to think of it, why are you having to reverse engineer the contractor's project? If he wrote the code while in your employ, I would expect that you would own the intellectual property rights to the code, and normally you would expect to have a copy of the source after his contract ends. Unless you bought this from him as a finished product rather than contracting his time to write it for you. In which case, he owns the copyright and reverse engineering it could be a breach of the licence terms (which normally forbid that sort of thing).
-
Ian Shlasko wrote:
It's harder to hide it that way.
No, it hides it in different places; your way has all the information in one place. Plus, using a resource and config makes it brittle -- if someone changes or removes the entries chaos will ensue.
Nah, the point is that everything looks normal from the outside... Then you drill down into the utility functions, and each one is completely illegible. So you've already ported half of the library, and now you don't want to touch it because you're afraid you'll miss something and break an edge condition.
Proud to have finally moved to the A-Ark. Which one are you in? Author of Guardians of Xen (Sci-Fi/Fantasy novel)
-
Nah, the point is that everything looks normal from the outside... Then you drill down into the utility functions, and each one is completely illegible. So you've already ported half of the library, and now you don't want to touch it because you're afraid you'll miss something and break an edge condition.
Proud to have finally moved to the A-Ark. Which one are you in? Author of Guardians of Xen (Sci-Fi/Fantasy novel)
Nice thinking, job security at it's best.
Software Kinetics (requires SL3 beta) - Moving software
-
My guess is that this is an artifact of Reflector, not of the original coder. I do know that in VB, the Chr() function actually does use Convert.ToChar internally so my guess is that C# does the same. Who knows what Environment.NewLine does internally. I assume that the compiler has in-lined the Chr function, and Reflector has simply given you back what the compiler produced. Anyone with too much free time on their hands and a handy copy of Reflector is invited to experiment to find out what the compiler does with this sort of thing. Reflector is showing you what the code looks like after the compiler has munged it around and played merry havoc with your beautiful code.
The Chr() = Convert.ToChar() thing makes some sense, but why int.Parse("13") instead of just 13?
-
My guess is that this is an artifact of Reflector, not of the original coder. I do know that in VB, the Chr() function actually does use Convert.ToChar internally so my guess is that C# does the same. Who knows what Environment.NewLine does internally. I assume that the compiler has in-lined the Chr function, and Reflector has simply given you back what the compiler produced. Anyone with too much free time on their hands and a handy copy of Reflector is invited to experiment to find out what the compiler does with this sort of thing. Reflector is showing you what the code looks like after the compiler has munged it around and played merry havoc with your beautiful code.
Looks like
temp = Chr(13) + Chr(10)
gets decompiled intotemp = "\r\n";
so the compiler is smart enough to actually make the string when you call Chr with a constant. Environment.NewLine shows up as a property call in Reflector, but the JIT may inline it as a literal string. There's no way Reflector would generate what the OP is seeing unless the code really was that bad. -
If that's obfuscation, I'm not impressed... If I wanted to make it REALLY confusing, I'd do something like this:
const string blarphnik = "51209576120381929170992";
string elkabong = Convert.ToChar(int.Parse(blarphnik.SubString(1,2))- int.Parse(blarphnik /* If I had a pet monkey, I'd name it blarphnik */.SubString(8 /* What a nice number */,1)))
- Convert.ToChar(int.Parse(blarphnik.SubString(18, 2))
/ int.Parse(blarphnik.SubString(6,1) /* Todo: Fix this */));
And then I would publish this as part of a self-help book entitled "How to Drive a Programmer Insane"
Proud to have finally moved to the A-Ark. Which one are you in? Author of Guardians of Xen (Sci-Fi/Fantasy novel)
Ian Shlasko wrote:
self-help book
Ian Shlasko wrote:
How to Drive a Programmer Insane
So your target audience, precisely, is ...?
Personally, I love the idea that Raymond spends his nights posting bad regexs to mailing lists under the pseudonym of Jane Smith. He'd be like a super hero, only more nerdy and less useful. [Trevel]
| FoldWithUs! | sighist | µLaunch - program launcher for server core and hyper-v server -
Ian Shlasko wrote:
self-help book
Ian Shlasko wrote:
How to Drive a Programmer Insane
So your target audience, precisely, is ...?
Personally, I love the idea that Raymond spends his nights posting bad regexs to mailing lists under the pseudonym of Jane Smith. He'd be like a super hero, only more nerdy and less useful. [Trevel]
| FoldWithUs! | sighist | µLaunch - program launcher for server core and hyper-v serverpeterchen wrote:
So your target audience, precisely, is ...?
I don't think that far ahead
Proud to have finally moved to the A-Ark. Which one are you in? Author of Guardians of Xen (Sci-Fi/Fantasy novel)
-
Ian Shlasko wrote:
self-help book
Ian Shlasko wrote:
How to Drive a Programmer Insane
So your target audience, precisely, is ...?
Personally, I love the idea that Raymond spends his nights posting bad regexs to mailing lists under the pseudonym of Jane Smith. He'd be like a super hero, only more nerdy and less useful. [Trevel]
| FoldWithUs! | sighist | µLaunch - program launcher for server core and hyper-v serversane programmers with good reading skills, not a big audience IMO. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
-
Come to think of it, why are you having to reverse engineer the contractor's project? If he wrote the code while in your employ, I would expect that you would own the intellectual property rights to the code, and normally you would expect to have a copy of the source after his contract ends. Unless you bought this from him as a finished product rather than contracting his time to write it for you. In which case, he owns the copyright and reverse engineering it could be a breach of the licence terms (which normally forbid that sort of thing).
-
Come to think of it, why are you having to reverse engineer the contractor's project? If he wrote the code while in your employ, I would expect that you would own the intellectual property rights to the code, and normally you would expect to have a copy of the source after his contract ends. Unless you bought this from him as a finished product rather than contracting his time to write it for you. In which case, he owns the copyright and reverse engineering it could be a breach of the licence terms (which normally forbid that sort of thing).
David Skelly wrote:
reverse engineering it could be a breach of the licence terms
But not in Australia: http://www.austlii.org/au/legis/cth/consol_act/ca1968133/s47d.html[^] and it refers to "adaptation" which is defined here: http://www.austlii.org/au/legis/cth/consol_act/ca1968133/s10.html#adaptation[^] at (ba), and that is a definition of decompilation, let alone reverse engineering in general. Of course the OP is in Germany, so that is irrelevant :-)
Regards, Mark Hurd, B.Sc.(Ma.) (Hons.)