瀏覽代碼

* CodeGeneratorFromExpressionTest.cs: Added tests for
CodePrimitiveExpression.
* CSharpCodeGenerator.cs: Override GeneratePrimitiveExpression to
match .NET 1.x and 2.0 for float, decimal, char, ushort, uint, ulong
and sbyte.
* CodeGenerator.cs: Modified GeneratePrimitiveExpression to throw
ArgumentException for sbyte value, use GenerateSingleFloatValue for
float, GenerateDecimalValue for decimal and GenerateDoubleValue for
double. Modified exception message for non-primitive types to match
MS.NET.
* ICodeCompiler.cs: Set eol-style to native.
* CodeCompiler.cs: Set eol-style to native.
* CodeDomConfigurationHandler.cs: Set eol-style to native.
* CodeDomProvider.cs: Set eol-style to native.
* CodeGeneratorOptions.cs: Set eol-style to native.
* CodeParser.cs: Set eol-style to native.
* CompilerError.cs: Set eol-style to native.
* CompilerErrorCollection.cs: Set eol-style to native.
* CompilerInfo.cs: Set eol-style to native.
* CompilerParameters.cs: Set eol-style to native.
* CompilerResults.cs: Set eol-style to native.
* Executor.cs: Set eol-style to native.
* GeneratorSupport.cs: Set eol-style to native.
* ICodeGenerator.cs: Set eol-style to native.
* ICodeParser.cs: Set eol-style to native.
* LanguageOptions.cs: Set eol-style to native.
* TempFileCollection.cs: Set eol-style to native.
* VBCodeGenerator.cs: Modified GeneratePrimitiveExpression to match
.NET 1.x and 2.0 for char, float, ushort, uint, ulong and sbyte.

svn path=/trunk/mcs/; revision=54032

Gert Driesen 20 年之前
父節點
當前提交
c3f574d8f0

+ 88 - 1
mcs/class/System/Microsoft.CSharp/CSharpCodeGenerator.cs

@@ -798,7 +798,7 @@ namespace Mono.CSharp
 			Indent--;
 			Output.WriteLine ('}');
 		}
-		
+
 		protected override void GenerateTypeConstructor (CodeTypeConstructor constructor)
 		{
 			if (IsCurrentDelegate || IsCurrentEnum || IsCurrentInterface) {
@@ -1114,6 +1114,93 @@ namespace Mono.CSharp
 			return "\"" + output + "\"";
 		}
 
+		protected override void GeneratePrimitiveExpression(CodePrimitiveExpression e)
+		{
+			if (e.Value is char) {
+				this.GenerateCharValue ((char) e.Value);
+#if NET_2_0
+			} else if (e.Value is ushort) {
+				ushort uc = (ushort) e.Value;
+				Output.Write (uc.ToString(CultureInfo.InvariantCulture));
+			} else if (e.Value is uint) {
+				uint ui = (uint) e.Value;
+				Output.Write (ui.ToString(CultureInfo.InvariantCulture));
+				Output.Write ("u");
+			} else if (e.Value is ulong) {
+				ulong ul = (ulong) e.Value;
+				Output.Write (ul.ToString(CultureInfo.InvariantCulture));
+				Output.Write ("ul");
+			} else if (e.Value is sbyte) {
+				sbyte sb = (sbyte) e.Value;
+				Output.Write (sb.ToString(CultureInfo.InvariantCulture));
+#endif
+			} else {
+				base.GeneratePrimitiveExpression (e);
+			}
+		}
+
+		private void GenerateCharValue (char c)
+		{
+			Output.Write ('\'');
+
+			switch (c) {
+				case '\0':
+					Output.Write ("\\0");
+					break;
+				case '\t':
+					Output.Write ("\\t");
+					break;
+				case '\n':
+					Output.Write ("\\n");
+					break;
+				case '\r':
+					Output.Write ("\\r");
+					break;
+				case '"':
+					Output.Write ("\\\"");
+					break;
+				case '\'':
+					Output.Write ("\\'");
+					break;
+				case '\\':
+					Output.Write ("\\\\");
+					break;
+				case '\u2028':
+					Output.Write ("\\u");
+#if NET_2_0
+					Output.Write (((int) c).ToString ("X4", CultureInfo.InvariantCulture));
+#else
+					Output.Write (((int) c).ToString (CultureInfo.InvariantCulture));
+#endif
+					break;
+				case '\u2029':
+					Output.Write ("\\u");
+#if NET_2_0
+					Output.Write (((int) c).ToString ("X4", CultureInfo.InvariantCulture));
+#else
+					Output.Write (((int) c).ToString (CultureInfo.InvariantCulture));
+#endif
+					break;
+				default:
+					Output.Write (c);
+					break;
+			}
+
+			Output.Write ('\'');
+		}
+
+		protected override void GenerateSingleFloatValue (float f)
+		{
+			base.GenerateSingleFloatValue (f);
+			base.Output.Write ('F');
+		}
+
+		protected override void GenerateDecimalValue (decimal d)
+		{
+			base.GenerateDecimalValue (d);
+			base.Output.Write ('m');
+		}
+
 		protected override void GenerateParameterDeclarationExpression (CodeParameterDeclarationExpression e)
 		{
 			OutputAttributes (e.CustomAttributes, null, true);

+ 6 - 0
mcs/class/System/Microsoft.CSharp/ChangeLog

@@ -1,3 +1,9 @@
+2005-12-07  Gert Driesen  <[email protected]>
+
+	* CSharpCodeGenerator.cs: Override GeneratePrimitiveExpression to
+	match .NET 1.x and 2.0 for float, decimal, char, ushort, uint, ulong
+	and sbyte.
+
 2005-11-30  Gert Driesen  <[email protected]>
 
 	* CSharpCodeGenerator.cs: No longer output semicolon and newline for

+ 5 - 0
mcs/class/System/Microsoft.VisualBasic/ChangeLog

@@ -1,3 +1,8 @@
+2005-12-07  Gert Driesen  <[email protected]>
+
+	* VBCodeGenerator.cs: Modified GeneratePrimitiveExpression to match
+	.NET 1.x and 2.0 for char, float, ushort, uint, ulong and sbyte.
+
 2005-11-30  Gert Driesen  <[email protected]>
 
 	* VBCodeGenerator.cs: Fixed NRE in GenerateEventReferenceExpression,

+ 32 - 23
mcs/class/System/Microsoft.VisualBasic/VBCodeGenerator.cs

@@ -322,31 +322,40 @@ namespace Microsoft.VisualBasic
 
 		protected override void GeneratePrimitiveExpression (CodePrimitiveExpression e)
 		{
-			TextWriter output = Output;
-
-			if (e.Value == null) {
-				output.Write (NullToken);
-				return;
+			if (e.Value is char) {
+				char c = (char) e.Value;
+				int ch = (int) c;
+#if NET_2_0
+				Output.Write("Global.Microsoft.VisualBasic.ChrW(" + ch.ToString(CultureInfo.InvariantCulture) + ")");
+			} else if (e.Value is ushort) {
+				ushort uc = (ushort) e.Value;
+				Output.Write (uc.ToString(CultureInfo.InvariantCulture));
+				Output.Write ("US");
+			} else if (e.Value is uint) {
+				uint ui = (uint) e.Value;
+				Output.Write (ui.ToString(CultureInfo.InvariantCulture));
+				Output.Write ("UI");
+			} else if (e.Value is ulong) {
+				ulong ul = (ulong) e.Value;
+				Output.Write (ul.ToString(CultureInfo.InvariantCulture));
+				Output.Write ("UL");
+			} else if (e.Value is sbyte) {
+				sbyte sb = (sbyte) e.Value;
+				Output.Write ("CSByte(");
+				Output.Write (sb.ToString(CultureInfo.InvariantCulture));
+				Output.Write (')');
+#else
+				Output.Write("Microsoft.VisualBasic.ChrW(" + ch.ToString(CultureInfo.InvariantCulture) + ")");
+#endif
+			} else {
+				base.GeneratePrimitiveExpression(e);
 			}
+		}
 
-			Type type = e.Value.GetType ();
-			if (type == typeof (bool)) {
-				output.Write (e.Value.ToString ().ToLower (CultureInfo.InvariantCulture));
-			} 
-			else if (type == typeof (char)) {
-				output.Write ("\"" + e.Value.ToString () + "\"c");
-			} 
-			else if (type == typeof (string)) {
-				output.Write (QuoteSnippetString ((string) e.Value));
-			} 
-			else if (type == typeof (byte) || type == typeof (sbyte) || type == typeof (short) ||
-				type == typeof (int) || type == typeof (long) || type == typeof (float) ||
-				type == typeof (double) || type == typeof (decimal)) {
-				output.Write (e.Value.ToString ());
-			} 
-			else {
-				throw new ArgumentException ("Value type (" + type + ") is not a primitive type");
-			}
+		protected override void GenerateSingleFloatValue (float s)
+		{
+			base.GenerateSingleFloatValue (s);
+			base.Output.Write ('!');
 		}
 
 		protected override void GeneratePropertyReferenceExpression (CodePropertyReferenceExpression expression)

+ 25 - 0
mcs/class/System/System.CodeDom.Compiler/ChangeLog

@@ -1,3 +1,28 @@
+2005-12-07  Gert Driesen  <[email protected]>
+
+	* CodeGenerator.cs: Modified GeneratePrimitiveExpression to throw 
+	ArgumentException for sbyte value, use GenerateSingleFloatValue for 
+	float, GenerateDecimalValue for decimal and GenerateDoubleValue for
+	double. Modified exception message for non-primitive types to match
+	MS.NET.
+	* ICodeCompiler.cs: Set eol-style to native.
+	* CodeCompiler.cs: Set eol-style to native.
+	* CodeDomConfigurationHandler.cs: Set eol-style to native.
+	* CodeDomProvider.cs: Set eol-style to native.
+	* CodeGeneratorOptions.cs: Set eol-style to native.
+	* CodeParser.cs: Set eol-style to native.
+	* CompilerError.cs: Set eol-style to native.
+	* CompilerErrorCollection.cs: Set eol-style to native.
+	* CompilerInfo.cs: Set eol-style to native.
+	* CompilerParameters.cs: Set eol-style to native.
+	* CompilerResults.cs: Set eol-style to native.
+	* Executor.cs: Set eol-style to native.
+	* GeneratorSupport.cs: Set eol-style to native.
+	* ICodeGenerator.cs: Set eol-style to native.
+	* ICodeParser.cs: Set eol-style to native.
+	* LanguageOptions.cs: Set eol-style to native.
+	* TempFileCollection.cs: Set eol-style to native.
+
 2005-11-30  Gert Driesen  <[email protected]>
 
 	* CodeGenerator.cs: Corrected line endings. Set eol-style to native.

+ 15 - 9
mcs/class/System/System.CodeDom.Compiler/CodeGenerator.cs

@@ -493,20 +493,26 @@ namespace System.CodeDom.Compiler {
 				output.Write ("'" + e.Value.ToString () + "'");
 			} else if (type == typeof (string)) {
 				output.Write (QuoteSnippetString ((string) e.Value));
-			} else if (type == typeof (byte) || type == typeof (sbyte) || type == typeof (short) ||
-				   type == typeof (int) || type == typeof (long) || type == typeof (float) ||
-				   type == typeof (double) || type == typeof (decimal)) {
+			} else if (type == typeof (float)) {
+				GenerateSingleFloatValue((float) e.Value);
+			} else if (type == typeof (double)) {
+				GenerateDoubleValue((double) e.Value);
+			} else if (type == typeof (decimal)) {
+				this.GenerateDecimalValue((decimal) e.Value);
+			} else if (type == typeof (byte) || type == typeof (short) || 
+				type == typeof (int) || type == typeof (long)) {
 				// All of these should be IFormatable, I am just being safe/slow 
 				IFormattable formattable = e.Value as IFormattable;
-				if (formattable != null)
+				if (formattable != null) {
 					output.Write (formattable.ToString (null, CultureInfo.InvariantCulture));
-				else
+				} else {
 					output.Write (e.Value.ToString ());
-					
-				if (type == typeof (float))
-					output.Write ("f");
+				}
 			} else {
-				throw new ArgumentException ("Value type (" + type + ") is not a primitive type");
+				throw new ArgumentException (string.Format(CultureInfo.InvariantCulture,
+					"Invalid Primitive Type: {0}. Only CLS compliant primitive " +
+					"types can be used. Consider using CodeObjectCreateExpression.",
+					type.FullName));
 			}
 		}
 

+ 5 - 0
mcs/class/System/Test/Microsoft.CSharp/ChangeLog

@@ -1,3 +1,8 @@
+2005-12-07  Gert Driesen  <[email protected]>
+
+	* CodeGeneratorFromExpressionTest.cs: Added tests for 
+	CodePrimitiveExpression.
+
 2005-11-30  Gert Driesen  <[email protected]>
 
 	* CodeGeneratorFromStatementTest.cs: Added tests for 

+ 190 - 0
mcs/class/System/Test/Microsoft.CSharp/CodeGeneratorFromExpressionTest.cs

@@ -121,6 +121,196 @@ namespace MonoTests.Microsoft.CSharp
 			}
 		}
 
+		[Test]
+		public void PrimitiveExpressionTest ()
+		{
+			StringBuilder sb = new StringBuilder ();
+
+			using (StringWriter sw = new StringWriter (sb)) {
+				Assert.AreEqual ("null", Generate (new CodePrimitiveExpression (null), sw), "#1");
+				sb.Length = 0;
+				Assert.AreEqual ("\"AB\\\"C\"", Generate (new CodePrimitiveExpression ("AB\"C"), sw), "#2");
+				sb.Length = 0;
+				Assert.AreEqual ("5", Generate (new CodePrimitiveExpression ((byte) 5), sw), "#4");
+				sb.Length = 0;
+				Assert.AreEqual ("20", Generate (new CodePrimitiveExpression ((short) 20), sw), "#5");
+				sb.Length = 0;
+				Assert.AreEqual ("243", Generate (new CodePrimitiveExpression (243), sw), "#6");
+				sb.Length = 0;
+				Assert.AreEqual ("434343", Generate (new CodePrimitiveExpression ((long) 434343), sw), "#7");
+				sb.Length = 0;
+				Assert.AreEqual ("6.445F", Generate (new CodePrimitiveExpression ((float) 6.445), sw), "#8");
+				sb.Length = 0;
+				Assert.AreEqual ("5.76", Generate (new CodePrimitiveExpression ((double) 5.76), sw), "#9");
+				sb.Length = 0;
+				Assert.AreEqual ("7.667m", Generate (new CodePrimitiveExpression ((decimal) 7.667), sw), "#10");
+				sb.Length = 0;
+				Assert.AreEqual ("true", Generate (new CodePrimitiveExpression (true), sw), "#11");
+				sb.Length = 0;
+				Assert.AreEqual ("false", Generate (new CodePrimitiveExpression (false), sw), "#12");
+				sw.Close ();
+			}
+		}
+
+		[Test]
+		public void PrimitiveExpressionTest_Char ()
+		{
+			StringBuilder sb = new StringBuilder ();
+
+			using (StringWriter sw = new StringWriter (sb)) {
+				Assert.AreEqual ("'\\0'", Generate (new CodePrimitiveExpression ('\0'), sw), "#0");
+				sb.Length = 0;
+				Assert.AreEqual ("'\x01'", Generate (new CodePrimitiveExpression ('\x01'), sw), "#1");
+				sb.Length = 0;
+				Assert.AreEqual ("'\x02'", Generate (new CodePrimitiveExpression ('\x02'), sw), "#2");
+				sb.Length = 0;
+				Assert.AreEqual ("'\x03'", Generate (new CodePrimitiveExpression ('\x03'), sw), "#3");
+				sb.Length = 0;
+				Assert.AreEqual ("'\x04'", Generate (new CodePrimitiveExpression ('\x04'), sw), "#4");
+				sb.Length = 0;
+				Assert.AreEqual ("'\x05'", Generate (new CodePrimitiveExpression ('\x05'), sw), "#5");
+				sb.Length = 0;
+				Assert.AreEqual ("'\x06'", Generate (new CodePrimitiveExpression ('\x06'), sw), "#6");
+				sb.Length = 0;
+				Assert.AreEqual ("'\a'", Generate (new CodePrimitiveExpression ('\a'), sw), "#7");
+				sb.Length = 0;
+				Assert.AreEqual ("'\b'", Generate (new CodePrimitiveExpression ('\b'), sw), "#8");
+				sb.Length = 0;
+				Assert.AreEqual ("'\\t'", Generate (new CodePrimitiveExpression ('\t'), sw), "#9");
+				sb.Length = 0;
+				Assert.AreEqual ("'\\n'", Generate (new CodePrimitiveExpression ('\n'), sw), "#10");
+				sb.Length = 0;
+				Assert.AreEqual ("'\v'", Generate (new CodePrimitiveExpression ('\v'), sw), "#11");
+				sb.Length = 0;
+				Assert.AreEqual ("'\f'", Generate (new CodePrimitiveExpression ('\f'), sw), "#12");
+				sb.Length = 0;
+				Assert.AreEqual ("'\\r'", Generate (new CodePrimitiveExpression ('\r'), sw), "#13");
+				sb.Length = 0;
+				Assert.AreEqual ("'\x0E'", Generate (new CodePrimitiveExpression ('\x0E'), sw), "#14");
+				sb.Length = 0;
+				Assert.AreEqual ("'\x0F'", Generate (new CodePrimitiveExpression ('\x0F'), sw), "#15");
+				sb.Length = 0;
+				Assert.AreEqual ("'\x10'", Generate (new CodePrimitiveExpression ('\x10'), sw), "#16");
+				sb.Length = 0;
+				Assert.AreEqual ("'\x11'", Generate (new CodePrimitiveExpression ('\x11'), sw), "#17");
+				sb.Length = 0;
+				Assert.AreEqual ("'\x12'", Generate (new CodePrimitiveExpression ('\x12'), sw), "#18");
+				sb.Length = 0;
+				Assert.AreEqual ("'\x13'", Generate (new CodePrimitiveExpression ('\x13'), sw), "#19");
+				sb.Length = 0;
+				Assert.AreEqual ("'\x14'", Generate (new CodePrimitiveExpression ('\x14'), sw), "#20");
+				sb.Length = 0;
+				Assert.AreEqual ("'\x15'", Generate (new CodePrimitiveExpression ('\x15'), sw), "#21");
+				sb.Length = 0;
+				Assert.AreEqual ("'\x16'", Generate (new CodePrimitiveExpression ('\x16'), sw), "#22");
+				sb.Length = 0;
+				Assert.AreEqual ("'\x17'", Generate (new CodePrimitiveExpression ('\x17'), sw), "#23");
+				sb.Length = 0;
+				Assert.AreEqual ("'\x18'", Generate (new CodePrimitiveExpression ('\x18'), sw), "#24");
+				sb.Length = 0;
+				Assert.AreEqual ("'\x19'", Generate (new CodePrimitiveExpression ('\x19'), sw), "#25");
+				sb.Length = 0;
+				Assert.AreEqual ("'\x1A'", Generate (new CodePrimitiveExpression ('\x1A'), sw), "#26");
+				sb.Length = 0;
+				Assert.AreEqual ("'\x1B'", Generate (new CodePrimitiveExpression ('\x1B'), sw), "#27");
+				sb.Length = 0;
+				Assert.AreEqual ("'\x1C'", Generate (new CodePrimitiveExpression ('\x1C'), sw), "#28");
+				sb.Length = 0;
+				Assert.AreEqual ("'\x1D'", Generate (new CodePrimitiveExpression ('\x1D'), sw), "#29");
+				sb.Length = 0;
+				Assert.AreEqual ("'\x1E'", Generate (new CodePrimitiveExpression ('\x1E'), sw), "#30");
+				sb.Length = 0;
+				Assert.AreEqual ("'\x1F'", Generate (new CodePrimitiveExpression ('\x1F'), sw), "#31");
+				sb.Length = 0;
+				Assert.AreEqual ("'\x20'", Generate (new CodePrimitiveExpression ('\x20'), sw), "#32");
+				sb.Length = 0;
+				Assert.AreEqual ("'\x21'", Generate (new CodePrimitiveExpression ('\x21'), sw), "#33");
+				sb.Length = 0;
+				Assert.AreEqual ("'\\\"'", Generate (new CodePrimitiveExpression ('"'), sw), "#34");
+				sb.Length = 0;
+				Assert.AreEqual ("'\x23'", Generate (new CodePrimitiveExpression ('\x23'), sw), "#35");
+				sb.Length = 0;
+				Assert.AreEqual ("'\x24'", Generate (new CodePrimitiveExpression ('\x24'), sw), "#36");
+				sb.Length = 0;
+				Assert.AreEqual ("'\x25'", Generate (new CodePrimitiveExpression ('\x25'), sw), "#37");
+				sb.Length = 0;
+				Assert.AreEqual ("'\x26'", Generate (new CodePrimitiveExpression ('\x26'), sw), "#38");
+				sb.Length = 0;
+				Assert.AreEqual ("'\\''", Generate (new CodePrimitiveExpression ('\''), sw), "#39");
+				sb.Length = 0;
+#if NET_2_0
+				Assert.AreEqual ("'\\u2028'", Generate (new CodePrimitiveExpression ('\u2028'), sw), "#40");
+#else
+				Assert.AreEqual ("'\\u8232'", Generate (new CodePrimitiveExpression ('\u2028'), sw), "#40");
+#endif
+				sb.Length = 0;
+#if NET_2_0
+				Assert.AreEqual ("'\\u2029'", Generate (new CodePrimitiveExpression ('\u2029'), sw), "#41");
+#else
+				Assert.AreEqual ("'\\u8233'", Generate (new CodePrimitiveExpression ('\u2029'), sw), "#41");
+#endif
+				sb.Length = 0;
+				Assert.AreEqual ("'\u2030'", Generate (new CodePrimitiveExpression ('\u2030'), sw), "#42");
+				sw.Close ();
+			}
+		}
+
+		[Test]
+#if ONLY_1_1
+		[ExpectedException (typeof (ArgumentException))]
+#endif
+		public void PrimitiveExpressionTest_SByte ()
+		{
+			StringBuilder sb = new StringBuilder ();
+
+			using (StringWriter sw = new StringWriter (sb)) {
+				Assert.AreEqual ("5", Generate (new CodePrimitiveExpression ((sbyte) 5), sw));
+				sw.Close ();
+			}
+		}
+
+		[Test]
+#if ONLY_1_1
+		[ExpectedException (typeof (ArgumentException))]
+#endif
+		public void PrimitiveExpressionTest_UInt16 ()
+		{
+			StringBuilder sb = new StringBuilder ();
+
+			using (StringWriter sw = new StringWriter (sb)) {
+				Assert.AreEqual ("5", Generate (new CodePrimitiveExpression ((ushort) 5), sw));
+				sw.Close ();
+			}
+		}
+
+		[Test]
+#if ONLY_1_1
+		[ExpectedException (typeof (ArgumentException))]
+#endif
+		public void PrimitiveExpressionTest_UInt32 ()
+		{
+			StringBuilder sb = new StringBuilder ();
+
+			using (StringWriter sw = new StringWriter (sb)) {
+				Assert.AreEqual ("5u", Generate (new CodePrimitiveExpression ((uint) 5), sw));
+				sw.Close ();
+			}
+		}
+
+		[Test]
+#if ONLY_1_1
+		[ExpectedException (typeof (ArgumentException))]
+#endif
+		public void PrimitiveExpressionTest_UInt64 ()
+		{
+			StringBuilder sb = new StringBuilder ();
+
+			using (StringWriter sw = new StringWriter (sb)) {
+				Assert.AreEqual ("5ul", Generate (new CodePrimitiveExpression ((ulong) 5), sw));
+				sw.Close ();
+			}
+		}
+
 		[Test]
 		public void ParameterDeclarationExpressionTest ()
 		{

+ 5 - 0
mcs/class/System/Test/Microsoft.VisualBasic/ChangeLog

@@ -1,3 +1,8 @@
+2005-12-07  Gert Driesen  <[email protected]>
+
+	* CodeGeneratorFromExpressionTest.cs: Added tests for
+	CodePrimitiveExpression.
+
 2005-11-30  Gert Driesen  <[email protected]>
 
 	* CodeGeneratorFromStatementTest.cs: Added tests for

+ 187 - 0
mcs/class/System/Test/Microsoft.VisualBasic/CodeGeneratorFromExpressionTest.cs

@@ -109,6 +109,193 @@ namespace MonoTests.Microsoft.VisualBasic
 			}
 		}
 
+		[Test]
+		public void PrimitiveExpressionTest ()
+		{
+			StringBuilder sb = new StringBuilder ();
+
+			using (StringWriter sw = new StringWriter (sb)) {
+				Assert.AreEqual ("Nothing", Generate (new CodePrimitiveExpression (null), sw), "#1");
+				sb.Length = 0;
+				Assert.AreEqual ("\"AB\"\"C\"", Generate (new CodePrimitiveExpression ("AB\"C"), sw), "#2");
+				sb.Length = 0;
+				Assert.AreEqual ("5", Generate (new CodePrimitiveExpression ((byte) 5), sw), "#4");
+				sb.Length = 0;
+				Assert.AreEqual ("20", Generate (new CodePrimitiveExpression ((short) 20), sw), "#5");
+				sb.Length = 0;
+				Assert.AreEqual ("243", Generate (new CodePrimitiveExpression (243), sw), "#6");
+				sb.Length = 0;
+				Assert.AreEqual ("434343", Generate (new CodePrimitiveExpression ((long) 434343), sw), "#7");
+				sb.Length = 0;
+				Assert.AreEqual ("6.445!", Generate (new CodePrimitiveExpression ((float) 6.445), sw), "#8");
+				sb.Length = 0;
+				Assert.AreEqual ("5.76", Generate (new CodePrimitiveExpression ((double) 5.76), sw), "#9");
+				sb.Length = 0;
+				Assert.AreEqual ("7.667", Generate (new CodePrimitiveExpression ((decimal) 7.667), sw), "#10");
+				sb.Length = 0;
+				Assert.AreEqual ("true", Generate (new CodePrimitiveExpression (true), sw), "#11");
+				sb.Length = 0;
+				Assert.AreEqual ("false", Generate (new CodePrimitiveExpression (false), sw), "#12");
+				sw.Close ();
+			}
+		}
+
+		[Test]
+		public void PrimitiveExpressionTest_Char ()
+		{
+#if NET_2_0
+			string vbNs = "Global.Microsoft.VisualBasic";
+#else
+			string vbNs = "Microsoft.VisualBasic";
+#endif
+			StringBuilder sb = new StringBuilder ();
+
+			using (StringWriter sw = new StringWriter (sb)) {
+				Assert.AreEqual (vbNs + ".ChrW(0)", Generate (new CodePrimitiveExpression ('\0'), sw), "#0");
+				sb.Length = 0;
+				Assert.AreEqual (vbNs + ".ChrW(1)", Generate (new CodePrimitiveExpression ('\x01'), sw), "#1");
+				sb.Length = 0;
+				Assert.AreEqual (vbNs + ".ChrW(2)", Generate (new CodePrimitiveExpression ('\x02'), sw), "#2");
+				sb.Length = 0;
+				Assert.AreEqual (vbNs + ".ChrW(3)", Generate (new CodePrimitiveExpression ('\x03'), sw), "#3");
+				sb.Length = 0;
+				Assert.AreEqual (vbNs + ".ChrW(4)", Generate (new CodePrimitiveExpression ('\x04'), sw), "#4");
+				sb.Length = 0;
+				Assert.AreEqual (vbNs + ".ChrW(5)", Generate (new CodePrimitiveExpression ('\x05'), sw), "#5");
+				sb.Length = 0;
+				Assert.AreEqual (vbNs + ".ChrW(6)", Generate (new CodePrimitiveExpression ('\x06'), sw), "#6");
+				sb.Length = 0;
+				Assert.AreEqual (vbNs + ".ChrW(7)", Generate (new CodePrimitiveExpression ('\a'), sw), "#7");
+				sb.Length = 0;
+				Assert.AreEqual (vbNs + ".ChrW(8)", Generate (new CodePrimitiveExpression ('\b'), sw), "#8");
+				sb.Length = 0;
+				Assert.AreEqual (vbNs + ".ChrW(9)", Generate (new CodePrimitiveExpression ('\t'), sw), "#9");
+				sb.Length = 0;
+				Assert.AreEqual (vbNs + ".ChrW(10)", Generate (new CodePrimitiveExpression ('\n'), sw), "#10");
+				sb.Length = 0;
+				Assert.AreEqual (vbNs + ".ChrW(11)", Generate (new CodePrimitiveExpression ('\v'), sw), "#11");
+				sb.Length = 0;
+				Assert.AreEqual (vbNs + ".ChrW(12)", Generate (new CodePrimitiveExpression ('\f'), sw), "#12");
+				sb.Length = 0;
+				Assert.AreEqual (vbNs + ".ChrW(13)", Generate (new CodePrimitiveExpression ('\r'), sw), "#13");
+				sb.Length = 0;
+				Assert.AreEqual (vbNs + ".ChrW(14)", Generate (new CodePrimitiveExpression ('\x0E'), sw), "#14");
+				sb.Length = 0;
+				Assert.AreEqual (vbNs + ".ChrW(15)", Generate (new CodePrimitiveExpression ('\x0F'), sw), "#15");
+				sb.Length = 0;
+				Assert.AreEqual (vbNs + ".ChrW(16)", Generate (new CodePrimitiveExpression ('\x10'), sw), "#16");
+				sb.Length = 0;
+				Assert.AreEqual (vbNs + ".ChrW(17)", Generate (new CodePrimitiveExpression ('\x11'), sw), "#17");
+				sb.Length = 0;
+				Assert.AreEqual (vbNs + ".ChrW(18)", Generate (new CodePrimitiveExpression ('\x12'), sw), "#18");
+				sb.Length = 0;
+				Assert.AreEqual (vbNs + ".ChrW(19)", Generate (new CodePrimitiveExpression ('\x13'), sw), "#19");
+				sb.Length = 0;
+				Assert.AreEqual (vbNs + ".ChrW(20)", Generate (new CodePrimitiveExpression ('\x14'), sw), "#20");
+				sb.Length = 0;
+				Assert.AreEqual (vbNs + ".ChrW(21)", Generate (new CodePrimitiveExpression ('\x15'), sw), "#21");
+				sb.Length = 0;
+				Assert.AreEqual (vbNs + ".ChrW(22)", Generate (new CodePrimitiveExpression ('\x16'), sw), "#22");
+				sb.Length = 0;
+				Assert.AreEqual (vbNs + ".ChrW(23)", Generate (new CodePrimitiveExpression ('\x17'), sw), "#23");
+				sb.Length = 0;
+				Assert.AreEqual (vbNs + ".ChrW(24)", Generate (new CodePrimitiveExpression ('\x18'), sw), "#24");
+				sb.Length = 0;
+				Assert.AreEqual (vbNs + ".ChrW(25)", Generate (new CodePrimitiveExpression ('\x19'), sw), "#25");
+				sb.Length = 0;
+				Assert.AreEqual (vbNs + ".ChrW(26)", Generate (new CodePrimitiveExpression ('\x1A'), sw), "#26");
+				sb.Length = 0;
+				Assert.AreEqual (vbNs + ".ChrW(27)", Generate (new CodePrimitiveExpression ('\x1B'), sw), "#27");
+				sb.Length = 0;
+				Assert.AreEqual (vbNs + ".ChrW(28)", Generate (new CodePrimitiveExpression ('\x1C'), sw), "#28");
+				sb.Length = 0;
+				Assert.AreEqual (vbNs + ".ChrW(29)", Generate (new CodePrimitiveExpression ('\x1D'), sw), "#29");
+				sb.Length = 0;
+				Assert.AreEqual (vbNs + ".ChrW(30)", Generate (new CodePrimitiveExpression ('\x1E'), sw), "#30");
+				sb.Length = 0;
+				Assert.AreEqual (vbNs + ".ChrW(31)", Generate (new CodePrimitiveExpression ('\x1F'), sw), "#31");
+				sb.Length = 0;
+				Assert.AreEqual (vbNs + ".ChrW(32)", Generate (new CodePrimitiveExpression ('\x20'), sw), "#32");
+				sb.Length = 0;
+				Assert.AreEqual (vbNs + ".ChrW(33)", Generate (new CodePrimitiveExpression ('\x21'), sw), "#33");
+				sb.Length = 0;
+				Assert.AreEqual (vbNs + ".ChrW(34)", Generate (new CodePrimitiveExpression ('"'), sw), "#34");
+				sb.Length = 0;
+				Assert.AreEqual (vbNs + ".ChrW(35)", Generate (new CodePrimitiveExpression ('\x23'), sw), "#35");
+				sb.Length = 0;
+				Assert.AreEqual (vbNs + ".ChrW(36)", Generate (new CodePrimitiveExpression ('\x24'), sw), "#36");
+				sb.Length = 0;
+				Assert.AreEqual (vbNs + ".ChrW(37)", Generate (new CodePrimitiveExpression ('\x25'), sw), "#37");
+				sb.Length = 0;
+				Assert.AreEqual (vbNs + ".ChrW(38)", Generate (new CodePrimitiveExpression ('\x26'), sw), "#38");
+				sb.Length = 0;
+				Assert.AreEqual (vbNs + ".ChrW(39)", Generate (new CodePrimitiveExpression ('\''), sw), "#39");
+				sb.Length = 0;
+				Assert.AreEqual (vbNs + ".ChrW(8232)", Generate (new CodePrimitiveExpression ('\u2028'), sw), "#40");
+				sb.Length = 0;
+				Assert.AreEqual (vbNs + ".ChrW(8233)", Generate (new CodePrimitiveExpression ('\u2029'), sw), "#41");
+				sb.Length = 0;
+				Assert.AreEqual (vbNs + ".ChrW(8240)", Generate (new CodePrimitiveExpression ('\u2030'), sw), "#42");
+				sw.Close ();
+			}
+		}
+
+		[Test]
+#if ONLY_1_1
+		[ExpectedException (typeof (ArgumentException))]
+#endif
+		public void PrimitiveExpressionTest_SByte ()
+		{
+			StringBuilder sb = new StringBuilder ();
+
+			using (StringWriter sw = new StringWriter (sb)) {
+				Assert.AreEqual ("CSByte(5)", Generate (new CodePrimitiveExpression ((sbyte) 5), sw));
+				sw.Close ();
+			}
+		}
+
+		[Test]
+#if ONLY_1_1
+		[ExpectedException (typeof (ArgumentException))]
+#endif
+		public void PrimitiveExpressionTest_UInt16 ()
+		{
+			StringBuilder sb = new StringBuilder ();
+
+			using (StringWriter sw = new StringWriter (sb)) {
+				Assert.AreEqual ("5US", Generate (new CodePrimitiveExpression ((ushort) 5), sw));
+				sw.Close ();
+			}
+		}
+
+		[Test]
+#if ONLY_1_1
+		[ExpectedException (typeof (ArgumentException))]
+#endif
+		public void PrimitiveExpressionTest_UInt32 ()
+		{
+			StringBuilder sb = new StringBuilder ();
+
+			using (StringWriter sw = new StringWriter (sb)) {
+				Assert.AreEqual ("5UI", Generate (new CodePrimitiveExpression ((uint) 5), sw));
+				sw.Close ();
+			}
+		}
+
+		[Test]
+#if ONLY_1_1
+		[ExpectedException (typeof (ArgumentException))]
+#endif
+		public void PrimitiveExpressionTest_UInt64 ()
+		{
+			StringBuilder sb = new StringBuilder ();
+
+			using (StringWriter sw = new StringWriter (sb)) {
+				Assert.AreEqual ("5UL", Generate (new CodePrimitiveExpression ((ulong) 5), sw));
+				sw.Close ();
+			}
+		}
+
 		[Test]
 		public void ParameterDeclarationExpressionTest ()
 		{