<Compile Include="$(BclSourcesRoot)\System\Runtime\CompilerServices\CustomConstantAttribute.cs" />
<Compile Include="$(BclSourcesRoot)\System\Runtime\CompilerServices\DateTimeConstantAttribute.cs" />
<Compile Include="$(BclSourcesRoot)\System\Runtime\CompilerServices\DecimalConstantAttribute.cs" />
- <Compile Include="$(BclSourcesRoot)\System\Runtime\CompilerServices\CompilationRelaxations.cs" />
- <Compile Include="$(BclSourcesRoot)\System\Runtime\CompilerServices\InternalsVisibleToAttribute.cs" />
+ <Compile Include="$(BclSourcesRoot)\System\Runtime\CompilerServices\FriendAccessAllowedAttribute.cs" />
<Compile Include="$(BclSourcesRoot)\System\Runtime\CompilerServices\MethodImplAttribute.cs" />
<Compile Include="$(BclSourcesRoot)\System\Runtime\CompilerServices\TypeDependencyAttribute.cs" />
<Compile Include="$(BclSourcesRoot)\System\Runtime\CompilerServices\jithelpers.cs" />
<Compile Include="$(BclSourcesRoot)\System\Runtime\CompilerServices\Unsafe.cs" />
- <Compile Include="$(BclSourcesRoot)\System\Runtime\CompilerServices\SuppressMergeCheckAttribute.cs" />
<Compile Condition="'$(FeatureICastable)' == 'true'" Include="$(BclSourcesRoot)\System\Runtime\CompilerServices\ICastable.cs" />
<Compile Include="$(BclSourcesRoot)\System\Runtime\CompilerServices\RuntimeWrappedException.cs" />
<Compile Include="$(BclSourcesRoot)\System\Runtime\CompilerServices\ConditionalWeakTable.cs" />
<Compile Include="$(BclSourcesRoot)\System\ValueType.cs" />
<Compile Include="$(BclSourcesRoot)\System\WeakReference.cs" />
<Compile Include="$(BclSourcesRoot)\System\WeakReferenceOfT.cs" />
- <Compile Include="$(BclSourcesRoot)\System\XmlIgnoreMemberAttribute.cs" />
<Compile Include="$(BclSourcesRoot)\System\CLRConfig.cs" />
<Compile Condition="'$(FeatureCominterop)' == 'true'" Include="$(BclSourcesRoot)\System\__ComObject.cs" />
<Compile Condition="'$(FeatureCominterop)' == 'true'" Include="$(BclSourcesRoot)\System\Variant.cs" />
<Compile Include="$(BclSourcesRoot)\System\Runtime\Remoting\ObjectHandle.cs" />
</ItemGroup>
<ItemGroup>
- <Compile Include="$(BclSourcesRoot)\System\Text\ASCIIEncoding.cs" />
- <Compile Include="$(BclSourcesRoot)\System\Text\Decoder.cs" />
<Compile Include="$(BclSourcesRoot)\System\Text\DecoderNLS.cs" />
<Compile Include="$(BclSourcesRoot)\System\Text\DecoderBestFitFallback.cs" />
<Compile Include="$(BclSourcesRoot)\System\Text\DecoderExceptionFallback.cs" />
<Compile Include="$(BclSourcesRoot)\System\Text\DecoderFallback.cs" />
<Compile Include="$(BclSourcesRoot)\System\Text\DecoderReplacementFallback.cs" />
- <Compile Include="$(BclSourcesRoot)\System\Text\Encoder.cs" />
<Compile Include="$(BclSourcesRoot)\System\Text\EncoderNLS.cs" />
<Compile Include="$(BclSourcesRoot)\System\Text\EncoderBestFitFallback.cs" />
<Compile Include="$(BclSourcesRoot)\System\Text\EncoderExceptionFallback.cs" />
<Compile Include="$(BclSourcesRoot)\System\Text\EncoderFallback.cs" />
<Compile Include="$(BclSourcesRoot)\System\Text\EncoderReplacementFallback.cs" />
<Compile Include="$(BclSourcesRoot)\System\Text\Encoding.cs" />
- <Compile Include="$(BclSourcesRoot)\System\Text\EncodingInfo.cs" />
- <Compile Include="$(BclSourcesRoot)\System\Text\EncodingNLS.cs" />
- <Compile Include="$(BclSourcesRoot)\System\Text\EncodingProvider.cs" />
<Compile Include="$(BclSourcesRoot)\System\Text\Latin1Encoding.cs" />
<Compile Include="$(BclSourcesRoot)\System\Text\Normalization.Windows.cs" Condition="'$(TargetsUnix)' != 'true'" />
- <Compile Include="$(BclSourcesRoot)\System\Text\UnicodeEncoding.cs" />
<Compile Include="$(BclSourcesRoot)\System\Text\UTF7Encoding.cs" />
- <Compile Include="$(BclSourcesRoot)\System\Text\UTF8Encoding.cs" />
- <Compile Include="$(BclSourcesRoot)\System\Text\UTF32Encoding.cs" />
</ItemGroup>
<ItemGroup>
<Compile Include="$(BclSourcesRoot)\Microsoft\Win32\UnsafeNativeMethods.cs" />
<Compile Include="$(BclSourcesRoot)\Interop\Windows\Normaliz\Interop.Idna.cs" />
<Compile Include="$(BclSourcesRoot)\Interop\Windows\Normaliz\Interop.Normalization.cs" />
</ItemGroup>
- <ItemGroup Condition="'$(TargetsUnix)' != 'true'">
- <Compile Include="$(BclSourcesRoot)\System\Security\SecureString.Windows.cs" />
- <!-- Interop sources -->
- <Compile Include="$(BclSourcesRoot)\Interop\Windows\NtDll\Interop.ZeroMemory.cs" />
- <Compile Include="$(BclSourcesRoot)\Interop\Windows\oleaut32\Interop.SysAllocStringLen.cs" />
- <Compile Include="$(BclSourcesRoot)\Interop\Windows\oleaut32\Interop.SysStringLen.cs" />
- </ItemGroup>
- <ItemGroup Condition="'$(TargetsUnix)' == 'true'">
- <Compile Include="$(BclSourcesRoot)\Interop\Unix\System.Native\Interop.GetRandomBytes.cs" />
- </ItemGroup>
<!-- Include additional sources shared files in the compilation -->
<ItemGroup>
<!-- These are files are preprocessed -->
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Diagnostics;
+using System.Runtime.InteropServices;
+
+internal partial class Interop
+{
+ internal unsafe partial class Sys
+ {
+ [DllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_GetNonCryptographicallySecureRandomBytes")]
+ internal static unsafe extern void GetNonCryptographicallySecureRandomBytes(byte* buffer, int length);
+ }
+
+ internal static unsafe void GetRandomBytes(byte* buffer, int length)
+ {
+ Sys.GetNonCryptographicallySecureRandomBytes(buffer, length);
+ }
+}
internal partial class OleAut32
{
[DllImport(Libraries.OleAut32, CharSet = CharSet.Unicode)]
- internal static extern SafeBSTRHandle SysAllocStringLen(IntPtr src, uint len); // BSTR
+ internal static extern SafeBSTRHandle SysAllocStringLen(IntPtr src, uint len);
+
+ [DllImport(Libraries.OleAut32, CharSet = CharSet.Unicode)]
+ internal static extern IntPtr SysAllocStringLen(String src, int len);
}
}
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Runtime.InteropServices;
+
+internal partial class Interop
+{
+ internal partial class OleAut32
+ {
+ [DllImport(Libraries.OleAut32)]
+ internal static extern void SysFreeString(IntPtr bstr);
+ }
+}
[DllImport(Libraries.OleAut32)]
internal static extern uint SysStringLen(IntPtr bstr);
-
- [DllImport(Libraries.OleAut32)]
- internal static extern void SysFreeString(IntPtr bstr);
}
}
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.WideCharToMultiByte.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.WriteFile_SafeHandle_IntPtr.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.WriteFile_SafeHandle_NativeOverlapped.cs"/>
+ <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\NtDll\Interop.ZeroMemory.cs"/>
+ <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\OleAut32\Interop.SysAllocStringLen.cs"/>
+ <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\OleAut32\Interop.SysFreeString.cs"/>
+ <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\OleAut32\Interop.SysStringLen.cs"/>
</ItemGroup>
<ItemGroup Condition="$(TargetsUnix)">
<Compile Include="$(MSBuildThisFileDirectory)Interop\Unix\Interop.Errors.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)Interop\Unix\System.Native\Interop.FSync.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)Interop\Unix\System.Native\Interop.FTruncate.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)Interop\Unix\System.Native\Interop.GetCwd.cs"/>
+ <Compile Include="$(MSBuildThisFileDirectory)Interop\Unix\System.Native\Interop.GetRandomBytes.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)Interop\Unix\System.Native\Interop.LockFileRegion.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)Interop\Unix\System.Native\Interop.LSeek.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)Interop\Unix\System.Native\Interop.MksTemps.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\CallerLineNumberAttribute.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\CallerMemberNameAttribute.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\CompilationRelaxations.cs"/>
+ <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\CompilationRelaxationsAttribute.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\CompilerGeneratedAttribute.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\CompilerGlobalScopeAttribute.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\DefaultDependencyAttribute.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\FormattableStringFactory.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\IAsyncStateMachine.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\IndexerNameAttribute.cs"/>
+ <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\InternalsVisibleToAttribute.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\INotifyCompletion.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\IsVolatile.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\CompilerServices\IteratorStateMachineAttribute.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\ConstrainedExecution\ReliabilityContractAttribute.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\CallingConvention.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\CharSet.cs"/>
+ <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\ComVisibleAttribute.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\ExternalException.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\LayoutKind.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\StringBuffer.cs"/>
+ <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\UnmanagedFunctionPointerAttribute.cs"/>
+ <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\UnmanagedType.cs"/>
+ <Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\VarEnum.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Serialization\IFormatterConverter.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Serialization\IObjectReference.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\Serialization\ISafeSerializationData.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)System\StringComparison.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)System\StringSplitOptions.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)System\SystemException.cs"/>
+ <Compile Include="$(MSBuildThisFileDirectory)System\Text\ASCIIEncoding.cs"/>
+ <Compile Include="$(MSBuildThisFileDirectory)System\Text\Decoder.cs"/>
+ <Compile Include="$(MSBuildThisFileDirectory)System\Text\Encoder.cs"/>
+ <Compile Include="$(MSBuildThisFileDirectory)System\Text\EncodingInfo.cs"/>
+ <Compile Include="$(MSBuildThisFileDirectory)System\Text\EncodingNLS.cs"/>
+ <Compile Include="$(MSBuildThisFileDirectory)System\Text\EncodingProvider.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)System\Text\Normalization.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)System\Text\StringBuilder.cs"/>
+ <Compile Include="$(MSBuildThisFileDirectory)System\Text\UTF32Encoding.cs"/>
+ <Compile Include="$(MSBuildThisFileDirectory)System\Text\UTF8Encoding.cs"/>
+ <Compile Include="$(MSBuildThisFileDirectory)System\Text\UnicodeEncoding.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)System\ThreadAttributes.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\DeferredDisposableLifetime.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\Tasks\TaskCanceledException.cs"/>
<Compile Include="$(MSBuildThisFileDirectory)System\IO\PathInternal.Windows.StringBuffer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\IO\Win32Marshal.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Security\SafeBSTRHandle.cs"/>
+ <Compile Include="$(MSBuildThisFileDirectory)System\Security\SecureString.Windows.cs"/>
</ItemGroup>
<ItemGroup Condition="$(TargetsUnix)">
<Compile Include="$(MSBuildThisFileDirectory)Microsoft\Win32\SafeHandles\SafeFileHandle.Unix.cs"/>
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.CompilerServices
+{
+ [Serializable]
+ [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Method)]
+ public class CompilationRelaxationsAttribute : Attribute
+ {
+ public CompilationRelaxationsAttribute(int relaxations)
+ {
+ CompilationRelaxations = relaxations;
+ }
+
+ public CompilationRelaxationsAttribute(CompilationRelaxations relaxations)
+ {
+ CompilationRelaxations = (int)relaxations;
+ }
+
+ public int CompilationRelaxations { get; }
+ }
+}
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+
+namespace System.Runtime.CompilerServices
+{
+ [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true, Inherited = false)]
+ public sealed class InternalsVisibleToAttribute : Attribute
+ {
+ public InternalsVisibleToAttribute(string assemblyName)
+ {
+ AssemblyName = assemblyName;
+ }
+
+ public string AssemblyName { get; }
+ public bool AllInternalsVisible { get; set; } = true;
+ }
+}
+
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.InteropServices
+{
+ [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Interface | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Delegate | AttributeTargets.Enum | AttributeTargets.Field | AttributeTargets.Method | AttributeTargets.Property, Inherited = false)]
+ public sealed class ComVisibleAttribute : Attribute
+ {
+ public ComVisibleAttribute(bool visibility)
+ {
+ Value = visibility;
+ }
+
+ public bool Value { get; }
+ }
+}
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.InteropServices
+{
+ [AttributeUsage(AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
+ public sealed class UnmanagedFunctionPointerAttribute : Attribute
+ {
+ public bool BestFitMapping;
+ public bool SetLastError;
+ public bool ThrowOnUnmappableChar;
+ public CharSet CharSet;
+
+ public UnmanagedFunctionPointerAttribute()
+ {
+ CallingConvention = CallingConvention.Winapi;
+ }
+
+ public UnmanagedFunctionPointerAttribute(CallingConvention callingConvention)
+ {
+ CallingConvention = callingConvention;
+ }
+
+ public CallingConvention CallingConvention { get; }
+ }
+}
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.InteropServices
+{
+ public enum UnmanagedType
+ {
+ Bool = 0x2, // 4 byte boolean value (true != 0, false == 0)
+ I1 = 0x3, // 1 byte signed value
+ U1 = 0x4, // 1 byte unsigned value
+ I2 = 0x5, // 2 byte signed value
+ U2 = 0x6, // 2 byte unsigned value
+ I4 = 0x7, // 4 byte signed value
+ U4 = 0x8, // 4 byte unsigned value
+ I8 = 0x9, // 8 byte signed value
+ U8 = 0xa, // 8 byte unsigned value
+ R4 = 0xb, // 4 byte floating point
+ R8 = 0xc, // 8 byte floating point
+ Currency = 0xf, // A currency
+ BStr = 0x13, // OLE Unicode BSTR
+ LPStr = 0x14, // Ptr to SBCS string
+ LPWStr = 0x15, // Ptr to Unicode string
+ LPTStr = 0x16, // Ptr to OS preferred (SBCS/Unicode) string
+ ByValTStr = 0x17, // OS preferred (SBCS/Unicode) inline string (only valid in structs)
+ IUnknown = 0x19, // COM IUnknown pointer.
+ IDispatch = 0x1a, // COM IDispatch pointer
+ Struct = 0x1b, // Structure
+ Interface = 0x1c, // COM interface
+ SafeArray = 0x1d, // OLE SafeArray
+ ByValArray = 0x1e, // Array of fixed size (only valid in structs)
+ SysInt = 0x1f, // Hardware natural sized signed integer
+ SysUInt = 0x20,
+ VBByRefStr = 0x22,
+ AnsiBStr = 0x23, // OLE BSTR containing SBCS characters
+ TBStr = 0x24, // Ptr to OS preferred (SBCS/Unicode) BSTR
+ VariantBool = 0x25, // OLE defined BOOLEAN (2 bytes, true == -1, false == 0)
+ FunctionPtr = 0x26, // Function pointer
+ AsAny = 0x28, // Paired with Object type and does runtime marshalling determination
+ LPArray = 0x2a, // C style array
+ LPStruct = 0x2b, // Pointer to a structure
+ CustomMarshaler = 0x2c,
+ Error = 0x2d,
+ IInspectable = 0x2e,
+ HString = 0x2f, // Windows Runtime HSTRING
+ }
+}
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Runtime.InteropServices
+{
+ public enum VarEnum
+ {
+ VT_EMPTY = 0,
+ VT_NULL = 1,
+ VT_I2 = 2,
+ VT_I4 = 3,
+ VT_R4 = 4,
+ VT_R8 = 5,
+ VT_CY = 6,
+ VT_DATE = 7,
+ VT_BSTR = 8,
+ VT_DISPATCH = 9,
+ VT_ERROR = 10,
+ VT_BOOL = 11,
+ VT_VARIANT = 12,
+ VT_UNKNOWN = 13,
+ VT_DECIMAL = 14,
+ VT_I1 = 16,
+ VT_UI1 = 17,
+ VT_UI2 = 18,
+ VT_UI4 = 19,
+ VT_I8 = 20,
+ VT_UI8 = 21,
+ VT_INT = 22,
+ VT_UINT = 23,
+ VT_VOID = 24,
+ VT_HRESULT = 25,
+ VT_PTR = 26,
+ VT_SAFEARRAY = 27,
+ VT_CARRAY = 28,
+ VT_USERDEFINED = 29,
+ VT_LPSTR = 30,
+ VT_LPWSTR = 31,
+ VT_RECORD = 36,
+ VT_FILETIME = 64,
+ VT_BLOB = 65,
+ VT_STREAM = 66,
+ VT_STORAGE = 67,
+ VT_STREAMED_OBJECT = 68,
+ VT_STORED_OBJECT = 69,
+ VT_BLOB_OBJECT = 70,
+ VT_CF = 71,
+ VT_CLSID = 72,
+ VT_VECTOR = 0x1000,
+ VT_ARRAY = 0x2000,
+ VT_BYREF = 0x4000
+ }
+}
_buffer.AcquirePointer(ref bufferPtr);
int resultByteLength = (length + 1) * sizeof(char);
- ptr = Win32Native.SysAllocStringLen(null, length);
+ ptr = Interop.OleAut32.SysAllocStringLen(null, length);
if (ptr == IntPtr.Zero)
{
throw new OutOfMemoryException();
if (result == IntPtr.Zero && ptr != IntPtr.Zero)
{
Interop.NtDll.ZeroMemory(ptr, (UIntPtr)(length * sizeof(char)));
- Win32Native.SysFreeString(ptr);
+ Interop.OleAut32.SysFreeString(ptr);
}
if (bufferPtr != null)
// See the LICENSE file in the project root for more information.
using System;
-using System.Runtime.Serialization;
using System.Diagnostics;
using System.Diagnostics.Contracts;
+using System.Runtime.Serialization;
namespace System.Text
{
//
// If the caller doesn't want to try again after GetChars() throws an error, then they need to call Reset().
//
- // Virtual implimentation has to call GetChars with flush and a big enough buffer to clear a 0 byte string
+ // Virtual implementation has to call GetChars with flush and a big enough buffer to clear a 0 byte string
// We avoid GetMaxCharCount() because a) we can't call the base encoder and b) it might be really big.
public virtual void Reset()
{
}
// We expect this to be the workhorse for NLS Encodings, but for existing
- // ones we need a working (if slow) default implimentation)
+ // ones we need a working (if slow) default implementation)
[CLSCompliant(false)]
public virtual unsafe int GetCharCount(byte* bytes, int count, bool flush)
{
}
// We expect this to be the workhorse for NLS Encodings, but for existing
- // ones we need a working (if slow) default implimentation)
+ // ones we need a working (if slow) default implementation)
//
// WARNING WARNING WARNING
//
// and indexes are correct when you call this method.
//
// In addition, we have internal code, which will be marked as "safe" calling
- // this code. However this code is dependent upon the implimentation of an
+ // this code. However this code is dependent upon the implementation of an
// external GetChars() method, which could be overridden by a third party and
// the results of which cannot be guaranteed. We use that result to copy
// the char[] to our char* output buffer. If the result count was wrong, we
// Copy the char array
// WARNING: We MUST make sure that we don't copy too many chars. We can't
- // rely on result because it could be a 3rd party implimentation. We need
+ // rely on result because it could be a 3rd party implementation. We need
// to make sure we never copy more than charCount chars no matter the value
// of result
if (result < charCount)
//
// If the caller doesn't want to try again after GetBytes() throws an error, then they need to call Reset().
//
- // Virtual implimentation has to call GetBytes with flush and a big enough buffer to clear a 0 char string
+ // Virtual implementation has to call GetBytes with flush and a big enough buffer to clear a 0 char string
// We avoid GetMaxByteCount() because a) we can't call the base encoder and b) it might be really big.
public virtual void Reset()
{
byte[] bytes, int byteIndex, bool flush);
// We expect this to be the workhorse for NLS Encodings, but for existing
- // ones we need a working (if slow) default implimentation)
+ // ones we need a working (if slow) default implementation)
//
// WARNING WARNING WARNING
//
// and indexes are correct when you call this method.
//
// In addition, we have internal code, which will be marked as "safe" calling
- // this code. However this code is dependent upon the implimentation of an
+ // this code. However this code is dependent upon the implementation of an
// external GetBytes() method, which could be overridden by a third party and
// the results of which cannot be guaranteed. We use that result to copy
// the byte[] to our byte* output buffer. If the result count was wrong, we
// Copy the byte array
// WARNING: We MUST make sure that we don't copy too many bytes. We can't
- // rely on result because it could be a 3rd party implimentation. We need
+ // rely on result because it could be a 3rd party implementation. We need
// to make sure we never copy more than byteCount bytes no matter the value
// of result
if (result < byteCount)
public sealed class EncodingInfo
{
private int iCodePage; // Code Page #
- private String strEncodingName; // Short name (web name)
- private String strDisplayName; // Full localized name
+ private string strEncodingName; // Short name (web name)
+ private string strDisplayName; // Full localized name
internal EncodingInfo(int codePage, string name, string displayName)
{
}
- public String Name
+ public string Name
{
get
{
}
- public String DisplayName
+ public string DisplayName
{
get
{
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+using System;
+using System.Diagnostics.Contracts;
+using System.Collections;
+using System.Globalization;
+using System.Threading;
+
namespace System.Text
{
- using System;
- using System.Diagnostics.Contracts;
- using System.Collections;
- using System.Runtime.Remoting;
- using System.Globalization;
- using System.Threading;
- using Win32Native = Microsoft.Win32.Win32Native;
-
// This class overrides Encoding with the things we need for our NLS Encodings
//
// All of the GetBytes/Chars GetByte/CharCount methods are just wrappers for the pointer
return;
}
- var providers = new EncodingProvider[s_providers.Length + 1];
+ EncodingProvider[] providers = new EncodingProvider[s_providers.Length + 1];
Array.Copy(s_providers, providers, s_providers.Length);
providers[providers.Length - 1] = provider;
s_providers = providers;
if (s_providers == null)
return null;
- var providers = s_providers;
+ EncodingProvider[] providers = s_providers;
foreach (EncodingProvider provider in providers)
{
Encoding enc = provider.GetEncoding(codepage);
if (s_providers == null)
return null;
- var providers = s_providers;
+ EncodingProvider[] providers = s_providers;
foreach (EncodingProvider provider in providers)
{
Encoding enc = provider.GetEncoding(encodingName);
if (s_providers == null)
return null;
- var providers = s_providers;
+ EncodingProvider[] providers = s_providers;
foreach (EncodingProvider provider in providers)
{
Encoding encing = provider.GetEncoding(codepage, enc, dec);
if (s_providers == null)
return null;
- var providers = s_providers;
+ EncodingProvider[] providers = s_providers;
foreach (EncodingProvider provider in providers)
{
Encoding encoding = provider.GetEncoding(encodingName, enc, dec);
// Don't override IsAlwaysNormalized because it is just a Unicode Transformation and could be confused.
//
-
using System;
using System.Diagnostics;
using System.Diagnostics.Contracts;
internal static readonly UTF32Encoding s_default = new UTF32Encoding(bigEndian: false, byteOrderMark: true);
internal static readonly UTF32Encoding s_bigEndianDefault = new UTF32Encoding(bigEndian: true, byteOrderMark: true);
- private bool emitUTF32ByteOrderMark = false;
- private bool isThrowException = false;
- private bool bigEndian = false;
+ private bool _emitUTF32ByteOrderMark = false;
+ private bool _isThrowException = false;
+ private bool _bigEndian = false;
public UTF32Encoding() : this(false, true, false)
public UTF32Encoding(bool bigEndian, bool byteOrderMark, bool throwOnInvalidCharacters) :
base(bigEndian ? 12001 : 12000)
{
- this.bigEndian = bigEndian;
- emitUTF32ByteOrderMark = byteOrderMark;
- isThrowException = throwOnInvalidCharacters;
+ _bigEndian = bigEndian;
+ _emitUTF32ByteOrderMark = byteOrderMark;
+ _isThrowException = throwOnInvalidCharacters;
// Encoding constructor already did this, but it'll be wrong if we're throwing exceptions
- if (isThrowException)
+ if (_isThrowException)
SetDefaultFallbacks();
}
internal override void SetDefaultFallbacks()
{
// For UTF-X encodings, we use a replacement fallback with an empty string
- if (isThrowException)
+ if (_isThrowException)
{
this.encoderFallback = EncoderFallback.ExceptionFallback;
this.decoderFallback = DecoderFallback.ExceptionFallback;
break;
}
- if (bigEndian)
+ if (_bigEndian)
{
*(bytes++) = (byte)(0x00);
*(bytes++) = (byte)(iTemp >> 16); // Implies & 0xFF, which isn't needed cause high are all 0
break; // Didn't throw, stop
}
- if (bigEndian)
+ if (_bigEndian)
{
*(bytes++) = (byte)(0x00);
*(bytes++) = (byte)(0x00);
while (bytes < end && charCount >= 0)
{
// Get our next character
- if (bigEndian)
+ if (_bigEndian)
{
// Scoot left and add it to the bottom
iChar <<= 8;
{
// Need to fall back these 4 bytes
byte[] fallbackBytes;
- if (bigEndian)
+ if (_bigEndian)
{
fallbackBytes = new byte[] {
unchecked((byte)(iChar>>24)), unchecked((byte)(iChar>>16)),
{
// Oops, there's something left over with no place to go.
byte[] fallbackBytes = new byte[readCount];
- if (bigEndian)
+ if (_bigEndian)
{
while (readCount > 0)
{
while (bytes < byteEnd)
{
// Get our next character
- if (bigEndian)
+ if (_bigEndian)
{
// Scoot left and add it to the bottom
iChar <<= 8;
{
// Need to fall back these 4 bytes
byte[] fallbackBytes;
- if (bigEndian)
+ if (_bigEndian)
{
fallbackBytes = new byte[] {
unchecked((byte)(iChar>>24)), unchecked((byte)(iChar>>16)),
// Oops, there's something left over with no place to go.
byte[] fallbackBytes = new byte[readCount];
int tempCount = readCount;
- if (bigEndian)
+ if (_bigEndian)
{
while (tempCount > 0)
{
public override byte[] GetPreamble()
{
- if (emitUTF32ByteOrderMark)
+ if (_emitUTF32ByteOrderMark)
{
// Allocate new array to prevent users from modifying it.
- if (bigEndian)
+ if (_bigEndian)
{
return new byte[4] { 0x00, 0x00, 0xFE, 0xFF };
}
}
}
else
- return EmptyArray<Byte>.Value;
+ return Array.Empty<byte>();
}
UTF32Encoding that = value as UTF32Encoding;
if (that != null)
{
- return (emitUTF32ByteOrderMark == that.emitUTF32ByteOrderMark) &&
- (bigEndian == that.bigEndian) &&
- // (isThrowException == that.isThrowException) && // same as encoder/decoderfallback being exceptions
+ return (_emitUTF32ByteOrderMark == that._emitUTF32ByteOrderMark) &&
+ (_bigEndian == that._bigEndian) &&
(EncoderFallback.Equals(that.EncoderFallback)) &&
(DecoderFallback.Equals(that.DecoderFallback));
}
{
//Not great distribution, but this is relatively unlikely to be used as the key in a hashtable.
return this.EncoderFallback.GetHashCode() + this.DecoderFallback.GetHashCode() +
- CodePage + (emitUTF32ByteOrderMark ? 4 : 0) + (bigEndian ? 8 : 0);
+ CodePage + (_emitUTF32ByteOrderMark ? 4 : 0) + (_bigEndian ? 8 : 0);
}
[Serializable]
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-
// The worker functions in this file was optimized for performance. If you make changes
// you should use care to consider all of the interesting cases.
// the problem is fastloop-specific.
#define FASTLOOP
+using System;
+using System.Runtime.Serialization;
+using System.Diagnostics;
+using System.Diagnostics.Contracts;
+using System.Globalization;
+
namespace System.Text
{
- using System;
- using System.Globalization;
- using System.Runtime.Serialization;
- using System.Diagnostics;
- using System.Diagnostics.Contracts;
-
// Encodes text into and out of UTF-8. UTF-8 is a way of writing
// Unicode characters with variable numbers of bytes per character,
// optimized for the lower 127 ASCII characters. It's an efficient way
// Yes, the idea of emitting U+FEFF as a UTF-8 identifier has made it into
// the standard.
- private bool emitUTF8Identifier = false;
+ private bool _emitUTF8Identifier = false;
- private bool isThrowException = false;
+ private bool _isThrowException = false;
public UTF8Encoding() : this(false)
public UTF8Encoding(bool encoderShouldEmitUTF8Identifier, bool throwOnInvalidBytes) :
base(UTF8_CODEPAGE)
{
- emitUTF8Identifier = encoderShouldEmitUTF8Identifier;
- isThrowException = throwOnInvalidBytes;
+ _emitUTF8Identifier = encoderShouldEmitUTF8Identifier;
+ _isThrowException = throwOnInvalidBytes;
// Encoding's constructor already did this, but it'll be wrong if we're throwing exceptions
- if (isThrowException)
+ if (_isThrowException)
SetDefaultFallbacks();
}
internal override void SetDefaultFallbacks()
{
// For UTF-X encodings, we use a replacement fallback with an empty string
- if (isThrowException)
+ if (_isThrowException)
{
this.encoderFallback = EncoderFallback.ExceptionFallback;
this.decoderFallback = DecoderFallback.ExceptionFallback;
public override byte[] GetPreamble()
{
- if (emitUTF8Identifier)
+ if (_emitUTF8Identifier)
{
// Allocate new array to prevent users from modifying it.
return new byte[3] { 0xEF, 0xBB, 0xBF };
}
else
- return EmptyArray<Byte>.Value;
+ return Array.Empty<byte>();
}
UTF8Encoding that = value as UTF8Encoding;
if (that != null)
{
- return (emitUTF8Identifier == that.emitUTF8Identifier) &&
- // (isThrowException == that.isThrowException) && // Same as encoder/decoderfallbacks being exception
+ return (_emitUTF8Identifier == that._emitUTF8Identifier) &&
(EncoderFallback.Equals(that.EncoderFallback)) &&
(DecoderFallback.Equals(that.DecoderFallback));
}
{
//Not great distribution, but this is relatively unlikely to be used as the key in a hashtable.
return this.EncoderFallback.GetHashCode() + this.DecoderFallback.GetHashCode() +
- UTF8_CODEPAGE + (emitUTF8Identifier ? 1 : 0);
+ UTF8_CODEPAGE + (_emitUTF8Identifier ? 1 : 0);
}
[Serializable]
// Don't override IsAlwaysNormalized because it is just a Unicode Transformation and could be confused.
//
+using System;
+using System.Globalization;
+using System.Runtime.Serialization;
+using System.Diagnostics;
+using System.Diagnostics.Contracts;
+
namespace System.Text
{
- using System;
- using System.Globalization;
- using System.Runtime.Serialization;
- using System.Diagnostics;
- using System.Diagnostics.Contracts;
-
-
[Serializable]
public class UnicodeEncoding : Encoding
{
else
return new byte[2] { 0xff, 0xfe };
}
- return EmptyArray<Byte>.Value;
+ return Array.Empty<Byte>();
}
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System;
-using System.Diagnostics;
-using System.Runtime.InteropServices;
-
-internal partial class Interop
-{
- internal static unsafe void GetRandomBytes(byte* bytes, int byteCount)
- {
- // We want to avoid dependencies on the Crypto library when compiling in CoreCLR. This
- // will use the existing PAL implementation.
- byte[] buffer = new byte[byteCount];
- Microsoft.Win32.Win32Native.Random(bStrong: true, buffer: buffer, length: byteCount);
- System.Runtime.InteropServices.Marshal.Copy(buffer, 0, (IntPtr)bytes, byteCount);
- }
-}
[return: MarshalAs(UnmanagedType.Bool)]
internal extern static bool QueryUnbiasedInterruptTime(out ulong UnbiasedTime);
-#if FEATURE_PAL
- [DllImport(KERNEL32, EntryPoint = "PAL_Random")]
- internal extern static bool Random(bool bStrong,
- [Out, MarshalAs(UnmanagedType.LPArray)] byte[] buffer, int length);
-#else
- private const int BCRYPT_USE_SYSTEM_PREFERRED_RNG = 0x00000002;
-#endif
-
internal const byte VER_GREATER_EQUAL = 0x3;
internal const uint VER_MAJORVERSION = 0x0000002;
internal const uint VER_MINORVERSION = 0x0000001;
}
}
- [XmlIgnoreMember]
public AppDomainInitializer AppDomainInitializer
{
get
_ApplicationTrust = permissionSetName;
}
- [XmlIgnoreMember]
internal ApplicationTrust ApplicationTrust
{
get
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////
-
-
-using System;
-
-namespace System.Runtime.CompilerServices
-{
- [Serializable]
- [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Method)]
- public class CompilationRelaxationsAttribute : Attribute
- {
- private int m_relaxations; // The relaxations.
-
- public CompilationRelaxationsAttribute(
- int relaxations)
- {
- m_relaxations = relaxations;
- }
-
- public CompilationRelaxationsAttribute(
- CompilationRelaxations relaxations)
- {
- m_relaxations = (int)relaxations;
- }
-
- public int CompilationRelaxations
- {
- get
- {
- return m_relaxations;
- }
- }
- }
-}
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-//------------------------------------------------------------------------------
-//------------------------------------------------------------------------------
-
-using System;
-
namespace System.Runtime.CompilerServices
{
- [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true, Inherited = false)]
- public sealed class InternalsVisibleToAttribute : Attribute
- {
- private string _assemblyName;
- private bool _allInternalsVisible = true;
-
- public InternalsVisibleToAttribute(string assemblyName)
- {
- _assemblyName = assemblyName;
- }
-
- public string AssemblyName
- {
- get
- {
- return _assemblyName;
- }
- }
-
- public bool AllInternalsVisible
- {
- get { return _allInternalsVisible; }
- set { _allInternalsVisible = value; }
- }
- }
-
/// <summary>
/// If AllInternalsVisible is not true for a friend assembly, the FriendAccessAllowed attribute
/// indicates which internals are shared with that friend assembly.
{
}
}
-
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-
-using System.Runtime.InteropServices;
-
-namespace System.Runtime.CompilerServices
-{
- [AttributeUsage(AttributeTargets.Class |
- AttributeTargets.Constructor |
- AttributeTargets.Method |
- AttributeTargets.Field |
- AttributeTargets.Event |
- AttributeTargets.Property)]
-
- internal sealed class SuppressMergeCheckAttribute : Attribute
- {
- public SuppressMergeCheckAttribute()
- { }
- }
-}
-
namespace System.Runtime.InteropServices
{
- [AttributeUsage(AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
- public sealed class UnmanagedFunctionPointerAttribute : Attribute
- {
- private CallingConvention m_callingConvention;
-
- public UnmanagedFunctionPointerAttribute(CallingConvention callingConvention) { m_callingConvention = callingConvention; }
-
- public CallingConvention CallingConvention { get { return m_callingConvention; } }
-
- public CharSet CharSet;
- public bool BestFitMapping;
- public bool ThrowOnUnmappableChar;
-
- // This field is ignored and marshaling behaves as if it was true (for historical reasons).
- public bool SetLastError;
-
- // P/Invoke via delegate always preserves signature, HRESULT swapping is not supported.
- //public bool PreserveSig;
- }
-
[AttributeUsage(AttributeTargets.Interface | AttributeTargets.Enum | AttributeTargets.Struct | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
public sealed class TypeIdentifierAttribute : Attribute
{
public ClassInterfaceType Value { get { return _val; } }
}
- [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Interface | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Delegate | AttributeTargets.Enum | AttributeTargets.Field | AttributeTargets.Method | AttributeTargets.Property, Inherited = false)]
- public sealed class ComVisibleAttribute : Attribute
- {
- internal bool _val;
- public ComVisibleAttribute(bool visibility)
- {
- _val = visibility;
- }
- public bool Value { get { return _val; } }
- }
-
[AttributeUsage(AttributeTargets.Method, Inherited = false)]
public sealed class LCIDConversionAttribute : Attribute
{
public String Value { get { return _val; } }
}
- [Serializable]
- public enum VarEnum
- {
- VT_EMPTY = 0,
- VT_NULL = 1,
- VT_I2 = 2,
- VT_I4 = 3,
- VT_R4 = 4,
- VT_R8 = 5,
- VT_CY = 6,
- VT_DATE = 7,
- VT_BSTR = 8,
- VT_DISPATCH = 9,
- VT_ERROR = 10,
- VT_BOOL = 11,
- VT_VARIANT = 12,
- VT_UNKNOWN = 13,
- VT_DECIMAL = 14,
- VT_I1 = 16,
- VT_UI1 = 17,
- VT_UI2 = 18,
- VT_UI4 = 19,
- VT_I8 = 20,
- VT_UI8 = 21,
- VT_INT = 22,
- VT_UINT = 23,
- VT_VOID = 24,
- VT_HRESULT = 25,
- VT_PTR = 26,
- VT_SAFEARRAY = 27,
- VT_CARRAY = 28,
- VT_USERDEFINED = 29,
- VT_LPSTR = 30,
- VT_LPWSTR = 31,
- VT_RECORD = 36,
- VT_FILETIME = 64,
- VT_BLOB = 65,
- VT_STREAM = 66,
- VT_STORAGE = 67,
- VT_STREAMED_OBJECT = 68,
- VT_STORED_OBJECT = 69,
- VT_BLOB_OBJECT = 70,
- VT_CF = 71,
- VT_CLSID = 72,
- VT_VECTOR = 0x1000,
- VT_ARRAY = 0x2000,
- VT_BYREF = 0x4000
- }
-
- [Serializable]
- // Note that this enum should remain in-sync with the CorNativeType enum in corhdr.h
- public enum UnmanagedType
- {
- Bool = 0x2, // 4 byte boolean value (true != 0, false == 0)
-
- I1 = 0x3, // 1 byte signed value
-
- U1 = 0x4, // 1 byte unsigned value
-
- I2 = 0x5, // 2 byte signed value
-
- U2 = 0x6, // 2 byte unsigned value
-
- I4 = 0x7, // 4 byte signed value
-
- U4 = 0x8, // 4 byte unsigned value
-
- I8 = 0x9, // 8 byte signed value
-
- U8 = 0xa, // 8 byte unsigned value
-
- R4 = 0xb, // 4 byte floating point
-
- R8 = 0xc, // 8 byte floating point
-
- Currency = 0xf, // A currency
-
- BStr = 0x13, // OLE Unicode BSTR
-
- LPStr = 0x14, // Ptr to SBCS string
-
- LPWStr = 0x15, // Ptr to Unicode string
-
- LPTStr = 0x16, // Ptr to OS preferred (SBCS/Unicode) string
-
- ByValTStr = 0x17, // OS preferred (SBCS/Unicode) inline string (only valid in structs)
-
- IUnknown = 0x19, // COM IUnknown pointer.
-
- IDispatch = 0x1a, // COM IDispatch pointer
-
- Struct = 0x1b, // Structure
-
- Interface = 0x1c, // COM interface
-
- SafeArray = 0x1d, // OLE SafeArray
-
- ByValArray = 0x1e, // Array of fixed size (only valid in structs)
-
- SysInt = 0x1f, // Hardware natural sized signed integer
-
- SysUInt = 0x20,
-
- VBByRefStr = 0x22,
-
- AnsiBStr = 0x23, // OLE BSTR containing SBCS characters
-
- TBStr = 0x24, // Ptr to OS preferred (SBCS/Unicode) BSTR
-
- VariantBool = 0x25, // OLE defined BOOLEAN (2 bytes, true == -1, false == 0)
-
- FunctionPtr = 0x26, // Function pointer
-
- AsAny = 0x28, // Paired with Object type and does runtime marshalling determination
-
- LPArray = 0x2a, // C style array
-
- LPStruct = 0x2b, // Pointer to a structure
-
- CustomMarshaler = 0x2c,
-
- Error = 0x2d,
-
- IInspectable = 0x2e,
-
- HString = 0x2f, // Windows Runtime HSTRING
-
- LPUTF8Str = 0x30, // UTF8 string
- }
-
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.ReturnValue, Inherited = false)]
public unsafe sealed class MarshalAsAttribute : Attribute
{
+++ /dev/null
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-/*=============================================================================
-**
-**
-**
-** Purpose: Attribute for properties/members that the Xml Serializer should
-** ignore.
-**
-**
-=============================================================================*/
-
-namespace System
-{
- [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
- internal sealed class XmlIgnoreMemberAttribute : Attribute
- {
- }
-}