Ayende @ Rahien

Unnatural acts on source code

Fun with DSL - Didja know the CLR allows it?

I swear that I didn't mean to do it, but it just happened.

image

Comments

Florian Krüsch
02/14/2008 02:48 PM by
Florian Krüsch

hehe, that's funny. Díd you use ILASM to create that?

Ayende Rahien
02/14/2008 02:55 PM by
Ayende Rahien

No, Boo DSL based on XML storage.

Freaky stuff

Peter Ritchie
02/14/2008 03:33 PM by
Peter Ritchie

Yeah, sorta the basis of much obfuscation software: just rename members to use something in the Unicode set that C#/VB/etc doesn't support...

James Curran
02/14/2008 03:42 PM by
James Curran

I wonder if that were part of the changes for the C++/CLR version, where has things like "for each" being a single keyword.

Luke Breuer
02/14/2008 05:18 PM by
Luke Breuer

Why are you specifying an hour value in hex?

Ayende Rahien
02/14/2008 05:49 PM by
Ayende Rahien

That is a Reflector setting

Justin Etheredge
02/14/2008 08:49 PM by
Justin Etheredge

Hmm, it is surprising that they allow that.

Yuri Korchyomkin
02/15/2008 05:50 AM by
Yuri Korchyomkin

Yes, this ability of CLR to grok names with whitespaces is used for a long time by Nemerle guys in their unit-testing DSL (their site seems to be down but contents can be found in google cache, for example).

Yuri Korchyomkin
02/15/2008 05:50 AM by
Yuri Korchyomkin

Yes, this ability of CLR to grok names with whitespaces is used for a long time by Nemerle guys in their unit-testing DSL (their site seems to be down but contents can be found in google cache, for example).

Anders
02/15/2008 10:55 AM by
Anders

Do you have a feed for the comments on your blog Oren?

Ayende Rahien
02/15/2008 11:39 AM by
Ayende Rahien

Andres,

Not that I know of.

If SubText has it, then probably

yitzchok
02/15/2008 06:27 PM by
yitzchok

That's nice is there any way to call it from C#?

Ayende Rahien
02/15/2008 06:58 PM by
Ayende Rahien

Not really, no.

VB probably can, though

Thomas Danecker
02/16/2008 12:58 PM by
Thomas Danecker

You can also call it by C# code, just use something like administrators\u0020can\u0020always\u0020login. C# allows unicode escapes in identifier names. See the language specification ECMA-334, section 9.4.2 Identifiers. This is a valid example from this section:

class @class

{

public static void @static(bool @bool) {

if (@bool)

System.Console.WriteLine("true");

else

System.Console.WriteLine("false");

}

}

class Class1

{

static void M() {

cl\u0061ss.st\u0061tic(true);

}

}

Ayende Rahien
02/16/2008 01:01 PM by
Ayende Rahien

Thomas,

Thanks, it is good to know.

Scary as hell, too.

Comments have been closed on this topic.