Explorar el Código

2008-05-28 Marek Habersack <[email protected]>

	* TemplateParser.cs: added support for #pragma checksum

2008-05-28  Marek Habersack  <[email protected]>

	* AspParser.cs, AspGenerator.cs, BaseCompiler.cs: added support
	for #pragma checksum

svn path=/trunk/mcs/; revision=104321
Marek Habersack hace 17 años
padre
commit
f0d27ade04

+ 1 - 0
mcs/class/System.Web/System.Web.Compilation/AspGenerator.cs

@@ -250,6 +250,7 @@ namespace System.Web.Compilation
 				
 				tparser.AddDependency (arvp);
 			}
+			tparser.MD5Checksum = parser.MD5Checksum;
 		}
 		
 		void InitParser (string filename)

+ 10 - 0
mcs/class/System.Web/System.Web.Compilation/AspParser.cs

@@ -33,6 +33,7 @@ using System.Globalization;
 using System.IO;
 using System.Text;
 using System.Web.Util;
+using System.Security.Cryptography;
 
 namespace System.Web.Compilation
 {
@@ -46,6 +47,7 @@ namespace System.Web.Compilation
 		int beginLine, endLine;
 		int beginColumn, endColumn;
 		int beginPosition, endPosition;
+		byte[] md5checksum;
 		string filename;
 		string fileText;
 		string verbatimID;
@@ -54,10 +56,18 @@ namespace System.Web.Compilation
 		{
 			this.filename = filename;
 			fileText = input.ReadToEnd ();
+
+			MD5 md5 = MD5.Create ();
+			md5checksum = md5.ComputeHash (Encoding.UTF8.GetBytes (fileText));
+			
 			StringReader reader = new StringReader (fileText);
 			tokenizer = new AspTokenizer (reader);
 		}
 
+		public byte[] MD5Checksum {
+			get { return md5checksum; }
+		}
+		
 		public int BeginLine {
 			get { return beginLine; }
 		}

+ 14 - 1
mcs/class/System.Web/System.Web.Compilation/BaseCompiler.cs

@@ -44,7 +44,8 @@ namespace System.Web.Compilation
 	abstract class BaseCompiler
 	{
 		const string DEFAULT_NAMESPACE = "ASP";
-		
+
+		static Guid HashMD5 = new Guid(0x406ea660, 0x64cf, 0x4c82, 0xb6, 0xf0, 0x42, 0xd4, 0x81, 0x72, 0xa7, 0x99);
 #if NET_2_0
 		static BindingFlags replaceableFlags = BindingFlags.Public | BindingFlags.NonPublic |
 						  BindingFlags.Instance;
@@ -142,6 +143,18 @@ namespace System.Web.Compilation
 		internal void ConstructType ()
 		{
 			unit = new CodeCompileUnit ();
+
+			byte[] md5checksum = parser.MD5Checksum;
+
+			if (md5checksum != null) {
+				CodeChecksumPragma pragma = new CodeChecksumPragma ();
+				pragma.FileName = parser.InputFile;
+				pragma.ChecksumAlgorithmId = HashMD5;
+				pragma.ChecksumData = md5checksum;
+
+				unit.StartDirectives.Add (pragma);
+			}
+			
 #if NET_2_0
 			if (parser.IsPartial) {
 				string partialns = null;

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

@@ -1,3 +1,8 @@
+2008-05-28  Marek Habersack  <[email protected]>
+
+	* AspParser.cs, AspGenerator.cs, BaseCompiler.cs: added support
+	for #pragma checksum
+
 2008-05-19  Marek Habersack  <[email protected]>
 
 	* AspGenerator.cs: if the last tag parsed was a code directive,

+ 4 - 0
mcs/class/System.Web/System.Web.UI/ChangeLog

@@ -1,3 +1,7 @@
+2008-05-28  Marek Habersack  <[email protected]>
+
+	* TemplateParser.cs: added support for #pragma checksum
+
 2008-05-19  Juraj Skripsky  <[email protected]>
 
 	* Page.cs (ValidateCollection): Don't check _eventValidation, it

+ 6 - 0
mcs/class/System.Web/System.Web.UI/TemplateParser.cs

@@ -105,6 +105,7 @@ namespace System.Web.UI {
 		Stack includeDirs;
 #endif
 		ILocation directiveLocation;
+		byte[] md5checksum;
 		
 		Assembly srcAssembly;
 		int appAssemblyIndex = -1;
@@ -883,6 +884,11 @@ namespace System.Web.UI {
 		internal abstract string DefaultBaseTypeName { get; }
 		internal abstract string DefaultDirectiveName { get; }
 
+		internal byte[] MD5Checksum {
+			get { return md5checksum; }
+			set { md5checksum = value; }
+		}
+		
 		internal Type DefaultBaseType {
 			get {
 				Type type = Type.GetType (DefaultBaseTypeName, true);