Names that start with @

  • Thread starter Thread starter Jon Shemitz
  • Start date Start date
J

Jon Shemitz

I'm trying to call some code written in Delphi for .Net. In Delphi,
every class has a corresponding metaclass type; you can use a
metaclass reference to create instances of the class &c. What's
important here is that some methods take a metaclass reference as a
parameter.

On .Net, metaclasses are implemented as compiler created nested
classes - something like

public class Foo
{
public class @MetaFoo
{
public static @MetaFoo @Instance;
}

public static void Bar(@MetaFoo MetaRef) {}
}

Now, VS's Object Browser can see @MetaFoo and @MetaFoo.@MetaInstance.
Intellisense even sees @MetaFoo when I type

Foo.Bar(Foo.

BUT! Intellisense does NOT see @Instance when I type


Foo.Bar(Foo.@MetaFoo.


AND when I try to compile

Foo.Bar(Foo.@MetaFoo.@Instance);

I get a message that Foo "does not contain a definition for
'MetaFoo'". I know that @Identifier is an escape to allow use of
keywords as identifiers, but how do I (can I?) tell C# that I really
truly mean @MetaFoo and @Instance, not MetaFoo and Instance?
(@@MetaFoo.@@Instance does not work.)
 
Jon Shemitz said:
I'm trying to call some code written in Delphi for .Net. In Delphi,
every class has a corresponding metaclass type; you can use a
metaclass reference to create instances of the class &c. What's
important here is that some methods take a metaclass reference as a
parameter.
BUT! Intellisense does NOT see @Instance when I type


Foo.Bar(Foo.@MetaFoo.


AND when I try to compile

Foo.Bar(Foo.@MetaFoo.@Instance);

I get a message that Foo "does not contain a definition for
'MetaFoo'". I know that @Identifier is an escape to allow use of
keywords as identifiers, but how do I (can I?) tell C# that I really
truly mean @MetaFoo and @Instance, not MetaFoo and Instance?
(@@MetaFoo.@@Instance does not work.)


Hi Jon,

I see the same thing as you, where Intellisense is not showing the verbatim
identifiers correctly. Rather it is showing the identifier without the @
symbol.

However, I ignored Intellisense and coded in the verbatim identifiers and
your code did compile for me (VS.NET 2003).

Joe
 
Joe said:
However, I ignored Intellisense and coded in the verbatim identifiers and
your code did compile for me (VS.NET 2003).

Thanks, Joe. Unfortunately for me, the key words in my message in
this regard were "something like". I hadn't tried compiling the
schematic code (yes, I should have) but I, too, find it compiles just
fine. So, the problem is elsewhere - not with C# and the @ escape;
perhaps with Delphi's hand-built metadata tables or somesuch. It is
strange, though, because the VS.2003 Object Browser, ILDASM, and Lutz
Roeder's Reflector can all browse the @MetaFoo type of definitions,
and can unassemble/decompile as appropriate.
 
I see the same thing as you, where Intellisense is not showing the verbatim
identifiers correctly. Rather it is showing the identifier without the @
symbol.

However, I ignored Intellisense and coded in the verbatim identifiers and
your code did compile for me (VS.NET 2003).

Actually, if you look at the Object Browser &c, it looks like when you
declare a name like @Foo, the @ gets stripped off and what is compiled
is Foo ....
 
Back
Top