Author: marek
Date: 2005-07-07 07:09:52 -0400 (Thu, 07 Jul 2005)
New Revision: 47034
Modified:
trunk/mcs/mcs/ChangeLog
trunk/mcs/mcs/attribute.cs
trunk/mcs/mcs/driver.cs
Log:
2005-07-07 Marek Safar <[EMAIL PROTECTED]>
Fix #74975
* attribute.cs (orig_sec_assembly): Holds original version of assembly.
(ExtractSecurityPermissionSet): Cope with self referencing security
attributes properly.
* driver.cs (SetOutputFile): Made public property OutputFile.
Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog 2005-07-07 10:16:42 UTC (rev 47033)
+++ trunk/mcs/mcs/ChangeLog 2005-07-07 11:09:52 UTC (rev 47034)
@@ -1,3 +1,12 @@
+2005-07-07 Marek Safar <[EMAIL PROTECTED]>
+
+ Fix #74975
+ * attribute.cs (orig_sec_assembly): Holds original version of assembly.
+ (ExtractSecurityPermissionSet): Cope with self referencing security
+ attributes properly.
+
+ * driver.cs (SetOutputFile): Made public property OutputFile.
+
2005-07-07 Raja R Harinath <[EMAIL PROTECTED]>
Fix #75486.
Modified: trunk/mcs/mcs/attribute.cs
===================================================================
--- trunk/mcs/mcs/attribute.cs 2005-07-07 10:16:42 UTC (rev 47033)
+++ trunk/mcs/mcs/attribute.cs 2005-07-07 11:09:52 UTC (rev 47034)
@@ -21,6 +21,7 @@
using System.Security;
using System.Security.Permissions;
using System.Text;
+using System.IO;
namespace Mono.CSharp {
@@ -84,6 +85,7 @@
bool resolve_error;
static AttributeUsageAttribute DefaultUsageAttribute = new
AttributeUsageAttribute (AttributeTargets.All);
+ static Assembly orig_sec_assembly;
// non-null if named args present after Resolve () is called
PropertyInfo [] prop_info_arr;
@@ -838,14 +840,34 @@
/// <returns></returns>
public void ExtractSecurityPermissionSet (ListDictionary
permissions)
{
- if (TypeManager.LookupDeclSpace (Type) != null &&
RootContext.StdLib) {
- Error_AttributeEmitError ("security custom
attributes can not be referenced from defining assembly");
- return;
+ Type orig_assembly_type = null;
+
+ if (TypeManager.LookupDeclSpace (Type) != null) {
+ if (!RootContext.StdLib) {
+ orig_assembly_type = Type.GetType
(Type.FullName);
+ } else {
+ string orig_version_path =
Environment.GetEnvironmentVariable ("__SECURITY_BOOTSTRAP_DB");
+ if (orig_version_path == null) {
+ Error_AttributeEmitError
("security custom attributes can not be referenced from defining assembly");
+ return;
+ }
+
+ if (orig_sec_assembly == null) {
+ string file = Path.Combine
(orig_version_path, Driver.OutputFile);
+ orig_sec_assembly =
Assembly.LoadFile (file);
+ }
+
+ orig_assembly_type =
orig_sec_assembly.GetType (Type.FullName, true);
+ if (orig_assembly_type == null) {
+ Report.Warning (-112, 1,
Location, "Self-referenced security attribute `{0}' was not found in previous
version of assembly");
+ return;
+ }
+ }
}
SecurityAttribute sa;
- // For all assemblies except corlib we can avoid all
hacks
- if (RootContext.StdLib) {
+ // For all non-selfreferencing security attributes we
can avoid all hacks
+ if (orig_assembly_type == null) {
sa = (SecurityAttribute)
Activator.CreateInstance (Type, pos_values);
if (prop_info_arr != null) {
@@ -855,15 +877,14 @@
}
}
} else {
- Type temp_type = Type.GetType (Type.FullName);
- // HACK: All mscorlib attributes have same ctor
syntax
- sa = (SecurityAttribute)
Activator.CreateInstance (temp_type, new object[] { GetSecurityActionValue () }
);
+ // HACK: All security attributes have same ctor
syntax
+ sa = (SecurityAttribute)
Activator.CreateInstance (orig_assembly_type, new object[] {
GetSecurityActionValue () } );
- // All types are from newly created corlib but
for invocation with old we need to convert them
+ // All types are from newly created assembly
but for invocation with old one we need to convert them
if (prop_info_arr != null) {
for (int i = 0; i <
prop_info_arr.Length; ++i) {
PropertyInfo emited_pi =
prop_info_arr [i];
- PropertyInfo pi =
temp_type.GetProperty (emited_pi.Name, emited_pi.PropertyType);
+ PropertyInfo pi =
orig_assembly_type.GetProperty (emited_pi.Name, emited_pi.PropertyType);
object old_instance =
pi.PropertyType.IsEnum ?
System.Enum.ToObject
(pi.PropertyType, prop_values_arr [i]) :
Modified: trunk/mcs/mcs/driver.cs
===================================================================
--- trunk/mcs/mcs/driver.cs 2005-07-07 10:16:42 UTC (rev 47033)
+++ trunk/mcs/mcs/driver.cs 2005-07-07 11:09:52 UTC (rev 47034)
@@ -601,9 +601,14 @@
soft_references.Insert (p++, def);
}
- static void SetOutputFile (string name)
+ public static string OutputFile
{
- output_file = name;
+ set {
+ output_file = value;
+ }
+ get {
+ return Path.GetFileName (output_file);
+ }
}
static void SetWarningLevel (string s)
@@ -711,7 +716,7 @@
Usage ();
Environment.Exit (1);
}
- SetOutputFile (args [++i]);
+ OutputFile = args [++i];
return true;
case "--checked":
@@ -949,7 +954,7 @@
Usage ();
Environment.Exit (1);
}
- SetOutputFile (value);
+ OutputFile = value;
return true;
case "/optimize":
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches