Imported Upstream version 5.8.0.22

Former-commit-id: df344e34b07851d296efb3e6604c8db42b6f7aa3
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-10-19 20:04:20 +00:00
parent 5f4a27cc8a
commit 7d05485754
5020 changed files with 114082 additions and 186061 deletions

View File

@@ -504,10 +504,8 @@
</type>
<!-- appdomain.c: ves_icall_System_AppDomain_GetAssemblies -->
<type fullname="System.Reflection.Assembly" preserve="fields">
<method name="MonoDebugger_GetMethodToken" feature="sre" />
<method name="GetNamespaces" feature="sre" />
</type>
<type fullname="System.Reflection.Assembly" preserve="fields"/>
<type fullname="System.Reflection.AssemblyName" preserve="fields" />
<type fullname="System.Reflection.ConstructorInfo" preserve="fields" />

View File

@@ -91,6 +91,8 @@ DEFAULT_REFERENCES =
TEST_LIB_REFS = System.Core System
XTEST_LIB_REFS = System System.Core Facades/System.Threading.Tasks Facades/System.Runtime.InteropServices.RuntimeInformation
ifndef AOT_FRIENDLY_PROFILE
ifneq ($(PROFILE),testing_aot_hybrid)
TEST_LIB_REFS += Mono.Posix

View File

@@ -43,22 +43,12 @@ namespace System
public static Type GetType(string typeName)
{
if (typeName == null)
throw new ArgumentNullException ("TypeName");
return internal_from_name (typeName, false, false);
return GetType (typeName, false, false);
}
public static Type GetType(string typeName, bool throwOnError)
{
if (typeName == null)
throw new ArgumentNullException ("TypeName");
Type type = internal_from_name (typeName, throwOnError, false);
if (throwOnError && type == null)
throw new TypeLoadException ("Error loading '" + typeName + "'");
return type;
return GetType (typeName, throwOnError, false);
}
public static Type GetType(string typeName, bool throwOnError, bool ignoreCase)
@@ -66,6 +56,11 @@ namespace System
if (typeName == null)
throw new ArgumentNullException ("TypeName");
if (typeName == String.Empty)
if (throwOnError)
throw new TypeLoadException ("A null or zero length string does not represent a valid Type.");
else
return null;
Type t = internal_from_name (typeName, throwOnError, ignoreCase);
if (throwOnError && t == null)
throw new TypeLoadException ("Error loading '" + typeName + "'");
@@ -82,6 +77,8 @@ namespace System
{
if (typeName == null)
throw new ArgumentNullException ("typeName");
if (typeName == String.Empty && throwIfNotFound)
throw new TypeLoadException ("A null or zero length string does not represent a valid Type");
int idx = typeName.IndexOf (',');
if (idx < 0 || idx == 0 || idx == typeName.Length - 1)
throw new ArgumentException ("Assembly qualifed type name is required", "typeName");

View File

@@ -41,6 +41,8 @@ using System.Security;
using System.Text;
using System.Security.AccessControl;
using Microsoft.Win32.SafeHandles;
namespace System.IO {
[Serializable]
@@ -424,39 +426,57 @@ namespace System.IO {
return EnumerateFileSystemInfos (FullPath, searchPattern, searchOption);
}
static internal IEnumerable<FileSystemInfo> EnumerateFileSystemInfos (string full, string searchPattern, SearchOption searchOption)
static internal IEnumerable<FileSystemInfo> EnumerateFileSystemInfos (string basePath, string searchPattern, SearchOption searchOption)
{
string path_with_pattern = Path.Combine (full, searchPattern);
IntPtr handle = IntPtr.Zero;
MonoIOError error;
FileAttributes rattr;
bool subdirs = searchOption == SearchOption.AllDirectories;
Path.Validate (basePath);
SafeFindHandle findHandle = null;
Path.Validate (full);
try {
string s = MonoIO.FindFirst (full, path_with_pattern, out rattr, out error, out handle);
if (s == null)
string filePath;
int nativeAttrs;
string basePathWithPattern = Path.Combine (basePath, searchPattern);
int nativeError;
try {} finally {
findHandle = new SafeFindHandle (MonoIO.FindFirstFile (basePathWithPattern, out filePath, out nativeAttrs, out nativeError));
}
if (findHandle.IsInvalid) {
MonoIOError error = (MonoIOError) nativeError;
if (error != MonoIOError.ERROR_FILE_NOT_FOUND)
throw MonoIO.GetException (Path.GetDirectoryName (basePathWithPattern), error);
yield break;
if (error != 0)
throw MonoIO.GetException (Path.GetDirectoryName (path_with_pattern), (MonoIOError) error);
}
do {
if (((rattr & FileAttributes.ReparsePoint) == 0)){
if ((rattr & FileAttributes.Directory) != 0)
yield return new DirectoryInfo (s);
if (filePath == null)
yield break;
if (filePath == "." || filePath == "..")
continue;
FileAttributes attrs = (FileAttributes) nativeAttrs;
string fullPath = Path.Combine (basePath, filePath);
if ((attrs & FileAttributes.ReparsePoint) == 0) {
if ((attrs & FileAttributes.Directory) != 0)
yield return new DirectoryInfo (fullPath);
else
yield return new FileInfo (s);
yield return new FileInfo (fullPath);
}
if (((rattr & FileAttributes.Directory) != 0) && subdirs)
foreach (FileSystemInfo child in EnumerateFileSystemInfos (s, searchPattern, searchOption))
if ((attrs & FileAttributes.Directory) != 0 && searchOption == SearchOption.AllDirectories) {
foreach (FileSystemInfo child in EnumerateFileSystemInfos (fullPath, searchPattern, searchOption))
yield return child;
} while ((s = MonoIO.FindNext (handle, out rattr, out error)) != null);
}
} while (MonoIO.FindNextFile (findHandle.DangerousGetHandle (), out filePath, out nativeAttrs, out int _));
} finally {
if (handle != IntPtr.Zero)
MonoIO.FindClose (handle);
if (findHandle != null)
findHandle.Dispose ();
}
}

View File

@@ -174,9 +174,6 @@ namespace System.IO
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public extern static bool RemoveDirectory (string path, out MonoIOError error);
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public extern static string [] GetFileSystemEntries (string path, string path_with_pattern, int attrs, int mask, out MonoIOError error);
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public extern static string GetCurrentDirectory (out MonoIOError error);
@@ -229,14 +226,6 @@ namespace System.IO
//
// Find file methods
//
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public extern static string FindFirst (string path, string pattern, out FileAttributes result_attr, out MonoIOError error, out IntPtr handle);
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public extern static string FindNext (IntPtr handle, out FileAttributes result_attr, out MonoIOError error);
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public extern static int FindClose (IntPtr handle);
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public extern static IntPtr FindFirstFile (string path_with_pattern, out string fileName, out int fileAttr, out int error);

View File

@@ -257,6 +257,9 @@ namespace System.Reflection.Emit
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern void basic_init (AssemblyBuilder ab);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
static extern void UpdateNativeCustomAttributes (AssemblyBuilder ab);
/* Keep this in sync with codegen.cs in mcs */
private const AssemblyBuilderAccess COMPILER_ACCESS = (AssemblyBuilderAccess) 0x800;
@@ -949,6 +952,12 @@ namespace System.Reflection.Emit
cattrs = new CustomAttributeBuilder [1];
cattrs [0] = customBuilder;
}
/*
Only update the native list of custom attributes if we're adding one that is known to change dynamic execution behavior.
*/
if (customBuilder.Ctor != null && customBuilder.Ctor.DeclaringType == typeof (System.Runtime.CompilerServices.RuntimeCompatibilityAttribute))
UpdateNativeCustomAttributes (this);
}
[ComVisible (true)]

View File

@@ -235,7 +235,10 @@ namespace System.Reflection.Emit {
public ParameterBuilder DefineParameter (int iSequence, ParameterAttributes attributes, string strParamName)
{
if (iSequence < 1 || iSequence > GetParametersCount ())
// The 0th ParameterBuilder does not correspond to an
// actual parameter, but .NETFramework lets you define
// it anyway. It is not useful.
if (iSequence < 0 || iSequence > GetParametersCount ())
throw new ArgumentOutOfRangeException ("iSequence");
if (type.is_created)
throw not_after_created ();

View File

@@ -58,9 +58,13 @@ namespace System.Reflection.Emit {
[MethodImplAttribute(MethodImplOptions.InternalCall)]
static extern byte[] GetBlob(Assembly asmb, ConstructorInfo con, object[] constructorArgs, PropertyInfo[] namedProperties, object[] propertyValues, FieldInfo[] namedFields, object[] fieldValues);
internal CustomAttributeBuilder( ConstructorInfo con, byte[] cdata) {
internal CustomAttributeBuilder( ConstructorInfo con, byte[] binaryAttribute) {
if (con == null)
throw new ArgumentNullException ("con");
if (binaryAttribute == null)
throw new ArgumentNullException ("binaryAttribute");
ctor = con;
data = (byte[])cdata.Clone ();
data = (byte[])binaryAttribute.Clone ();
/* should we check that the user supplied data is correct? */
}

View File

@@ -156,6 +156,9 @@ namespace System.Reflection.Emit {
public void SetCustomAttribute (CustomAttributeBuilder customBuilder) {
RejectIfCreated ();
if (customBuilder == null)
throw new ArgumentNullException ("customBuilder");
string attrname = customBuilder.Ctor.ReflectedType.FullName;
if (attrname == "System.Runtime.InteropServices.FieldOffsetAttribute") {
byte[] data = customBuilder.Data;
@@ -202,6 +205,8 @@ namespace System.Reflection.Emit {
public void SetOffset( int iOffset) {
RejectIfCreated ();
if (iOffset < 0)
throw new ArgumentException ("Negative field offset is not allowed");
offset = iOffset;
}

View File

@@ -342,7 +342,7 @@ namespace System.Reflection.Emit
//
// Extension: Mono allows position == 0 for the return attribute
//
if ((position < 0) || (position > parameters.Length))
if ((position < 0) || parameters == null || (position > parameters.Length))
throw new ArgumentOutOfRangeException ("position");
ParameterBuilder pb = new ParameterBuilder (this, position, attributes, strParamName);

View File

@@ -159,21 +159,28 @@ namespace System.Reflection.Emit {
if (data == null)
throw new ArgumentNullException ("data");
FieldBuilder fb = DefineUninitializedData (name, data.Length,
attributes | FieldAttributes.HasFieldRVA);
var maskedAttributes = attributes & ~FieldAttributes.ReservedMask;
FieldBuilder fb = DefineDataImpl (name, data.Length, maskedAttributes | FieldAttributes.HasFieldRVA);
fb.SetRVAData (data);
return fb;
}
public FieldBuilder DefineUninitializedData (string name, int size, FieldAttributes attributes)
{
return DefineDataImpl (name, size, attributes & ~FieldAttributes.ReservedMask);
}
private FieldBuilder DefineDataImpl (string name, int size, FieldAttributes attributes)
{
if (name == null)
throw new ArgumentNullException ("name");
if (name == String.Empty)
throw new ArgumentException ("name cannot be empty", "name");
if (global_type_created != null)
throw new InvalidOperationException ("global fields already created");
if ((size <= 0) || (size > 0x3f0000))
throw new ArgumentException ("size", "Data size must be > 0 and < 0x3f0000");
if ((size <= 0) || (size >= 0x3f0000))
throw new ArgumentException ("Data size must be > 0 and < 0x3f0000", null as string);
CreateGlobalType ();
@@ -709,8 +716,7 @@ namespace System.Reflection.Emit {
static int typespec_tokengen = 0x1bffffff;
static int memberref_tokengen = 0x0affffff;
static int methoddef_tokengen = 0x06ffffff;
Dictionary<MemberInfo, int> inst_tokens = new Dictionary<MemberInfo, int> ();
Dictionary<MemberInfo, int> inst_tokens_open = new Dictionary<MemberInfo, int> ();
Dictionary<MemberInfo, int> inst_tokens, inst_tokens_open;
//
// Assign a pseudo token to the various TypeBuilderInst objects, so the runtime
@@ -720,16 +726,20 @@ namespace System.Reflection.Emit {
// still encounter these objects, it will resolve them by calling their
// RuntimeResolve () methods.
//
int GetPseudoToken (MemberInfo member, bool create_open_instance) {
int GetPseudoToken (MemberInfo member, bool create_open_instance)
{
int token;
if (create_open_instance) {
if (inst_tokens_open.TryGetValue (member, out token))
return token;
} else {
if (inst_tokens.TryGetValue (member, out token))
return token;
var dict = create_open_instance ? inst_tokens_open : inst_tokens;
if (dict == null) {
dict = new Dictionary<MemberInfo, int> (ReferenceEqualityComparer<MemberInfo>.Instance);
if (create_open_instance)
inst_tokens_open = dict;
else
inst_tokens = dict;
} else if (dict.TryGetValue (member, out token)) {
return token;
}
// Count backwards to avoid collisions with the tokens
// allocated by the runtime
if (member is TypeBuilderInstantiation || member is SymbolType)
@@ -751,10 +761,7 @@ namespace System.Reflection.Emit {
token = typeref_tokengen --;
} else if (member is EnumBuilder) {
token = GetPseudoToken ((member as EnumBuilder).GetTypeBuilder(), create_open_instance);
if (create_open_instance)
inst_tokens_open[member] = token;
else
inst_tokens[member] = token;
dict[member] = token;
// n.b. don't register with the runtime, the TypeBuilder already did it.
return token;
} else if (member is ConstructorBuilder) {
@@ -772,10 +779,8 @@ namespace System.Reflection.Emit {
token = typespec_tokengen --;
} else
throw new NotImplementedException ();
if (create_open_instance)
inst_tokens_open [member] = token;
else
inst_tokens [member] = token;
dict [member] = token;
RegisterToken (member, token);
return token;
}
@@ -904,11 +909,14 @@ namespace System.Reflection.Emit {
//
// Fixup the pseudo tokens assigned to the various SRE objects
//
void FixupTokens () {
void FixupTokens ()
{
var token_map = new Dictionary<int, int> ();
var member_map = new Dictionary<int, MemberInfo> ();
FixupTokens (token_map, member_map, inst_tokens, false);
FixupTokens (token_map, member_map, inst_tokens_open, true);
if (inst_tokens != null)
FixupTokens (token_map, member_map, inst_tokens, false);
if (inst_tokens_open != null)
FixupTokens (token_map, member_map, inst_tokens_open, true);
// Replace the tokens in the IL stream
if (types != null) {

View File

@@ -1239,7 +1239,7 @@ namespace System.Runtime.InteropServices
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern static IntPtr BufferToBSTR (Array ptr, int slen);
extern static IntPtr BufferToBSTR (Array ptr, int slen);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern static IntPtr UnsafeAddrOfPinnedArrayElement (Array arr, int index);

View File

@@ -54,12 +54,12 @@ namespace System.Runtime.Remoting.Lifetime
_initialLeaseTime = LifetimeServices.LeaseTime;
_renewOnCallTime = LifetimeServices.RenewOnCallTime;
_sponsorshipTimeout = LifetimeServices.SponsorshipTimeout;
_leaseExpireTime = DateTime.Now + _initialLeaseTime;
_leaseExpireTime = DateTime.UtcNow + _initialLeaseTime;
}
public TimeSpan CurrentLeaseTime
{
get { return _leaseExpireTime - DateTime.Now; }
get { return _leaseExpireTime - DateTime.UtcNow; }
}
public LeaseState CurrentState
@@ -82,7 +82,7 @@ namespace System.Runtime.Remoting.Lifetime
throw new RemotingException ("InitialLeaseTime property can only be set when the lease is in initial state; state is " + _currentState + ".");
_initialLeaseTime = value;
_leaseExpireTime = DateTime.Now + _initialLeaseTime;
_leaseExpireTime = DateTime.UtcNow + _initialLeaseTime;
if (value == TimeSpan.Zero) _currentState = LeaseState.Null;
}
}
@@ -130,7 +130,7 @@ namespace System.Runtime.Remoting.Lifetime
public TimeSpan Renew (TimeSpan renewalTime)
{
DateTime newTime = DateTime.Now + renewalTime;
DateTime newTime = DateTime.UtcNow + renewalTime;
if (newTime > _leaseExpireTime) _leaseExpireTime = newTime;
return CurrentLeaseTime;
}

View File

@@ -114,6 +114,7 @@ namespace System.Security.Cryptography {
persisted = true;
this.FromXmlString (store.KeyValue);
}
privateKeyExportable = (parameters.Flags & CspProviderFlags.UseNonExportableKey) == 0;
}
~DSACryptoServiceProvider ()

View File

@@ -111,6 +111,7 @@ namespace System.Security.Cryptography {
store = new KeyPairPersistence (p);
bool exists = store.Load ();
bool required = (p.Flags & CspProviderFlags.UseExistingKey) != 0;
privateKeyExportable = (p.Flags & CspProviderFlags.UseNonExportableKey) == 0;
if (required && !exists)
throw new CryptographicException ("Keyset does not exist");

View File

@@ -49,6 +49,9 @@ namespace System.Threading
static int WaitMultiple(WaitHandle[] waitHandles, int millisecondsTimeout, bool exitContext, bool WaitAll)
{
if (waitHandles.Length > MaxWaitHandles)
return WAIT_FAILED;
int release_last = -1;
try {
@@ -58,8 +61,7 @@ namespace System.Threading
#endif
for (int i = 0; i < waitHandles.Length; ++i) {
try {
} finally {
try {} finally {
/* we have to put it in a finally block, to avoid having a ThreadAbortException
* between the return from DangerousAddRef and the assignement to release_last */
bool release = false;
@@ -68,10 +70,14 @@ namespace System.Threading
}
}
if (WaitAll)
return WaitAll_internal (waitHandles, millisecondsTimeout);
else
return WaitAny_internal (waitHandles, millisecondsTimeout);
unsafe {
IntPtr* handles = stackalloc IntPtr[waitHandles.Length];
for (int i = 0; i < waitHandles.Length; ++i)
handles[i] = waitHandles[i].SafeWaitHandle.DangerousGetHandle ();
return Wait_internal(handles, waitHandles.Length, WaitAll, millisecondsTimeout);
}
} finally {
for (int i = release_last; i >= 0; --i) {
waitHandles [i].SafeWaitHandle.DangerousRelease ();
@@ -84,12 +90,6 @@ namespace System.Threading
}
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern int WaitAll_internal(WaitHandle[] handles, int ms);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern int WaitAny_internal(WaitHandle[] handles, int ms);
static int WaitOneNative (SafeHandle waitableSafeHandle, uint millisecondsTimeout, bool hasThreadAffinity, bool exitContext)
{
bool release = false;
@@ -101,7 +101,10 @@ namespace System.Threading
waitableSafeHandle.DangerousAddRef (ref release);
return WaitOne_internal (waitableSafeHandle.DangerousGetHandle (), (int) millisecondsTimeout);
unsafe {
IntPtr handle = waitableSafeHandle.DangerousGetHandle();
return Wait_internal(&handle, 1, false, (int)millisecondsTimeout);
}
} finally {
if (release)
waitableSafeHandle.DangerousRelease ();
@@ -114,7 +117,7 @@ namespace System.Threading
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
static extern int WaitOne_internal(IntPtr handle, int ms);
unsafe static extern int Wait_internal(IntPtr* handles, int numHandles, bool waitAll, int ms);
static int SignalAndWaitOne (SafeWaitHandle waitHandleToSignal,SafeWaitHandle waitHandleToWaitOn, int millisecondsTimeout, bool hasThreadAffinity, bool exitContext)
{

View File

@@ -42,12 +42,14 @@ namespace System
var displayName = DeserializeString (ref input);
var standardName = DeserializeString (ref input);
var daylightName = DeserializeString (ref input);
var rules = new List<TimeZoneInfo.AdjustmentRule> ();
List<TimeZoneInfo.AdjustmentRule> rules = null;
while (input [0] != ';') {
if (rules == null)
rules = new List<TimeZoneInfo.AdjustmentRule> ();
rules.Add (DeserializeAdjustmentRule (ref input));
}
var offsetSpan = TimeSpan.FromMinutes (offset);
return TimeZoneInfo.CreateCustomTimeZone (tzId, offsetSpan, displayName, standardName, daylightName, rules.ToArray ());
return TimeZoneInfo.CreateCustomTimeZone (tzId, offsetSpan, displayName, standardName, daylightName, rules?.ToArray ());
}
public string ToSerializedString ()

View File

@@ -624,7 +624,7 @@ namespace System
else
ParseRegTzi(adjustmentRules, 1, 9999, reg_tzi);
return CreateCustomTimeZone (id, baseUtcOffset, display_name, standard_name, daylight_name, ValidateRules (adjustmentRules).ToArray ());
return CreateCustomTimeZone (id, baseUtcOffset, display_name, standard_name, daylight_name, ValidateRules (adjustmentRules));
}
private static void ParseRegTzi (List<AdjustmentRule> adjustmentRules, int start_year, int end_year, byte [] buffer)
@@ -1231,8 +1231,11 @@ namespace System
return new DateTime (year, transition.Month, day) + transition.TimeOfDay.TimeOfDay;
}
static List<AdjustmentRule> ValidateRules (List<AdjustmentRule> adjustmentRules)
static AdjustmentRule[] ValidateRules (List<AdjustmentRule> adjustmentRules)
{
if (adjustmentRules == null || adjustmentRules.Count == 0)
return null;
AdjustmentRule prev = null;
foreach (AdjustmentRule current in adjustmentRules.ToArray ()) {
if (prev != null && prev.DateEnd > current.DateStart) {
@@ -1240,7 +1243,7 @@ namespace System
}
prev = current;
}
return adjustmentRules;
return adjustmentRules.ToArray ();
}
#if LIBC || MONOTOUCH
@@ -1404,13 +1407,13 @@ namespace System
}
tz = CreateCustomTimeZone (id, baseUtcOffset, id, standardDisplayName);
} else {
tz = CreateCustomTimeZone (id, baseUtcOffset, id, standardDisplayName, daylightDisplayName, ValidateRules (adjustmentRules).ToArray ());
tz = CreateCustomTimeZone (id, baseUtcOffset, id, standardDisplayName, daylightDisplayName, ValidateRules (adjustmentRules));
}
if (storeTransition && transitions.Count > 0) {
tz.transitions = transitions;
tz.supportsDaylightSavingTime = true;
}
tz.supportsDaylightSavingTime = adjustmentRules.Count > 0;
return tz;
}

View File

@@ -455,7 +455,9 @@ namespace System {
}
if (name_start < pos)
data.AddName (name.Substring (name_start, pos - name_start));
data.AddName (name.Substring (name_start, pos - name_start));
else if (name_start == pos)
data.AddName (String.Empty);
if (in_modifiers) {
for (; pos < name.Length; ++pos) {

View File

@@ -1 +1 @@
048091d2d7cb9dbb624836c4833bfa52d79b89cc
bef88b0c599515481b21854be4e0073c3fea3617

Some files were not shown because too many files have changed in this diff Show More