Imported Upstream version 5.0.0.42

Former-commit-id: fd56571888259555122d8a0f58c68838229cea2b
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-04-10 11:41:01 +00:00
parent 1190d13a04
commit 6bdd276d05
19939 changed files with 3099680 additions and 93811 deletions

View File

@@ -27,11 +27,12 @@ namespace System {
, IComparable<Boolean>, IEquatable<Boolean>
#endif
{
#pragma warning disable 649
//
// Member Variables
//
private bool m_value;
#pragma warning disable
// The true value.
//

View File

@@ -910,7 +910,9 @@ namespace System.Collections.Generic {
Contract.EndContractBlock();
if (count > 0) {
#if !MONO
int i = _size;
#endif
_size -= count;
if (index < _size) {
Array.Copy(_items, index + count, _items, index, _size - index);

View File

@@ -1 +1 @@
ce8bafab2deef044445d927a8898f6424e28abe6
4767195da3cf472f95631b2e33ccce96be7ddf11

View File

@@ -989,7 +989,7 @@ namespace System {
[System.Security.SecurityCritical] // auto-generated
internal virtual String InternalToString()
{
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
try
{
#pragma warning disable 618

View File

@@ -46,7 +46,9 @@ namespace System.Globalization {
internal const int UNICODE_CATEGORY_OFFSET = 0;
internal const int BIDI_CATEGORY_OFFSET = 1;
#pragma warning disable 414
static bool s_initialized = InitTable();
#pragma warning restore
// The native pointer to the 12:4:4 index table of the Unicode cateogry data.
[SecurityCritical]

View File

@@ -103,11 +103,13 @@ namespace System.Globalization {
[NonSerialized]
private String m_sortName; // The name that defines our behavior
#if !MONO
[NonSerialized]
private IntPtr m_dataHandle;
[NonSerialized]
private IntPtr m_handleOrigin;
#endif
////////////////////////////////////////////////////////////////////////
//
@@ -258,8 +260,10 @@ namespace System.Globalization {
// the following fields are defined to keep the compatibility with Whidbey.
// don't change/remove the names/types of these fields.
#if FEATURE_USE_LCID || MONO
#pragma warning disable 169
[OptionalField(VersionAdded = 1)]
private int win32LCID; // mapped sort culture id of this instance
#pragma warning restore
private int culture; // the culture ID used to create this instance.
#endif
[OnDeserializing]
@@ -1143,12 +1147,17 @@ namespace System.Globalization {
{
throw new ArgumentException(Environment.GetResourceString("Argument_InvalidFlag"), "options");
}
#if !MONO
byte[] keyData = null;
#endif
// The OS doesn't have quite the same behavior so we have to test for empty inputs
if (String.IsNullOrEmpty(source))
{
#if !MONO
// Empty strings get an empty sort key
keyData = EmptyArray<Byte>.Value;
#endif
// Fake value to test though so we can verify our flags
source = "\x0000";
}

View File

@@ -1 +1 @@
cc6bc05d4d040352118265e0dea3270c9253a790
7c03df01a4c5f9072065355c954d3e1ae956b871

View File

@@ -1 +1 @@
da422367d637dc6a26c15d3e0a8941355ac41088
991ac5117029a5071717bee473bbd049bed9c4e9

View File

@@ -164,10 +164,13 @@ namespace System.Globalization {
[System.Security.SecuritySafeCritical] // auto-generated
private static EraInfo[] GetErasFromRegistry()
{
#if MONO
return null;
#else
// Look in the registry key and see if we can find any ranges
int iFoundEras = 0;
EraInfo[] registryEraRanges = null;
#if !MONO
try
{
// Need to access registry
@@ -249,9 +252,10 @@ namespace System.Globalization {
registryEraRanges[i].maxEraYear = registryEraRanges[i-1].yearOffset + 1 - registryEraRanges[i].yearOffset;
}
}
#endif
// Return our ranges
return registryEraRanges;
#endif
}
//

View File

@@ -30,7 +30,9 @@ namespace System.Globalization {
m_NlsVersion = nlsVersion;
if(customVersion == Guid.Empty) {
#if !MONO
byte[] b = BitConverter.GetBytes(effectiveId);
#endif
byte b1 = (byte) ((uint) effectiveId >> 24);
byte b2 = (byte) ((effectiveId & 0x00FF0000) >> 16);
byte b3 = (byte) ((effectiveId & 0x0000FF00) >> 8);

View File

@@ -92,7 +92,7 @@ namespace System.IO {
bool safeToReturn = false;
try {
if (!isInvalidPath) {
#if !FEATURE_CORECLR && FEATURE_MONO_CAS
#if !FEATURE_CORECLR && MONO_FEATURE_CAS
FileIOPermission.QuickDemand(FileIOPermissionAccess.PathDiscovery, path, false, false);
#endif
safeToReturn = true;

View File

@@ -421,7 +421,7 @@ namespace System.IO {
// put in InternalReadChars.
int charsRead = 0;
int numBytes = 0;
long posSav = posSav = 0;
long posSav = 0;
if (m_stream.CanSeek)
posSav = m_stream.Position;

View File

@@ -37,7 +37,8 @@ using System.Security.AccessControl;
namespace System.IO {
[ComVisible(true)]
public static class Directory {
public static partial class Directory {
#if !MONO
[ResourceExposure(ResourceScope.Machine)]
[ResourceConsumption(ResourceScope.Machine)]
public static DirectoryInfo GetParent(String path)
@@ -590,6 +591,8 @@ namespace System.IO {
}
#endif
#endif // !MONO
// Returns an array of filenames in the DirectoryInfo specified by path
[ResourceExposure(ResourceScope.Machine)]
[ResourceConsumption(ResourceScope.Machine)]
@@ -1007,6 +1010,7 @@ namespace System.IO {
includeFiles, includeDirs, searchOption, true);
}
#if !MONO
// Retrieves the names of the logical drives on this machine in the
// form "C:\".
//
@@ -1540,6 +1544,7 @@ namespace System.IO {
private const int FILE_SHARE_DELETE = 0x00000004;
private const int OPEN_EXISTING = 0x00000003;
private const int FILE_FLAG_BACKUP_SEMANTICS = 0x02000000;
#endif // !MONO
}
}

View File

@@ -130,7 +130,7 @@ namespace System.IO {
[System.Security.SecurityCritical] // auto-generated
private FileInfo(SerializationInfo info, StreamingContext context) : base(info, context)
{
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
#if !FEATURE_CORECLR
FileIOPermission.QuickDemand(FileIOPermissionAccess.Read, FullPath, false, false);
#endif
@@ -187,7 +187,7 @@ namespace System.IO {
String directoryName = Path.GetDirectoryName(FullPath);
if (directoryName != null)
{
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
#if FEATURE_CORECLR
FileSecurityState state = new FileSecurityState(FileSecurityStateAccess.Read, DisplayPath, FullPath);
state.EnsureState();
@@ -338,7 +338,7 @@ namespace System.IO {
[ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)]
public override void Delete()
{
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
#if FEATURE_CORECLR
FileSecurityState state = new FileSecurityState(FileSecurityStateAccess.Write, DisplayPath, FullPath);
state.EnsureState();

View File

@@ -174,11 +174,11 @@ namespace System.IO
SafeFindHandle _hnd = null;
bool needsParentPathDiscoveryDemand;
// empty means we know in advance that we won<EFBFBD>t find any search results, which can happen if:
// 1. we don<EFBFBD>t have a search pattern
// 2. we<EFBFBD>re enumerating only the top directory and found no matches during the first call
// This flag allows us to return early for these cases. We can<EFBFBD>t know this in advance for
// SearchOption.AllDirectories because we do a <EFBFBD>*<2A> search for subdirs and then use the
// empty means we know in advance that we won't find any search results, which can happen if:
// 1. we don't have a search pattern
// 2. we're enumerating only the top directory and found no matches during the first call
// This flag allows us to return early for these cases. We can't know this in advance for
// SearchOption.AllDirectories because we do a "*" search for subdirs and then use the
// searchPattern at each directory level.
bool empty;
@@ -186,7 +186,9 @@ namespace System.IO
private SearchOption searchOption;
private String fullPath;
private String normalizedSearchPath;
#if !MONO
private int oldMode;
#endif
private bool _checkHost;
[System.Security.SecuritySafeCritical]
@@ -198,7 +200,9 @@ namespace System.IO
Contract.Requires(searchOption == SearchOption.AllDirectories || searchOption == SearchOption.TopDirectoryOnly);
Contract.Requires(resultHandler != null);
#if !MONO // TODO: check if we need this on Windows
oldMode = Win32Native.SetErrorMode(Win32Native.SEM_FAILCRITICALERRORS);
#endif
searchStack = new List<Directory.SearchData>();
@@ -219,12 +223,17 @@ namespace System.IO
// permission demands
String[] demandPaths = new String[2];
#if MONO
// TODO: we don't call FileIOPermission.HasIllegalCharacters on Mono since CAS is disabled
#else
// Any illegal chars such as *, ? will be caught by FileIOPermission.HasIllegalCharacters
#endif
demandPaths[0] = Directory.GetDemandDir(fullPath, true);
// For filters like foo\*.cs we need to verify if the directory foo is not denied access.
// Do a demand on the combined path so that we can fail early in case of deny
demandPaths[1] = Directory.GetDemandDir(normalizedSearchPath, true);
_checkHost = checkHost;
#if MONO_FEATURE_CAS
#if FEATURE_CORECLR
if (checkHost)
{
@@ -235,6 +244,7 @@ namespace System.IO
}
#else
FileIOPermission.QuickDemand(FileIOPermissionAccess.PathDiscovery, demandPaths, false, false);
#endif
#endif
// normalize search criteria
@@ -267,11 +277,20 @@ namespace System.IO
Win32Native.WIN32_FIND_DATA data = new Win32Native.WIN32_FIND_DATA();
// Open a Find handle
#if MONO
int error;
_hnd = new SafeFindHandle (MonoIO.FindFirstFile (searchPath, out data.cFileName, out data.dwFileAttributes, out error));
#else
_hnd = Win32Native.FindFirstFile(searchPath, data);
#endif
if (_hnd.IsInvalid)
{
#if MONO
int hr = error;
#else
int hr = Marshal.GetLastWin32Error();
#endif
if (hr != Win32Native.ERROR_FILE_NOT_FOUND && hr != Win32Native.ERROR_NO_MORE_FILES)
{
HandleError(hr, searchData.fullPath);
@@ -331,6 +350,7 @@ namespace System.IO
// For filters like foo\*.cs we need to verify if the directory foo is not denied access.
// Do a demand on the combined path so that we can fail early in case of deny
demandPaths[1] = Directory.GetDemandDir(normalizedSearchPath, true);
#if MONO_FEATURE_CAS
#if FEATURE_CORECLR
if (checkHost)
{
@@ -341,6 +361,7 @@ namespace System.IO
}
#else
FileIOPermission.QuickDemand(FileIOPermissionAccess.PathDiscovery, demandPaths, false, false);
#endif
#endif
searchData = new Directory.SearchData(normalizedSearchPath, userPath, searchOption);
CommonInit();
@@ -368,7 +389,9 @@ namespace System.IO
}
finally
{
#if !MONO // TODO: check if we need this on Windows
Win32Native.SetErrorMode(oldMode);
#endif
base.Dispose(disposing);
}
}
@@ -421,10 +444,19 @@ namespace System.IO
String searchPath = Path.InternalCombine(searchData.fullPath, searchCriteria);
// Open a Find handle
#if MONO
int error;
_hnd = new SafeFindHandle (MonoIO.FindFirstFile (searchPath, out data.cFileName, out data.dwFileAttributes, out error));
#else
_hnd = Win32Native.FindFirstFile(searchPath, data);
#endif
if (_hnd.IsInvalid)
{
#if MONO
int hr = error;
#else
int hr = Marshal.GetLastWin32Error();
#endif
if (hr == Win32Native.ERROR_FILE_NOT_FOUND || hr == Win32Native.ERROR_NO_MORE_FILES || hr == Win32Native.ERROR_PATH_NOT_FOUND)
continue;
@@ -457,8 +489,13 @@ namespace System.IO
{
if (searchData != null && _hnd != null)
{
// Keep asking for more matching files/dirs, add it to the list
// Keep asking for more matching files/dirs, add it to the list
#if MONO
int error;
while (MonoIO.FindNextFile (_hnd.DangerousGetHandle(), out data.cFileName, out data.dwFileAttributes, out error))
#else
while (Win32Native.FindNextFile(_hnd, data))
#endif
{
SearchResult searchResult = CreateSearchResult(searchData, data);
if (_resultHandler.IsResultIncluded(searchResult))
@@ -473,8 +510,12 @@ namespace System.IO
}
}
#if MONO
int hr = error;
#else
// Make sure we quit with a sensible error.
int hr = Marshal.GetLastWin32Error();
#endif
if (_hnd != null)
_hnd.Dispose();
@@ -534,11 +575,20 @@ namespace System.IO
try
{
// Get all files and dirs
#if MONO
int error;
hnd = new SafeFindHandle (MonoIO.FindFirstFile (searchPath, out data.cFileName, out data.dwFileAttributes, out error));
#else
hnd = Win32Native.FindFirstFile(searchPath, data);
#endif
if (hnd.IsInvalid)
{
#if MONO
int hr = error;
#else
int hr = Marshal.GetLastWin32Error();
#endif
// This could happen if the dir doesn't contain any files.
// Continue with the recursive search though, eventually
@@ -570,7 +620,11 @@ namespace System.IO
searchStack.Insert(incr++, searchDataSubDir);
}
#if MONO
} while (MonoIO.FindNextFile (hnd.DangerousGetHandle(), out data.cFileName, out data.dwFileAttributes, out error));
#else
} while (Win32Native.FindNextFile(hnd, data));
#endif
// We don't care about errors here
}
finally
@@ -583,6 +637,7 @@ namespace System.IO
[System.Security.SecurityCritical]
internal void DoDemand(String fullPathToDemand)
{
#if MONO_FEATURE_CAS
#if FEATURE_CORECLR
if(_checkHost) {
String demandDir = Directory.GetDemandDir(fullPathToDemand, true);
@@ -592,6 +647,7 @@ namespace System.IO
#else
String demandDir = Directory.GetDemandDir(fullPathToDemand, true);
FileIOPermission.QuickDemand(FileIOPermissionAccess.PathDiscovery, demandDir, false, false);
#endif
#endif
}
@@ -701,11 +757,13 @@ namespace System.IO
internal override FileInfo CreateObject(SearchResult result)
{
String name = result.FullPath;
#if MONO_FEATURE_CAS
#if FEATURE_CORECLR
FileSecurityState state = new FileSecurityState(FileSecurityStateAccess.Read, String.Empty, name);
state.EnsureState();
#else
FileIOPermission.QuickDemand(FileIOPermissionAccess.Read, name, false, false);
#endif
#endif
FileInfo fi = new FileInfo(name, false);
fi.InitializeFrom(result.FindData);
@@ -726,12 +784,14 @@ namespace System.IO
{
String name = result.FullPath;
String permissionName = name + "\\.";
#if MONO_FEATURE_CAS
#if FEATURE_CORECLR
FileSecurityState state = new FileSecurityState(FileSecurityStateAccess.Read, String.Empty, permissionName);
state.EnsureState();
#else
FileIOPermission.QuickDemand(FileIOPermissionAccess.Read, permissionName, false, false);
#endif
#endif
DirectoryInfo di = new DirectoryInfo(name, false);
di.InitializeFrom(result.FindData);
@@ -763,11 +823,13 @@ namespace System.IO
String name = result.FullPath;
String permissionName = name + "\\.";
#if MONO_FEATURE_CAS
#if FEATURE_CORECLR
FileSecurityState state = new FileSecurityState(FileSecurityStateAccess.Read, String.Empty, permissionName);
state.EnsureState();
#else
FileIOPermission.QuickDemand(FileIOPermissionAccess.Read, permissionName, false, false);
#endif
#endif
DirectoryInfo di = new DirectoryInfo(name, false);
di.InitializeFrom(result.FindData);
@@ -778,11 +840,13 @@ namespace System.IO
Contract.Assert(isFile);
String name = result.FullPath;
#if MONO_FEATURE_CAS
#if FEATURE_CORECLR
FileSecurityState state = new FileSecurityState(FileSecurityStateAccess.Read, String.Empty, name);
state.EnsureState();
#else
FileIOPermission.QuickDemand(FileIOPermissionAccess.Read, name, false, false);
#endif
#endif
FileInfo fi = new FileInfo(name, false);
fi.InitializeFrom(result.FindData);
@@ -834,14 +898,22 @@ namespace System.IO
internal static bool IsDir(Win32Native.WIN32_FIND_DATA data)
{
// Don't add "." nor ".."
#if MONO
return (0 != (data.dwFileAttributes & (int)Win32Native.FILE_ATTRIBUTE_DIRECTORY))
#else
return (0 != (data.dwFileAttributes & Win32Native.FILE_ATTRIBUTE_DIRECTORY))
#endif
&& !data.cFileName.Equals(".") && !data.cFileName.Equals("..");
}
[System.Security.SecurityCritical] // auto-generated
internal static bool IsFile(Win32Native.WIN32_FIND_DATA data)
{
#if MONO
return 0 == (data.dwFileAttributes & (int)Win32Native.FILE_ATTRIBUTE_DIRECTORY);
#else
return 0 == (data.dwFileAttributes & Win32Native.FILE_ATTRIBUTE_DIRECTORY);
#endif
}
}

View File

@@ -18,7 +18,7 @@
using System;
using System.Collections;
using System.Security;
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
using System.Security.Permissions;
#endif
using Microsoft.Win32;
@@ -30,7 +30,7 @@ using System.Diagnostics.Contracts;
namespace System.IO {
[Serializable]
#if !FEATURE_CORECLR && FEATURE_MONO_CAS
#if !FEATURE_CORECLR && MONO_FEATURE_CAS
[FileIOPermissionAttribute(SecurityAction.InheritanceDemand,Unrestricted=true)]
#endif
[ComVisible(true)]
@@ -83,26 +83,32 @@ namespace System.IO {
// Lazily initialize the file attributes.
_dataInitialised = -1;
}
#if !MONO
[System.Security.SecurityCritical]
internal void InitializeFrom(Win32Native.WIN32_FIND_DATA findData)
{
#if MONO
throw new NotImplementedException ();
#else
_data = new Win32Native.WIN32_FILE_ATTRIBUTE_DATA();
_data.PopulateFrom(findData);
_dataInitialised = 0;
}
#endif
}
// Full path of the direcory/file
public virtual String FullName {
[System.Security.SecuritySafeCritical]
get
{
#pragma warning disable 219
String demandDir;
#pragma warning restore
if (this is DirectoryInfo)
demandDir = Directory.GetDemandDir(FullPath, true);
else
demandDir = FullPath;
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
#if FEATURE_CORECLR
FileSecurityState sourceState = new FileSecurityState(FileSecurityStateAccess.PathDiscovery, String.Empty, demandDir);
sourceState.EnsureState();
@@ -119,12 +125,14 @@ namespace System.IO {
[System.Security.SecurityCritical]
get
{
#pragma warning disable 219
String demandDir;
#pragma warning restore
if (this is DirectoryInfo)
demandDir = Directory.GetDemandDir(FullPath, true);
else
demandDir = FullPath;
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
#if !FEATURE_CORECLR
FileIOPermission.QuickDemand(FileIOPermissionAccess.PathDiscovery, demandDir);
#endif
@@ -351,7 +359,7 @@ namespace System.IO {
[System.Security.SecuritySafeCritical]
#endif
set {
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
#if !FEATURE_CORECLR
FileIOPermission.QuickDemand(FileIOPermissionAccess.Write, FullPath);
#endif
@@ -384,7 +392,7 @@ namespace System.IO {
[ComVisible(false)]
public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
{
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
#if !FEATURE_CORECLR
FileIOPermission.QuickDemand(FileIOPermissionAccess.PathDiscovery, FullPath);
#endif

View File

@@ -32,8 +32,10 @@ namespace System.IO {
// This information isn't guaranteed to be correct, but is our second
// best effort at a file or directory involved, after the exception
// message.
#pragma warning disable 414
[NonSerialized]
private String _maybeFullPath; // For debuggers on partial trust code
#pragma warning restore
public IOException()
: base(Environment.GetResourceString("Arg_IOException")) {

View File

@@ -240,9 +240,11 @@ namespace System.IO
// write any buffered data to those streams even during finalization, which
// is generally the right thing to do.
if (stream != null) {
#pragma warning disable 184
// Note: flush on the underlying stream can throw (ex., low disk space)
if (disposing || (LeaveOpen && stream is __ConsoleStream))
{
#pragma warning restore
#if FEATURE_ASYNC_IO
CheckAsyncTaskInProgress();
#endif

View File

@@ -163,7 +163,7 @@ namespace System.IO {
if (_isOpen) {
throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CalledTwice"));
}
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
if (!skipSecurityCheck) {
#pragma warning disable 618
new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
@@ -244,7 +244,7 @@ namespace System.IO {
if (_isOpen)
throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CalledTwice"));
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
if (!skipSecurityCheck)
#pragma warning disable 618
new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();

View File

@@ -51,7 +51,7 @@ namespace System.Resources {
// Don't use Assembly manifest, but grovel on disk for a file.
try
{
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
new System.Security.Permissions.FileIOPermission(System.Security.Permissions.PermissionState.Unrestricted).Assert();
#endif
@@ -79,7 +79,7 @@ namespace System.Resources {
}
finally
{
#if FEATURE_MONO_CAS
#if MONO_FEATURE_CAS
System.Security.CodeAccessPermission.RevertAssert();
#endif
}

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