Re: csc (C# Compiler) bug
From: Daniel O'Connell [C# MVP] (onyxkirx_at_--NOSPAM--comcast.net)
Date: 06/03/04
- Next message: S. Han: "Re: Reading a file from DLL."
- Previous message: Patrick Steele [MVP]: "Re: Error handle"
- In reply to: Paul Reeder: "csc (C# Compiler) bug"
- Next in thread: Paul Reeder: "Re: csc (C# Compiler) bug"
- Reply: Paul Reeder: "Re: csc (C# Compiler) bug"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 3 Jun 2004 12:22:46 -0500
"Paul Reeder" <paul@reeder.ws> wrote in message
news:52D3A0D0-C1A7-45EA-8555-F4C597F827D5@microsoft.com...
>I hope that MS watches this newsgroup.
>
> I seem to have found a bug in csc. I am compiling from VS.NET 2003. The
> csc version information (from command line) is:
> Microsoft (R) Visual C# .NET Compiler version 7.10.3052.4
> for Microsoft (R) .NET Framework version 1.1.4322
> Copyright (C) Microsoft Corporation 2001-2002. All rights reserved.
>
> In my application, I am using some custom display options that use
> non-standard characters as special icons, and often have strings which
> have characters >0x80. When used as a constant, these do not compile
> properly. Here is some source that does not compile properly:
> private const string DELETE = " \x84DELETE";
>
> Using ildasm to view the MSIL, I see:
> .field private static literal string DELETE = bytearray (20 00 DE 84 4C 00
> 45 00 54 00 45 00 ) // ...L.E.T.E.
>
> Definitely not what is expected! This does not happen with all strings
> which contain '\x84' followed by other characters. In fact, I have only
> seen it twice, with the example above and with " \x84Acknowledge".
>
Its not a bug, its actually correct. In both cases, it is assuming you mean
the hex string 84de and 84ac instead of 84. The \x is a variant length
escape sequence, there is no other way to do this.
You should probably use \u, which is fixed length, instead,
private const string DELETE = "\u0084DELETE";
otherwise you will have to concatenate.
This is also not related to being greater than 80, I was able to reproduce
it using the string "\x12delete"
> At runtime, such strings can be built using contatenation, as shown in the
> code below:
> private static bool _SMANI_HACK = false;
> private static string DELETE = "DELETE";
> public <.ctor>(...)
> {
> //HACK: FIXED MICROSOFT >0x80 bug (?)
> if (!_SMANI_HACK)
> {
> _SMANI_HACK = true;
> DELETE = " \x84" + DELETE;
> }
> //normal constructor information
> }
>
> But of course, this only really works for private constants, since others
> may be called before any instances are instantiated (calling constructor).
> The other way would be to buffer these strings behind a static property,
> and though that would probably work, it seems like it would be a severe
> performance hit.
>
> I suppose another work around would be to manually modify the MSIL, but
> this really seems extreme, and not something that one wants to have to
> remember to do for a product that may be in a state of flux.
>
> Any information would be appreciated.
>
- Next message: S. Han: "Re: Reading a file from DLL."
- Previous message: Patrick Steele [MVP]: "Re: Error handle"
- In reply to: Paul Reeder: "csc (C# Compiler) bug"
- Next in thread: Paul Reeder: "Re: csc (C# Compiler) bug"
- Reply: Paul Reeder: "Re: csc (C# Compiler) bug"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|