Răsfoiți Sursa

2007-04-06 Marek Habersack <[email protected]>

	* BaseCompiler.cs: display the source of the file in which the
	error actually happened if the file exists, or the unit
	otherwise.

svn path=/trunk/mcs/; revision=75482
Marek Habersack 19 ani în urmă
părinte
comite
0fe038646e

+ 13 - 3
mcs/class/System.Web/System.Web.Compilation/BaseCompiler.cs

@@ -440,9 +440,19 @@ namespace System.Web.Compilation
 			if (results.NativeCompilerReturnValue == 0)
 				return;
 
-			StringWriter writer = new StringWriter();
-			provider.CreateGenerator().GenerateCodeFromCompileUnit (unit, writer, null);
-			throw new CompilationException (parser.InputFile, results.Errors, writer.ToString ());
+			string fileText = null;
+			CompilerErrorCollection errors = results.Errors;
+			CompilerError ce = (errors != null && errors.Count > 0) ? errors [0] : null;
+			string inFile = (ce != null) ? ce.FileName : null;
+			
+			if (inFile != null && File.Exists (inFile))
+				fileText = File.ReadAllText (inFile);
+			else {
+				StringWriter writer = new StringWriter();
+				provider.CreateGenerator().GenerateCodeFromCompileUnit (unit, writer, null);
+				fileText = writer.ToString ();
+			}
+			throw new CompilationException (parser.InputFile, errors, fileText);
 		}
 
 		protected string DynamicDir ()

+ 6 - 0
mcs/class/System.Web/System.Web.Compilation/ChangeLog

@@ -1,3 +1,9 @@
+2007-04-06  Marek Habersack  <[email protected]>
+
+	* BaseCompiler.cs: display the source of the file in which the
+	error actually happened if the file exists, or the unit
+	otherwise.
+
 2007-04-03  Marek Habersack  <[email protected]>
 
 	* AppResourcesCompiler.cs: global resources are put in the