Imported Upstream version 4.8.0.309

Former-commit-id: 5f9c6ae75f295e057a7d2971f3a6df4656fa8850
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2016-11-10 13:04:39 +00:00
parent ee1447783b
commit 94b2861243
4912 changed files with 390737 additions and 49310 deletions

View File

@@ -53,11 +53,12 @@ namespace System.Reflection {
[ClassInterface(ClassInterfaceType.None)]
[StructLayout (LayoutKind.Sequential)]
#if MOBILE
public partial class Assembly : ICustomAttributeProvider {
public partial class Assembly : ICustomAttributeProvider, ISerializable
#else
public abstract class Assembly : ICustomAttributeProvider, _Assembly, IEvidenceFactory, ISerializable {
public abstract class Assembly : ICustomAttributeProvider, _Assembly, IEvidenceFactory, ISerializable
#endif
internal class ResolveEventHolder {
{
internal class ResolveEventHolder {
public event ModuleResolveEventHandler ModuleResolve;
}
@@ -88,7 +89,7 @@ namespace System.Reflection {
// Note: changes to fields must be reflected in _MonoReflectionAssembly struct (object-internals.h)
#pragma warning disable 649
private IntPtr _mono_assembly;
internal IntPtr _mono_assembly;
#pragma warning restore 649
private ResolveEventHolder resolve_event_holder;
@@ -115,7 +116,7 @@ namespace System.Reflection {
// We can't store the event directly in this class, since the
// compiler would silently insert the fields before _mono_assembly
//
public event ModuleResolveEventHandler ModuleResolve {
public virtual event ModuleResolveEventHandler ModuleResolve {
[SecurityPermission (SecurityAction.LinkDemand, ControlAppDomain = true)]
add {
resolve_event_holder.ModuleResolve += value;
@@ -145,7 +146,7 @@ namespace System.Reflection {
private string GetCodeBase (bool escaped)
{
string cb = get_code_base (escaped);
#if !NET_2_1
#if !MOBILE
if (SecurityManager.SecurityEnabled) {
// we cannot divulge local file informations
if (String.Compare ("FILE://", 0, cb, 0, 7, true, CultureInfo.InvariantCulture) == 0) {
@@ -215,7 +216,7 @@ namespace System.Reflection {
return String.Empty;
string loc = get_location ();
#if !NET_2_1
#if !MOBILE
if ((loc != String.Empty) && SecurityManager.SecurityEnabled) {
// we cannot divulge local file informations
new FileIOPermission (FileIOPermissionAccess.PathDiscovery, loc).Demand ();
@@ -425,19 +426,9 @@ namespace System.Reflection {
[MethodImplAttribute (MethodImplOptions.InternalCall)]
internal extern static void InternalGetAssemblyName (string assemblyFile, AssemblyName aname);
[MethodImplAttribute (MethodImplOptions.InternalCall)]
static extern void FillName (Assembly ass, AssemblyName aname);
[MonoTODO ("copiedName == true is not supported")]
public virtual AssemblyName GetName (Boolean copiedName)
{
#if !MOBILE
// CodeBase, which is restricted, will be copied into the AssemblyName object so...
if (SecurityManager.SecurityEnabled) {
GetCodeBase (true); // this will ensure the Demand is made
}
#endif
return UnprotectedGetName ();
throw new NotImplementedException ();
}
public virtual AssemblyName GetName ()
@@ -445,14 +436,6 @@ namespace System.Reflection {
return GetName (false);
}
// the security runtime requires access to the assemblyname (e.g. to get the strongname)
internal virtual AssemblyName UnprotectedGetName ()
{
AssemblyName aname = new AssemblyName ();
FillName (this, aname);
return aname;
}
public override string ToString ()
{
// note: ToString work without requiring CodeBase (so no checks are needed)
@@ -523,10 +506,14 @@ namespace System.Reflection {
// Try the assembly directory
string location = Path.GetDirectoryName (Location);
string fullName = Path.Combine (location, Path.Combine (culture.Name, an.Name + ".dll"));
if (!throwOnFileNotFound && !File.Exists (fullName))
return null;
return (RuntimeAssembly)LoadFrom (fullName);
try {
return (RuntimeAssembly)LoadFrom (fullName);
} catch {
if (!throwOnFileNotFound && !File.Exists (fullName))
return null;
throw;
}
}
#if !MOBILE
@@ -549,7 +536,7 @@ namespace System.Reflection {
public static Assembly LoadFrom (String assemblyFile, Evidence securityEvidence)
{
Assembly a = LoadFrom (assemblyFile, false);
#if !NET_2_1
#if !MOBILE
if ((a != null) && (securityEvidence != null)) {
// merge evidence (i.e. replace defaults with provided evidences)
a.Evidence.Merge (securityEvidence);
@@ -821,7 +808,7 @@ namespace System.Reflection {
return other._mono_assembly == _mono_assembly;
}
#if !NET_2_1
#if !MOBILE
// Code Access Security
internal void Resolve ()
@@ -906,13 +893,12 @@ namespace System.Reflection {
public virtual PermissionSet PermissionSet {
get { return this.GrantedPermissionSet; }
}
#endif
public virtual SecurityRuleSet SecurityRuleSet {
get { throw CreateNIE (); }
}
#endif
static Exception CreateNIE ()
{
return new NotImplementedException ("Derived classes must implement it");