Author: mhabersack
Date: 2008-02-06 10:04:00 -0500 (Wed, 06 Feb 2008)
New Revision: 95028
Modified:
trunk/mcs/class/System.Web/System.Web.Compilation/AppCodeCompiler.cs
trunk/mcs/class/System.Web/System.Web.Compilation/AppResourcesAssemblyBuilder.cs
trunk/mcs/class/System.Web/System.Web.Compilation/AssemblyBuilder.cs
trunk/mcs/class/System.Web/System.Web.Compilation/BuildManager.cs
trunk/mcs/class/System.Web/System.Web.Compilation/ChangeLog
trunk/mcs/class/System.Web/System.Web.Compilation/GenericBuildProvider.cs
Log:
2008-02-06 Marek Habersack <[EMAIL PROTECTED]>
* GenericBuildProvider.cs: GetGeneratedType may return a type even
though the results are null.
* AssemblyBuilder.cs: if there are no units and no source files,
do not attempt to compile the assembly.
* AppResourcesAssemblyBuilder.cs, AppCodeCompiler.cs: expect that
BuildAssembly may return null results.
* BuildManager.cs: If AssemblyBuilder returns no results from
BuildAssembly, it might
mean we're dealing with a compilation of empty .as[hm]x files,
with no code and only code-behind in bin/. Do not report an error
in that case, only add the compiled types to the cache. Fixes bug
#357624.
Modified: trunk/mcs/class/System.Web/System.Web.Compilation/AppCodeCompiler.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.Compilation/AppCodeCompiler.cs
2008-02-06 14:44:06 UTC (rev 95027)
+++ trunk/mcs/class/System.Web/System.Web.Compilation/AppCodeCompiler.cs
2008-02-06 15:04:00 UTC (rev 95028)
@@ -257,6 +257,9 @@
foreach (Assembly a in BuildManager.TopLevelAssemblies)
parameters.ReferencedAssemblies.Add
(a.Location);
CompilerResults results = abuilder.BuildAssembly
(parameters);
+ if (results == null)
+ return;
+
if (results.NativeCompilerReturnValue == 0) {
BuildManager.CodeAssemblies.Add
(results.CompiledAssembly);
BuildManager.TopLevelAssemblies.Add
(results.CompiledAssembly);
Modified:
trunk/mcs/class/System.Web/System.Web.Compilation/AppResourcesAssemblyBuilder.cs
===================================================================
---
trunk/mcs/class/System.Web/System.Web.Compilation/AppResourcesAssemblyBuilder.cs
2008-02-06 14:44:06 UTC (rev 95027)
+++
trunk/mcs/class/System.Web/System.Web.Compilation/AppResourcesAssemblyBuilder.cs
2008-02-06 15:04:00 UTC (rev 95028)
@@ -114,6 +114,9 @@
cp.EmbeddedResources.Add (f);
CompilerResults results = abuilder.BuildAssembly (cp);
+ if (results == null)
+ return;
+
Assembly ret = null;
if (results.NativeCompilerReturnValue == 0) {
Modified: trunk/mcs/class/System.Web/System.Web.Compilation/AssemblyBuilder.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.Compilation/AssemblyBuilder.cs
2008-02-06 14:44:06 UTC (rev 95027)
+++ trunk/mcs/class/System.Web/System.Web.Compilation/AssemblyBuilder.cs
2008-02-06 15:04:00 UTC (rev 95028)
@@ -508,8 +508,13 @@
// files. This also facilates possible debugging for the
// end user, since they get the code beforehand.
List <string> files = SourceFiles;
+
+ if (units.Length == 0 && files.Count == 0)
+ return null;
+
string filename;
StreamWriter sw = null;
+
foreach (CodeCompileUnit unit in units) {
filename = GetTempFilePhysicalPath
(provider.FileExtension);
try {
Modified: trunk/mcs/class/System.Web/System.Web.Compilation/BuildManager.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.Compilation/BuildManager.cs
2008-02-06 14:44:06 UTC (rev 95027)
+++ trunk/mcs/class/System.Web/System.Web.Compilation/BuildManager.cs
2008-02-06 15:04:00 UTC (rev 95028)
@@ -825,12 +825,17 @@
foreach (AssemblyBuilder abuilder in
abuilders) {
abuilder.AddAssemblyReference
(GetReferencedAssemblies () as List <Assembly>);
results =
abuilder.BuildAssembly (virtualPath);
- compiledAssembly =
results.CompiledAssembly;
+
+ // No results is not an error -
it is possible that the assembly builder contained only .asmx and
+ // .ashx files which had no
body, just the directive. In such case, no code unit or code file is added
+ // to the assembly builder and,
in effect, no assembly is produced but there are STILL types that need
+ // to be added to the cache.
+ compiledAssembly = results !=
null ? results.CompiledAssembly : null;
lock (buildCacheLock) {
switch (buildKind) {
case
BuildKind.NonPages:
- if
(!referencedAssemblies.Contains (compiledAssembly))
+ if
(compiledAssembly != null && !referencedAssemblies.Contains (compiledAssembly))
referencedAssemblies.Add (compiledAssembly);
break;
@@ -852,7 +857,7 @@
buildCache.Add (vp, new BuildCacheItem (compiledAssembly, bp, results));
}
- if
(!nonPagesCache.ContainsKey (vp))
+ if
(compiledAssembly != null && !nonPagesCache.ContainsKey (vp))
nonPagesCache.Add (vp, compiledAssembly);
}
}
Modified: trunk/mcs/class/System.Web/System.Web.Compilation/ChangeLog
===================================================================
--- trunk/mcs/class/System.Web/System.Web.Compilation/ChangeLog 2008-02-06
14:44:06 UTC (rev 95027)
+++ trunk/mcs/class/System.Web/System.Web.Compilation/ChangeLog 2008-02-06
15:04:00 UTC (rev 95028)
@@ -1,10 +1,24 @@
2008-02-06 Marek Habersack <[EMAIL PROTECTED]>
+ * GenericBuildProvider.cs: GetGeneratedType may return a type even
+ though the results are null.
+
+ * AssemblyBuilder.cs: if there are no units and no source files,
+ do not attempt to compile the assembly.
+
+ * AppResourcesAssemblyBuilder.cs, AppCodeCompiler.cs: expect that
+ BuildAssembly may return null results.
+
* BuildManager.cs: protect non-page builds from endless recursion
if a non-page file recursively references/includes another file
from the same batch. If such case is detected, the recursively
referenced file is compiled into a separate assembly and removed
from the previous compilation batch. Fixes bug #358742.
+ If AssemblyBuilder returns no results from BuildAssembly, it might
+ mean we're dealing with a compilation of empty .as[hm]x files,
+ with no code and only code-behind in bin/. Do not report an error
+ in that case, only add the compiled types to the cache. Fixes bug
+ #357624.
2008-02-05 Marek Habersack <[EMAIL PROTECTED]>
Modified:
trunk/mcs/class/System.Web/System.Web.Compilation/GenericBuildProvider.cs
===================================================================
--- trunk/mcs/class/System.Web/System.Web.Compilation/GenericBuildProvider.cs
2008-02-06 14:44:06 UTC (rev 95027)
+++ trunk/mcs/class/System.Web/System.Web.Compilation/GenericBuildProvider.cs
2008-02-06 15:04:00 UTC (rev 95028)
@@ -124,15 +124,12 @@
public override Type GetGeneratedType (CompilerResults results)
{
- if (_compiler == null || results == null)
- return null;
-
- if (NeedsLoadFromBin)
+ if (NeedsLoadFromBin && _compiler != null)
return LoadTypeFromBin (_compiler, Parser);
// This is not called if compilation failed.
// Returning null makes the caller throw an
InvalidCastException
- Assembly assembly = results.CompiledAssembly;
+ Assembly assembly = results != null ?
results.CompiledAssembly : null;
if (assembly == null)
return null;
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches