using System;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class OleAut32
+ internal static partial class OleAut32
{
[DllImport(Libraries.OleAut32)]
internal static extern void VariantClear(IntPtr variant);
namespace System.Diagnostics.Tracing
{
- internal sealed class RuntimeEventSourceHelper
+ internal static class RuntimeEventSourceHelper
{
private static Interop.Sys.ProcessCpuInformation cpuInfo;
namespace System.Diagnostics.Tracing
{
- internal sealed class RuntimeEventSourceHelper
+ internal static class RuntimeEventSourceHelper
{
private static long prevProcUserTime = 0;
private static long prevProcKernelTime = 0;
private static GetSourceLineInfoDelegate? s_getSourceLineInfo = null;
[ThreadStatic]
- private static int t_reentrancy = 0;
+ private static int t_reentrancy;
public StackFrameHelper(Thread? target)
{
return StartNoGCRegionWorker(totalSize, true, lohSize, disallowFullBlockingGC);
}
- private static EndNoGCRegionStatus EndNoGCRegionWorker()
+ public static void EndNoGCRegion()
{
EndNoGCRegionStatus status = (EndNoGCRegionStatus)_EndNoGCRegion();
if (status == EndNoGCRegionStatus.NotInProgress)
throw new InvalidOperationException("Garbage collection was induced in NoGCRegion mode");
else if (status == EndNoGCRegionStatus.AllocationExceeded)
throw new InvalidOperationException("Allocated memory exceeds specified memory for NoGCRegion mode");
-
- return EndNoGCRegionStatus.Succeeded;
- }
-
- public static void EndNoGCRegion()
- {
- EndNoGCRegionWorker();
}
private readonly struct MemoryLoadChangeNotification
namespace System.Globalization
{
- internal sealed partial class GlobalizationMode
+ internal static partial class GlobalizationMode
{
private static bool GetGlobalizationInvariantMode()
{
namespace System.Globalization
{
- internal sealed partial class GlobalizationMode
+ internal static partial class GlobalizationMode
{
private static bool GetGlobalizationInvariantMode()
{
namespace System.Globalization
{
- internal sealed partial class GlobalizationMode
+ internal static partial class GlobalizationMode
{
internal static bool Invariant { get; } = GetGlobalizationInvariantMode();
// Transparent DynamicMethod to call the current DynamicMethod.
//
- RuntimeMethodHandle method = GetMethodDescriptor();
+ _ = GetMethodDescriptor();
// ignore obj since it's a static method
// create a signature object
private static Type? GetType(string strFormat, Type baseType)
{
// This function takes a string to describe the compound type, such as "[,][]", and a baseType.
- if (strFormat == null || strFormat.Equals(string.Empty))
+ if (string.IsNullOrEmpty(strFormat))
{
return baseType;
}
runtimeType2 = t2;
}
- // If the type builder view is eqaul then it is equal
+ // If the type builder view is equal then it is equal
if (tb1 != null && tb2 != null && object.ReferenceEquals(tb1, tb2))
return true;
// The signature grabbing code has to be up here or the signature won't be finished
// and our equals check won't work.
- int sigLength;
- byte[] sigBytes = method.GetMethodSignature().InternalGetSignature(out sigLength);
+ _ = method.GetMethodSignature().InternalGetSignature(out _);
if (m_listMethods.Contains(method))
{
private Type m_type;
private Type[] m_inst;
private string? m_strFullQualName;
- internal Hashtable m_hashtable = new Hashtable();
+ internal Hashtable m_hashtable;
#endregion
{
INVOCATION_FLAGS invocationFlags = InvocationFlags;
- // get the declaring TypeHandle early for consistent exceptions in IntrospectionOnly context
- RuntimeTypeHandle declaringTypeHandle = m_declaringType.TypeHandle;
-
if ((invocationFlags & (INVOCATION_FLAGS.INVOCATION_FLAGS_NO_INVOKE | INVOCATION_FLAGS.INVOCATION_FLAGS_CONTAINS_STACK_POINTERS | INVOCATION_FLAGS.INVOCATION_FLAGS_NO_CTOR_INVOKE)) != 0)
ThrowNoInvokeException();
#endregion
#region MethodBase Overrides
- internal override ParameterInfo[] GetParametersNoCopy()
- {
+ internal override ParameterInfo[] GetParametersNoCopy() =>
FetchNonReturnParameters();
- return m_parameters!;
- }
-
public override ParameterInfo[] GetParameters()
{
- FetchNonReturnParameters();
+ ParameterInfo[] parameters = FetchNonReturnParameters();
- if (m_parameters!.Length == 0)
- return m_parameters;
+ if (parameters.Length == 0)
+ return parameters;
- ParameterInfo[] ret = new ParameterInfo[m_parameters.Length];
+ ParameterInfo[] ret = new ParameterInfo[parameters.Length];
- Array.Copy(m_parameters, 0, ret, 0, m_parameters.Length);
+ Array.Copy(parameters, 0, ret, 0, parameters.Length);
return ret;
}
|| (vt == VarEnum.VT_UNKNOWN)
|| (vt == VarEnum.VT_DISPATCH)
|| (vt == VarEnum.VT_VARIANT)
- || (vt == VarEnum.VT_RECORD)
- || (vt == VarEnum.VT_VARIANT))
+ || (vt == VarEnum.VT_RECORD))
{
unsafe
{
int argCnt = (providedArgs != null) ? providedArgs.Length : 0;
binder ??= DefaultBinder;
- bool bDefaultBinder = (binder == DefaultBinder);
// Delegate to Activator.CreateInstance
if ((bindingFlags & BindingFlags.CreateInstance) != 0)
using System.Runtime.InteropServices;
using System.Text;
using System.Text.Unicode;
-using Internal.Runtime.CompilerServices;
namespace System
{
}
}
- internal partial class Sys
+ internal static partial class Sys
{
internal static Error GetLastError()
{
using System.Diagnostics;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
internal unsafe partial class Sys
{
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Advapi32
+ internal static partial class Advapi32
{
internal enum ActivityControl : uint
{
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Advapi32
+ internal static partial class Advapi32
{
internal enum EVENT_INFO_CLASS
{
using System;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Advapi32
+ internal static partial class Advapi32
{
internal const int EVENT_CONTROL_CODE_DISABLE_PROVIDER = 0;
internal const int EVENT_CONTROL_CODE_ENABLE_PROVIDER = 1;
using System;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Advapi32
+ internal static partial class Advapi32
{
[DllImport(Libraries.Advapi32, ExactSpelling = true)]
internal static extern int EventActivityIdControl(ActivityControl ControlCode, ref Guid ActivityId);
using System;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Advapi32
+ internal static partial class Advapi32
{
[DllImport(Libraries.Advapi32, ExactSpelling = true)]
internal static extern unsafe uint EventRegister(
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Advapi32
+ internal static partial class Advapi32
{
[DllImport(Libraries.Advapi32, ExactSpelling = true)]
internal static extern unsafe int EventSetInformation(
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Advapi32
+ internal static partial class Advapi32
{
internal enum TRACE_QUERY_INFO_CLASS
{
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Advapi32
+ internal static partial class Advapi32
{
[DllImport(Libraries.Advapi32, ExactSpelling = true)]
internal static extern uint EventUnregister(long registrationHandle);
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Advapi32
+ internal static partial class Advapi32
{
[DllImport(Libraries.Advapi32, ExactSpelling = true)]
internal static extern int EventWriteString(
using System.Diagnostics.Tracing;
#endif
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Advapi32
+ internal static partial class Advapi32
{
/// <summary>
/// Call the ETW native API EventWriteTransfer and checks for invalid argument error.
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Advapi32
+ internal static partial class Advapi32
{
[DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
internal static extern bool LookupAccountNameW(
using System;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Advapi32
+ internal static partial class Advapi32
{
[DllImport(Libraries.Advapi32)]
internal static extern int RegCloseKey(IntPtr hKey);
#endif
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Advapi32
+ internal static partial class Advapi32
{
// Note: RegCreateKeyEx won't set the last error on failure - it returns
// an error code if it fails.
#endif
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Advapi32
+ internal static partial class Advapi32
{
[DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegDeleteKeyExW")]
internal static extern int RegDeleteKeyEx(SafeRegistryHandle hKey, string lpSubKey, int samDesired, int Reserved);
#endif
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Advapi32
+ internal static partial class Advapi32
{
[DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegDeleteValueW")]
internal static extern int RegDeleteValue(SafeRegistryHandle hKey, string? lpValueName);
#endif
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Advapi32
+ internal static partial class Advapi32
{
[DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegEnumKeyExW")]
internal static extern unsafe int RegEnumKeyEx(
using System;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Advapi32
+ internal static partial class Advapi32
{
[DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegEnumValueW")]
internal static extern unsafe int RegEnumValue(
#endif
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Advapi32
+ internal static partial class Advapi32
{
[DllImport(Libraries.Advapi32)]
internal static extern int RegFlushKey(SafeRegistryHandle hKey);
using System;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Advapi32
+ internal static partial class Advapi32
{
[DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegOpenKeyExW")]
internal static extern int RegOpenKeyEx(
using System.Runtime.InteropServices;
using System.Text;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Advapi32
+ internal static partial class Advapi32
{
[DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegQueryInfoKeyW")]
internal static extern int RegQueryInfoKey(
#endif
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Advapi32
+ internal static partial class Advapi32
{
[DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegQueryValueExW")]
internal static extern int RegQueryValueEx(
#endif
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Advapi32
+ internal static partial class Advapi32
{
[DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegSetValueExW")]
internal static extern int RegSetValueEx(
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Advapi32
+ internal static partial class Advapi32
{
internal static class RegistryOptions
{
using System;
using System.Diagnostics;
-internal partial class Interop
+internal static partial class Interop
{
internal static unsafe void GetRandomBytes(byte* buffer, int length)
{
using System;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class BCrypt
+ internal static partial class BCrypt
{
internal const int BCRYPT_USE_SYSTEM_PREFERRED_RNG = 0x00000002;
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class BCrypt
+ internal static partial class BCrypt
{
internal enum NTSTATUS : uint
{
using System.Runtime.InteropServices;
using System.Security;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Crypt32
+ internal static partial class Crypt32
{
internal const uint CRYPTPROTECTMEMORY_BLOCK_SIZE = 16;
internal const uint CRYPTPROTECTMEMORY_SAME_PROCESS = 0;
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-internal partial class Interop
+internal static partial class Interop
{
/// <summary>
/// Blittable version of Windows BOOL type. It is convenient in situations where
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-internal partial class Interop
+internal static partial class Interop
{
/// <summary>
/// Blittable version of Windows BOOLEAN type. It is convenient in situations where
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-internal partial class Interop
+internal static partial class Interop
{
// As defined in winerror.h and https://msdn.microsoft.com/en-us/library/windows/desktop/ms681382.aspx
- internal partial class Errors
+ internal static partial class Errors
{
internal const int ERROR_SUCCESS = 0x0;
internal const int ERROR_FILE_NOT_FOUND = 0x2;
using System.IO;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
internal unsafe struct CREATEFILE2_EXTENDED_PARAMETERS
{
using System.Runtime.InteropServices;
using System.Threading;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[DllImport(Libraries.Kernel32, SetLastError = true)]
internal static extern unsafe bool CancelIoEx(SafeHandle handle, NativeOverlapped* lpOverlapped);
using System;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[DllImport(Libraries.Kernel32, SetLastError = true)]
internal static extern bool CloseHandle(IntPtr handle);
using System.IO;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
/// <summary>
/// WARNING: This method does not implicitly handle long paths. Use CreateFile.
using System.IO;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[DllImport(Libraries.Kernel32, EntryPoint = "CreateFile2", SetLastError = true, CharSet = CharSet.Unicode)]
private static extern SafeFileHandle CreateFile2Private(
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[DllImport(Libraries.Kernel32, EntryPoint = "ExpandEnvironmentStringsW", CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern uint ExpandEnvironmentStrings(string lpSrc, ref char lpDst, uint nSize);
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
internal enum FILE_INFO_BY_HANDLE_CLASS : uint
{
using System;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
internal struct FILE_TIME
{
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
internal partial class FileAttributes
{
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[DllImport(Libraries.Kernel32)]
internal static extern unsafe Interop.BOOL FileTimeToSystemTime(long* lpFileTime, Interop.Kernel32.SYSTEMTIME* lpSystemTime);
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
internal partial class FileTypes
{
using System;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[DllImport(Libraries.Kernel32, SetLastError = true)]
internal static extern bool FindClose(IntPtr hFindFile);
using System.IO;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
/// <summary>
/// WARNING: This method does not implicitly handle long paths. Use FindFirstFile.
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[DllImport(Libraries.Kernel32, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
using System;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
private const int FORMAT_MESSAGE_IGNORE_INSERTS = 0x00000200;
private const int FORMAT_MESSAGE_FROM_HMODULE = 0x00000800;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[DllImport(Libraries.Kernel32, EntryPoint = "FreeEnvironmentStringsW", SetLastError = true, CharSet = CharSet.Unicode, BestFitMapping = false)]
internal static extern unsafe bool FreeEnvironmentStrings(char* lpszEnvironmentBlock);
using System;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
internal static extern bool FreeLibrary(IntPtr hModule);
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
internal enum GET_FILEEX_INFO_LEVELS : uint
{
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[StructLayout(LayoutKind.Sequential)]
internal unsafe struct CPINFO
using System;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, EntryPoint = "GetComputerNameW")]
private static extern unsafe int GetComputerName(ref char lpBuffer, ref uint nSize);
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[DllImport(Libraries.Kernel32, EntryPoint = "GetCurrentDirectoryW", SetLastError = true, CharSet = CharSet.Unicode, BestFitMapping = false)]
internal static extern uint GetCurrentDirectory(uint nBufferLength, ref char lpBuffer);
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[DllImport(Libraries.Kernel32)]
internal static extern uint GetCurrentProcessId();
using System;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[DllImport(Libraries.Kernel32)]
internal static extern IntPtr GetCurrentProcess();
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[DllImport(Libraries.Kernel32, EntryPoint = "GetEnvironmentStringsW", SetLastError = true, CharSet = CharSet.Unicode, BestFitMapping = false)]
internal static extern unsafe char* GetEnvironmentStrings();
using System;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
internal static unsafe int GetEnvironmentVariable(string lpName, Span<char> buffer)
{
using System.IO;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
/// <summary>
/// WARNING: This method does not implicitly handle long paths. Use GetFileAttributesEx.
using Microsoft.Win32.SafeHandles;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[DllImport(Libraries.Kernel32, SetLastError = true)]
internal static extern bool GetFileInformationByHandleEx(SafeFileHandle hFile, FILE_INFO_BY_HANDLE_CLASS FileInformationClass, out FILE_STANDARD_INFO lpFileInformation, uint dwBufferSize);
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[DllImport(Libraries.Kernel32, SetLastError = true)]
internal static extern int GetFileType(SafeHandle hFile);
using System;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
/// <summary>
/// WARNING: This method does not implicitly handle long paths. Use GetFullPathName or PathHelper.
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[DllImport(Libraries.Kernel32, SetLastError = true)]
internal static extern int GetLogicalDrives();
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
/// <summary>
/// WARNING: This method does not implicitly handle long paths. Use GetFullPath/PathHelper.
using System;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
internal const int ProcessLeapSecondInfo = 8;
using System;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[StructLayout(LayoutKind.Sequential)]
internal struct PROCESS_MEMORY_COUNTERS
using System;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[DllImport(Libraries.Kernel32, SetLastError = true)]
internal static extern bool GetProcessTimes(IntPtr handleProcess, out long creation, out long exit, out long kernel, out long user);
using System;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[DllImport(Libraries.Kernel32)]
internal static extern IntPtr GetStdHandle(int nStdHandle); // param is NOT a handle, but it returns one!
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[DllImport(Libraries.Kernel32)]
internal static extern void GetSystemInfo(out SYSTEM_INFO lpSystemInfo);
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[DllImport(Libraries.Kernel32)]
internal static extern unsafe void GetSystemTime(Interop.Kernel32.SYSTEMTIME* lpSystemTime);
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[DllImport(Libraries.Kernel32)]
internal static extern unsafe void GetSystemTimeAsFileTime(long* lpSystemTimeAsFileTime);
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[DllImport(Libraries.Kernel32)]
internal static extern unsafe void GetSystemTimePreciseAsFileTime(long* lpSystemTimeAsFileTime);
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[DllImport(Libraries.Kernel32, SetLastError = true)]
internal static extern bool GetSystemTimes(out long idle, out long kernel, out long user);
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true, BestFitMapping = false)]
internal static extern uint GetTempFileNameW(ref char lpPathName, string lpPrefixString, uint uUnique, ref char lpTempFileName);
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, BestFitMapping = false)]
internal static extern uint GetTempPathW(int bufferLen, ref char buffer);
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern bool GetVersionExW(ref OSVERSIONINFOEX osvi);
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
internal static unsafe bool GlobalMemoryStatusEx(ref MEMORYSTATUSEX buffer)
{
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
internal partial class HandleTypes
{
using System;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[DllImport(Libraries.Kernel32, SetLastError = true)]
internal static extern bool IsWow64Process(IntPtr hProcess, out bool Wow64Process);
using System;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
internal const int LOAD_LIBRARY_AS_DATAFILE = 0x00000002;
internal const int LOAD_LIBRARY_SEARCH_SYSTEM32 = 0x00000800;
using System;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
internal const uint LMEM_FIXED = 0x0000;
internal const uint LMEM_MOVEABLE = 0x0002;
using Microsoft.Win32.SafeHandles;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[DllImport(Libraries.Kernel32, SetLastError = true)]
internal static extern bool LockFile(SafeFileHandle handle, int offsetLow, int offsetHigh, int countLow, int countHigh);
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
internal const int MAX_PATH = 260;
}
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[StructLayout(LayoutKind.Sequential)]
internal struct MEMORYSTATUSEX
using System;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[StructLayout(LayoutKind.Sequential)]
internal unsafe struct MEMORY_BASIC_INFORMATION
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[DllImport(Libraries.Kernel32)]
internal static extern unsafe int MultiByteToWideChar(
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
internal unsafe struct OSVERSIONINFOEX
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[DllImport(Interop.Libraries.Kernel32, CharSet = CharSet.Unicode, EntryPoint = "OutputDebugStringW", ExactSpelling = true)]
internal static extern void OutputDebugString(string message);
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
// The actual native signature is:
// BOOL WINAPI QueryPerformanceCounter(
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
// The actual native signature is:
// BOOL WINAPI QueryPerformanceFrequency(
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[DllImport(Libraries.Kernel32)]
internal static extern bool QueryUnbiasedInterruptTime(out ulong UnbiasedTime);
using System;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[DllImport(Libraries.Kernel32, SetLastError = true)]
internal static extern unsafe int ReadFile(
using System.Runtime.InteropServices;
using System.Threading;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[DllImport(Libraries.Kernel32, SetLastError = true)]
internal static extern unsafe int ReadFile(
using System;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[StructLayout(LayoutKind.Sequential)]
internal struct SECURITY_ATTRIBUTES
using System;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[StructLayout(LayoutKind.Sequential)]
internal struct SYSTEM_INFO
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
- internal partial class SecurityOptions
+ internal static partial class SecurityOptions
{
internal const int SECURITY_SQOS_PRESENT = 0x00100000;
internal const int SECURITY_ANONYMOUS = 0 << 16;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[DllImport(Libraries.Kernel32, EntryPoint = "SetCurrentDirectoryW", SetLastError = true, CharSet = CharSet.Unicode, BestFitMapping = false)]
internal static extern bool SetCurrentDirectory(string path);
using Microsoft.Win32.SafeHandles;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[DllImport(Libraries.Kernel32, SetLastError = true)]
internal static extern bool SetEndOfFile(SafeFileHandle hFile);
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[DllImport(Libraries.Kernel32, EntryPoint = "SetEnvironmentVariableW", SetLastError = true, CharSet = CharSet.Unicode, BestFitMapping = false)]
internal static extern bool SetEnvironmentVariable(string lpName, string? lpValue);
using Microsoft.Win32.SafeHandles;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[DllImport(Libraries.Kernel32, SetLastError = true)]
internal static extern bool SetFilePointerEx(SafeFileHandle hFile, long liDistanceToMove, out long lpNewFilePointer, uint dwMoveMethod);
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[DllImport(Libraries.Kernel32, SetLastError = true, ExactSpelling = true)]
internal static extern bool SetThreadErrorMode(uint dwNewMode, out uint lpOldMode);
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[DllImport(Libraries.Kernel32)]
internal static extern unsafe Interop.BOOL SystemTimeToFileTime(Interop.Kernel32.SYSTEMTIME* lpSystemTime, long* lpFileTime);
using System;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[DllImport(Libraries.Kernel32)]
internal static extern unsafe Interop.BOOL TzSpecificLocalTimeToSystemTime(
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[DllImport(Libraries.Kernel32)]
internal static extern ulong VerSetConditionMask(ulong ConditionMask, uint TypeMask, byte Condition);
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
internal const byte VER_GREATER_EQUAL = 0x3;
internal const uint VER_MAJORVERSION = 0x0000002;
using System;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
internal const int MEM_COMMIT = 0x1000;
internal const int MEM_RESERVE = 0x2000;
using System;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[DllImport(Libraries.Kernel32)]
internal static extern unsafe bool VirtualFree(void* lpAddress, UIntPtr dwSize, int dwFreeType);
using System;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[DllImport(Libraries.Kernel32, SetLastError = true)]
internal static extern unsafe UIntPtr VirtualQuery(void* lpAddress, ref MEMORY_BASIC_INFORMATION lpBuffer, UIntPtr dwLength);
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
internal struct WIN32_FILE_ATTRIBUTE_DATA
{
using System;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
internal unsafe struct WIN32_FIND_DATA
using System;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
[DllImport(Libraries.Kernel32)]
internal static extern unsafe int WideCharToMultiByte(
using System;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
// Note there are two different WriteFile prototypes - this is to use
// the type system to force you to not trip across a "feature" in
using System;
using System.Runtime.InteropServices;
using System.Threading;
-internal partial class Interop
+
+internal static partial class Interop
{
- internal partial class Kernel32
+ internal static partial class Kernel32
{
// Note there are two different WriteFile prototypes - this is to use
// the type system to force you to not trip across a "feature" in
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Normaliz
+ internal static partial class Normaliz
{
//
// Idn APIs
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Normaliz
+ internal static partial class Normaliz
{
[DllImport("Normaliz.dll", CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern bool IsNormalizedString(int normForm, string source, int length);
using System;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class NtDll
+ internal static partial class NtDll
{
[DllImport(Libraries.NtDll, ExactSpelling = true)]
internal static extern unsafe int NtQueryInformationFile(
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class NtDll
+ internal static partial class NtDll
{
[DllImport(Libraries.NtDll)]
internal static extern unsafe int NtQuerySystemInformation(int SystemInformationClass, void* SystemInformation, int SystemInformationLength, uint* ReturnLength);
using System;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Ole32
+ internal static partial class Ole32
{
[DllImport(Libraries.Ole32)]
internal static extern IntPtr CoTaskMemAlloc(UIntPtr cb);
using System;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class OleAut32
+ internal static partial class OleAut32
{
[DllImport(Libraries.OleAut32)]
internal static extern IntPtr SysAllocStringByteLen(byte[]? str, uint len);
using System.Runtime.InteropServices;
using System.Security;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class OleAut32
+ internal static partial class OleAut32
{
[DllImport(Libraries.OleAut32, CharSet = CharSet.Unicode)]
internal static extern SafeBSTRHandle SysAllocStringLen(IntPtr src, uint len);
using System;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class OleAut32
+ internal static partial class OleAut32
{
[DllImport(Libraries.OleAut32)]
internal static extern void SysFreeString(IntPtr bstr);
using System.Runtime.InteropServices;
using System.Security;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class OleAut32
+ internal static partial class OleAut32
{
[DllImport(Libraries.OleAut32)]
internal static extern uint SysStringLen(SafeBSTRHandle bstr);
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Secur32
+ internal static partial class Secur32
{
[DllImport(Libraries.Secur32, CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern BOOLEAN GetUserNameExW(int NameFormat, ref char lpNameBuffer, ref uint lpnSize);
using System;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class Shell32
+ internal static partial class Shell32
{
internal const int COR_E_PLATFORMNOTSUPPORTED = unchecked((int)0x80131539);
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class User32
+ internal static partial class User32
{
internal const int HWND_BROADCAST = 0xffff;
internal const int WM_SETTINGCHANGE = 0x001A;
using System.Runtime.InteropServices;
using Microsoft.Win32.SafeHandles;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class User32
+ internal static partial class User32
{
[DllImport(Libraries.User32, SetLastError = true, EntryPoint = "LoadStringW", CharSet = CharSet.Unicode)]
internal static extern unsafe int LoadString(SafeLibraryHandle hInstance, uint uID, char* lpBuffer, int cchBufferMax);
using System;
using System.Runtime.InteropServices;
-internal partial class Interop
+internal static partial class Interop
{
- internal partial class User32
+ internal static partial class User32
{
[DllImport(Libraries.User32, EntryPoint = "SendMessageTimeoutW", CharSet = CharSet.Unicode)]
public static extern IntPtr SendMessageTimeout(IntPtr hWnd, int msg, IntPtr wParam, string lParam, int flags, int timeout, IntPtr pdwResult);
[AttributeUsage(AttributeTargets.Class, Inherited = true)]
public sealed class AttributeUsageAttribute : Attribute
{
- private readonly AttributeTargets _attributeTarget = AttributeTargets.All; // Defaults to all
+ private readonly AttributeTargets _attributeTarget; // Defaults to all
private bool _allowMultiple = false; // Defaults to false
private bool _inherited = true; // Defaults to true
===========================================================*/
using System.Diagnostics;
-using System.Diagnostics.CodeAnalysis;
namespace System.Collections
{
// 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.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Reflection;
using System.Threading;
using BitOperations = Microsoft.Diagnostics.Tracing.Internal.BitOperations;
#endif
using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Numerics;
using System.Runtime.InteropServices;
return m_eventProvider.EventRegister(eventSource, enableCallback, null, ref m_regHandle);
}
- private uint EventUnregister(long registrationHandle)
- {
- return m_eventProvider.EventUnregister(registrationHandle);
- }
+ private void EventUnregister(long registrationHandle) =>
+ m_eventProvider.EventUnregister(registrationHandle);
#if PLATFORM_WINDOWS
private static bool m_setInformationMissing;
{
if (attrib.Guid != null)
{
- Guid g = Guid.Empty;
#if !ES_BUILD_AGAINST_DOTNET_V35
- if (Guid.TryParse(attrib.Guid, out g))
+ if (Guid.TryParse(attrib.Guid, out Guid g))
return g;
#else
try { return new Guid(attrib.Guid); }
#endif
m_outOfBandMessageCount = 0;
- bool shouldReport = (commandArgs.perEventSourceSessionId > 0) && (commandArgs.perEventSourceSessionId <= SessionMask.MAX);
try
{
EnsureDescriptorsInitialized();
// Send out the ETW manifest XML out to ETW
// Today, we only send the manifest to ETW, custom listeners don't get it.
- private unsafe bool SendManifest(byte[]? rawManifest)
+ private unsafe void SendManifest(byte[]? rawManifest)
{
- bool success = true;
-
if (rawManifest == null)
- return false;
+ return;
Debug.Assert(!SelfDescribingEvents);
goto TRY_AGAIN_WITH_SMALLER_CHUNK_SIZE;
}
}
- success = false;
+
if (ThrowOnEventWriteErrors)
ThrowEventSourceException("SendManifest");
break;
}
}
#endif // FEATURE_MANAGED_ETW
- return success;
}
#if (ES_BUILD_PCL)
}
#if (!ES_BUILD_PCL && !ES_BUILD_PN)
- // In the reflection only context, we have to do things by hand.
- string fullTypeNameToFind = attributeType.FullName!;
-
-#if EVENT_SOURCE_LEGACY_NAMESPACE_SUPPORT
- fullTypeNameToFind = fullTypeNameToFind.Replace("System.Diagnostics.Eventing", "System.Diagnostics.Tracing");
-#endif
-
foreach (CustomAttributeData data in CustomAttributeData.GetCustomAttributes(member))
{
if (AttributeTypeNamesMatch(attributeType, data.Constructor.ReflectedType!))
internal static uint s_currentPid; // current process id, used in synthesizing quasi-GUIDs
[ThreadStatic]
- private static byte m_EventSourceExceptionRecurenceCount = 0; // current recursion count inside ThrowEventSourceException
+ private static byte m_EventSourceExceptionRecurenceCount; // current recursion count inside ThrowEventSourceException
[ThreadStatic]
- private static bool m_EventSourceInDecodeObject = false;
+ private static bool m_EventSourceInDecodeObject;
#if FEATURE_MANAGED_ETW_CHANNELS
internal volatile ulong[]? m_channelData;
/// and another EventSource is created as part of the process.
/// </summary>
[ThreadStatic]
- private static bool s_ConnectingEventSourcesAndListener = false;
+ private static bool s_ConnectingEventSourcesAndListener;
#endif
/// <summary>
break;
case 'r':
case 'R': // RFC 1123 Standard
+ case 'u': // Universal time in sortable format.
if (offset != NullOffset)
{
// Convert to UTC invariants mean this will be in range
case 's': // Sortable without Time Zone Info
dtfi = DateTimeFormatInfo.InvariantInfo;
break;
- case 'u': // Universal time in sortable format.
- if (offset != NullOffset)
- {
- // Convert to UTC invariants mean this will be in range
- dateTime -= offset;
- }
- dtfi = DateTimeFormatInfo.InvariantInfo;
- break;
case 'U': // Universal time in culture dependent format.
if (offset != NullOffset)
{
// with this issue.
if ((result.flags & ParseFlags.CaptureOffset) != 0)
{
- if ((result.flags & ParseFlags.Rfc1123Pattern) != 0 && quotedStr == GMTName)
- {
- result.flags |= ParseFlags.TimeZoneUsed;
- result.timeZoneOffset = TimeSpan.Zero;
- }
- else if ((result.flags & ParseFlags.UtcSortPattern) != 0 && quotedStr == ZuluName)
+ if (((result.flags & ParseFlags.Rfc1123Pattern) != 0 && quotedStr == GMTName) ||
+ ((result.flags & ParseFlags.UtcSortPattern) != 0 && quotedStr == ZuluName))
{
result.flags |= ParseFlags.TimeZoneUsed;
result.timeZoneOffset = TimeSpan.Zero;
0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366
};
- internal int m_maxYear = 9999;
+ internal int m_maxYear;
internal int m_minYear;
internal Calendar m_Cal;
using System.Buffers.Binary;
using System.Diagnostics;
using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
using System.Text;
namespace System.IO
char* digits = stackalloc char[MaxUInt32DecDigits];
char* p = UInt32ToDecChars(digits + MaxUInt32DecDigits, (uint)value, minDigits);
- int i = (int)(digits + MaxUInt32DecDigits - p);
sb.Append(p, (int)(digits + MaxUInt32DecDigits - p));
}
{
case '\'':
case '"':
- while (src < format.Length && pFormat[src] != 0 && pFormat[src++] != ch)
- ;
+ while (src < format.Length && pFormat[src] != 0 && pFormat[src++] != ch) ;
break;
case '\\':
if (src < format.Length && pFormat[src] != 0)
short maxSize = (short)Math.Min(end - i, (int)c_MaxUnicodeCharsReallocate - 1);
short count = 1;
- for (; count < maxSize && pStr[i + count] > '\x7f'; ++count)
- ;
+ for (; count < maxSize && pStr[i + count] > '\x7f'; ++count) ;
// Is the last a high surrogate?
if (pStr[i + count - 1] >= 0xD800 && pStr[i + count - 1] <= 0xDBFF)
}
prevInputPos = i + 1;
}
- else if (ch == force1 || ch == force2)
- {
- dest = EnsureDestinationSize(pStr, dest, i, c_EncodedCharsPerByte,
- c_MaxAsciiCharsReallocate * c_EncodedCharsPerByte, ref destPos, prevInputPos);
- EscapeAsciiChar(ch, dest, ref destPos);
- prevInputPos = i + 1;
- }
- else if (ch != rsvd && (isUriString ? !IsReservedUnreservedOrHash(ch) : !IsUnreserved(ch)))
+ else if (ch == force1 || ch == force2 || (ch != rsvd && (isUriString ? !IsReservedUnreservedOrHash(ch) : !IsUnreserved(ch))))
{
dest = EnsureDestinationSize(pStr, dest, i, c_EncodedCharsPerByte,
c_MaxAsciiCharsReallocate * c_EncodedCharsPerByte, ref destPos, prevInputPos);
// there is any outstanding enumerator, no compaction is performed.
private ConditionalWeakTable<TKey, TValue>? _table; // parent table, set to null when disposed
- private readonly int _maxIndexInclusive; // last index in the container that should be enumerated
- private int _currentIndex = -1; // the current index into the container
- private KeyValuePair<TKey, TValue> _current; // the current entry set by MoveNext and returned from Current
+ private readonly int _maxIndexInclusive; // last index in the container that should be enumerated
+ private int _currentIndex; // the current index into the container
+ private KeyValuePair<TKey, TValue> _current; // the current entry set by MoveNext and returned from Current
public Enumerator(ConditionalWeakTable<TKey, TValue> table)
{
// See the LICENSE file in the project root for more information.
using System.Diagnostics;
-using System.Diagnostics.CodeAnalysis;
using System.Runtime.ConstrainedExecution;
using System.Threading;
// returns whether there is enough space. In all cases, we update
// our last known free address space, hopefully avoiding needing to
// probe again.
- private static bool CheckForFreeAddressSpace(ulong size, bool shouldThrow)
+ private static void CheckForFreeAddressSpace(ulong size, bool shouldThrow)
{
// Unreachable until CheckForAvailableMemory is implemented
- return false;
}
// Allocate a specified number of bytes, commit them and free them. This should enlarge
return true;
}
- // Based on the shouldThrow parameter, this will throw an exception, or
- // returns whether there is enough space. In all cases, we update
- // our last known free address space, hopefully avoiding needing to
- // probe again.
- private static unsafe bool CheckForFreeAddressSpace(ulong size, bool shouldThrow)
+ // Based on the shouldThrow parameter, this will throw an exception.
+ // In all cases, we update our last known free address space, hopefully
+ // avoiding needing to probe again.
+ private static unsafe void CheckForFreeAddressSpace(ulong size, bool shouldThrow)
{
// Start walking the address space at 0. VirtualAlloc may wrap
// around the address space. We don't need to find the exact
if (freeSpaceAfterGCHeap < size && shouldThrow)
throw new InsufficientMemoryException(SR.InsufficientMemory_MemFailPoint_VAFrag);
- return freeSpaceAfterGCHeap >= size;
}
// Returns the amount of consecutive free memory available in a block
set => Volatile.Write(ref s_hiddenLastKnownFreeAddressSpace, value);
}
- private static long AddToLastKnownFreeAddressSpace(long addend) =>
+ private static void AddToLastKnownFreeAddressSpace(long addend) =>
Interlocked.Add(ref s_hiddenLastKnownFreeAddressSpace, addend);
private static long LastTimeCheckingAddressSpace
if (value == null)
return null;
- if (ReferenceEquals(foundType, type) || type.IsAssignableFrom(foundType) || value == null)
+ if (ReferenceEquals(foundType, type) || type.IsAssignableFrom(foundType))
{
return value;
}
newValue ??= string.Empty;
- int deltaLength = newValue.Length - oldValue.Length;
-
int[]? replacements = null; // A list of replacement positions in a chunk to apply
int replacementsCount = 0;
{
// Replacing mutates the blocks, so we need to convert to a logical index and back afterwards.
int index = indexInChunk + chunk.m_ChunkOffset;
- int indexBeforeAdjustment = index;
// See if we accumulated any replacements, if so apply them.
Debug.Assert(replacements != null || replacementsCount == 0, "replacements was null and replacementsCount != 0");
// 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.Text
{
/// <summary>
// 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.CompilerServices;
using System.Runtime.InteropServices;
using Internal.Runtime.CompilerServices;
/// being stored and used. The event will be signaled or unsignaled depending on
/// the state of the thin-event itself, with synchronization taken into account.
/// </summary>
- /// <returns>True if a new event was created and stored, false otherwise.</returns>
- private bool LazyInitializeEvent()
+ private void LazyInitializeEvent()
{
bool preInitializeIsSet = IsSet;
ManualResetEvent newEventObj = new ManualResetEvent(preInitializeIsSet);
{
// Someone else set the value due to a race condition. Destroy the garbage event.
newEventObj.Dispose();
-
- return false;
}
else
{
}
}
}
-
- return true;
}
}
using System.Collections.Generic;
using System.Diagnostics;
-using System.Diagnostics.CodeAnalysis;
namespace System.Threading.Tasks
{
// touch all Task.Id fields so that the debugger doesn't need to do a lot of cross-proc calls to generate them
foreach (Task t in activeTasksArray)
{
- int tmp = t.Id;
+ _ = t.Id;
}
return activeTasksArray;
foreach (TaskScheduler scheduler in arr)
{
Debug.Assert(scheduler != null, "Table returned an incorrect Count or CopyTo failed");
- int tmp = scheduler.Id; // force Ids for debugger
+ _ = scheduler.Id; // force Ids for debugger
}
return arr;
}
}
/// <summary>ETW tasks that have start/stop events.</summary>
- public class Tasks // this name is important for EventSource
+ public static class Tasks // this name is important for EventSource
{
/// <summary>A parallel loop.</summary>
public const EventTask Loop = (EventTask)1;
public const EventTask TraceSynchronousWork = (EventTask)9;
}
- public class Keywords // thisname is important for EventSource
+ public static class Keywords // this name is important for EventSource
{
/// <summary>
/// Only the most basic information about the workings of the task library
}
}
+ /// <summary>
+ /// Normalize adjustment rule offset so that it is within valid range
+ /// This method should not be called at all but is here in case something changes in the future
+ /// or if really old time zones are present on the OS (no combination is known at the moment)
+ /// </summary>
+ private static void NormalizeAdjustmentRuleOffset(TimeSpan baseUtcOffset, [NotNull] ref AdjustmentRule adjustmentRule)
+ {
+ // Certain time zones such as:
+ // Time Zone start date end date offset
+ // -----------------------------------------------------
+ // America/Yakutat 0001-01-01 1867-10-18 14:41:00
+ // America/Yakutat 1867-10-18 1900-08-20 14:41:00
+ // America/Sitka 0001-01-01 1867-10-18 14:58:00
+ // America/Sitka 1867-10-18 1900-08-20 14:58:00
+ // Asia/Manila 0001-01-01 1844-12-31 -15:56:00
+ // Pacific/Guam 0001-01-01 1845-01-01 -14:21:00
+ // Pacific/Saipan 0001-01-01 1845-01-01 -14:21:00
+ //
+ // have larger offset than currently supported by framework.
+ // If for whatever reason we find that time zone exceeding max
+ // offset of 14h this function will truncate it to the max valid offset.
+ // Updating max offset may cause problems with interacting with SQL server
+ // which uses SQL DATETIMEOFFSET field type which was originally designed to be
+ // bit-for-bit compatible with DateTimeOffset.
+
+ TimeSpan utcOffset = GetUtcOffset(baseUtcOffset, adjustmentRule);
+
+ // utc base offset delta increment
+ TimeSpan adjustment = TimeSpan.Zero;
+
+ if (utcOffset > MaxOffset)
+ {
+ adjustment = MaxOffset - utcOffset;
+ }
+ else if (utcOffset < MinOffset)
+ {
+ adjustment = MinOffset - utcOffset;
+ }
+
+ if (adjustment != TimeSpan.Zero)
+ {
+ adjustmentRule = AdjustmentRule.CreateAdjustmentRule(
+ adjustmentRule.DateStart,
+ adjustmentRule.DateEnd,
+ adjustmentRule.DaylightDelta,
+ adjustmentRule.DaylightTransitionStart,
+ adjustmentRule.DaylightTransitionEnd,
+ adjustmentRule.BaseUtcOffsetDelta + adjustment,
+ adjustmentRule.NoDaylightTransitions);
+ }
+ }
+
private struct TZifType
{
public const int Length = 6;
TimeSpan utcOffset = GetUtcOffset(baseUtcOffset, adjustmentRule);
return !UtcOffsetOutOfRange(utcOffset);
}
-
- /// <summary>
- /// Normalize adjustment rule offset so that it is within valid range
- /// This method should not be called at all but is here in case something changes in the future
- /// or if really old time zones are present on the OS (no combination is known at the moment)
- /// </summary>
- private static void NormalizeAdjustmentRuleOffset(TimeSpan baseUtcOffset, [NotNull] ref AdjustmentRule adjustmentRule)
- {
- // Certain time zones such as:
- // Time Zone start date end date offset
- // -----------------------------------------------------
- // America/Yakutat 0001-01-01 1867-10-18 14:41:00
- // America/Yakutat 1867-10-18 1900-08-20 14:41:00
- // America/Sitka 0001-01-01 1867-10-18 14:58:00
- // America/Sitka 1867-10-18 1900-08-20 14:58:00
- // Asia/Manila 0001-01-01 1844-12-31 -15:56:00
- // Pacific/Guam 0001-01-01 1845-01-01 -14:21:00
- // Pacific/Saipan 0001-01-01 1845-01-01 -14:21:00
- //
- // have larger offset than currently supported by framework.
- // If for whatever reason we find that time zone exceeding max
- // offset of 14h this function will truncate it to the max valid offset.
- // Updating max offset may cause problems with interacting with SQL server
- // which uses SQL DATETIMEOFFSET field type which was originally designed to be
- // bit-for-bit compatible with DateTimeOffset.
-
- TimeSpan utcOffset = GetUtcOffset(baseUtcOffset, adjustmentRule);
-
- // utc base offset delta increment
- TimeSpan adjustment = TimeSpan.Zero;
-
- if (utcOffset > MaxOffset)
- {
- adjustment = MaxOffset - utcOffset;
- }
- else if (utcOffset < MinOffset)
- {
- adjustment = MinOffset - utcOffset;
- }
-
- if (adjustment != TimeSpan.Zero)
- {
- adjustmentRule = AdjustmentRule.CreateAdjustmentRule(
- adjustmentRule.DateStart,
- adjustmentRule.DateEnd,
- adjustmentRule.DaylightDelta,
- adjustmentRule.DaylightTransitionStart,
- adjustmentRule.DaylightTransitionEnd,
- adjustmentRule.BaseUtcOffsetDelta + adjustment,
- adjustmentRule.NoDaylightTransitions);
- }
- }
}
}