Author: jbevain
Date: 2007-10-06 23:01:07 -0400 (Sat, 06 Oct 2007)
New Revision: 87045
Modified:
trunk/mcs/mcs/ChangeLog
trunk/mcs/mcs/codegen.cs
trunk/mcs/mcs/typemanager.cs
Log:
2007-10-07 Jb Evain <[EMAIL PROTECTED]>
* typemanager.cs: add `assembly_version_attribute_type`.
* codegen.cs: on attribute emission, check that the
AssemblyVersionAttribute doesn't overflow.
Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog 2007-10-07 02:58:50 UTC (rev 87044)
+++ trunk/mcs/mcs/ChangeLog 2007-10-07 03:01:07 UTC (rev 87045)
@@ -1,3 +1,9 @@
+2007-10-07 Jb Evain <[EMAIL PROTECTED]>
+
+ * typemanager.cs: add `assembly_version_attribute_type`.
+ * codegen.cs: on attribute emission, check that the
+ AssemblyVersionAttribute doesn't overflow.
+
2007-10-05 Marek Safar <[EMAIL PROTECTED]>
A fix for bug #324677
Modified: trunk/mcs/mcs/codegen.cs
===================================================================
--- trunk/mcs/mcs/codegen.cs 2007-10-07 02:58:50 UTC (rev 87044)
+++ trunk/mcs/mcs/codegen.cs 2007-10-07 03:01:07 UTC (rev 87045)
@@ -1315,6 +1315,23 @@
}
#endif
+ static bool IsValidAssemblyVersion (string version)
+ {
+ Version v;
+ try {
+ v = new Version (version);
+ } catch {
+ return false;
+ }
+
+ foreach (int candidate in new int [] { v.Major,
v.Minor, v.Build, v.Revision }) {
+ if (candidate > ushort.MaxValue)
+ return false;
+ }
+
+ return true;
+ }
+
public override void ApplyAttributeBuilder (Attribute a,
CustomAttributeBuilder customBuilder)
{
if (a.Type.IsSubclassOf
(TypeManager.security_attr_type) && a.CheckSecurityActionValidity (true)) {
@@ -1336,6 +1353,17 @@
}
}
+ if (a.Type ==
TypeManager.assembly_version_attribute_type) {
+ string value = a.GetString ();
+ if (value == null || value.Length == 0)
+ return;
+
+ if (!IsValidAssemblyVersion (value)) {
+ a.Error_AttributeEmitError
(string.Format ("Specified version `{0}' is not valid", value));
+ return;
+ }
+ }
+
#if GMCS_SOURCE
if (a.Type == TypeManager.internals_visible_attr_type
&& !CheckInternalsVisibleAttribute (a))
return;
Modified: trunk/mcs/mcs/typemanager.cs
===================================================================
--- trunk/mcs/mcs/typemanager.cs 2007-10-07 02:58:50 UTC (rev 87044)
+++ trunk/mcs/mcs/typemanager.cs 2007-10-07 03:01:07 UTC (rev 87045)
@@ -108,6 +108,7 @@
static public Type required_attr_type;
static public Type guid_attr_type;
static public Type assembly_culture_attribute_type;
+ static public Type assembly_version_attribute_type;
static public Type coclass_attr_type;
static public Type comimport_attr_type;
@@ -1103,6 +1104,7 @@
required_attr_type = CoreLookupType
("System.Runtime.CompilerServices", "RequiredAttributeAttribute", true);
guid_attr_type = CoreLookupType
("System.Runtime.InteropServices", "GuidAttribute");
assembly_culture_attribute_type = CoreLookupType
("System.Reflection", "AssemblyCultureAttribute");
+ assembly_version_attribute_type = CoreLookupType
("System.Reflection", "AssemblyVersionAttribute");
comimport_attr_type = CoreLookupType
("System.Runtime.InteropServices", "ComImportAttribute");
coclass_attr_type = CoreLookupType
("System.Runtime.InteropServices", "CoClassAttribute");
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches