BUG: You receive a "CS1519" compiler error code when you use surrogate characters as a token in Visual C# .NET (814824)



The information in this article applies to:

  • Microsoft Visual C# .NET (2002)
  • Microsoft Visual C# .NET (2003)
  • Microsoft Visual C# 2005, Express Edition

SYMPTOMS

When you compile Visual C# .NET or Visual C# 2005 code with surrogate Unicode characters as a token name, you may receive the following CS1519 compiler error message:
Error Invalid token 'token' in class, struct, or interface member declaration

CAUSE

Visual C# .NET or Visual C# 2005 only accepts alphabetical and numeric characters in a token name.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

A surrogate pair is a coded character representation for a single abstract character is made up of a sequence of two code units. The first unit of the pair is a high-surrogate (U+D800 through U+DBFF) and the second is a low-surrogate (U+DC00 through U+DFFF).

The Visual C# .NET or Visual C# 2005 compiler does not support surrogate Unicode characters as a token name.

Steps to Reproduce the Behavior

  1. Start Notepad, and then paste the following code:
    using System;
    using System.Threading;
    using System.Globalization;
    
    namespace application1
    { 
    	class SurrogateTest
    	{
    		public static string \u20105()
    		{
    		  return "\u20105";
    		}
    		public static void Main(String[] args) 
    		{
    		  Console.WriteLine ("Function return: {0}", \u20105());
    		}
    	}
    }
  2. Save the file as Surrogate_Unicode_test.cs.
  3. Open a Visual Studio .NET 2002 command prompt or Visual Studio 2005 command prompt.
  4. Type csc Surrogate_Unicode_test.cs to compile the file.
  5. You may receive the error message that is described in the "Symptoms" section of this article.

REFERENCES

For additional information, visit the following Microsoft Developer Network (MSDN) Web site:

Modification Type:MinorLast Reviewed:1/12/2006
Keywords:kbCompiler kbbug KB814824 kbAudDeveloper kbAudITPRO