- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
I actually agree with you here; I've done this for some small internal projects that do things like a complete database initialization, etc. As James says, it's an elaborate are you sure style prompt.
However, this is not security ^_~
Admin
Nah.. I could totally buy this happening. Its undeniably stupid, but I'd certainly believe that there is someone that realises that they don't want code out there messing with his 'isModified' function but at the same time doesn't know about the value of 'internal'. In my experience lots of perfectly good C# programmers don't grok the meaning of internal type modifiers initially. (yes, and myself).
Also, even if you know about internal, sometimes its not quite enough.
I've briefly contemplated this type of insane solution (soon to realise that it is in fact a total wtf) when you have a situation where you want one and only class - in fact specifically an object factory in this case - to be able to call a SetClean() method just like this example.
In that situation the internal keyword doesn't quite cut it because you want only that factory class to be able to call the SetClean() function, not just anything in the assembly. C++ 'friend' would do the job here but C# doesn't have "friend". Still at a certain point you have to stop being so dang paranoid.
But yeah, I'd definitely believe this is not fake.
Admin
This code HAD to be concieved by Ed Malloy.
Admin
/// Overrides the IsUpdated value. Used to set the value to false /// after properties have been populated by the constructor.
Umm, isn't the real WTF that the guy didn't just set updated to false at the end of the constructor?
Admin
I've seen this kind of thing before in functions exposed in DLLs, only it was a magic number, not a string. This makes less sense though.
Admin
Wow. Killer idea, actually.
Admin
Jeebus... Can we just retire the whiners who bitch and moan about the posts? It's getting really repetitive, and it wasn't funny even the first time, much less the 100th.
Seriously... If you don't like the damned articles, don't read them. Wasting your time and ours whining just demonstrates what a moron you are, and accomplishes nothing else.
Admin
Jeebus. Can we just retire the the moaners who bitch and whine about the whinerer who bitch and moan about the posts? It's getting really recursive.
Admin
I have to admit, I'm thoroughly enjoying the long, drawn out conversation on the use of == when Alex made it clear already that Alex introduced that artifact himself and wasn't in the original code!
Admin
I wrote the following a short while ago:
Admin
This is .NET, the author clearly should have used code access security attribributes instead of a password.
[PrincipalPermission(SecurityAction.Demand, Role = "UpdateStatusFlippers")] OverrideIsUpdated( bool status ) { _IsUpdated = status; }
Admin
I also think he shouldn't have changed it in the first place. This "change to make it easier to see" spawned a whole discussion on it's own even if you ignore the part about the ==/!= mixup.
Admin
The fact that they're using a "String" object, and that, according to alex, it originally was a comparator method, not '==', makes me think it's not C#... or if it is, apparently the coder was also unaware that C# can handle 'string' (lowercase) as if it were a primitive type.
Admin
I'm not the only one!
Admin
Admin
Technically your right but that doesn't mean that using a password w. obfuscation solution would still be terrible! The correct way to secure that your code i only called by your own assembly is CAS. But still it should only be used in a few cases.
Admin
There is no difference in C# between the alias 'string' and the CLR type 'System.String'. They are both references to the same type; the C# compiler maps an object declared as a 'string' to a 'System.String' object.
Furthermore, strings in C# are kind of a hybrid between value-types and reference-types ( value-type being the .NET parlance for a primitive ). For example, a string in .NET can be assigned the value null ( which is not possible for value-types ), but a string passed as an argument to a method is passed by value ( which is not typical for reference-types ).
Admin
It's not quite that difficult to set a private field in a .NET class using Reflection. Here's an example of some code that creates a delegate that can do it: