Imported Upstream version 5.10.0.47

Former-commit-id: d0813289fa2d35e1f8ed77530acb4fb1df441bc0
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2018-01-24 17:04:36 +00:00
parent 88ff76fe28
commit e46a49ecf1
5927 changed files with 226314 additions and 129848 deletions

View File

@@ -250,6 +250,8 @@
<method signature="System.Void .ctor(System.String)" />
<!-- exception.c (mono_get_exception_type_load) mono_exception_from_name_two_strings -->
<method signature="System.Void .ctor(System.String,System.String)" />
<!-- exception.c mono_exception_from_name_four_strings -->
<method signature="System.Void .ctor(System.String,System.String,System.String,System.String)" />
</type>
<!-- threadpool.c: mono_thread_pool_init (assert) -->

View File

@@ -8,6 +8,7 @@ LIBRARY_NAME = mscorlib.dll
LIB_MCS_FLAGS = $(REFERENCE_SOURCES_FLAGS) $(RESOURCE_FILES:%=-resource:%)
LIBRARY_WARN_AS_ERROR = yes
#LIBRARY_USE_INTERMEDIATE_FILE = yes
ifeq (2, $(FRAMEWORK_VERSION_MAJOR))
@@ -21,18 +22,25 @@ endif
endif
ifeq ($(PROFILE),build)
CSC_RUNTIME_FLAGS=--profile=aot:output=$(topdir)/class/lib/$(PROFILE)/csc.$(LIBRARY).aotprofile
CSC_RUNTIME_FLAGS=--profile=aot:output=$(topdir)/class/lib/$(PROFILE_DIRECTORY)/csc.$(LIBRARY).aotprofile
endif
RESOURCE_STRINGS = ../referencesource/mscorlib/mscorlib.txt
RESX_RESOURCE_STRING = \
../../../external/corert/src/System.Private.CoreLib/src/Resources/Strings.resx \
../../../external/corefx/src/System.Collections.Concurrent/src/Resources/Strings.resx
../../../external/corefx/src/System.Collections.Concurrent/src/Resources/Strings.resx \
../../../external/corefx/src/System.Memory/src/Resources/Strings.resx \
../../../external/corefx/src/System.Runtime.InteropServices.RuntimeInformation/src/Resources/Strings.resx \
LIBRARY_COMPILE = $(BOOT_COMPILE)
LIBRARY_INSTALL_DIR = $(mono_libdir)/mono/$(FRAMEWORK_VERSION)
ifneq ($(PROFILE),basic)
RESOURCE_STRINGS = ../referencesource/mscorlib/mscorlib.txt
include il/il.make
MODULE_DEPS = $(IL_REPLACE)
endif
RESOURCE_FILES = \
resources/charinfo.nlp \
resources/collation.core.bin \
@@ -44,7 +52,7 @@ RESOURCE_FILES = \
resources/collation.cjkKOlv2.bin \
LinkerDescriptor/mscorlib.xml
REFERENCE_SOURCES_FLAGS = -d:FEATURE_PAL,GENERICS_WORK,FEATURE_LIST_PREDICATES,FEATURE_SERIALIZATION,FEATURE_ASCII,FEATURE_LATIN1,FEATURE_UTF7,FEATURE_UTF32,MONO_HYBRID_ENCODING_SUPPORT,FEATURE_ASYNC_IO,NEW_EXPERIMENTAL_ASYNC_IO,FEATURE_UTF32,FEATURE_EXCEPTIONDISPATCHINFO,FEATURE_CORRUPTING_EXCEPTIONS,FEATURE_EXCEPTION_NOTIFICATIONS,FEATURE_STRONGNAME_MIGRATION,FEATURE_USE_LCID,FEATURE_FUSION,FEATURE_CRYPTO,FEATURE_X509_SECURESTRINGS,FEATURE_SYNCHRONIZATIONCONTEXT,FEATURE_SYNCHRONIZATIONCONTEXT_WAIT,HAS_CORLIB_CONTRACTS
REFERENCE_SOURCES_FLAGS = -d:FEATURE_PAL,GENERICS_WORK,FEATURE_LIST_PREDICATES,FEATURE_SERIALIZATION,FEATURE_ENCODINGNLS,FEATURE_ASCII,FEATURE_LATIN1,FEATURE_UTF7,FEATURE_UTF32,MONO_HYBRID_ENCODING_SUPPORT,FEATURE_ASYNC_IO,NEW_EXPERIMENTAL_ASYNC_IO,FEATURE_UTF32,FEATURE_EXCEPTIONDISPATCHINFO,FEATURE_CORRUPTING_EXCEPTIONS,FEATURE_EXCEPTION_NOTIFICATIONS,FEATURE_STRONGNAME_MIGRATION,FEATURE_USE_LCID,FEATURE_FUSION,FEATURE_CRYPTO,FEATURE_X509_SECURESTRINGS,FEATURE_SYNCHRONIZATIONCONTEXT,FEATURE_SYNCHRONIZATIONCONTEXT_WAIT,HAS_CORLIB_CONTRACTS
ifndef MOBILE_PROFILE
REFERENCE_SOURCES_FLAGS += -d:FEATURE_MACL
@@ -86,12 +94,13 @@ LIB_MCS_FLAGS += -d:MONO_FEATURE_APPLE_X509
endif
WARNING_ABOUT_DISABLED_WARNING=1635
LOCAL_MCS_FLAGS = -unsafe -nostdlib -nowarn:612,618,$(WARNING_ABOUT_DISABLED_WARNING) -d:INSIDE_CORLIB,MONO_CULTURE_DATA -d:LIBC $(REFERENCE_SOURCES_FLAGS)
LOCAL_MCS_FLAGS = -unsafe -nostdlib -nowarn:612,618,3001,3002,3003,$(WARNING_ABOUT_DISABLED_WARNING) -d:INSIDE_CORLIB,MONO_CULTURE_DATA -d:LIBC $(REFERENCE_SOURCES_FLAGS)
DEFAULT_REFERENCES =
TEST_LIB_REFS = System.Core System
XTEST_LIB_REFS = System System.Core Facades/System.Threading.Tasks Facades/System.Runtime.InteropServices.RuntimeInformation
XTEST_LIB_REFS = System System.Core Facades/System.Threading.Tasks Facades/System.Runtime.InteropServices.RuntimeInformation System.Numerics.Vectors System.Runtime.CompilerServices.Unsafe
XTEST_LIB_FLAGS = -d:netcoreapp -publicsign -keyfile:../mono.snk
ifndef AOT_FRIENDLY_PROFILE
ifneq ($(PROFILE),testing_aot_hybrid)
@@ -147,7 +156,7 @@ TEST_RESX_RESOURCES_SATELITE = \
Test/resources/Resources.es-ES.resources \
Test/resources/Resources.nn-NO.resources \
CLEAN_FILES += $(TEST_RESX_RESOURCES)
CLEAN_FILES += $(TEST_RESX_RESOURCES) $(IL_REPLACE)
include $(topdir)/build/library.make
@@ -159,7 +168,7 @@ TEST_RESOURCES = $(TEST_RESX_RESOURCES) $(TEST_RESX_RESOURCES_SATELITE)
satellite_assembly1 = es-ES/$(patsubst %.dll,%.resources.dll,$(test_lib))
satellite_assembly2 = nn-NO/$(patsubst %.dll,%.resources.dll,$(test_lib))
$(test_lib): $(TEST_RESOURCES) $(satellite_assembly1) $(satellite_assembly2)
$(test_lib_output): $(TEST_RESOURCES) $(satellite_assembly1) $(satellite_assembly2) $(test_lib_dir)
$(satellite_assembly1): Test/resources/culture-es-ES.cs Test/resources/Resources.es-ES.resources
@mkdir -p es-ES
@@ -197,7 +206,7 @@ TEST_MONO_PATH=$(PWD)/../lib/$(PROFILE)
run-test-vts: test-vts
@echo Running vts tests...
PATH="$(TEST_RUNTIME_WRAPPERS_PATH):$(PATH)" $(TEST_RUNTIME) $(RUNTIME_FLAGS) $(TEST_HARNESS) $(NOSHADOW_FLAG) \
PATH="$(TEST_RUNTIME_WRAPPERS_PATH):$(PATH)" $(TEST_RUNTIME) $(TEST_RUNTIME_FLAGS) $(TEST_HARNESS) $(NOSHADOW_FLAG) \
$(vtsdir)/$(PROFILE)_TestLib/BinarySerializationOverVersions.exe
ifdef NO_TEST
@@ -219,7 +228,10 @@ EXTRA_DISTFILES += \
$(vtsdir)/VersionTolerantSerializationTestLib/4.0/Address.cs \
$(vtsdir)/VersionTolerantSerializationTestLib/5.0/Address.cs \
$(vtsdir)/VersionTolerantSerializationTestLib/6.0/Address.cs \
$(vtsdir)/BinarySerializationOverVersions.cs
$(vtsdir)/BinarySerializationOverVersions.cs \
System.Runtime.CompilerServices/Unsafe.il \
il/il.make \
il/Makefile
#
# Android TimeZoneInfo testing....

View File

@@ -4,5 +4,7 @@ namespace System.Runtime.Versioning
{
public static readonly bool TargetsAtLeast_Desktop_V4_5 = true;
public static readonly bool TargetsAtLeast_Desktop_V4_5_1 = true;
// should be a property for System.Xml.BinaryCompatibility
public static bool TargetsAtLeast_Desktop_V4_5_2 => true;
}
}

View File

@@ -783,6 +783,10 @@ namespace System
public override string FullName {
get {
// https://bugzilla.xamarin.com/show_bug.cgi?id=57938
if (IsGenericType && ContainsGenericParameters && !IsGenericTypeDefinition)
return null;
string fullName;
// This doesn't need locking
if (type_info == null)

View File

@@ -195,11 +195,18 @@ namespace System.IO
// on Moonlight this does not throw but returns false
if (!SecurityManager.CheckElevatedPermissions ())
return false;
string full_path;
try {
full_path = Path.GetFullPath (path);
} catch {
return false;
}
MonoIOError error;
bool exists;
exists = MonoIO.ExistsDirectory (path, out error);
exists = MonoIO.ExistsDirectory (full_path, out error);
/* This should not throw exceptions */
return exists;
}

View File

@@ -3,6 +3,7 @@
using System;
using System.IO;
using System.Text;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace System.IO {
@@ -12,13 +13,14 @@ namespace System.IO {
const string LibLog = "/system/lib/liblog.so";
const string LibLog64 = "/system/lib64/liblog.so";
readonly byte[] appname;
TextWriter stdout;
readonly string appname;
StringBuilder line = new StringBuilder ();
public LogcatTextWriter (string appname, TextWriter stdout)
{
this.appname = appname;
this.appname = Encoding.UTF8.GetBytes (appname);
this.stdout = stdout;
}
@@ -46,34 +48,22 @@ namespace System.IO {
var o = line.ToString ();
line.Clear ();
Log (LogLevel.Info, appname, o);
unsafe {
fixed (byte *b_appname = appname)
fixed (byte *b_message = Encoding.UTF8.GetBytes(o)) {
Log (b_appname, 1 << 5 /* G_LOG_LEVEL_MESSAGE */, b_message);
}
}
stdout.WriteLine (o);
}
enum LogLevel {
Unknown,
Default,
Verbose,
Debug,
Info,
Warn,
Error,
Fatal,
Silent
}
public static bool IsRunningOnAndroid ()
{
return File.Exists (LibLog) || File.Exists (LibLog64);
}
[DllImport ("liblog")]
static extern void __android_log_print (LogLevel level, string appname, string format, string args, IntPtr zero);
static void Log (LogLevel level, string appname, string log)
{
__android_log_print (level, appname, "%s", log, IntPtr.Zero);
}
[MethodImpl(MethodImplOptions.InternalCall)]
static unsafe extern void Log (byte *appname, int level, byte *message);
}
}

View File

@@ -169,44 +169,135 @@ namespace System.IO
// directory methods
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public extern static bool CreateDirectory (string path, out MonoIOError error);
private unsafe extern static bool CreateDirectory (char* path, out MonoIOError error);
public static bool CreateDirectory (string path, out MonoIOError error)
{
unsafe {
fixed (char* pathChars = path) {
return CreateDirectory (pathChars, out error);
}
}
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public extern static bool RemoveDirectory (string path, out MonoIOError error);
private unsafe extern static bool RemoveDirectory (char* path, out MonoIOError error);
public static bool RemoveDirectory (string path, out MonoIOError error)
{
unsafe {
fixed (char* pathChars = path) {
return RemoveDirectory (pathChars, out error);
}
}
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public extern static string GetCurrentDirectory (out MonoIOError error);
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public extern static bool SetCurrentDirectory (string path, out MonoIOError error);
private unsafe extern static bool SetCurrentDirectory (char* path, out MonoIOError error);
public static bool SetCurrentDirectory (string path, out MonoIOError error)
{
unsafe {
fixed (char* pathChars = path) {
return SetCurrentDirectory (pathChars, out error);
}
}
}
// file methods
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public extern static bool MoveFile (string path, string dest,
out MonoIOError error);
private unsafe extern static bool MoveFile (char* path, char* dest,
out MonoIOError error);
public static bool MoveFile (string path, string dest,
out MonoIOError error)
{
unsafe {
fixed (char* pathChars = path, destChars = dest) {
return MoveFile (pathChars, destChars, out error);
}
}
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public extern static bool CopyFile (string path, string dest,
bool overwrite,
out MonoIOError error);
private unsafe extern static bool CopyFile (char* path, char* dest,
bool overwrite,
out MonoIOError error);
public static bool CopyFile (string path, string dest,
bool overwrite,
out MonoIOError error)
{
unsafe {
fixed (char* pathChars = path, destChars = dest) {
return CopyFile (pathChars, destChars, overwrite, out error);
}
}
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public extern static bool DeleteFile (string path,
out MonoIOError error);
private unsafe extern static bool DeleteFile (char* path,
out MonoIOError error);
public static bool DeleteFile (string path,
out MonoIOError error)
{
unsafe {
fixed (char* pathChars = path) {
return DeleteFile (pathChars, out error);
}
}
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public extern static bool ReplaceFile (string sourceFileName,
string destinationFileName,
string destinationBackupFileName,
bool ignoreMetadataErrors,
out MonoIOError error);
private unsafe extern static bool ReplaceFile (char* sourceFileName,
char* destinationFileName,
char* destinationBackupFileName,
bool ignoreMetadataErrors,
out MonoIOError error);
public static bool ReplaceFile (string sourceFileName,
string destinationFileName,
string destinationBackupFileName,
bool ignoreMetadataErrors,
out MonoIOError error)
{
unsafe {
fixed (char* sourceFileNameChars = sourceFileName,
destinationFileNameChars = destinationFileName,
destinationBackupFileNameChars = destinationBackupFileName) {
return ReplaceFile (sourceFileNameChars, destinationFileNameChars, destinationBackupFileNameChars, ignoreMetadataErrors, out error);
}
}
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public extern static FileAttributes GetFileAttributes (string path, out MonoIOError error);
private unsafe extern static FileAttributes GetFileAttributes (char* path, out MonoIOError error);
public static FileAttributes GetFileAttributes (string path, out MonoIOError error)
{
unsafe {
fixed (char* pathChars = path) {
return GetFileAttributes (pathChars, out error);
}
}
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public extern static bool SetFileAttributes (string path, FileAttributes attrs, out MonoIOError error);
private extern static bool SetFileAttributes (char* path, FileAttributes attrs, out MonoIOError error);
public static bool SetFileAttributes (string path, FileAttributes attrs, out MonoIOError error)
{
unsafe {
fixed (char* pathChars = path) {
return SetFileAttributes (pathChars, attrs, out error);
}
}
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
private extern static MonoFileType GetFileType (IntPtr handle, out MonoIOError error);
@@ -228,7 +319,16 @@ namespace System.IO
//
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public extern static IntPtr FindFirstFile (string path_with_pattern, out string fileName, out int fileAttr, out int error);
private unsafe extern static IntPtr FindFirstFile (char* pathWithPattern, out string fileName, out int fileAttr, out int error);
public static IntPtr FindFirstFile (string pathWithPattern, out string fileName, out int fileAttr, out int error)
{
unsafe {
fixed (char* pathWithPatternChars = pathWithPattern) {
return FindFirstFile (pathWithPatternChars, out fileName, out fileAttr, out error);
}
}
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public extern static bool FindNextFile (IntPtr hnd, out string fileName, out int fileAttr, out int error);
@@ -294,19 +394,44 @@ namespace System.IO
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public extern static bool GetFileStat (string path,
out MonoIOStat stat,
out MonoIOError error);
private unsafe extern static bool GetFileStat (char* path,
out MonoIOStat stat,
out MonoIOError error);
public static bool GetFileStat (string path,
out MonoIOStat stat,
out MonoIOError error)
{
unsafe {
fixed (char* pathChars = path) {
return GetFileStat (pathChars, out stat, out error);
}
}
}
// handle methods
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public extern static IntPtr Open (string filename,
FileMode mode,
FileAccess access,
FileShare share,
FileOptions options,
out MonoIOError error);
private unsafe extern static IntPtr Open (char* filename,
FileMode mode,
FileAccess access,
FileShare share,
FileOptions options,
out MonoIOError error);
public static IntPtr Open (string filename,
FileMode mode,
FileAccess access,
FileShare share,
FileOptions options,
out MonoIOError error)
{
unsafe {
fixed (char* filenameChars = filename) {
return Open (filenameChars, mode, access, share, options, out error);
}
}
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public extern static bool Close (IntPtr handle,

View File

@@ -46,6 +46,11 @@ namespace System.Reflection.Emit {
public class CustomAttributeBuilder : _CustomAttributeBuilder {
ConstructorInfo ctor;
byte[] data;
object [] args;
PropertyInfo [] namedProperties;
object [] propertyValues;
FieldInfo [] namedFields;
object [] fieldValues;
internal ConstructorInfo Ctor {
get {return ctor;}
@@ -57,7 +62,20 @@ 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 object Invoke ()
{
object result = ctor.Invoke (args);
for (int i=0; i < namedFields.Length; i++)
namedFields [i].SetValue (result, fieldValues [i]);
for (int i=0; i < namedProperties.Length; i++)
namedProperties [i].SetValue (result, propertyValues [i]);
return result;
}
internal CustomAttributeBuilder( ConstructorInfo con, byte[] binaryAttribute) {
if (con == null)
throw new ArgumentNullException ("con");
@@ -140,6 +158,12 @@ namespace System.Reflection.Emit {
FieldInfo [] namedFields, object [] fieldValues)
{
ctor = con;
args = constructorArgs;
this.namedProperties = namedProperties;
this.propertyValues = propertyValues;
this.namedFields = namedFields;
this.fieldValues = fieldValues;
if (con == null)
throw new ArgumentNullException ("con");
if (constructorArgs == null)

View File

@@ -1169,32 +1169,55 @@ namespace System.Reflection.Emit {
public override object[] GetCustomAttributes (bool inherit)
{
return base.GetCustomAttributes (inherit);
return GetCustomAttributes (null, inherit);
}
public override object[] GetCustomAttributes (Type attributeType, bool inherit)
{
return base.GetCustomAttributes (attributeType, inherit);
if (cattrs == null || cattrs.Length == 0)
return Array.Empty<object> ();
if (attributeType is TypeBuilder)
throw new InvalidOperationException ("First argument to GetCustomAttributes can't be a TypeBuilder");
List<object> results = new List<object> ();
for (int i=0; i < cattrs.Length; i++) {
Type t = cattrs [i].Ctor.GetType ();
if (t is TypeBuilder)
throw new InvalidOperationException ("Can't construct custom attribute for TypeBuilder type");
if (attributeType == null || attributeType.IsAssignableFrom (t))
results.Add (cattrs [i].Invoke ());
}
return results.ToArray ();
}
public override FieldInfo GetField (string name, BindingFlags bindingAttr)
{
return base.GetField (name, bindingAttr);
if (global_type_created == null)
throw new InvalidOperationException ("Module-level fields cannot be retrieved until after the CreateGlobalFunctions method has been called for the module.");
return global_type_created.GetField (name, bindingAttr);
}
public override FieldInfo[] GetFields (BindingFlags bindingFlags)
{
return base.GetFields (bindingFlags);
if (global_type_created == null)
throw new InvalidOperationException ("Module-level fields cannot be retrieved until after the CreateGlobalFunctions method has been called for the module.");
return global_type_created.GetFields (bindingFlags);
}
public override MethodInfo[] GetMethods (BindingFlags bindingFlags)
{
return base.GetMethods (bindingFlags);
if (global_type_created == null)
throw new InvalidOperationException ("Module-level methods cannot be retrieved until after the CreateGlobalFunctions method has been called for the module.");
return global_type_created.GetMethods (bindingFlags);
}
public override int MetadataToken {
get {
return base.MetadataToken;
return get_MetadataToken (this);
}
}
}

View File

@@ -0,0 +1,118 @@
//
// Unsafe.cs: Compile only stubs for Unsafe implementation
//
// Authors:
// Marek Safar (marek.safar@gmail.com)
//
// Copyright (C) 2017 Microsoft Corporation (http://microsoft.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace System.Runtime.CompilerServices
{
static partial class Unsafe
{
public static ref T Add<T> (ref T source, int elementOffset)
{
throw new NotImplementedException ();
}
public static ref T Add<T> (ref T source, System.IntPtr elementOffset)
{
throw new NotImplementedException ();
}
public unsafe static void* Add<T> (void* source, int elementOffset)
{
throw new NotImplementedException ();
}
public static ref T AddByteOffset<T> (ref T source, System.IntPtr byteOffset)
{
throw new NotImplementedException ();
}
public static bool AreSame<T> (ref T left, ref T right)
{
throw new NotImplementedException ();
}
public static T As<T> (object o) where T : class
{
throw new NotImplementedException ();
}
public static ref TTo As<TFrom, TTo>(ref TFrom source)
{
throw new NotImplementedException ();
}
public unsafe static ref T AsRef<T> (void* source)
{
throw new NotImplementedException ();
}
public static System.IntPtr ByteOffset<T> (ref T origin, ref T target)
{
throw new NotImplementedException ();
}
public static void CopyBlock (ref byte destination, ref byte source, uint byteCount)
{
throw new NotImplementedException ();
}
public static void InitBlockUnaligned (ref byte startAddress, byte value, uint byteCount)
{
throw new NotImplementedException ();
}
public unsafe static void InitBlockUnaligned (void* startAddress, byte value, uint byteCount)
{
throw new NotImplementedException ();
}
public unsafe static T Read<T> (void* source)
{
throw new NotImplementedException ();
}
public static T ReadUnaligned<T> (ref byte source)
{
throw new NotImplementedException ();
}
public static int SizeOf<T> ()
{
throw new NotImplementedException ();
}
public static ref T Subtract<T> (ref T source, int elementOffset)
{
throw new NotImplementedException ();
}
public static void WriteUnaligned<T> (ref byte destination, T value)
{
throw new NotImplementedException ();
}
}
}

View File

@@ -0,0 +1,351 @@
// Simplified version of ../../../external/corefx/src/System.Runtime.CompilerServices.Unsafe/src/System.Runtime.CompilerServices.Unsafe.il
.class public abstract auto ansi sealed beforefieldinit System.Runtime.CompilerServices.Unsafe
{
.method public hidebysig static !!T Read<T>(void* source) cil managed aggressiveinlining
{
.maxstack 1
ldarg.0
ldobj !!T
ret
}
.method public hidebysig static !!T ReadUnaligned<T>(void* source) cil managed aggressiveinlining
{
.maxstack 1
ldarg.0
unaligned. 0x1
ldobj !!T
ret
}
.method public hidebysig static !!T ReadUnaligned<T>(uint8& source) cil managed aggressiveinlining
{
.maxstack 1
ldarg.0
unaligned. 0x1
ldobj !!T
ret
}
.method public hidebysig static void Write<T>(void* destination,
!!T 'value') cil managed aggressiveinlining
{
.maxstack 2
ldarg.0
ldarg.1
stobj !!T
ret
}
.method public hidebysig static void WriteUnaligned<T>(void* destination,
!!T 'value') cil managed aggressiveinlining
{
.maxstack 2
ldarg.0
ldarg.1
unaligned. 0x01
stobj !!T
ret
}
.method public hidebysig static void WriteUnaligned<T>(uint8& destination,
!!T 'value') cil managed aggressiveinlining
{
.maxstack 2
ldarg.0
ldarg.1
unaligned. 0x01
stobj !!T
ret
}
.method public hidebysig static void Copy<T>(void* destination,
!!T& source) cil managed aggressiveinlining
{
.maxstack 2
ldarg.0
ldarg.1
ldobj !!T
stobj !!T
ret
}
.method public hidebysig static void Copy<T>(!!T& destination,
void* source) cil managed aggressiveinlining
{
.maxstack 2
ldarg.0
ldarg.1
ldobj !!T
stobj !!T
ret
}
.method public hidebysig static void* AsPointer<T>(!!T& 'value') cil managed aggressiveinlining
{
.maxstack 1
ldarg.0
conv.u
ret
}
.method public hidebysig static int32 SizeOf<T>() cil managed aggressiveinlining
{
.maxstack 1
sizeof !!T
ret
}
.method public hidebysig static void CopyBlock(void* destination, void* source, uint32 byteCount) cil managed aggressiveinlining
{
.maxstack 3
ldarg.0
ldarg.1
ldarg.2
cpblk
ret
}
.method public hidebysig static void CopyBlock(uint8& destination, uint8& source, uint32 byteCount) cil managed aggressiveinlining
{
.maxstack 3
ldarg.0
ldarg.1
ldarg.2
cpblk
ret
}
.method public hidebysig static void CopyBlockUnaligned(void* destination, void* source, uint32 byteCount) cil managed aggressiveinlining
{
.maxstack 3
ldarg.0
ldarg.1
ldarg.2
unaligned. 0x1
cpblk
ret
}
.method public hidebysig static void CopyBlockUnaligned(uint8& destination, uint8& source, uint32 byteCount) cil managed aggressiveinlining
{
.maxstack 3
ldarg.0
ldarg.1
ldarg.2
unaligned. 0x1
cpblk
ret
}
.method public hidebysig static void InitBlock(void* startAddress, uint8 'value', uint32 byteCount) cil managed aggressiveinlining
{
.maxstack 3
ldarg.0
ldarg.1
ldarg.2
initblk
ret
}
.method public hidebysig static void InitBlock(uint8& startAddress, uint8 'value', uint32 byteCount) cil managed aggressiveinlining
{
.maxstack 3
ldarg.0
ldarg.1
ldarg.2
initblk
ret
}
.method public hidebysig static void InitBlockUnaligned(void* startAddress, uint8 'value', uint32 byteCount) cil managed aggressiveinlining
{
.maxstack 3
ldarg.0
ldarg.1
ldarg.2
unaligned. 0x1
initblk
ret
}
.method public hidebysig static void InitBlockUnaligned(uint8& startAddress, uint8 'value', uint32 byteCount) cil managed aggressiveinlining
{
.maxstack 3
ldarg.0
ldarg.1
ldarg.2
unaligned. 0x1
initblk
ret
}
.method public hidebysig static !!T As<class T>(object o) cil managed aggressiveinlining
{
.maxstack 1
ldarg.0
ret
}
.method public hidebysig static !!T& AsRef<T>(void* source) cil managed aggressiveinlining
{
.maxstack 1
ldarg.0
ret
}
.method public hidebysig static !!T& AsRef<T>(!!T& source) cil managed aggressiveinlining
{
.param [1]
.custom instance void [mscorlib]System.Runtime.CompilerServices.IsReadOnlyAttribute::.ctor() = ( 01 00 00 00 )
.maxstack 1
ldarg.0
ret
}
.method public hidebysig static !!TTo& As<TFrom, TTo>(!!TFrom& source) cil managed aggressiveinlining
{
.maxstack 1
ldarg.0
ret
}
.method public hidebysig static !!T& Add<T>(!!T& source, int32 elementOffset) cil managed aggressiveinlining
{
.maxstack 3
ldarg.0
ldarg.1
sizeof !!T
conv.i
mul
add
ret
}
.method public hidebysig static void* Add<T>(void* source, int32 elementOffset) cil managed aggressiveinlining
{
.maxstack 3
ldarg.0
ldarg.1
sizeof !!T
conv.i
mul
add
ret
}
.method public hidebysig static !!T& Add<T>(!!T& source, native int elementOffset) cil managed aggressiveinlining
{
.maxstack 3
ldarg.0
ldarg.1
sizeof !!T
mul
add
ret
}
.method public hidebysig static !!T& AddByteOffset<T>(!!T& source, native int byteOffset) cil managed aggressiveinlining
{
.maxstack 2
ldarg.0
ldarg.1
add
ret
}
.method public hidebysig static !!T& Subtract<T>(!!T& source, int32 elementOffset) cil managed aggressiveinlining
{
.maxstack 3
ldarg.0
ldarg.1
sizeof !!T
conv.i
mul
sub
ret
}
.method public hidebysig static void* Subtract<T>(void* source, int32 elementOffset) cil managed aggressiveinlining
{
.maxstack 3
ldarg.0
ldarg.1
sizeof !!T
conv.i
mul
sub
ret
}
.method public hidebysig static !!T& Subtract<T>(!!T& source, native int elementOffset) cil managed aggressiveinlining
{
.maxstack 3
ldarg.0
ldarg.1
sizeof !!T
mul
sub
ret
}
.method public hidebysig static !!T& SubtractByteOffset<T>(!!T& source, native int byteOffset) cil managed aggressiveinlining
{
.maxstack 2
ldarg.0
ldarg.1
sub
ret
}
.method public hidebysig static native int ByteOffset<T>(!!T& origin, !!T& target) cil managed aggressiveinlining
{
.maxstack 2
ldarg.1
ldarg.0
sub
ret
}
.method public hidebysig static bool AreSame<T>(!!T& left, !!T& right) cil managed aggressiveinlining
{
.maxstack 2
ldarg.0
ldarg.1
ceq
ret
}
}

View File

@@ -0,0 +1,84 @@
//
// RuntimeInformation.cs
//
// Author:
// Alexander Köplinger (alexander.koeplinger@xamarin.com)
//
// (C) 2016 Xamarin, Inc.
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.IO;
using System.Reflection;
namespace System.Runtime.InteropServices
{
public static class RuntimeInformation
{
public static string FrameworkDescription {
get {
return "Mono " + Mono.Runtime.GetDisplayName ();
}
}
public static bool IsOSPlatform (OSPlatform osPlatform)
{
switch (Environment.Platform) {
case PlatformID.Win32NT:
return osPlatform == OSPlatform.Windows;
case PlatformID.MacOSX:
return osPlatform == OSPlatform.OSX;
case PlatformID.Unix:
return osPlatform == OSPlatform.Linux;
default:
return false;
}
}
public static string OSDescription
{
get
{
return Environment.OSVersion.VersionString;
}
}
public static Architecture OSArchitecture
{
get
{
// TODO: very barebones implementation, doesn't respect ARM
return Environment.Is64BitOperatingSystem ? Architecture.X64 : Architecture.X86;
}
}
public static Architecture ProcessArchitecture
{
get
{
// TODO: very barebones implementation, doesn't respect ARM
return Environment.Is64BitProcess ? Architecture.X64 : Architecture.X86;
}
}
}
}

View File

@@ -97,9 +97,39 @@ namespace System.Runtime.Remoting.Messaging {
else
sig_cand = type.GetMethod (methodName, BindingFlags.Public|BindingFlags.NonPublic|BindingFlags.Instance, null, param_types, null);
if (sig_cand != null && generic_arg_names != null && !sig_cand.IsGenericMethodDefinition)
sig_cand = null;
if (sig_cand != null && generic_arg_names != null)
sig_cand = ((MethodInfo)sig_cand).MakeGenericMethod (GetTypes (generic_arg_names));
// We have a generic method with parameters that contain generic arguments
if (sig_cand == null && generic_arg_names != null) {
foreach (var method in type.GetMethods ()) {
if (method.Name != methodName)
continue;
if (!method.IsGenericMethodDefinition || method.GetGenericArguments().Length != generic_arg_names.Length)
continue;
sig_cand = ((MethodInfo)method).MakeGenericMethod (GetTypes (generic_arg_names));
var parameters = sig_cand.GetParameters ();
if (param_names.Length != parameters.Length)
continue;
for (int i=0; i < parameters.Length; i++) {
if (parameters [i].ParameterType.AssemblyQualifiedName != param_names [i]) {
sig_cand = null;
break;
}
}
if (sig_cand != null)
break;
}
}
if (sig_cand == null)
throw new RemotingException ($"Method '{methodName}' not found in type '{typeName}'");
@@ -113,19 +143,17 @@ namespace System.Runtime.Remoting.Messaging {
ctor = method.IsConstructor;
methodName = method.Name;
var param_types = method.GetParameters ();
param_names = new string [param_types.Length];
for (int i = 0; i < param_types.Length; ++i)
param_names [i] = param_types [i].ParameterType.AssemblyQualifiedName;
if (!ctor && method.IsGenericMethod) {
var ga = method.GetGenericArguments ();
generic_arg_names = new string [ga.Length];
for (int i = 0; i < ga.Length; ++i)
generic_arg_names [i] = ga [i].AssemblyQualifiedName;
method = ((MethodInfo)method).GetGenericMethodDefinition ();
}
var param_types = method.GetParameters ();
param_names = new string [param_types.Length];
for (int i = 0; i < param_types.Length; ++i)
param_names [i] = param_types [i].ParameterType.AssemblyQualifiedName;
}
}

View File

@@ -1,353 +0,0 @@
/*
* Latin1Encoding.cs - Implementation of the
* "System.Text.Latin1Encoding" class.
*
* Copyright (c) 2002 Southern Storm Software, Pty Ltd
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
namespace System.Text
{
using System;
[Serializable]
internal class Latin1Encoding : Encoding
{
// until we change the callers:
internal static string _ (string arg) {
return arg;
}
// Magic number used by Windows for the ISO Latin1 code page.
internal const int ISOLATIN_CODE_PAGE = 28591;
// Constructor.
public Latin1Encoding () : base (ISOLATIN_CODE_PAGE)
{
// Nothing to do here.
}
public override bool IsSingleByte {
get { return true; }
}
public override bool IsAlwaysNormalized (NormalizationForm form)
{
return form == NormalizationForm.FormC;
}
// Get the number of bytes needed to encode a character buffer.
public override int GetByteCount (char[] chars, int index, int count)
{
if (chars == null) {
throw new ArgumentNullException ("chars");
}
if (index < 0 || index > chars.Length) {
throw new ArgumentOutOfRangeException ("index", _("ArgRange_Array"));
}
if (count < 0 || count > (chars.Length - index)) {
throw new ArgumentOutOfRangeException ("count", _("ArgRange_Array"));
}
return count;
}
// Convenience wrappers for "GetByteCount".
public override int GetByteCount (String s)
{
if (s == null) {
throw new ArgumentNullException ("s");
}
return s.Length;
}
// Get the bytes that result from encoding a character buffer.
public override int GetBytes (char[] chars, int charIndex, int charCount,
byte[] bytes, int byteIndex)
{
EncoderFallbackBuffer buffer = null;
char [] fallback_chars = null;
return GetBytes (chars, charIndex, charCount, bytes,
byteIndex, ref buffer, ref fallback_chars);
}
int GetBytes (char[] chars, int charIndex, int charCount,
byte[] bytes, int byteIndex,
ref EncoderFallbackBuffer buffer,
ref char [] fallback_chars)
{
if (chars == null)
throw new ArgumentNullException ("chars");
unsafe {
fixed (char *cptr = chars) {
return InternalGetBytes (cptr, chars.Length, charIndex, charCount, bytes, byteIndex, ref buffer, ref fallback_chars);
}
}
}
// Convenience wrappers for "GetBytes".
public override int GetBytes (String s, int charIndex, int charCount,
byte[] bytes, int byteIndex)
{
EncoderFallbackBuffer buffer = null;
char [] fallback_chars = null;
return GetBytes (s, charIndex, charCount, bytes, byteIndex,
ref buffer, ref fallback_chars);
}
int GetBytes (String s, int charIndex, int charCount,
byte[] bytes, int byteIndex,
ref EncoderFallbackBuffer buffer,
ref char [] fallback_chars)
{
if (s == null)
throw new ArgumentNullException ("s");
unsafe {
fixed (char *chars = s) {
return InternalGetBytes (chars, s.Length, charIndex, charCount, bytes, byteIndex, ref buffer, ref fallback_chars);
}
}
}
unsafe int InternalGetBytes (char *chars, int charLength, int charIndex, int charCount,
byte[] bytes, int byteIndex,
ref EncoderFallbackBuffer buffer,
ref char [] fallback_chars)
{
if (bytes == null)
throw new ArgumentNullException ("bytes");
if (charIndex < 0 || charIndex > charLength)
throw new ArgumentOutOfRangeException ("charIndex", _("ArgRange_Array"));
if (charCount < 0 || charCount > (charLength - charIndex))
throw new ArgumentOutOfRangeException ("charCount", _("ArgRange_Array"));
if (byteIndex < 0 || byteIndex > bytes.Length)
throw new ArgumentOutOfRangeException ("byteIndex", _("ArgRange_Array"));
if ((bytes.Length - byteIndex) < charCount)
throw new ArgumentException (_("Arg_InsufficientSpace"));
int count = charCount;
char ch;
while (count-- > 0) {
ch = chars [charIndex++];
if (ch < (char)0x0100) {
bytes [byteIndex++] = (byte)ch;
} else if (ch >= '\uFF01' && ch <= '\uFF5E') {
bytes [byteIndex++] = (byte)(ch - 0xFEE0);
} else {
if (buffer == null)
buffer = EncoderFallback.CreateFallbackBuffer ();
if (Char.IsSurrogate (ch) && count > 1 &&
Char.IsSurrogate (chars [charIndex]))
{
buffer.Fallback (ch, chars [charIndex], charIndex - 1);
charIndex++;
count--;
}
else
buffer.Fallback (ch, charIndex - 1);
if (fallback_chars == null || fallback_chars.Length < buffer.Remaining)
fallback_chars = new char [buffer.Remaining];
for (int i = 0; i < fallback_chars.Length; i++)
fallback_chars [i] = buffer.GetNextChar ();
byteIndex += GetBytes (fallback_chars, 0,
fallback_chars.Length, bytes, byteIndex,
ref buffer, ref fallback_chars);
}
}
return charCount;
}
// Get the number of characters needed to decode a byte buffer.
public override int GetCharCount (byte[] bytes, int index, int count)
{
if (bytes == null) {
throw new ArgumentNullException ("bytes");
}
if (index < 0 || index > bytes.Length) {
throw new ArgumentOutOfRangeException ("index", _("ArgRange_Array"));
}
if (count < 0 || count > (bytes.Length - index)) {
throw new ArgumentOutOfRangeException ("count", _("ArgRange_Array"));
}
return count;
}
// Get the characters that result from decoding a byte buffer.
public override int GetChars (byte[] bytes, int byteIndex, int byteCount,
char[] chars, int charIndex)
{
if (bytes == null) {
throw new ArgumentNullException ("bytes");
}
if (chars == null) {
throw new ArgumentNullException ("chars");
}
if (byteIndex < 0 || byteIndex > bytes.Length) {
throw new ArgumentOutOfRangeException ("byteIndex", _("ArgRange_Array"));
}
if (byteCount < 0 || byteCount > (bytes.Length - byteIndex)) {
throw new ArgumentOutOfRangeException ("byteCount", _("ArgRange_Array"));
}
if (charIndex < 0 || charIndex > chars.Length) {
throw new ArgumentOutOfRangeException ("charIndex", _("ArgRange_Array"));
}
if ((chars.Length - charIndex) < byteCount) {
throw new ArgumentException (_("Arg_InsufficientSpace"));
}
int count = byteCount;
while (count-- > 0) {
chars [charIndex++] = (char)(bytes [byteIndex++]);
}
return byteCount;
}
// Get the maximum number of bytes needed to encode a
// specified number of characters.
public override int GetMaxByteCount (int charCount)
{
if (charCount < 0) {
throw new ArgumentOutOfRangeException ("charCount", _("ArgRange_NonNegative"));
}
return charCount;
}
// Get the maximum number of characters needed to decode a
// specified number of bytes.
public override int GetMaxCharCount (int byteCount)
{
if (byteCount < 0) {
throw new ArgumentOutOfRangeException ("byteCount", _("ArgRange_NonNegative"));
}
return byteCount;
}
// Decode a buffer of bytes into a string.
public override String GetString (byte[] bytes, int index, int count)
{
if (bytes == null) {
throw new ArgumentNullException ("bytes");
}
if (index < 0 || index > bytes.Length) {
throw new ArgumentOutOfRangeException ("index", _("ArgRange_Array"));
}
if (count < 0 || count > (bytes.Length - index)) {
throw new ArgumentOutOfRangeException ("count", _("ArgRange_Array"));
}
if (count == 0)
return String.Empty;
unsafe {
fixed (byte* bytePtr = bytes) {
string s = string.FastAllocateString (count);
fixed (char* charPtr = s) {
byte* currByte = bytePtr + index;
byte* lastByte = currByte + count;
char* currChar = charPtr;
while (currByte < lastByte)
currChar++ [0] = (char) currByte++ [0];
}
return s;
}
}
}
public override String GetString (byte[] bytes)
{
if (bytes == null) {
throw new ArgumentNullException ("bytes");
}
return GetString (bytes, 0, bytes.Length);
}
#if !ECMA_COMPAT
// Get the mail body name for this encoding.
public override String BodyName
{
get {
return "iso-8859-1";
}
}
// Get the human-readable name for this encoding.
public override String EncodingName
{
get {
return "Western European (ISO)";
}
}
// Get the mail agent header name for this encoding.
public override String HeaderName
{
get {
return "iso-8859-1";
}
}
// Determine if this encoding can be displayed in a Web browser.
public override bool IsBrowserDisplay
{
get {
return true;
}
}
// Determine if this encoding can be saved from a Web browser.
public override bool IsBrowserSave
{
get {
return true;
}
}
// Determine if this encoding can be displayed in a mail/news agent.
public override bool IsMailNewsDisplay
{
get {
return true;
}
}
// Determine if this encoding can be saved from a mail/news agent.
public override bool IsMailNewsSave
{
get {
return true;
}
}
// Get the IANA-preferred Web name for this encoding.
public override String WebName
{
get {
return "iso-8859-1";
}
}
#endif // !ECMA_COMPAT
}; // class Latin1Encoding
}; // namespace System.Text

View File

@@ -326,13 +326,12 @@ namespace System.Threading {
[Obsolete ("Deprecated in favor of GetApartmentState, SetApartmentState and TrySetApartmentState.")]
public ApartmentState ApartmentState {
get {
if ((ThreadState & ThreadState.Stopped) != 0)
throw new ThreadStateException ("Thread is dead; state can not be accessed.");
ValidateThreadState ();
return (ApartmentState)Internal.apartment_state;
}
set {
ValidateThreadState ();
TrySetApartmentState (value);
}
}
@@ -368,14 +367,12 @@ namespace System.Threading {
public bool IsBackground {
get {
ThreadState thread_state = GetState (Internal);
if ((thread_state & ThreadState.Stopped) != 0)
throw new ThreadStateException ("Thread is dead; state can not be accessed.");
return (thread_state & ThreadState.Background) != 0;
var state = ValidateThreadState ();
return (state & ThreadState.Background) != 0;
}
set {
ValidateThreadState ();
if (value) {
SetState (Internal, ThreadState.Background);
} else {
@@ -649,6 +646,7 @@ namespace System.Threading {
public ApartmentState GetApartmentState ()
{
ValidateThreadState ();
return (ApartmentState)Internal.apartment_state;
}
@@ -712,5 +710,13 @@ namespace System.Threading {
{
throw new PlatformNotSupportedException ();
}
ThreadState ValidateThreadState ()
{
var state = GetState (Internal);
if ((state & ThreadState.Stopped) != 0)
throw new ThreadStateException ("Thread is dead; state can not be accessed.");
return state;
}
}
}

View File

@@ -139,7 +139,7 @@ namespace System.Threading
throw new ArgumentOutOfRangeException ("period");
if (disposed)
return false;
throw new ObjectDisposedException (null, Environment.GetResourceString ("ObjectDisposed_Generic"));
due_time_ms = dueTime;
period_ms = period;

View File

@@ -68,7 +68,10 @@ namespace System
internal IEnumerator<T> InternalArray__IEnumerable_GetEnumerator<T> ()
{
return new InternalEnumerator<T> (this);
if (Length == 0)
return EmptyInternalEnumerator<T>.Value;
else
return new InternalEnumerator<T> (this);
}
internal void InternalArray__ICollection_Clear ()
@@ -207,7 +210,7 @@ namespace System
// we just decr the size, so, 0 - 1 == FINISHED
const int FINISHED = -1;
Array array;
readonly Array array;
int idx;
internal InternalEnumerator (Array array)
@@ -218,7 +221,6 @@ namespace System
public void Dispose ()
{
idx = NOT_STARTED;
}
public bool MoveNext ()
@@ -272,6 +274,38 @@ namespace System
}
}
internal class EmptyInternalEnumerator<T> : IEnumerator<T>
{
public static readonly EmptyInternalEnumerator<T> Value = new EmptyInternalEnumerator<T> ();
public void Dispose ()
{
return;
}
public bool MoveNext ()
{
return false;
}
public T Current {
get {
throw new InvalidOperationException ("Enumeration has not started. Call MoveNext");
}
}
object IEnumerator.Current {
get {
return Current;
}
}
void IEnumerator.Reset ()
{
return;
}
}
// InternalCall Methods
[MethodImplAttribute (MethodImplOptions.InternalCall)]
extern int GetRank ();
@@ -320,7 +354,7 @@ namespace System
"Index has to be between upper and lower bound of the array."));
if (GetType ().GetElementType ().IsPointer)
throw new NotSupportedException ("Type is not supported");
throw new NotSupportedException ("Type is not supported.");
return GetValueImpl (index - lb);
}
@@ -348,7 +382,7 @@ namespace System
"Index has to be >= lower bound and <= upper bound of the array."));
if (GetType ().GetElementType ().IsPointer)
throw new NotSupportedException ("Type is not supported");
throw new NotSupportedException ("Type is not supported.");
SetValueImpl (value, index - lb);
}
@@ -701,7 +735,7 @@ namespace System
get {
if (_index < 0) throw new InvalidOperationException (SR.InvalidOperation_EnumNotStarted);
if (_index >= _endIndex) throw new InvalidOperationException (SR.InvalidOperation_EnumEnded);
if (_index == 0 && _array.GetType ().GetElementType ().IsPointer) throw new NotSupportedException ("Type is not supported");
if (_index == 0 && _array.GetType ().GetElementType ().IsPointer) throw new NotSupportedException ("Type is not supported.");
return _array.GetValueImpl(_index);
}
}

View File

@@ -97,7 +97,7 @@ namespace System.IO {
public override string ReadToEnd ()
{
try {
return (base.ReadToEnd ());
return driver.ReadToEnd ();
} catch (IOException) {
}

View File

@@ -214,7 +214,7 @@ namespace System {
//
static OperatingSystem os;
static extern PlatformID Platform {
static internal PlatformID Platform {
[MethodImplAttribute (MethodImplOptions.InternalCall)]
get;
}

View File

@@ -1102,6 +1102,16 @@ namespace System {
}
public string ReadLine ()
{
return ReadUntilConditionInternal (true);
}
public string ReadToEnd ()
{
return ReadUntilConditionInternal (false);
}
private string ReadUntilConditionInternal (bool haltOnNewLine)
{
if (!inited)
Init ();
@@ -1120,6 +1130,8 @@ namespace System {
rl_starty = cursorTop;
char eof = (char) control_characters [ControlCharacters.EOF];
bool treatAsEnterKey;
do {
key = ReadKeyInternal (out fresh);
echo = echo || fresh;
@@ -1128,7 +1140,9 @@ namespace System {
if (c == eof && c != 0 && builder.Length == 0)
return null;
if (key.Key != ConsoleKey.Enter) {
treatAsEnterKey = haltOnNewLine && (key.Key == ConsoleKey.Enter);
if (!treatAsEnterKey) {
if (key.Key != ConsoleKey.Backspace) {
builder.Append (c);
} else if (builder.Length > 0) {
@@ -1142,7 +1156,7 @@ namespace System {
// echo fresh keys back to the console
if (echo)
Echo (key);
} while (key.Key != ConsoleKey.Enter);
} while (!treatAsEnterKey);
EchoFlush ();

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