Jelajahi Sumber

[corlib] Move the implementations of virtual methods from Assembly to RuntimeAssembly to ease netcore integration. (#12805)

* [corlib] Move the implementations of virtual methods from Assembly to RuntimeAssembly to ease netcore integration.

* [corlib] Move more code to RuntimeAssembly.

* [corlib] Move fields from Assembly to RuntimeAssembly/AssemblyBuilder.cs. Reduce the amount of fields visible to runtime code.

* Update serialization tests.

* Fix the MOBILE build.

* Bump API snapshot submodule
Zoltan Varga 6 tahun lalu
induk
melakukan
e14ef8a658

+ 1 - 1
configure.ac

@@ -48,7 +48,7 @@ MONO_VERSION_BUILD=`echo $VERSION | cut -d . -f 3`
 # There is no ordering of corlib versions, no old or new,
 # the runtime expects an exact match.
 #
-MONO_CORLIB_VERSION=9032116E-BB4E-4ED5-9C71-9E5E0B0230CA
+MONO_CORLIB_VERSION=C79A0703-DD79-437D-BE29-99A84058CAC5
 
 #
 # Put a quoted #define in config.h.

+ 1 - 1
external/api-snapshot

@@ -1 +1 @@
-Subproject commit b5ab0878b257c27f34189d672caff2d6bc8b1f1b
+Subproject commit 5fdeee75a5e1170067a322a5fd56c225db69b513

File diff ditekan karena terlalu besar
+ 0 - 0
mcs/class/System.Web/Test/System.Web.Caching/OutputCacheTest.cs


+ 1 - 1
mcs/class/corlib/Mono.Globalization.Unicode/MSCompatUnicodeTable.cs

@@ -595,7 +595,7 @@ namespace Mono.Globalization.Unicode
 		{
 			int size;
 			Module module;
-			return Assembly.GetExecutingAssembly ().GetManifestResourceInternal (name, out size, out module);
+			return ((RuntimeAssembly)Assembly.GetExecutingAssembly ()).GetManifestResourceInternal (name, out size, out module);
 		}
 #elif USE_C_HEADER
 		const int CollationTableIdxIgnorables = 0;

+ 1 - 1
mcs/class/corlib/System.Diagnostics/StackTrace.cs

@@ -202,7 +202,7 @@ namespace System.Diagnostics {
 		static string GetAotId ()
 		{
 			if (!isAotidSet) {
-				aotid = Assembly.GetAotId ();
+				aotid = RuntimeAssembly.GetAotId ();
 				if (aotid != null)
 					aotid = new Guid (aotid).ToString ("N");
 				isAotidSet = true;

+ 71 - 9
mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.cs

@@ -239,6 +239,20 @@ namespace System.Reflection.Emit
 	[StructLayout (LayoutKind.Sequential)]
 	public sealed partial class AssemblyBuilder : Assembly
 	{
+		//
+		// AssemblyBuilder inherits from Assembly, but the runtime thinks its layout inherits from RuntimeAssembly
+		//
+		#region Sync with RuntimeAssembly.cs and ReflectionAssembly in object-internals.h
+#pragma warning disable 649
+		internal IntPtr _mono_assembly;
+#pragma warning restore 649
+#if !MOBILE
+		internal Evidence _evidence;
+#else
+		object _evidence;
+#endif
+		#endregion
+
 #pragma warning disable 169, 414, 649
 		#region Sync with object-internals.h
 		private UIntPtr dynamic_assembly; /* GC-tracked */
@@ -268,7 +282,17 @@ namespace System.Reflection.Emit
 		byte[] pktoken;
 		#endregion
 #pragma warning restore 169, 414, 649
-		
+
+#if !MOBILE
+		internal PermissionSet _minimum;	// for SecurityAction.RequestMinimum
+		internal PermissionSet _optional;	// for SecurityAction.RequestOptional
+		internal PermissionSet _refuse;		// for SecurityAction.RequestRefuse
+		internal PermissionSet _granted;		// for the resolved assembly granted permissions
+		internal PermissionSet _denied;		// for the resolved assembly denied permissions
+#else
+		object _minimum, _optional, _refuse, _granted, _denied;
+#endif
+		string assemblyName;
 		internal Type corlib_object_type = typeof (System.Object);
 		internal Type corlib_value_type = typeof (System.ValueType);
 		internal Type corlib_enum_type = typeof (System.Enum);
@@ -352,9 +376,11 @@ namespace System.Reflection.Emit
 		}
 
 		public override string CodeBase {
-			get {
-				throw not_supported ();
-			}
+			get { throw not_supported (); }
+		}
+
+		public override string EscapedCodeBase {
+			get { return RuntimeAssembly.GetCodeBase (this, true); }
 		}
 		
 		public override MethodInfo EntryPoint {
@@ -372,7 +398,7 @@ namespace System.Reflection.Emit
 		/* This is to keep signature compatibility with MS.NET */
 		public override string ImageRuntimeVersion {
 			get {
-				return base.ImageRuntimeVersion;
+				return RuntimeAssembly.InternalImageRuntimeVersion (this);
 			}
 		}
 
@@ -1203,23 +1229,59 @@ namespace System.Reflection.Emit
 			return base.GetHashCode ();
 		}
 
+		public override string ToString ()
+		{
+			if (assemblyName != null)
+				return assemblyName;
+
+			assemblyName = FullName;
+			return assemblyName;
+		}
+
 		public override bool IsDefined (Type attributeType, bool inherit)
 		{
-			return base.IsDefined (attributeType, inherit);
+			return MonoCustomAttrs.IsDefined (this, attributeType, inherit);
 		}
 
 		public override object[] GetCustomAttributes (bool inherit)
 		{
-			return base.GetCustomAttributes (inherit);
+			return MonoCustomAttrs.GetCustomAttributes (this, inherit);
 		}
 
 		public override object[] GetCustomAttributes (Type attributeType, bool inherit)
 		{
-			return base.GetCustomAttributes (attributeType, inherit);
+			return MonoCustomAttrs.GetCustomAttributes (this, attributeType, inherit);
 		}
 
 		public override string FullName {
-			get { return base.FullName; }
+			get { return RuntimeAssembly.get_fullname (this); }
+		}
+
+		internal override IntPtr MonoAssembly {
+			get {
+				return _mono_assembly;
+			}
+		}
+
+		public override Evidence Evidence {
+			[SecurityPermission (SecurityAction.Demand, ControlEvidence = true)]
+			get { return UnprotectedGetEvidence (); }
+		}
+
+		internal override Evidence UnprotectedGetEvidence ()
+		{
+#if MOBILE
+			return null;
+#else
+			// if the host (runtime) hasn't provided it's own evidence...
+			if (_evidence == null) {
+				// ... we will provide our own
+				lock (this) {
+					_evidence = Evidence.GetDefaultHostEvidence (this);
+				}
+			}
+			return _evidence;
+#endif
 		}
 	}
 }

+ 61 - 321
mcs/class/corlib/System.Reflection/Assembly.cs

@@ -64,58 +64,6 @@ namespace System.Reflection {
 #pragma warning restore
 		}
 
-		internal class UnmanagedMemoryStreamForModule : UnmanagedMemoryStream
-		{
-#pragma warning disable 414
-			Module module;
-#pragma warning restore
-
-			public unsafe UnmanagedMemoryStreamForModule (byte* pointer, long length, Module module)
-				: base (pointer, length)
-			{
-				this.module = module;
-			}
-
-			protected override void Dispose (bool disposing)
-			{
-				if (_isOpen) {
-					/* 
-					 * The returned pointer points inside metadata, so
-					 * we have to increase the refcount of the module, and decrease
-					 * it when the stream is finalized.
-					 */
-					module = null;
-				}
-
-				base.Dispose (disposing);
-			}
-		}
-
-		// Note: changes to fields must be reflected in _MonoReflectionAssembly struct (object-internals.h)
-#pragma warning disable 649
-		internal IntPtr _mono_assembly;
-#pragma warning restore 649
-
-		private ResolveEventHolder resolve_event_holder;
-#if !MOBILE
-		private Evidence _evidence;
-		internal PermissionSet _minimum;	// for SecurityAction.RequestMinimum
-		internal PermissionSet _optional;	// for SecurityAction.RequestOptional
-		internal PermissionSet _refuse;		// for SecurityAction.RequestRefuse
-		private PermissionSet _granted;		// for the resolved assembly granted permissions
-		private PermissionSet _denied;		// for the resolved assembly denied permissions
-#else
-		object _evidence, _minimum, _optional, _refuse, _granted, _denied;
-#endif
-		private bool fromByteArray;
-		private string assemblyName;
-
-		protected
-		Assembly ()
-		{
-			resolve_event_holder = new ResolveEventHolder ();
-		}
-
 		//
 		// We can't store the event directly in this class, since the
 		// compiler would silently insert the fields before _mono_assembly
@@ -123,117 +71,72 @@ namespace System.Reflection {
 		public virtual event ModuleResolveEventHandler ModuleResolve {
 			[SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
 			add {
-				resolve_event_holder.ModuleResolve += value;
+				throw new NotImplementedException ();
 			}
 			[SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
 			remove {
-				resolve_event_holder.ModuleResolve -= value;
-			}
-		}
-
-		[MethodImplAttribute (MethodImplOptions.InternalCall)]
-		private extern string get_code_base (bool escaped);
-
-		[MethodImplAttribute (MethodImplOptions.InternalCall)]
-		private extern string get_fullname ();
-
-		[MethodImplAttribute (MethodImplOptions.InternalCall)]
-		private extern string get_location ();
-
-		[MethodImplAttribute (MethodImplOptions.InternalCall)]
-		private extern string InternalImageRuntimeVersion ();
-
-		[MethodImplAttribute (MethodImplOptions.InternalCall)]
-		static internal extern string GetAotId ();
-
-		// SECURITY: this should be the only caller to icall get_code_base
-		private string GetCodeBase (bool escaped)
-		{
-			string cb = get_code_base (escaped);
-#if !MOBILE
-			if (SecurityManager.SecurityEnabled) {
-				// we cannot divulge local file informations
-				if (String.Compare ("FILE://", 0, cb, 0, 7, true, CultureInfo.InvariantCulture) == 0) {
-					string file = cb.Substring (7);
-					new FileIOPermission (FileIOPermissionAccess.PathDiscovery, file).Demand ();
-				}
+				throw new NotImplementedException ();
 			}
-#endif
-			return cb;
 		}
 
 		public virtual string CodeBase {
-			get { return GetCodeBase (false); }
+			get {
+				throw new NotImplementedException ();
+			}
 		}
 
 		public virtual string EscapedCodeBase {
-			get { return GetCodeBase (true); }
+			get {
+				throw new NotImplementedException ();
+			}
 		}
 
 		public virtual string FullName {
 			get {
-				//
-				// FIXME: This is wrong, but it gets us going
-				// in the compiler for now
-				//
-				return ToString ();
+				throw new NotImplementedException ();
 			}
 		}
 
-		public virtual extern MethodInfo EntryPoint {
-			[MethodImplAttribute (MethodImplOptions.InternalCall)]
-			get;
+		public virtual MethodInfo EntryPoint {
+			get {
+				throw new NotImplementedException ();
+			}
 		}
 
 		public virtual Evidence Evidence {
 			[SecurityPermission (SecurityAction.Demand, ControlEvidence = true)]
-			get { return UnprotectedGetEvidence (); }
+			get {
+				throw new NotImplementedException ();
+			}
 		}
 
-		// note: the security runtime requires evidences but may be unable to do so...
-		internal Evidence UnprotectedGetEvidence ()
+		internal virtual Evidence UnprotectedGetEvidence ()
 		{
-#if MOBILE
-			return null;
-#else
-			// if the host (runtime) hasn't provided it's own evidence...
-			if (_evidence == null) {
-				// ... we will provide our own
-				lock (this) {
-					_evidence = Evidence.GetDefaultHostEvidence (this);
-				}
-			}
-			return _evidence;
-#endif
+			throw new NotImplementedException ();
 		}
 
-		[MethodImplAttribute (MethodImplOptions.InternalCall)]
-		internal extern bool get_global_assembly_cache ();
+		internal virtual IntPtr MonoAssembly {
+			get {
+				throw new NotImplementedException ();
+			}
+		}
 
-		internal bool FromByteArray {
-			set { fromByteArray = value; }
+		internal virtual bool FromByteArray {
+			set {
+				throw new NotImplementedException ();
+			}
 		}
 
 		public virtual String Location {
 			get {
-				if (fromByteArray)
-					return String.Empty;
-
-				string loc = get_location ();
-#if !MOBILE
-				if ((loc != String.Empty) && SecurityManager.SecurityEnabled) {
-					// we cannot divulge local file informations
-					new FileIOPermission (FileIOPermissionAccess.PathDiscovery, loc).Demand ();
-				}
-#endif
-				return loc;
+				throw new NotImplementedException ();
 			}
 		}
 
 		[ComVisible (false)]
 		public virtual string ImageRuntimeVersion {
 			get {
-				return InternalImageRuntimeVersion ();
+				throw new NotImplementedException ();
 			}
 		}
 
@@ -244,22 +147,19 @@ namespace System.Reflection {
 
 		public virtual bool IsDefined (Type attributeType, bool inherit)
 		{
-			return MonoCustomAttrs.IsDefined (this, attributeType, inherit);
+			throw new NotImplementedException ();
 		}
 
 		public virtual object [] GetCustomAttributes (bool inherit)
 		{
-			return MonoCustomAttrs.GetCustomAttributes (this, inherit);
+			throw new NotImplementedException ();
 		}
 
 		public virtual object [] GetCustomAttributes (Type attributeType, bool inherit)
 		{
-			return MonoCustomAttrs.GetCustomAttributes (this, attributeType, inherit);
+			throw new NotImplementedException ();
 		}
 
-		[MethodImplAttribute (MethodImplOptions.InternalCall)]
-		private extern object GetFilesInternal (String name, bool getResourceModules);
-
 		public virtual FileStream[] GetFiles ()
 		{
 			return GetFiles (false);
@@ -267,90 +167,22 @@ namespace System.Reflection {
 
 		public virtual FileStream [] GetFiles (bool getResourceModules)
 		{
-			string[] names = (string[]) GetFilesInternal (null, getResourceModules);
-			if (names == null)
-				return EmptyArray<FileStream>.Value;
-
-			string location = Location;
-
-			FileStream[] res;
-			if (location != String.Empty) {
-				res = new FileStream [names.Length + 1];
-				res [0] = new FileStream (location, FileMode.Open, FileAccess.Read);
-				for (int i = 0; i < names.Length; ++i)
-					res [i + 1] = new FileStream (names [i], FileMode.Open, FileAccess.Read);
-			} else {
-				res = new FileStream [names.Length];
-				for (int i = 0; i < names.Length; ++i)
-					res [i] = new FileStream (names [i], FileMode.Open, FileAccess.Read);
-			}
-			return res;
+			throw new NotImplementedException ();
 		}
 
 		public virtual FileStream GetFile (String name)
 		{
-			if (name == null)
-				throw new ArgumentNullException (null, "Name cannot be null.");
-			if (name.Length == 0)
-				throw new ArgumentException ("Empty name is not valid");
-
-			string filename = (string)GetFilesInternal (name, true);
-			if (filename != null)
-				return new FileStream (filename, FileMode.Open, FileAccess.Read);
-			else
-				return null;
+			throw new NotImplementedException ();
 		}
 
-		[MethodImplAttribute (MethodImplOptions.InternalCall)]
-		internal extern IntPtr GetManifestResourceInternal (String name, out int size, out Module module);
-
 		public virtual Stream GetManifestResourceStream (String name)
 		{
-			if (name == null)
-				throw new ArgumentNullException ("name");
-			if (name.Length == 0)
-				throw new ArgumentException ("String cannot have zero length.",
-					"name");
-
-			ManifestResourceInfo info = GetManifestResourceInfo (name);
-			if (info == null) {
-				Assembly a = AppDomain.CurrentDomain.DoResourceResolve (name, this);
-				if (a != null && a != this)
-					return a.GetManifestResourceStream (name);
-				else
-					return null;
-			}
-
-			if (info.ReferencedAssembly != null)
-				return info.ReferencedAssembly.GetManifestResourceStream (name);
-			if ((info.FileName != null) && (info.ResourceLocation == 0)) {
-				if (fromByteArray)
-					throw new FileNotFoundException (info.FileName);
-
-				string location = Path.GetDirectoryName (Location);
-				string filename = Path.Combine (location, info.FileName);
-				return new FileStream (filename, FileMode.Open, FileAccess.Read);
-			}
-
-			int size;
-			Module module;
-			IntPtr data = GetManifestResourceInternal (name, out size, out module);
-			if (data == (IntPtr) 0)
-				return null;
-			else {
-				UnmanagedMemoryStream stream;
-				unsafe {
-					stream = new UnmanagedMemoryStreamForModule ((byte*) data, size, module);
-				}
-				return stream;
-			}
+			throw new NotImplementedException ();
 		}
 
-		[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
 		public virtual Stream GetManifestResourceStream (Type type, String name)
 		{
-			StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
-			return GetManifestResourceStream(type, name, false, ref stackMark);
+			throw new NotImplementedException ();
 		}
 
 		internal Stream GetManifestResourceStream (Type type, String name, bool skipSecurityCheck, ref StackCrawlMark stackMark)
@@ -413,7 +245,7 @@ namespace System.Reflection {
 
 		public virtual Type[] GetExportedTypes ()
 		{
-			return GetTypes (true);
+			throw new NotImplementedException ();
 		}
 
 		public virtual Type GetType (String name, Boolean throwOnError)
@@ -443,13 +275,7 @@ namespace System.Reflection {
 
 		public override string ToString ()
 		{
-			// note: ToString work without requiring CodeBase (so no checks are needed)
-
-			if (assemblyName != null)
-				return assemblyName;
-
-			assemblyName = get_fullname ();
-			return assemblyName;
+			return base.ToString ();
 		}
 
 		public static String CreateQualifiedName (String assemblyName, String typeName) 
@@ -759,12 +585,10 @@ namespace System.Reflection {
 			return GetModules (false);
 		}
 
-		[MethodImplAttribute (MethodImplOptions.InternalCall)]
-		internal virtual extern Module[] GetModulesInternal ();
+		internal virtual Module[] GetModulesInternal () {
+			throw new NotImplementedException ();
+		}
 		
-		[MethodImplAttribute (MethodImplOptions.InternalCall)]
-		public extern virtual String[] GetManifestResourceNames ();
-
 		[MethodImplAttribute (MethodImplOptions.InternalCall)]
 		public extern static Assembly GetExecutingAssembly ();
 
@@ -774,6 +598,11 @@ namespace System.Reflection {
 		[MethodImplAttribute (MethodImplOptions.InternalCall)]
 		internal static extern IntPtr InternalGetReferencedAssemblies (Assembly module);
 
+		public virtual String[] GetManifestResourceNames ()
+		{
+			throw new NotImplementedException ();
+		}
+
 		internal static AssemblyName[] GetReferencedAssemblies (Assembly module)
 		{
 			using (var nativeNames = new Mono.SafeGPtrArrayHandle (InternalGetReferencedAssemblies (module))) {
@@ -804,21 +633,9 @@ namespace System.Reflection {
 			}
 		}
 
-		[MethodImplAttribute (MethodImplOptions.InternalCall)]
-		private extern bool GetManifestResourceInfoInternal (String name, ManifestResourceInfo info);
-
 		public virtual ManifestResourceInfo GetManifestResourceInfo (String resourceName)
 		{
-			if (resourceName == null)
-				throw new ArgumentNullException ("resourceName");
-			if (resourceName.Length == 0)
-				throw new ArgumentException ("String cannot have zero length.");
-			ManifestResourceInfo result = new ManifestResourceInfo (null, null, 0);
-			bool found = GetManifestResourceInfoInternal (resourceName, result);
-			if (found)
-				return result;
-			else
-				return null;
+			throw new NotImplementedException ();
 		}
 
 		[MonoTODO ("Currently it always returns zero")]
@@ -829,18 +646,15 @@ namespace System.Reflection {
 			get { return 0; }
 		}
 
-
 		internal virtual Module GetManifestModule () {
-			return GetManifestModuleInternal ();
+			throw new NotImplementedException ();
 		}
 
-		[MethodImplAttribute (MethodImplOptions.InternalCall)]
-		internal extern Module GetManifestModuleInternal ();
-
 		[ComVisible (false)]
-		public virtual extern bool ReflectionOnly {
-			[MethodImplAttribute (MethodImplOptions.InternalCall)]
-			get;
+		public virtual bool ReflectionOnly {
+			get {
+				throw new NotImplementedException ();
+			}
 		}
 		
 		public override int GetHashCode ()
@@ -850,100 +664,26 @@ namespace System.Reflection {
 
 		public override bool Equals (object o)
 		{
-			if (((object) this) == o)
-				return true;
-
-			if (o == null)
-				return false;
-			
-			Assembly other = (Assembly) o;
-			return other._mono_assembly == _mono_assembly;
+			return base.Equals (o);
 		}
 
 #if !MOBILE
-		// Code Access Security
-
-		internal void Resolve () 
-		{
-			lock (this) {
-				// FIXME: As we (currently) delay the resolution until the first CAS
-				// Demand it's too late to evaluate the Minimum permission set as a 
-				// condition to load the assembly into the AppDomain
-				LoadAssemblyPermissions ();
-				Evidence e = new Evidence (UnprotectedGetEvidence ()); // we need a copy to add PRE
-				e.AddHost (new PermissionRequestEvidence (_minimum, _optional, _refuse));
-				_granted = SecurityManager.ResolvePolicy (e,
-					_minimum, _optional, _refuse, out _denied);
-			}
-		}
-
-		internal PermissionSet GrantedPermissionSet {
+		internal virtual PermissionSet GrantedPermissionSet {
 			get {
-				if (_granted == null) {
-					if (SecurityManager.ResolvingPolicyLevel != null) {
-						if (SecurityManager.ResolvingPolicyLevel.IsFullTrustAssembly (this))
-							return DefaultPolicies.FullTrust;
-						else
-							return null; // we can't resolve during resolution
-					}
-					Resolve ();
-				}
-				return _granted;
+				throw new NotImplementedException ();
 			}
 		}
 
-		internal PermissionSet DeniedPermissionSet {
+		internal virtual PermissionSet DeniedPermissionSet {
 			get {
-				// yes we look for granted, as denied may be null
-				if (_granted == null) {
-					if (SecurityManager.ResolvingPolicyLevel != null) {
-						if (SecurityManager.ResolvingPolicyLevel.IsFullTrustAssembly (this))
-							return null;
-						else
-							return DefaultPolicies.FullTrust; // deny unrestricted
-					}
-					Resolve ();
-				}
-				return _denied;
-			}
-		}
-
-		[MethodImplAttribute (MethodImplOptions.InternalCall)]
-		extern internal static bool LoadPermissions (Assembly a, 
-			ref IntPtr minimum, ref int minLength,
-			ref IntPtr optional, ref int optLength,
-			ref IntPtr refused, ref int refLength);
-
-		// Support for SecurityAction.RequestMinimum, RequestOptional and RequestRefuse
-		private void LoadAssemblyPermissions ()
-		{
-			IntPtr minimum = IntPtr.Zero, optional = IntPtr.Zero, refused = IntPtr.Zero;
-			int minLength = 0, optLength = 0, refLength = 0;
-			if (LoadPermissions (this, ref minimum, ref minLength, ref optional,
-				ref optLength, ref refused, ref refLength)) {
-
-				// Note: no need to cache these permission sets as they will only be created once
-				// at assembly resolution time.
-				if (minLength > 0) {
-					byte[] data = new byte [minLength];
-					Marshal.Copy (minimum, data, 0, minLength);
-					_minimum = SecurityManager.Decode (data);
-				}
-				if (optLength > 0) {
-					byte[] data = new byte [optLength];
-					Marshal.Copy (optional, data, 0, optLength);
-					_optional = SecurityManager.Decode (data);
-				}
-				if (refLength > 0) {
-					byte[] data = new byte [refLength];
-					Marshal.Copy (refused, data, 0, refLength);
-					_refuse = SecurityManager.Decode (data);
-				}
+				throw new NotImplementedException ();
 			}
 		}
 		
 		public virtual PermissionSet PermissionSet {
-			get { return this.GrantedPermissionSet; }
+			get {
+				throw new NotImplementedException ();
+			}
 		}
 #endif
 
@@ -958,7 +698,7 @@ namespace System.Reflection {
 		
 		public virtual IList<CustomAttributeData> GetCustomAttributesData ()
 		{
-			return CustomAttributeData.GetCustomAttributes (this);
+			throw new NotImplementedException ();
 		}
 
 		[MonoTODO]

+ 1 - 1
mcs/class/corlib/System.Reflection/AssemblyName.cs

@@ -530,7 +530,7 @@ namespace System.Reflection {
 		{
 			AssemblyName aname = new AssemblyName ();
 			unsafe {
-				MonoAssemblyName *native = GetNativeName (assembly._mono_assembly);
+				MonoAssemblyName *native = GetNativeName (assembly.MonoAssembly);
 				aname.FillName (native, fillCodebase ? assembly.CodeBase : null, true, true, true, false);
 			}
 			return aname;

+ 450 - 3
mcs/class/corlib/System.Reflection/RuntimeAssembly.cs

@@ -27,6 +27,7 @@
 //
 
 using System;
+using System.IO;
 using System.Collections;
 using System.Globalization;
 using System.Runtime.InteropServices;
@@ -50,8 +51,65 @@ namespace System.Reflection {
 	[ComDefaultInterfaceAttribute (typeof (_Assembly))]
 	[Serializable]
 	[ClassInterface(ClassInterfaceType.None)]
+	[StructLayout (LayoutKind.Sequential)]
 	class RuntimeAssembly : Assembly
 	{
+		#region Sync with AssemblyBuilder.cs and ReflectionAssembly in object-internals.h
+#pragma warning disable 649
+		internal IntPtr _mono_assembly;
+#pragma warning restore 649
+#if !MOBILE
+		internal Evidence _evidence;
+#else
+		object _evidence;
+#endif
+		#endregion
+
+		internal ResolveEventHolder resolve_event_holder;
+#if !MOBILE
+		internal PermissionSet _minimum;	// for SecurityAction.RequestMinimum
+		internal PermissionSet _optional;	// for SecurityAction.RequestOptional
+		internal PermissionSet _refuse;		// for SecurityAction.RequestRefuse
+		internal PermissionSet _granted;		// for the resolved assembly granted permissions
+		internal PermissionSet _denied;		// for the resolved assembly denied permissions
+#else
+		object _minimum, _optional, _refuse, _granted, _denied;
+#endif
+		internal bool fromByteArray;
+		internal string assemblyName;
+
+		internal class UnmanagedMemoryStreamForModule : UnmanagedMemoryStream
+		{
+#pragma warning disable 414
+			Module module;
+#pragma warning restore
+
+			public unsafe UnmanagedMemoryStreamForModule (byte* pointer, long length, Module module)
+				: base (pointer, length)
+			{
+				this.module = module;
+			}
+
+			protected override void Dispose (bool disposing)
+			{
+				if (_isOpen) {
+					/* 
+					 * The returned pointer points inside metadata, so
+					 * we have to increase the refcount of the module, and decrease
+					 * it when the stream is finalized.
+					 */
+					module = null;
+				}
+
+				base.Dispose (disposing);
+			}
+		}
+
+		protected RuntimeAssembly ()
+		{
+			resolve_event_holder = new ResolveEventHolder ();
+		}
+
 		public override void GetObjectData (SerializationInfo info, StreamingContext context)
 		{
 			if (info == null)
@@ -162,7 +220,6 @@ namespace System.Reflection {
 		// the security runtime requires access to the assemblyname (e.g. to get the strongname)
 		public override AssemblyName GetName (bool copiedName)
 		{
-
 #if !MOBILE
 			// CodeBase, which is restricted, will be copied into the AssemblyName object so...
 			if (SecurityManager.SecurityEnabled) {
@@ -269,7 +326,397 @@ namespace System.Reflection {
 				return get_global_assembly_cache ();
 			}
 		}
-	}
-}
 
+		public override Type[] GetExportedTypes ()
+		{
+			return GetTypes (true);
+		}
+
+		[MethodImplAttribute (MethodImplOptions.InternalCall)]
+		extern static string get_code_base (Assembly a, bool escaped);
+
+		[MethodImplAttribute (MethodImplOptions.InternalCall)]
+		private extern string get_location ();
+
+		[MethodImplAttribute (MethodImplOptions.InternalCall)]
+		internal extern static string get_fullname (Assembly a);
+
+		[MethodImplAttribute (MethodImplOptions.InternalCall)]
+		internal extern static string GetAotId ();
+
+		[MethodImplAttribute (MethodImplOptions.InternalCall)]
+		internal extern static string InternalImageRuntimeVersion (Assembly a);
+
+		[MethodImplAttribute (MethodImplOptions.InternalCall)]
+		internal extern bool get_global_assembly_cache ();
+
+		public override extern MethodInfo EntryPoint {
+			[MethodImplAttribute (MethodImplOptions.InternalCall)]
+			get;
+		}
+
+		[ComVisible (false)]
+		public override extern bool ReflectionOnly {
+			[MethodImplAttribute (MethodImplOptions.InternalCall)]
+			get;
+		}
+
+		// SECURITY: this should be the only caller to icall get_code_base
+		internal static string GetCodeBase (Assembly a, bool escaped)
+		{
+			string cb = get_code_base (a, escaped);
+#if !MOBILE
+			if (SecurityManager.SecurityEnabled) {
+				// we cannot divulge local file informations
+				if (String.Compare ("FILE://", 0, cb, 0, 7, true, CultureInfo.InvariantCulture) == 0) {
+					string file = cb.Substring (7);
+					new FileIOPermission (FileIOPermissionAccess.PathDiscovery, file).Demand ();
+				}
+			}
+#endif
+			return cb;
+		}
+
+		public override string CodeBase {
+			get { return GetCodeBase (this, false); }
+		}
+
+		public override string EscapedCodeBase {
+			get { return GetCodeBase (this, true); }
+		}
+
+		public override string FullName {
+			get {
+				return get_fullname (this);
+			}
+		}
+
+		[ComVisible (false)]
+		public override string ImageRuntimeVersion {
+			get {
+				return InternalImageRuntimeVersion (this);
+			}
+		}
+
+		internal override IntPtr MonoAssembly {
+			get {
+				return _mono_assembly;
+			}
+		}
+
+		internal override bool FromByteArray {
+			set { fromByteArray = value; }
+		}
+
+		public override String Location {
+			get {
+				if (fromByteArray)
+					return String.Empty;
+
+				string loc = get_location ();
+#if !MOBILE
+				if ((loc != String.Empty) && SecurityManager.SecurityEnabled) {
+					// we cannot divulge local file informations
+					new FileIOPermission (FileIOPermissionAccess.PathDiscovery, loc).Demand ();
+				}
+#endif
+				return loc;
+			}
+		}
+
+		[MethodImplAttribute (MethodImplOptions.InternalCall)]
+		private extern bool GetManifestResourceInfoInternal (String name, ManifestResourceInfo info);
+
+		public override ManifestResourceInfo GetManifestResourceInfo (String resourceName)
+		{
+			if (resourceName == null)
+				throw new ArgumentNullException ("resourceName");
+			if (resourceName.Length == 0)
+				throw new ArgumentException ("String cannot have zero length.");
+			ManifestResourceInfo result = new ManifestResourceInfo (null, null, 0);
+			bool found = GetManifestResourceInfoInternal (resourceName, result);
+			if (found)
+				return result;
+			else
+				return null;
+		}
+
+		[MethodImplAttribute (MethodImplOptions.InternalCall)]
+		public override extern String[] GetManifestResourceNames ();
+
+		[MethodImplAttribute (MethodImplOptions.InternalCall)]
+		internal extern IntPtr GetManifestResourceInternal (String name, out int size, out Module module);
+
+		public override Stream GetManifestResourceStream (String name)
+		{
+			if (name == null)
+				throw new ArgumentNullException ("name");
+			if (name.Length == 0)
+				throw new ArgumentException ("String cannot have zero length.",
+					"name");
+
+			ManifestResourceInfo info = GetManifestResourceInfo (name);
+			if (info == null) {
+				Assembly a = AppDomain.CurrentDomain.DoResourceResolve (name, this);
+				if (a != null && a != this)
+					return a.GetManifestResourceStream (name);
+				else
+					return null;
+			}
+
+			if (info.ReferencedAssembly != null)
+				return info.ReferencedAssembly.GetManifestResourceStream (name);
+			if ((info.FileName != null) && (info.ResourceLocation == 0)) {
+				if (fromByteArray)
+					throw new FileNotFoundException (info.FileName);
+
+				string location = Path.GetDirectoryName (Location);
+				string filename = Path.Combine (location, info.FileName);
+				return new FileStream (filename, FileMode.Open, FileAccess.Read);
+			}
+
+			int size;
+			Module module;
+			IntPtr data = GetManifestResourceInternal (name, out size, out module);
+			if (data == (IntPtr) 0)
+				return null;
+			else {
+				UnmanagedMemoryStream stream;
+				unsafe {
+					stream = new UnmanagedMemoryStreamForModule ((byte*) data, size, module);
+				}
+				return stream;
+			}
+		}
+
+		[MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
+		public override Stream GetManifestResourceStream (Type type, String name)
+		{
+			StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
+			return GetManifestResourceStream(type, name, false, ref stackMark);
+		}
+
+		public override bool IsDefined (Type attributeType, bool inherit)
+		{
+			return MonoCustomAttrs.IsDefined (this, attributeType, inherit);
+		}
+
+		public override object [] GetCustomAttributes (bool inherit)
+		{
+			return MonoCustomAttrs.GetCustomAttributes (this, inherit);
+		}
+
+		public override object [] GetCustomAttributes (Type attributeType, bool inherit)
+		{
+			return MonoCustomAttrs.GetCustomAttributes (this, attributeType, inherit);
+		}
+
+		public override IList<CustomAttributeData> GetCustomAttributesData ()
+		{
+			return CustomAttributeData.GetCustomAttributes (this);
+		}
+
+		//
+		// We can't store the event directly in this class, since the
+		// compiler would silently insert the fields before _mono_assembly
+		//
+		public override event ModuleResolveEventHandler ModuleResolve {
+			[SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
+			add {
+				resolve_event_holder.ModuleResolve += value;
+			}
+			[SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
+			remove {
+				resolve_event_holder.ModuleResolve -= value;
+			}
+		}
+
+		internal override Module GetManifestModule () {
+			return GetManifestModuleInternal ();
+		}
+
+		[MethodImplAttribute (MethodImplOptions.InternalCall)]
+		internal extern Module GetManifestModuleInternal ();
+
+		[MethodImplAttribute (MethodImplOptions.InternalCall)]
+		internal override extern Module[] GetModulesInternal ();
+
+		[MethodImplAttribute (MethodImplOptions.InternalCall)]
+		private extern object GetFilesInternal (String name, bool getResourceModules);
+
+		public override FileStream [] GetFiles (bool getResourceModules)
+		{
+			string[] names = (string[]) GetFilesInternal (null, getResourceModules);
+			if (names == null)
+				return EmptyArray<FileStream>.Value;
+
+			string location = Location;
+
+			FileStream[] res;
+			if (location != String.Empty) {
+				res = new FileStream [names.Length + 1];
+				res [0] = new FileStream (location, FileMode.Open, FileAccess.Read);
+				for (int i = 0; i < names.Length; ++i)
+					res [i + 1] = new FileStream (names [i], FileMode.Open, FileAccess.Read);
+			} else {
+				res = new FileStream [names.Length];
+				for (int i = 0; i < names.Length; ++i)
+					res [i] = new FileStream (names [i], FileMode.Open, FileAccess.Read);
+			}
+			return res;
+		}
+
+		public override FileStream GetFile (String name)
+		{
+			if (name == null)
+				throw new ArgumentNullException (null, "Name cannot be null.");
+			if (name.Length == 0)
+				throw new ArgumentException ("Empty name is not valid");
+
+			string filename = (string)GetFilesInternal (name, true);
+			if (filename != null)
+				return new FileStream (filename, FileMode.Open, FileAccess.Read);
+			else
+				return null;
+		}
+
+		public override int GetHashCode ()
+		{
+			return base.GetHashCode ();
+		}
+
+		public override bool Equals (object o)
+		{
+			if (((object) this) == o)
+				return true;
+
+			if (o == null)
+				return false;
+			
+			if (!(o is RuntimeAssembly))
+				return false;
+			var other = (RuntimeAssembly) o;
+			return other._mono_assembly == _mono_assembly;
+		}
+
+		public override string ToString ()
+		{
+			// note: ToString work without requiring CodeBase (so no checks are needed)
+
+			if (assemblyName != null)
+				return assemblyName;
+
+			assemblyName = FullName;
+			return assemblyName;
+		}
+
+		public override Evidence Evidence {
+			[SecurityPermission (SecurityAction.Demand, ControlEvidence = true)]
+			get { return UnprotectedGetEvidence (); }
+		}
+
+		// note: the security runtime requires evidences but may be unable to do so...
+		internal override Evidence UnprotectedGetEvidence ()
+		{
+#if MOBILE
+			return null;
+#else
+			// if the host (runtime) hasn't provided it's own evidence...
+			if (_evidence == null) {
+				// ... we will provide our own
+				lock (this) {
+					_evidence = Evidence.GetDefaultHostEvidence (this);
+				}
+			}
+			return _evidence;
+#endif
+		}
+
+#if !MOBILE
+		// Code Access Security
 
+		internal void Resolve () 
+		{
+			lock (this) {
+				// FIXME: As we (currently) delay the resolution until the first CAS
+				// Demand it's too late to evaluate the Minimum permission set as a 
+				// condition to load the assembly into the AppDomain
+				LoadAssemblyPermissions ();
+				Evidence e = new Evidence (UnprotectedGetEvidence ()); // we need a copy to add PRE
+				e.AddHost (new PermissionRequestEvidence (_minimum, _optional, _refuse));
+				_granted = SecurityManager.ResolvePolicy (e,
+					_minimum, _optional, _refuse, out _denied);
+			}
+		}
+
+		internal override PermissionSet GrantedPermissionSet {
+			get {
+				if (_granted == null) {
+					if (SecurityManager.ResolvingPolicyLevel != null) {
+						if (SecurityManager.ResolvingPolicyLevel.IsFullTrustAssembly (this))
+							return DefaultPolicies.FullTrust;
+						else
+							return null; // we can't resolve during resolution
+					}
+					Resolve ();
+				}
+				return _granted;
+			}
+		}
+
+		internal override PermissionSet DeniedPermissionSet {
+			get {
+				// yes we look for granted, as denied may be null
+				if (_granted == null) {
+					if (SecurityManager.ResolvingPolicyLevel != null) {
+						if (SecurityManager.ResolvingPolicyLevel.IsFullTrustAssembly (this))
+							return null;
+						else
+							return DefaultPolicies.FullTrust; // deny unrestricted
+					}
+					Resolve ();
+				}
+				return _denied;
+			}
+		}
+
+		[MethodImplAttribute (MethodImplOptions.InternalCall)]
+		extern internal static bool LoadPermissions (Assembly a, 
+			ref IntPtr minimum, ref int minLength,
+			ref IntPtr optional, ref int optLength,
+			ref IntPtr refused, ref int refLength);
+
+		// Support for SecurityAction.RequestMinimum, RequestOptional and RequestRefuse
+		private void LoadAssemblyPermissions ()
+		{
+			IntPtr minimum = IntPtr.Zero, optional = IntPtr.Zero, refused = IntPtr.Zero;
+			int minLength = 0, optLength = 0, refLength = 0;
+			if (LoadPermissions (this, ref minimum, ref minLength, ref optional,
+				ref optLength, ref refused, ref refLength)) {
+
+				// Note: no need to cache these permission sets as they will only be created once
+				// at assembly resolution time.
+				if (minLength > 0) {
+					byte[] data = new byte [minLength];
+					Marshal.Copy (minimum, data, 0, minLength);
+					_minimum = SecurityManager.Decode (data);
+				}
+				if (optLength > 0) {
+					byte[] data = new byte [optLength];
+					Marshal.Copy (optional, data, 0, optLength);
+					_optional = SecurityManager.Decode (data);
+				}
+				if (refLength > 0) {
+					byte[] data = new byte [refLength];
+					Marshal.Copy (refused, data, 0, refLength);
+					_refuse = SecurityManager.Decode (data);
+				}
+			}
+		}
+		
+		public override PermissionSet PermissionSet {
+			get { return this.GrantedPermissionSet; }
+		}
+#endif
+	}
+}

+ 18 - 20
mono/metadata/icall-def.h

@@ -581,35 +581,16 @@ HANDLES(OBJ_1, "GetType", ves_icall_System_Object_GetType, MonoReflectionType, 1
 ICALL(OBJ_2, "InternalGetHashCode", mono_object_hash_internal)
 HANDLES(OBJ_3, "MemberwiseClone", ves_icall_System_Object_MemberwiseClone, MonoObject, 1, (MonoObject))
 
-ICALL_TYPE(ASSEM, "System.Reflection.Assembly", ASSEM_1a)
-HANDLES(ASSEM_1a, "GetAotId", ves_icall_System_Reflection_Assembly_GetAotId, MonoString, 0, ())
+ICALL_TYPE(ASSEM, "System.Reflection.Assembly", ASSEM_2)
 HANDLES(ASSEM_2, "GetCallingAssembly", ves_icall_System_Reflection_Assembly_GetCallingAssembly, MonoReflectionAssembly, 0, ())
 HANDLES(ASSEM_3, "GetEntryAssembly", ves_icall_System_Reflection_Assembly_GetEntryAssembly, MonoReflectionAssembly, 0, ())
 HANDLES(ASSEM_4, "GetExecutingAssembly", ves_icall_System_Reflection_Assembly_GetExecutingAssembly, MonoReflectionAssembly, 0, ())
-HANDLES(ASSEM_5, "GetFilesInternal", ves_icall_System_Reflection_Assembly_GetFilesInternal, MonoObject, 3, (MonoReflectionAssembly, MonoString, MonoBoolean))
-HANDLES(ASSEM_6, "GetManifestModuleInternal", ves_icall_System_Reflection_Assembly_GetManifestModuleInternal, MonoReflectionModule, 1, (MonoReflectionAssembly))
-HANDLES(ASSEM_7, "GetManifestResourceInfoInternal", ves_icall_System_Reflection_Assembly_GetManifestResourceInfoInternal, MonoBoolean, 3, (MonoReflectionAssembly, MonoString, MonoManifestResourceInfo))
-HANDLES(ASSEM_8, "GetManifestResourceInternal", ves_icall_System_Reflection_Assembly_GetManifestResourceInternal, gpointer, 4, (MonoReflectionAssembly, MonoString, gint32_ref, MonoReflectionModuleOut))
-HANDLES(ASSEM_9, "GetManifestResourceNames", ves_icall_System_Reflection_Assembly_GetManifestResourceNames, MonoArray, 1, (MonoReflectionAssembly))
-HANDLES(ASSEM_10, "GetModulesInternal", ves_icall_System_Reflection_Assembly_GetModulesInternal, MonoArray, 1, (MonoReflectionAssembly))
-
-//ICALL(ASSEM_11, "GetNamespaces", ves_icall_System_Reflection_Assembly_GetNamespaces)
 HANDLES(ASSEM_13, "GetTypes", ves_icall_System_Reflection_Assembly_GetTypes, MonoArray, 2, (MonoReflectionAssembly, MonoBoolean))
 HANDLES(ASSEM_14, "InternalGetAssemblyName", ves_icall_System_Reflection_Assembly_InternalGetAssemblyName, void, 3, (MonoString, MonoAssemblyName_ref, MonoStringOut))
 HANDLES(ASSEM_12, "InternalGetReferencedAssemblies", ves_icall_System_Reflection_Assembly_InternalGetReferencedAssemblies, GPtrArray_ptr, 1, (MonoReflectionAssembly))
 HANDLES(ASSEM_15, "InternalGetType", ves_icall_System_Reflection_Assembly_InternalGetType, MonoReflectionType, 5, (MonoReflectionAssembly, MonoReflectionModule, MonoString, MonoBoolean, MonoBoolean))
-HANDLES(ASSEM_16, "InternalImageRuntimeVersion", ves_icall_System_Reflection_Assembly_InternalImageRuntimeVersion, MonoString, 1, (MonoReflectionAssembly))
 HANDLES(ASSEM_16a, "LoadFile_internal", ves_icall_System_Reflection_Assembly_LoadFile_internal, MonoReflectionAssembly, 2, (MonoString, MonoStackCrawlMark_ptr))
 HANDLES(ASSEM_17, "LoadFrom", ves_icall_System_Reflection_Assembly_LoadFrom, MonoReflectionAssembly, 3, (MonoString, MonoBoolean, MonoStackCrawlMark_ptr))
-HANDLES(ASSEM_18, "LoadPermissions", ves_icall_System_Reflection_Assembly_LoadPermissions, MonoBoolean, 7, (MonoReflectionAssembly, char_ptr_ref, guint32_ref, char_ptr_ref, guint32_ref, char_ptr_ref, guint32_ref))
-
-	/* normal icalls again */
-HANDLES(ASSEM_20, "get_EntryPoint", ves_icall_System_Reflection_Assembly_get_EntryPoint, MonoReflectionMethod, 1, (MonoReflectionAssembly))
-HANDLES(ASSEM_21, "get_ReflectionOnly", ves_icall_System_Reflection_Assembly_get_ReflectionOnly, MonoBoolean, 1, (MonoReflectionAssembly))
-HANDLES(ASSEM_22, "get_code_base", ves_icall_System_Reflection_Assembly_get_code_base, MonoString, 2, (MonoReflectionAssembly, MonoBoolean))
-HANDLES(ASSEM_23, "get_fullname", ves_icall_System_Reflection_Assembly_get_fullName, MonoString, 1, (MonoReflectionAssembly))
-HANDLES(ASSEM_24, "get_global_assembly_cache", ves_icall_System_Reflection_Assembly_get_global_assembly_cache, MonoBoolean, 1, (MonoReflectionAssembly))
-HANDLES(ASSEM_25, "get_location", ves_icall_System_Reflection_Assembly_get_location, MonoString, 1, (MonoReflectionAssembly))
 HANDLES(ASSEM_26, "load_with_partial_name", ves_icall_System_Reflection_Assembly_load_with_partial_name, MonoReflectionAssembly, 2, (MonoString, MonoObject))
 
 ICALL_TYPE(ASSEMN, "System.Reflection.AssemblyName", ASSEMN_0)
@@ -687,6 +668,23 @@ HANDLES(MMETHI_1, "get_method_info", ves_icall_get_method_info, void, 2, (MonoMe
 HANDLES(MMETHI_2, "get_parameter_info", ves_icall_System_Reflection_MonoMethodInfo_get_parameter_info, MonoArray, 2, (MonoMethod_ptr, MonoReflectionMethod))
 HANDLES(MMETHI_3, "get_retval_marshal", ves_icall_System_MonoMethodInfo_get_retval_marshal, MonoReflectionMarshalAsAttribute, 1, (MonoMethod_ptr))
 
+ICALL_TYPE(RASSEM, "System.Reflection.RuntimeAssembly", RASSEM_1)
+HANDLES(RASSEM_1, "GetAotId", ves_icall_System_Reflection_RuntimeAssembly_GetAotId, MonoString, 0, ())
+HANDLES(RASSEM_2, "GetFilesInternal", ves_icall_System_Reflection_RuntimeAssembly_GetFilesInternal, MonoObject, 3, (MonoReflectionAssembly, MonoString, MonoBoolean))
+HANDLES(RASSEM_3, "GetManifestModuleInternal", ves_icall_System_Reflection_Assembly_GetManifestModuleInternal, MonoReflectionModule, 1, (MonoReflectionAssembly))
+HANDLES(RASSEM_4, "GetManifestResourceInfoInternal", ves_icall_System_Reflection_RuntimeAssembly_GetManifestResourceInfoInternal, MonoBoolean, 3, (MonoReflectionAssembly, MonoString, MonoManifestResourceInfo))
+HANDLES(RASSEM_5, "GetManifestResourceInternal", ves_icall_System_Reflection_RuntimeAssembly_GetManifestResourceInternal, gpointer, 4, (MonoReflectionAssembly, MonoString, gint32_ref, MonoReflectionModuleOut))
+HANDLES(RASSEM_6, "GetManifestResourceNames", ves_icall_System_Reflection_RuntimeAssembly_GetManifestResourceNames, MonoArray, 1, (MonoReflectionAssembly))
+HANDLES(RASSEM_7, "GetModulesInternal", ves_icall_System_Reflection_RuntimeAssembly_GetModulesInternal, MonoArray, 1, (MonoReflectionAssembly))
+HANDLES(RASSEM_8, "InternalImageRuntimeVersion", ves_icall_System_Reflection_RuntimeAssembly_InternalImageRuntimeVersion, MonoString, 1, (MonoReflectionAssembly))
+HANDLES(RASSEM_9, "LoadPermissions", ves_icall_System_Reflection_RuntimeAssembly_LoadPermissions, MonoBoolean, 7, (MonoReflectionAssembly, char_ptr_ref, guint32_ref, char_ptr_ref, guint32_ref, char_ptr_ref, guint32_ref))
+HANDLES(RASSEM_10, "get_EntryPoint", ves_icall_System_Reflection_RuntimeAssembly_get_EntryPoint, MonoReflectionMethod, 1, (MonoReflectionAssembly))
+HANDLES(RASSEM_11, "get_ReflectionOnly", ves_icall_System_Reflection_RuntimeAssembly_get_ReflectionOnly, MonoBoolean, 1, (MonoReflectionAssembly))
+HANDLES(RASSEM_12, "get_code_base", ves_icall_System_Reflection_RuntimeAssembly_get_code_base, MonoString, 2, (MonoReflectionAssembly, MonoBoolean))
+HANDLES(RASSEM_13, "get_fullname", ves_icall_System_Reflection_RuntimeAssembly_get_fullname, MonoString, 1, (MonoReflectionAssembly))
+HANDLES(RASSEM_14, "get_global_assembly_cache", ves_icall_System_Reflection_RuntimeAssembly_get_global_assembly_cache, MonoBoolean, 1, (MonoReflectionAssembly))
+HANDLES(RASSEM_15, "get_location", ves_icall_System_Reflection_RuntimeAssembly_get_location, MonoString, 1, (MonoReflectionAssembly))
+
 ICALL_TYPE(MCMETH, "System.Reflection.RuntimeConstructorInfo", MCMETH_1)
 HANDLES(MCMETH_1, "GetGenericMethodDefinition_impl", ves_icall_RuntimeMethodInfo_GetGenericMethodDefinition, MonoReflectionMethod, 1, (MonoReflectionMethod))
 ICALL(MCMETH_2, "InternalInvoke", ves_icall_InternalInvoke)

+ 14 - 14
mono/metadata/icall.c

@@ -4654,7 +4654,7 @@ replace_shadow_path (MonoDomain *domain, gchar *dirname, gchar **filename)
 }
 
 MonoStringHandle
-ves_icall_System_Reflection_Assembly_get_code_base (MonoReflectionAssemblyHandle assembly, MonoBoolean escaped, MonoError *error)
+ves_icall_System_Reflection_RuntimeAssembly_get_code_base (MonoReflectionAssemblyHandle assembly, MonoBoolean escaped, MonoError *error)
 {
 	error_init (error);
 	MonoDomain *domain = MONO_HANDLE_DOMAIN (assembly);
@@ -4696,7 +4696,7 @@ ves_icall_System_Reflection_Assembly_get_code_base (MonoReflectionAssemblyHandle
 }
 
 MonoBoolean
-ves_icall_System_Reflection_Assembly_get_global_assembly_cache (MonoReflectionAssemblyHandle assembly, MonoError *error)
+ves_icall_System_Reflection_RuntimeAssembly_get_global_assembly_cache (MonoReflectionAssemblyHandle assembly, MonoError *error)
 {
 	error_init (error);
 	MonoAssembly *mass = MONO_HANDLE_GETVAL (assembly,assembly);
@@ -4726,7 +4726,7 @@ leave:
 }
 
 MonoStringHandle
-ves_icall_System_Reflection_Assembly_get_location (MonoReflectionAssemblyHandle refassembly, MonoError *error)
+ves_icall_System_Reflection_RuntimeAssembly_get_location (MonoReflectionAssemblyHandle refassembly, MonoError *error)
 {
 	MonoDomain *domain = MONO_HANDLE_DOMAIN (refassembly);
 	MonoAssembly *assembly = MONO_HANDLE_GETVAL (refassembly, assembly);
@@ -4734,7 +4734,7 @@ ves_icall_System_Reflection_Assembly_get_location (MonoReflectionAssemblyHandle
 }
 
 MonoBoolean
-ves_icall_System_Reflection_Assembly_get_ReflectionOnly (MonoReflectionAssemblyHandle assembly_h, MonoError *error)
+ves_icall_System_Reflection_RuntimeAssembly_get_ReflectionOnly (MonoReflectionAssemblyHandle assembly_h, MonoError *error)
 {
 	error_init (error);
 	MonoAssembly *assembly = MONO_HANDLE_GETVAL (assembly_h, assembly);
@@ -4742,7 +4742,7 @@ ves_icall_System_Reflection_Assembly_get_ReflectionOnly (MonoReflectionAssemblyH
 }
 
 MonoStringHandle
-ves_icall_System_Reflection_Assembly_InternalImageRuntimeVersion (MonoReflectionAssemblyHandle refassembly, MonoError *error)
+ves_icall_System_Reflection_RuntimeAssembly_InternalImageRuntimeVersion (MonoReflectionAssemblyHandle refassembly, MonoError *error)
 {
 	MonoDomain *domain = MONO_HANDLE_DOMAIN (refassembly);
 	MonoAssembly *assembly = MONO_HANDLE_GETVAL (refassembly, assembly);
@@ -4751,7 +4751,7 @@ ves_icall_System_Reflection_Assembly_InternalImageRuntimeVersion (MonoReflection
 }
 
 MonoReflectionMethodHandle
-ves_icall_System_Reflection_Assembly_get_EntryPoint (MonoReflectionAssemblyHandle assembly_h, MonoError *error) 
+ves_icall_System_Reflection_RuntimeAssembly_get_EntryPoint (MonoReflectionAssemblyHandle assembly_h, MonoError *error) 
 {
 	error_init (error);
 	MonoDomain *domain = MONO_HANDLE_DOMAIN (assembly_h);
@@ -4794,7 +4794,7 @@ leave:
 }
 
 MonoArrayHandle
-ves_icall_System_Reflection_Assembly_GetManifestResourceNames (MonoReflectionAssemblyHandle assembly_h, MonoError *error) 
+ves_icall_System_Reflection_RuntimeAssembly_GetManifestResourceNames (MonoReflectionAssemblyHandle assembly_h, MonoError *error) 
 {
 	error_init (error);
 	MonoDomain *domain = MONO_HANDLE_DOMAIN (assembly_h);
@@ -4814,7 +4814,7 @@ fail:
 }
 
 MonoStringHandle
-ves_icall_System_Reflection_Assembly_GetAotId (MonoError *error)
+ves_icall_System_Reflection_RuntimeAssembly_GetAotId (MonoError *error)
 {
 	char *guid = mono_runtime_get_aotid ();
 	if (guid == NULL)
@@ -4888,7 +4888,7 @@ g_concat_dir_and_file (const char *dir, const char *file)
 }
 
 void *
-ves_icall_System_Reflection_Assembly_GetManifestResourceInternal (MonoReflectionAssemblyHandle assembly_h, MonoStringHandle name, gint32 *size, MonoReflectionModuleHandleOut ref_module, MonoError *error) 
+ves_icall_System_Reflection_RuntimeAssembly_GetManifestResourceInternal (MonoReflectionAssemblyHandle assembly_h, MonoStringHandle name, gint32 *size, MonoReflectionModuleHandleOut ref_module, MonoError *error) 
 {
 	error_init (error);
 	MonoDomain *domain = MONO_HANDLE_DOMAIN (assembly_h);
@@ -5015,7 +5015,7 @@ leave:
 }
 
 MonoBoolean
-ves_icall_System_Reflection_Assembly_GetManifestResourceInfoInternal (MonoReflectionAssemblyHandle assembly_h, MonoStringHandle name, MonoManifestResourceInfoHandle info_h, MonoError *error)
+ves_icall_System_Reflection_RuntimeAssembly_GetManifestResourceInfoInternal (MonoReflectionAssemblyHandle assembly_h, MonoStringHandle name, MonoManifestResourceInfoHandle info_h, MonoError *error)
 {
 	error_init (error);
 	return get_manifest_resource_info_internal (assembly_h, name, info_h, error);
@@ -5037,7 +5037,7 @@ leave:
 }
 
 MonoObjectHandle
-ves_icall_System_Reflection_Assembly_GetFilesInternal (MonoReflectionAssemblyHandle assembly_h, MonoStringHandle name, MonoBoolean resource_modules, MonoError *error) 
+ves_icall_System_Reflection_RuntimeAssembly_GetFilesInternal (MonoReflectionAssemblyHandle assembly_h, MonoStringHandle name, MonoBoolean resource_modules, MonoError *error) 
 {
 	error_init (error);
 	MonoDomain *domain = MONO_HANDLE_DOMAIN (assembly_h);
@@ -5135,7 +5135,7 @@ leave:
 }
 
 MonoArrayHandle
-ves_icall_System_Reflection_Assembly_GetModulesInternal (MonoReflectionAssemblyHandle assembly_h, MonoError *error)
+ves_icall_System_Reflection_RuntimeAssembly_GetModulesInternal (MonoReflectionAssemblyHandle assembly_h, MonoError *error)
 {
 	error_init (error);
 	MonoDomain *domain = mono_domain_get();
@@ -5377,7 +5377,7 @@ ves_icall_RuntimeMethodInfo_get_core_clr_security_level (MonoReflectionMethodHan
 }
 
 MonoStringHandle
-ves_icall_System_Reflection_Assembly_get_fullName (MonoReflectionAssemblyHandle assembly, MonoError *error)
+ves_icall_System_Reflection_RuntimeAssembly_get_fullname (MonoReflectionAssemblyHandle assembly, MonoError *error)
 {
 	error_init (error);
 	MonoDomain *domain = MONO_HANDLE_DOMAIN (assembly);
@@ -5457,7 +5457,7 @@ ves_icall_System_Reflection_Assembly_InternalGetAssemblyName (MonoStringHandle f
 }
 
 MonoBoolean
-ves_icall_System_Reflection_Assembly_LoadPermissions (MonoReflectionAssemblyHandle assembly_h,
+ves_icall_System_Reflection_RuntimeAssembly_LoadPermissions (MonoReflectionAssemblyHandle assembly_h,
 						      char **minimum, guint32 *minLength, char **optional, guint32 *optLength, char **refused, guint32 *refLength, MonoError *error)
 {
 	error_init (error);

+ 0 - 9
mono/metadata/object-internals.h

@@ -1008,17 +1008,8 @@ TYPED_HANDLE_DECL (MonoReflectionMethodBody);
 struct _MonoReflectionAssembly {
 	MonoObject object;
 	MonoAssembly *assembly;
-	MonoObject *resolve_event_holder;
 	/* CAS related */
 	MonoObject *evidence;	/* Evidence */
-	MonoObject *minimum;	/* PermissionSet - for SecurityAction.RequestMinimum */
-	MonoObject *optional;	/* PermissionSet - for SecurityAction.RequestOptional */
-	MonoObject *refuse;	/* PermissionSet - for SecurityAction.RequestRefuse */
-	MonoObject *granted;	/* PermissionSet - for the resolved assembly granted permissions */
-	MonoObject *denied;	/* PermissionSet - for the resolved assembly denied permissions */
-	/* */
-	MonoBoolean from_byte_array;
-	MonoString *name;
 };
 
 typedef struct {

Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini