Imported Upstream version 4.2.0.179

Former-commit-id: 0a113cb3a6feb7873f632839b1307cc6033cd595
This commit is contained in:
Xamarin Public Jenkins
2015-08-26 07:17:56 -04:00
committed by Jo Shields
parent 183bba2c9a
commit 6992685b86
7507 changed files with 90259 additions and 657307 deletions

View File

@@ -70,7 +70,6 @@ using System.Runtime.InteropServices;
[assembly: AssemblyFileVersion (Consts.FxFileVersion)]
[assembly: ComVisible (false)]
[assembly: CompilationRelaxations (CompilationRelaxations.NoStringInterning)]
[assembly: TypeLibVersion (2, 4)]
[assembly: DefaultDependency (LoadHint.Always)]
[assembly: StringFreezing]

View File

@@ -6,13 +6,12 @@ export __SECURITY_BOOTSTRAP_DB=$(topdir)/class/corlib
LIBRARY = corlib.dll
LIBRARY_NAME = mscorlib.dll
REFERENCE_SOURCES_FLAGS = -d:FEATURE_PAL,PFX_LEGACY_3_5 -d:MONO -d:MONO_HYBRID_ENCODING_SUPPORT,PLATFORM_UNIX
LIB_MCS_FLAGS = $(REFERENCE_SOURCES_FLAGS) $(RESOURCE_FILES:%=-resource:%)
#LIBRARY_USE_INTERMEDIATE_FILE = yes
ifeq (2, $(FRAMEWORK_VERSION_MAJOR))
LIB_MCS_FLAGS += --runtime:v2
LIB_MCS_FLAGS += --runtime:v4
else
ifeq (4, $(FRAMEWORK_VERSION_MAJOR))
LIB_MCS_FLAGS += --runtime:v4
@@ -36,12 +35,12 @@ RESOURCE_FILES = \
resources/collation.cjkKO.bin \
resources/collation.cjkKOlv2.bin
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
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
MOBILE_STATIC := $(filter mobile_static monotouch monotouch_runtime, $(PROFILE))
MOBILE_STATIC := $(filter mobile_static monotouch monotouch_runtime monotouch_watch, $(PROFILE))
ifndef MOBILE_STATIC
REFERENCE_SOURCES_FLAGS += -d:FEATURE_REMOTING
REFERENCE_SOURCES_FLAGS += -d:FEATURE_REMOTING,MONO_COM,FEATURE_COMINTEROP,FEATURE_ROLE_BASED_SECURITY
endif
LOCAL_MCS_FLAGS = -unsafe -nostdlib -nowarn:612,618 -d:INSIDE_CORLIB,MONO_CULTURE_DATA -d:LIBC $(REFERENCE_SOURCES_FLAGS)
@@ -173,16 +172,24 @@ EXTRA_DISTFILES += \
# Android TimeZoneInfo testing....
#
tzi.exe: System/AndroidPlatform.cs $(wildcard System/TimeZone*.cs) ../../build/common/Consts.cs ../../build/common/Locale.cs ../Mono.Options/Mono.Options/Options.cs ReferenceSources/TimeZoneInfoOptions.cs
mcs /debug+ /out:$@ /unsafe "/d:INSIDE_CORLIB;MONODROID;MOBILE;NET_4_5;NET_4_0;LIBC;SELF_TEST" $^
TMP_FILE1=tzi1.tmp
TMP_FILE2=tzi2.tmp
# Remove some code that is protected so we don't have to include all the corlib files.
tzi.exe:System/AndroidPlatform.cs $(wildcard System/TimeZone*.cs) ../../build/common/Consts.cs ../../build/common/Locale.cs ../Mono.Options/Mono.Options/Options.cs
trap "rm -f $(TMP_FILE1) $(TMP_FILE2)" EXIT INT QUIT TERM && \
sed 's/Environment\.GetResourceString/string.Format/g' ../../../external/referencesource/mscorlib/system/timezoneinfo.cs > $(TMP_FILE1) && \
sed 's/StringBuilder\.DefaultCapacity/100/g' ../../../external/referencesource/mscorlib/system/text/stringbuildercache.cs > $(TMP_FILE2) && \
$(MCS) /debug+ /out:$@ -unsafe -nowarn:612,618 -d:INSIDE_CORLIB,MONO_CULTURE_DATA -d:LIBC $(REFERENCE_SOURCES_FLAGS) "/d:SELF_TEST;NET_1_1;NET_2_0;NET_2_1;NET_3_5;NET_4_0;NET_4_5;MONO;DISABLE_CAS_USE;MOBILE;MOBILE_DYNAMIC;MONODROID;ANDROID" $^ $(TMP_FILE1) $(TMP_FILE2)
android-pull-tzdb:
mkdir -p android/tzdb/usr/share/zoneinfo
mkdir -p android/tzdb/misc/zoneinfo/zoneinfo
android_root=`adb shell echo '$$ANDROID_ROOT' | tr -d "\r"` ; \
android_data=`adb shell echo '$$ANDROID_DATA' | tr -d "\r"` ; \
adb $(ADB_TARGET) pull $$android_root/usr/share/zoneinfo android/tzdb/usr/share/zoneinfo ; \
adb $(ADB_TARGET) pull $$android_data/misc/zoneinfo/tzdata android/tzdb/misc/zoneinfo
adb $(ADB_TARGET) pull $$android_root/usr/share/zoneinfo android/tzdb/usr/share/zoneinfo || true ; \
adb $(ADB_TARGET) pull $$android_data/misc/zoneinfo/tzdata android/tzdb/misc/zoneinfo || true
android-dump-tzdata: tzi.exe android-pull-tzdb
__XA_OVERRIDE_TIMEZONE_ID__=America/New_York ANDROID_ROOT="`pwd`/android/tzdb" ANDROID_DATA="`pwd`/android/tzdb" mono --debug tzi.exe -o android/tzdata
export
__XA_OVERRIDE_TIMEZONE_ID__=America/New_York ANDROID_ROOT="`pwd`/android/tzdb" ANDROID_DATA="`pwd`/android/tzdb" $(TEST_RUNTIME) tzi.exe -o android/tzdata

View File

@@ -1,58 +0,0 @@
2008-01-15 Zoltan Varga <vargaz@gmail.com>
* SafeWaitHandle.cs: Fix some argument names to be consistent with MS.
2007-07-18 Miguel de Icaza <miguel@novell.com>
* SafeWaitHandle.cs: Do not call DangerousGetHandle here as it
throws ObjectDisposedException when the refcount reaches zero.
* SafeFileHandle.cs: Same.
2007-05-12 Jonathan Chambers <joncham@gmail.com>
* SafeWaitHandle.cs: Add internal empty
constructor for pinvoke marshalling.
2007-04-30 Dick Porter <dick@ximian.com>
* CriticalHandleZeroOrMinusOneIsInvalid.cs:
* CriticalHandleMinusOneIsInvalid.cs:
* SafeWaitHandle.cs:
* SafeHandleZeroOrMinusOneIsInvalid.cs:
* SafeHandleMinusOneIsInvalid.cs: Added ReliabilityContract
attributes to complete 2.0 profile
2007-01-13 Miguel de Icaza <miguel@novell.com>
* Add a few more missing helper classes.
2006-12-11 Miguel de Icaza <miguel@novell.com>
* SafeWaitHandle.cs: Add new.
2006-12-10 Miguel de Icaza <miguel@novell.com>
* SafeFileHandle.cs: Implement this one.
2006-12-02 Miguel de Icaza <miguel@novell.com>
* SafeFileHandle.cs: Remove the IsInvalid method, as that is
present in the base class.
2006-01-12 Ben Maurer <bmaurer@andrew.cmu.edu>
* SafeHandleZeroOrMinusOneIsInvalid.cs: Update to RTM api
* SafeFileHandle.cs: Update to RTM api
2005-08-10 Zoltan Varga <vargaz@freemail.hu>
* SafeFileHandle.cs: Make this inherit from SafeHandleZeroOrMinusOneIsInvalid.
* SafeHandleZeroOrMinusOneIsInvalid.cs: New file.
2005-01-31 Sebastien Pouliot <sebastien@ximian.com>
* SafeFileHandle.cs: Class declaration to allow compiling System.IO
and System.IO.IsolatedStorage for the NET_2_0 profile.

View File

@@ -1,48 +0,0 @@
//
// Microsoft.Win32.SafeHandles.CriticalHandleMinusOneIsInvalid
//
// Author
// Zoltan Varga (vargaz@gmail.com)
// Miguel de Icaza (miguel@novell.com)
//
// Copyright (C) 2005, 2006 Novell, Inc (http://www.novell.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.
//
using System;
using System.Runtime.InteropServices;
using System.Runtime.ConstrainedExecution;
namespace Microsoft.Win32.SafeHandles {
public abstract class CriticalHandleMinusOneIsInvalid : CriticalHandle, IDisposable {
[ReliabilityContract (Consistency.WillNotCorruptState, Cer.MayFail)]
protected CriticalHandleMinusOneIsInvalid () : base ((IntPtr) (-1)) {
}
public override bool IsInvalid {
get {
return handle == (IntPtr)(-1);
}
}
}
}

View File

@@ -1,47 +0,0 @@
//
// Microsoft.Win32.SafeHandles.CriticalHandleZeroOrMinusOneIsInvalid
//
// Author
// Zoltan Varga (vargaz@gmail.com)
// Miguel de Icaza (miguel@novell.com)
//
// Copyright (C) 2005, 2006 Novell, Inc (http://www.novell.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.
//
using System;
using System.Runtime.InteropServices;
using System.Runtime.ConstrainedExecution;
namespace Microsoft.Win32.SafeHandles {
public abstract class CriticalHandleZeroOrMinusOneIsInvalid : CriticalHandle, IDisposable {
[ReliabilityContract (Consistency.WillNotCorruptState, Cer.MayFail)]
protected CriticalHandleZeroOrMinusOneIsInvalid () : base ((IntPtr) (-1)) {
}
public override bool IsInvalid {
get {
return handle == (IntPtr)(-1) || handle == IntPtr.Zero;
}
}
}
}

View File

@@ -1,57 +0,0 @@
//
// Microsoft.Win32.SafeHandles.SafeFileHandle
//
// Authors:
// Sebastien Pouliot <sebastien@ximian.com>
// Miguel de Icaza <miguel@novell.com>
//
// Copyright (C) 2005, 2006 Novell, Inc (http://www.novell.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.
//
using System;
using System.IO;
namespace Microsoft.Win32.SafeHandles {
public sealed class SafeFileHandle : SafeHandleZeroOrMinusOneIsInvalid {
public SafeFileHandle (IntPtr preexistingHandle, bool ownsHandle) : base (ownsHandle)
{
SetHandle (preexistingHandle);
}
// This is just for marshalling
internal SafeFileHandle () : base (true)
{
}
protected override bool ReleaseHandle ()
{
MonoIOError error;
MonoIO.Close (handle, out error);
return error == MonoIOError.ERROR_SUCCESS;
}
}
}

View File

@@ -1,47 +0,0 @@
//
// Microsoft.Win32.SafeHandles.SafeHandleMinusOneIsInvalid
//
// Author
// Zoltan Varga (vargaz@gmail.com)
// Miguel de Icaza (miguel@novell.com)
//
// Copyright (C) 2005, 2006 Novell, Inc (http://www.novell.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.
//
using System;
using System.Runtime.InteropServices;
using System.Runtime.ConstrainedExecution;
namespace Microsoft.Win32.SafeHandles {
public abstract class SafeHandleMinusOneIsInvalid : SafeHandle, IDisposable {
[ReliabilityContract (Consistency.WillNotCorruptState, Cer.MayFail)]
protected SafeHandleMinusOneIsInvalid (bool ownsHandle) : base ((IntPtr) 0, ownsHandle) {
}
public override bool IsInvalid {
get {
return handle == (IntPtr)(-1);
}
}
}
}

View File

@@ -1,46 +0,0 @@
//
// Microsoft.Win32.SafeHandles.SafeHandleZeroOrMinusOneIsInvalid
//
// Author
// Zoltan Varga (vargaz@gmail.com)
//
// Copyright (C) 2005 Novell, Inc (http://www.novell.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.
//
using System;
using System.Runtime.InteropServices;
using System.Runtime.ConstrainedExecution;
namespace Microsoft.Win32.SafeHandles {
public abstract class SafeHandleZeroOrMinusOneIsInvalid : SafeHandle, IDisposable {
[ReliabilityContract (Consistency.WillNotCorruptState, Cer.MayFail)]
protected SafeHandleZeroOrMinusOneIsInvalid (bool ownsHandle) : base ((IntPtr) 0, ownsHandle) {
}
public override bool IsInvalid {
get {
return handle == (IntPtr)(-1) || handle == (IntPtr) 0;
}
}
}
}

View File

@@ -1,55 +0,0 @@
//
// Microsoft.Win32.SafeHandles.SafeRegistryHandle
//
// Author
// Gonzalo Paniagua Javier (gonzalo@novell.com)
//
// Copyright (C) 2010 Novell, Inc (http://www.novell.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.
//
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.ConstrainedExecution;
namespace Microsoft.Win32.SafeHandles {
public sealed class SafeRegistryHandle : SafeHandleZeroOrMinusOneIsInvalid, IDisposable {
public SafeRegistryHandle (IntPtr preexistingHandle, bool ownsHandle) : base (ownsHandle)
{
handle = preexistingHandle;
}
protected override bool ReleaseHandle ()
{
// Need to release an unmanaged pointer *only* in Windows.
if (Path.DirectorySeparatorChar == '\\')
return RegCloseKey (handle) == 0;
return true;
}
[DllImport ("advapi32.dll", CharSet = CharSet.Unicode, EntryPoint="RegCloseKey")]
static extern int RegCloseKey (IntPtr keyHandle);
}
}

View File

@@ -1,51 +0,0 @@
//
// Microsoft.Win32.SafeHandles.SafeWaitHandle
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
// Miguel de Icaza <miguel@novell.com>
//
// Copyright (C) 2005, 2006 Novell, Inc (http://www.novell.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.
//
using System;
using System.IO;
using System.Threading;
using System.Runtime.ConstrainedExecution;
namespace Microsoft.Win32.SafeHandles {
public sealed class SafeWaitHandle : SafeHandleZeroOrMinusOneIsInvalid {
[ReliabilityContract (Consistency.WillNotCorruptState, Cer.MayFail)]
public SafeWaitHandle (IntPtr existingHandle, bool ownsHandle) : base (ownsHandle)
{
SetHandle (existingHandle);
}
protected override bool ReleaseHandle ()
{
NativeEventCalls.CloseEvent_internal (handle);
return true;
}
}
}

View File

@@ -102,6 +102,11 @@ namespace Microsoft.Win32
isWritable = writable;
}
static internal bool IsEquals (RegistryKey a, RegistryKey b)
{
return a.hive == b.hive && a.handle == b.handle && a.qname == b.qname && a.isRemoteRoot == b.isRemoteRoot && a.isWritable == b.isWritable;
}
#region PublicAPI
/// <summary>
@@ -114,17 +119,6 @@ namespace Microsoft.Win32
Close ();
}
/// <summary>
/// Final cleanup of registry key object. Close the
/// key if it's still open.
/// </summary>
~RegistryKey ()
{
Close ();
}
/// <summary>
/// Get the fully qualified registry key name.
/// </summary>

View File

@@ -93,9 +93,25 @@ namespace Microsoft.Win32 {
}
}
class RegistryKeyComparer : IEqualityComparer {
public new bool Equals(object x, object y)
{
return RegistryKey.IsEquals ((RegistryKey) x, (RegistryKey) y);
}
public int GetHashCode(object obj)
{
var n = ((RegistryKey) obj).Name;
if (n == null)
return 0;
return n.GetHashCode ();
}
}
class KeyHandler
{
static Hashtable key_to_handler = new Hashtable ();
static Hashtable key_to_handler = new Hashtable (new RegistryKeyComparer ());
static Hashtable dir_to_handler = new Hashtable (
new CaseInsensitiveHashCodeProvider (), new CaseInsensitiveComparer ());
const string VolatileDirectoryName = "volatile-keys";
@@ -487,7 +503,11 @@ namespace Microsoft.Win32 {
{
if (name == null)
return RegistryValueKind.Unknown;
object value = values [name];
object value;
lock (values)
value = values [name];
if (value == null)
return RegistryValueKind.Unknown;
@@ -513,7 +533,9 @@ namespace Microsoft.Win32 {
if (name == null)
name = string.Empty;
object value = values [name];
object value;
lock (values)
value = values [name];
ExpandString exp = value as ExpandString;
if (exp == null)
return value;
@@ -530,12 +552,14 @@ namespace Microsoft.Win32 {
if (name == null)
name = string.Empty;
// immediately convert non-native registry values to string to avoid
// returning it unmodified in calls to UnixRegistryApi.GetValue
if (value is int || value is string || value is byte[] || value is string[])
values[name] = value;
else
values[name] = value.ToString ();
lock (values){
// immediately convert non-native registry values to string to avoid
// returning it unmodified in calls to UnixRegistryApi.GetValue
if (value is int || value is string || value is byte[] || value is string[])
values[name] = value;
else
values[name] = value.ToString ();
}
SetDirty ();
}
@@ -543,11 +567,13 @@ namespace Microsoft.Win32 {
{
AssertNotMarkedForDeletion ();
ICollection keys = values.Keys;
string [] vals = new string [keys.Count];
keys.CopyTo (vals, 0);
return vals;
lock (values){
ICollection keys = values.Keys;
string [] vals = new string [keys.Count];
keys.CopyTo (vals, 0);
return vals;
}
}
public int GetSubKeyCount ()
@@ -600,52 +626,54 @@ namespace Microsoft.Win32 {
if (name == null)
name = string.Empty;
switch (valueKind){
case RegistryValueKind.String:
if (value is string){
values [name] = value;
return;
}
break;
case RegistryValueKind.ExpandString:
if (value is string){
values [name] = new ExpandString ((string)value);
return;
}
break;
case RegistryValueKind.Binary:
if (value is byte []){
values [name] = value;
return;
}
break;
case RegistryValueKind.DWord:
try {
values [name] = Convert.ToInt32 (value);
return;
} catch (OverflowException) {
lock (values){
switch (valueKind){
case RegistryValueKind.String:
if (value is string){
values [name] = value;
return;
}
break;
}
case RegistryValueKind.MultiString:
if (value is string []){
values [name] = value;
return;
}
break;
case RegistryValueKind.QWord:
try {
values [name] = Convert.ToInt64 (value);
return;
} catch (OverflowException) {
case RegistryValueKind.ExpandString:
if (value is string){
values [name] = new ExpandString ((string)value);
return;
}
break;
case RegistryValueKind.Binary:
if (value is byte []){
values [name] = value;
return;
}
break;
case RegistryValueKind.DWord:
try {
values [name] = Convert.ToInt32 (value);
return;
} catch (OverflowException) {
break;
}
case RegistryValueKind.MultiString:
if (value is string []){
values [name] = value;
return;
}
break;
case RegistryValueKind.QWord:
try {
values [name] = Convert.ToInt64 (value);
return;
} catch (OverflowException) {
break;
}
default:
throw new ArgumentException ("unknown value", "valueKind");
}
default:
throw new ArgumentException ("unknown value", "valueKind");
}
throw new ArgumentException ("Value could not be converted to specified type", "valueKind");
}
@@ -680,12 +708,14 @@ namespace Microsoft.Win32 {
if (name == null)
name = string.Empty;
return values.Contains (name);
lock (values)
return values.Contains (name);
}
public int ValueCount {
get {
return values.Keys.Count;
lock (values)
return values.Keys.Count;
}
}
@@ -699,7 +729,8 @@ namespace Microsoft.Win32 {
{
AssertNotMarkedForDeletion ();
values.Remove (name);
lock (values)
values.Remove (name);
SetDirty ();
}
@@ -713,45 +744,47 @@ namespace Microsoft.Win32 {
if (IsMarkedForDeletion)
return;
if (!File.Exists (file) && values.Count == 0)
return;
SecurityElement se = new SecurityElement ("values");
// With SecurityElement.Text = value, and SecurityElement.AddAttribute(key, value)
// the values must be escaped prior to being assigned.
foreach (DictionaryEntry de in values){
object val = de.Value;
SecurityElement value = new SecurityElement ("value");
value.AddAttribute ("name", SecurityElement.Escape ((string) de.Key));
if (val is string){
value.AddAttribute ("type", "string");
value.Text = SecurityElement.Escape ((string) val);
} else if (val is int){
value.AddAttribute ("type", "int");
value.Text = val.ToString ();
} else if (val is long) {
value.AddAttribute ("type", "qword");
value.Text = val.ToString ();
} else if (val is byte []){
value.AddAttribute ("type", "bytearray");
value.Text = Convert.ToBase64String ((byte[]) val);
} else if (val is ExpandString){
value.AddAttribute ("type", "expand");
value.Text = SecurityElement.Escape (val.ToString ());
} else if (val is string []){
value.AddAttribute ("type", "string-array");
foreach (string ss in (string[]) val){
SecurityElement str = new SecurityElement ("string");
str.Text = SecurityElement.Escape (ss);
value.AddChild (str);
lock (values){
if (!File.Exists (file) && values.Count == 0)
return;
// With SecurityElement.Text = value, and SecurityElement.AddAttribute(key, value)
// the values must be escaped prior to being assigned.
foreach (DictionaryEntry de in values){
object val = de.Value;
SecurityElement value = new SecurityElement ("value");
value.AddAttribute ("name", SecurityElement.Escape ((string) de.Key));
if (val is string){
value.AddAttribute ("type", "string");
value.Text = SecurityElement.Escape ((string) val);
} else if (val is int){
value.AddAttribute ("type", "int");
value.Text = val.ToString ();
} else if (val is long) {
value.AddAttribute ("type", "qword");
value.Text = val.ToString ();
} else if (val is byte []){
value.AddAttribute ("type", "bytearray");
value.Text = Convert.ToBase64String ((byte[]) val);
} else if (val is ExpandString){
value.AddAttribute ("type", "expand");
value.Text = SecurityElement.Escape (val.ToString ());
} else if (val is string []){
value.AddAttribute ("type", "string-array");
foreach (string ss in (string[]) val){
SecurityElement str = new SecurityElement ("string");
str.Text = SecurityElement.Escape (ss);
value.AddChild (str);
}
}
se.AddChild (value);
}
se.AddChild (value);
}
using (FileStream fs = File.Create (file)){
StreamWriter sw = new StreamWriter (fs);
@@ -969,8 +1002,9 @@ namespace Microsoft.Win32 {
private RegistryKey CreateSubKey (RegistryKey rkey, string keyname, bool writable, bool is_volatile)
{
KeyHandler self = KeyHandler.Lookup (rkey, true);
if (self == null)
if (self == null){
throw RegistryKey.CreateMarkedForDeletionException ();
}
if (KeyHandler.VolatileKeyExists (self.Dir) && !is_volatile)
throw new IOException ("Cannot create a non volatile subkey under a volatile key.");

View File

@@ -5,7 +5,7 @@ using System.Runtime.CompilerServices;
using NUtil = Mono.Globalization.Unicode.NormalizationTableUtil;
namespace Mono.Globalization.Unicode
namespace System.Text
{
internal enum NormalizationCheck {
Yes,
@@ -425,6 +425,20 @@ namespace Mono.Globalization.Unicode
return bufIdx;
}
public static bool IsNormalized (string source, NormalizationForm normalizationForm)
{
switch (normalizationForm) {
default:
return IsNormalized (source, 0);
case NormalizationForm.FormD:
return IsNormalized (source, 1);
case NormalizationForm.FormKC:
return IsNormalized (source, 2);
case NormalizationForm.FormKD:
return IsNormalized (source, 3);
}
}
public static bool IsNormalized (string source, int type)
{
int prevCC = -1;
@@ -462,6 +476,20 @@ namespace Mono.Globalization.Unicode
return true;
}
public static string Normalize (string source, NormalizationForm normalizationForm)
{
switch (normalizationForm) {
default:
return Normalization.Normalize (source, 0);
case NormalizationForm.FormD:
return Normalization.Normalize (source, 1);
case NormalizationForm.FormKC:
return Normalization.Normalize (source, 2);
case NormalizationForm.FormKD:
return Normalization.Normalize (source, 3);
}
}
public static string Normalize (string source, int type)
{
switch (type) {

View File

@@ -1452,9 +1452,9 @@ Console.WriteLine ("==== {0} {1} {2} {3} {4} {5} {6} {7} {8}", s, si, send, leng
public unsafe int IndexOf (string s, string target, int start, int length, CompareOptions opt)
{
if (opt == CompareOptions.Ordinal)
return IndexOfOrdinal (s, target, start, length);
throw new NotSupportedException ("Should not be reached");
if (opt == CompareOptions.OrdinalIgnoreCase)
return IndexOfOrdinalIgnoreCase (s, target, start, length);
throw new NotSupportedException ("Should not be reached");
if (opt == CompareOptions.None) {
bool testWasUnable;
int ret = QuickIndexOf (s, target, start, length, out testWasUnable);
@@ -1503,30 +1503,6 @@ Console.WriteLine ("==== {0} {1} {2} {3} {4} {5} {6} {7} {8}", s, si, send, leng
return -1;
}
int IndexOfOrdinalIgnoreCase (string s, string target, int start, int length)
{
if (target.Length == 0)
return 0;
else if (target.Length > length)
return -1;
int end = start + length - target.Length + 1;
for (int i = start; i < end; i++) {
bool no = false;
for (int j = 0; j < target.Length; j++) {
// I think almost all text has more lower letters than upper ones. Thus with this invariant comparison ToLower() should be faster since it costs less operations.
if (textInfo.ToLower (s [i + j]) != textInfo.ToLower (target [j])) {
no = true;
break;
}
}
if (no)
continue;
return i;
}
return -1;
}
// char
public int IndexOf (string s, char target, CompareOptions opt)
@@ -1537,9 +1513,9 @@ Console.WriteLine ("==== {0} {1} {2} {3} {4} {5} {6} {7} {8}", s, si, send, leng
public unsafe int IndexOf (string s, char target, int start, int length, CompareOptions opt)
{
if (opt == CompareOptions.Ordinal)
return IndexOfOrdinal (s, target, start, length);
throw new NotSupportedException ("Should not be reached");
if (opt == CompareOptions.OrdinalIgnoreCase)
return IndexOfOrdinalIgnoreCase (s, target, start, length);
throw new NotSupportedException ("Should not be reached");
byte* alwaysMatchFlags = stackalloc byte [16];
byte* neverMatchFlags = stackalloc byte [16];
byte* targetSortKey = stackalloc byte [4];
@@ -1588,16 +1564,6 @@ Console.WriteLine ("==== {0} {1} {2} {3} {4} {5} {6} {7} {8}", s, si, send, leng
return -1;
}
int IndexOfOrdinalIgnoreCase (string s, char target, int start, int length)
{
int end = start + length;
target = textInfo.ToLower (target);
for (int i = start; i < end; i++)
if (textInfo.ToLower (s [i]) == target)
return i;
return -1;
}
// Searches target byte[] keydata
unsafe int IndexOfSortKey (string s, int start, int length, byte* sortkey, char target, int ti, bool noLv4, ref Context ctx)
{
@@ -1695,7 +1661,7 @@ Console.WriteLine ("==== {0} {1} {2} {3} {4} {5} {6} {7} {8}", s, si, send, leng
if (opt == CompareOptions.Ordinal)
return LastIndexOfOrdinal (s, target, start, length);
if (opt == CompareOptions.OrdinalIgnoreCase)
return LastIndexOfOrdinalIgnoreCase (s, target, start, length);
throw new NotSupportedException ("Should not be reached");
byte* alwaysMatchFlags = stackalloc byte [16];
byte* neverMatchFlags = stackalloc byte [16];
byte* targetSortKey = stackalloc byte [4];
@@ -1740,34 +1706,6 @@ Console.WriteLine ("==== {0} {1} {2} {3} {4} {5} {6} {7} {8}", s, si, send, leng
return -1;
}
int LastIndexOfOrdinalIgnoreCase (string s, string target, int start, int length)
{
if (target.Length == 0)
return start;
if (s.Length < length || target.Length > length)
return -1;
int end = start - length + target.Length - 1;
char tail = textInfo.ToLower (target [target.Length - 1]);
for (int i = start; i > end;) {
if (textInfo.ToLower (s [i]) != tail) {
i--;
continue;
}
int x = i - target.Length + 1;
i--;
bool mismatch = false;
for (int j = target.Length - 2; j >= 0; j--)
if (textInfo.ToLower (s [x + j]) != textInfo.ToLower (target [j])) {
mismatch = true;
break;
}
if (mismatch)
continue;
return x;
}
return -1;
}
// char
public int LastIndexOf (string s, char target, CompareOptions opt)
@@ -1778,9 +1716,9 @@ Console.WriteLine ("==== {0} {1} {2} {3} {4} {5} {6} {7} {8}", s, si, send, leng
public unsafe int LastIndexOf (string s, char target, int start, int length, CompareOptions opt)
{
if (opt == CompareOptions.Ordinal)
return LastIndexOfOrdinal (s, target, start, length);
throw new NotSupportedException ();
if (opt == CompareOptions.OrdinalIgnoreCase)
return LastIndexOfOrdinalIgnoreCase (s, target, start, length);
throw new NotSupportedException ();
byte* alwaysMatchFlags = stackalloc byte [16];
byte* neverMatchFlags = stackalloc byte [16];
byte* targetSortKey = stackalloc byte [4];
@@ -1823,29 +1761,6 @@ Console.WriteLine ("==== {0} {1} {2} {3} {4} {5} {6} {7} {8}", s, si, send, leng
}
}
int LastIndexOfOrdinal (string s, char target, int start, int length)
{
if (s.Length == 0)
return -1;
int end = start - length;
for (int i = start; i > end; i--)
if (s [i] == target)
return i;
return -1;
}
int LastIndexOfOrdinalIgnoreCase (string s, char target, int start, int length)
{
if (s.Length == 0)
return -1;
int end = start - length;
char c = textInfo.ToUpper (target);
for (int i = start; i > end; i--)
if (textInfo.ToUpper (s [i]) == c)
return i;
return -1;
}
// Searches target byte[] keydata
unsafe int LastIndexOfSortKey (string s, int start, int orgStart, int length, byte* sortkey, int ti, bool noLv4, ref Context ctx)
{

View File

@@ -1030,6 +1030,8 @@ namespace Mono.Security {
// 4.a user info
pos = uriString.IndexOf ("@");
if (unixAbsPath)
pos = -1;
if (pos != -1) {
userinfo = uriString.Substring (0, pos);
uriString = uriString.Remove (0, pos + 1);

View File

@@ -20,5 +20,13 @@ namespace System {
{
return false;
}
internal static void CheckReflectionOnlyLoadSupported()
{
}
internal static void CheckLoadFromSupported()
{
}
}
}

View File

@@ -41,5 +41,15 @@ namespace System
internal static void Perf (bool expr, string msg)
{
}
[Conditional("_LOGGING")]
public static void Trace (string switchName, params object[]messages)
{
}
internal static bool CheckEnabled (string switchName)
{
return false;
}
}
}

View File

@@ -0,0 +1,176 @@
namespace System
{
partial class Buffer
{
public static int ByteLength (Array array)
{
// note: the other methods in this class also use ByteLength to test for
// null and non-primitive arguments as a side-effect.
if (array == null)
throw new ArgumentNullException ("array");
int length = _ByteLength (array);
if (length < 0)
throw new ArgumentException (Locale.GetText ("Object must be an array of primitives."));
return length;
}
public static byte GetByte (Array array, int index)
{
if (index < 0 || index >= ByteLength (array))
throw new ArgumentOutOfRangeException ("index");
return _GetByte (array, index);
}
public static void SetByte (Array array, int index, byte value)
{
if (index < 0 || index >= ByteLength (array))
throw new ArgumentOutOfRangeException ("index");
_SetByte (array, index, value);
}
public static void BlockCopy (Array src, int srcOffset, Array dst, int dstOffset, int count)
{
if (src == null)
throw new ArgumentNullException ("src");
if (dst == null)
throw new ArgumentNullException ("dst");
if (srcOffset < 0)
throw new ArgumentOutOfRangeException ("srcOffset", Locale.GetText(
"Non-negative number required."));
if (dstOffset < 0)
throw new ArgumentOutOfRangeException ("dstOffset", Locale.GetText (
"Non-negative number required."));
if (count < 0)
throw new ArgumentOutOfRangeException ("count", Locale.GetText (
"Non-negative number required."));
// We do the checks in unmanaged code for performance reasons
bool res = InternalBlockCopy (src, srcOffset, dst, dstOffset, count);
if (!res) {
// watch for integer overflow
if ((srcOffset > ByteLength (src) - count) || (dstOffset > ByteLength (dst) - count))
throw new ArgumentException (Locale.GetText (
"Offset and length were out of bounds for the array or count is greater than " +
"the number of elements from index to the end of the source collection."));
}
}
internal static unsafe void memcpy4 (byte *dest, byte *src, int size) {
/*while (size >= 32) {
// using long is better than int and slower than double
// FIXME: enable this only on correct alignment or on platforms
// that can tolerate unaligned reads/writes of doubles
((double*)dest) [0] = ((double*)src) [0];
((double*)dest) [1] = ((double*)src) [1];
((double*)dest) [2] = ((double*)src) [2];
((double*)dest) [3] = ((double*)src) [3];
dest += 32;
src += 32;
size -= 32;
}*/
while (size >= 16) {
((int*)dest) [0] = ((int*)src) [0];
((int*)dest) [1] = ((int*)src) [1];
((int*)dest) [2] = ((int*)src) [2];
((int*)dest) [3] = ((int*)src) [3];
dest += 16;
src += 16;
size -= 16;
}
while (size >= 4) {
((int*)dest) [0] = ((int*)src) [0];
dest += 4;
src += 4;
size -= 4;
}
while (size > 0) {
((byte*)dest) [0] = ((byte*)src) [0];
dest += 1;
src += 1;
--size;
}
}
internal static unsafe void memcpy2 (byte *dest, byte *src, int size) {
while (size >= 8) {
((short*)dest) [0] = ((short*)src) [0];
((short*)dest) [1] = ((short*)src) [1];
((short*)dest) [2] = ((short*)src) [2];
((short*)dest) [3] = ((short*)src) [3];
dest += 8;
src += 8;
size -= 8;
}
while (size >= 2) {
((short*)dest) [0] = ((short*)src) [0];
dest += 2;
src += 2;
size -= 2;
}
if (size > 0)
((byte*)dest) [0] = ((byte*)src) [0];
}
static unsafe void memcpy1 (byte *dest, byte *src, int size) {
while (size >= 8) {
((byte*)dest) [0] = ((byte*)src) [0];
((byte*)dest) [1] = ((byte*)src) [1];
((byte*)dest) [2] = ((byte*)src) [2];
((byte*)dest) [3] = ((byte*)src) [3];
((byte*)dest) [4] = ((byte*)src) [4];
((byte*)dest) [5] = ((byte*)src) [5];
((byte*)dest) [6] = ((byte*)src) [6];
((byte*)dest) [7] = ((byte*)src) [7];
dest += 8;
src += 8;
size -= 8;
}
while (size >= 2) {
((byte*)dest) [0] = ((byte*)src) [0];
((byte*)dest) [1] = ((byte*)src) [1];
dest += 2;
src += 2;
size -= 2;
}
if (size > 0)
((byte*)dest) [0] = ((byte*)src) [0];
}
internal static unsafe void Memcpy (byte *dest, byte *src, int size) {
// FIXME: if pointers are not aligned, try to align them
// so a faster routine can be used. Handle the case where
// the pointers can't be reduced to have the same alignment
// (just ignore the issue on x86?)
if ((((int)dest | (int)src) & 3) != 0) {
if (((int)dest & 1) != 0 && ((int)src & 1) != 0 && size >= 1) {
dest [0] = src [0];
++dest;
++src;
--size;
}
if (((int)dest & 2) != 0 && ((int)src & 2) != 0 && size >= 2) {
((short*)dest) [0] = ((short*)src) [0];
dest += 2;
src += 2;
size -= 2;
}
if ((((int)dest | (int)src) & 1) != 0) {
memcpy1 (dest, src, size);
return;
}
if ((((int)dest | (int)src) & 2) != 0) {
memcpy2 (dest, src, size);
return;
}
}
memcpy4 (dest, src, size);
}
}
}

View File

@@ -0,0 +1,162 @@
//
// CompareInfo.cs
//
// Authors:
// Marek Safar <marek.safar@gmail.com>
//
// Copyright (C) 2015 Xamarin Inc (http://www.xamarin.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.
//
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using Mono.Globalization.Unicode;
using System.Threading;
namespace System.Globalization
{
partial class CompareInfo
{
[NonSerialized]
SimpleCollator collator;
// Maps culture IDs to SimpleCollator objects
static Dictionary<string, SimpleCollator> collators;
static bool managedCollation;
static bool managedCollationChecked;
static bool UseManagedCollation {
get {
if (!managedCollationChecked) {
managedCollation = Environment.internalGetEnvironmentVariable ("MONO_DISABLE_MANAGED_COLLATION") != "yes" && MSCompatUnicodeTable.IsReady;
managedCollationChecked = true;
}
return managedCollation;
}
}
SimpleCollator GetCollator ()
{
if (collator != null)
return collator;
if (collators == null) {
Interlocked.CompareExchange (ref collators, new Dictionary<string, SimpleCollator> (StringComparer.Ordinal), null);
}
lock (collators) {
if (!collators.TryGetValue (m_sortName, out collator)) {
collator = new SimpleCollator (CultureInfo.GetCultureInfo (m_name));
collators [m_sortName] = collator;
}
}
return collator;
}
SortKey CreateSortKeyCore (string source, CompareOptions options)
{
if (UseManagedCollation)
return GetCollator ().GetSortKey (source, options);
SortKey key=new SortKey (culture, source, options);
/* Need to do the icall here instead of in the
* SortKey constructor, as we need access to
* this instance's collator.
*/
assign_sortkey (key, source, options);
return(key);
}
int internal_index_switch (string s, int sindex, int count, char c, CompareOptions opt, bool first)
{
if (opt == CompareOptions.Ordinal && first)
return s.IndexOfUnchecked (c, sindex, count);
return UseManagedCollation ?
internal_index_managed (s, sindex, count, c, opt, first) :
internal_index (s, sindex, count, c, opt, first);
}
int internal_index_switch (string s1, int sindex, int count, string s2, CompareOptions opt, bool first)
{
if (opt == CompareOptions.Ordinal && first)
return s1.IndexOfUnchecked (s2, sindex, count);
return UseManagedCollation ?
internal_index_managed (s1, sindex, count, s2, opt, first) :
internal_index (s1, sindex, count, s2, opt, first);
}
int internal_compare_switch (string str1, int offset1, int length1, string str2, int offset2, int length2, CompareOptions options)
{
return UseManagedCollation ?
internal_compare_managed (str1, offset1, length1,
str2, offset2, length2, options) :
internal_compare (str1, offset1, length1,
str2, offset2, length2, options);
}
int internal_compare_managed (string str1, int offset1, int length1, string str2, int offset2, int length2, CompareOptions options)
{
return GetCollator ().Compare (str1, offset1, length1,
str2, offset2, length2, options);
}
int internal_index_managed (string s, int sindex, int count, char c, CompareOptions opt, bool first)
{
return first ?
GetCollator ().IndexOf (s, c, sindex, count, opt) :
GetCollator ().LastIndexOf (s, c, sindex, count, opt);
}
int internal_index_managed (string s1, int sindex, int count, string s2, CompareOptions opt, bool first)
{
return first ?
GetCollator ().IndexOf (s1, s2, sindex, count, opt) :
GetCollator ().LastIndexOf (s1, s2, sindex, count, opt);
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
private extern void assign_sortkey (object key, string source,
CompareOptions options);
[MethodImplAttribute (MethodImplOptions.InternalCall)]
private extern int internal_compare (string str1, int offset1,
int length1, string str2,
int offset2, int length2,
CompareOptions options);
[MethodImplAttribute (MethodImplOptions.InternalCall)]
private extern int internal_index (string source, int sindex,
int count, char value,
CompareOptions options,
bool first);
[MethodImplAttribute (MethodImplOptions.InternalCall)]
private extern int internal_index (string source, int sindex,
int count, string value,
CompareOptions options,
bool first);
}
}

View File

@@ -65,6 +65,15 @@ namespace System.Globalization
// TODO: should query runtime with culture name for a list of culture's calendars
int calendarId;
int numberIndex;
int iDefaultAnsiCodePage;
int iDefaultOemCodePage;
int iDefaultMacCodePage;
int iDefaultEbcdicCodePage;
bool isRightToLeft;
string sListSeparator;
private CultureData (string name)
{
this.sRealName = name;
@@ -95,6 +104,13 @@ namespace System.Globalization
// Store for specific data about each calendar
invariant.calendars = new CalendarData[CalendarData.MAX_CALENDARS];
invariant.calendars[0] = CalendarData.Invariant;
invariant.iDefaultAnsiCodePage = 1252; // default ansi code page ID (ACP)
invariant.iDefaultOemCodePage = 437; // default oem code page ID (OCP or OEM)
invariant.iDefaultMacCodePage = 10000; // default macintosh code page
invariant.iDefaultEbcdicCodePage = 037; // default EBCDIC code page
invariant.sListSeparator = ",";
Interlocked.CompareExchange (ref s_Invariant, invariant, null);
}
@@ -113,7 +129,8 @@ namespace System.Globalization
}
}
public static CultureData GetCultureData (string cultureName, bool useUserOverride, int datetimeIndex, int calendarId, string iso2lang)
public static CultureData GetCultureData (string cultureName, bool useUserOverride, int datetimeIndex, int calendarId, int numberIndex, string iso2lang,
int ansiCodePage, int oemCodePage, int macCodePage, int ebcdicCodePage, bool rightToLeft, string listSeparator)
{
if (string.IsNullOrEmpty (cultureName))
return Invariant;
@@ -122,16 +139,29 @@ namespace System.Globalization
cd.fill_culture_data (datetimeIndex);
cd.bUseOverrides = useUserOverride;
cd.calendarId = calendarId;
cd.numberIndex = numberIndex;
cd.sISO639Language = iso2lang;
cd.iDefaultAnsiCodePage = ansiCodePage;
cd.iDefaultOemCodePage = oemCodePage;
cd.iDefaultMacCodePage = macCodePage;
cd.iDefaultEbcdicCodePage = ebcdicCodePage;
cd.isRightToLeft = rightToLeft;
cd.sListSeparator = listSeparator;
return cd;
}
internal static CultureData GetCultureData (int culture, bool bUseUserOverride)
{
// Legacy path which we should never hit
return null;
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
extern void fill_culture_data (int datetimeIndex);
public CalendarData GetCalendar (int calendarId)
{
// arrays are 0 based, calendarIds are 1 based
// arrays are 0 based, calendarIds are 1 based
int calendarIndex = calendarId - 1;
// Have to have calendars
@@ -219,17 +249,71 @@ namespace System.Globalization
}
}
internal String CultureName {
get {
return sRealName;
}
}
internal String SCOMPAREINFO {
get {
return "";
internal bool IsInvariantCulture {
get {
return string.IsNullOrEmpty (sRealName);
}
}
internal String CultureName {
get {
return sRealName;
}
}
internal String SCOMPAREINFO {
get {
return "";
}
}
internal String STEXTINFO {
get {
return sRealName;
}
}
internal int ILANGUAGE {
get {
return 0;
}
}
internal int IDEFAULTANSICODEPAGE {
get {
return iDefaultAnsiCodePage;
}
}
internal int IDEFAULTOEMCODEPAGE {
get {
return iDefaultOemCodePage;
}
}
internal int IDEFAULTMACCODEPAGE {
get {
return iDefaultMacCodePage;
}
}
internal int IDEFAULTEBCDICCODEPAGE {
get {
return iDefaultEbcdicCodePage;
}
}
internal bool IsRightToLeft {
get {
return isRightToLeft;
}
}
internal String SLIST {
get {
return sListSeparator;
}
}
}
#region from reference sources
@@ -510,5 +594,42 @@ namespace System.Globalization
{
return str;
}
internal static bool IsCustomCultureId(int cultureId)
{
return false;
}
internal void GetNFIValues (NumberFormatInfo nfi)
{
if (this.IsInvariantCulture)
{
// Same as default values
}
else
{
//
// We don't have information for the following four. All cultures use
// the same value of the number formatting values.
//
// PercentDecimalDigits
// PercentDecimalSeparator
// PercentGroupSize
// PercentGroupSeparator
//
fill_number_data (nfi, numberIndex);
}
//
// We don't have percent values, so use the number values
//
nfi.percentDecimalDigits = nfi.numberDecimalDigits;
nfi.percentDecimalSeparator = nfi.numberDecimalSeparator;
nfi.percentGroupSizes = nfi.numberGroupSizes;
nfi.percentGroupSeparator = nfi.numberGroupSeparator;
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
extern static void fill_number_data (NumberFormatInfo nfi, int numberIndex);
}
}

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