{
// Make sure that the _source field is initialized if Source is not overriden.
// We want it to contain the original faulting point.
- string? source = Source;
+ _ = Source;
string? tmpStackTraceString = StackTrace;
WinRT_IEnumerable<KeyValuePair<K, V>>(null, null, null);
// instantiate stubs for commonly used methods on IDictionary<K, V> and ICollection<KeyValuePair<K, V>>
- V dummy;
mapToDictionaryAdapter.Indexer_Get<K, V>(default);
mapToDictionaryAdapter.Indexer_Set<K, V>(default, default);
mapToDictionaryAdapter.ContainsKey<K, V>(default);
mapToDictionaryAdapter.Add<K, V>(default, default);
mapToDictionaryAdapter.Remove<K, V>(default);
- mapToDictionaryAdapter.TryGetValue<K, V>(default, out dummy);
+ mapToDictionaryAdapter.TryGetValue<K, V>(default, out _);
mapToCollectionAdapter.Count<K, V>();
mapToCollectionAdapter.Add<K, V>(new KeyValuePair<K, V>(default, default));
mapToCollectionAdapter.Clear<K, V>();
WinRT_IReadOnlyCollection<KeyValuePair<K, V>>(null);
// instantiate stubs for commonly used methods on IReadOnlyDictionary<K, V>
- V dummy;
mapToDictionaryAdapter.Indexer_Get<K, V>(default);
mapToDictionaryAdapter.ContainsKey<K, V>(default);
- mapToDictionaryAdapter.TryGetValue<K, V>(default, out dummy);
+ mapToDictionaryAdapter.TryGetValue<K, V>(default, out _);
// instantiate stubs for commonly used methods in IReadOnlyCollection<T>
mapViewToReadOnlyCollectionAdapter.Count<K, V>();
internal ConstructorBuilder(string name, MethodAttributes attributes, CallingConventions callingConvention,
Type[]? parameterTypes, Type[][]? requiredCustomModifiers, Type[][]? optionalCustomModifiers, ModuleBuilder mod, TypeBuilder type)
{
- int sigLength;
- byte[] sigBytes;
- MethodToken token;
-
m_methodBuilder = new MethodBuilder(name, attributes, callingConvention, null, null, null,
parameterTypes, requiredCustomModifiers, optionalCustomModifiers, mod, type, false);
type.m_listMethods.Add(m_methodBuilder);
- sigBytes = m_methodBuilder.GetMethodSignature().InternalGetSignature(out sigLength);
+ m_methodBuilder.GetMethodSignature().InternalGetSignature(out _);
- token = m_methodBuilder.GetToken();
+ m_methodBuilder.GetToken();
}
internal ConstructorBuilder(string name, MethodAttributes attributes, CallingConventions callingConvention,
Guid languageVendor,
Guid documentType)
{
- PunkSafeHandle psymUnmanagedDocumentWriter = new PunkSafeHandle();
-
+ PunkSafeHandle psymUnmanagedDocumentWriter;
int hr = m_vtable.DefineDocument(m_pWriter, url, ref language, ref languageVendor, ref documentType, out psymUnmanagedDocumentWriter);
if (hr < 0)
{
internal Type[] GetTypesNoLock()
{
- int size = _typeBuilderDict.Count;
Type[] typeList = new Type[_typeBuilderDict.Count];
int i = 0;
internal int GetMethodTokenInternal(MethodBase method, IEnumerable<Type>? optionalParameterTypes, bool useMethodDef)
{
- int tk = 0;
+ int tk;
MethodInfo? methodInfo = method as MethodInfo;
if (method.IsGenericMethod)
if (TypeBuilder.IsTypeEqual(c, this))
return true;
- Type? fromRuntimeType = null;
+ Type fromRuntimeType;
TypeBuilder? fromTypeBuilder = c as TypeBuilder;
if (fromTypeBuilder != null)
#region Private Static Members
internal static FieldInfo GetField(FieldInfo Field, TypeBuilderInstantiation type)
{
- FieldInfo? m = null;
+ FieldInfo m;
// This ifdef was introduced when non-generic collections were pulled from
// silverlight. See code:Dictionary#DictionaryVersusHashtableThreadSafety
public ConstArray GetMemberRefProps(int memberTokenRef)
{
- ConstArray signature = new ConstArray();
-
+ ConstArray signature;
_GetMemberRefProps(m_metadataImport2, memberTokenRef, out signature);
return signature;
public override unsafe Stream? GetManifestResourceStream(string name)
{
- uint length = 0;
+ uint length;
RuntimeAssembly runtimeAssembly = this;
byte* pbInMemoryResource = GetResource(JitHelpers.GetQCallAssemblyOnStack(ref runtimeAssembly), name, out length);
scope.GetEventProps(tkEvent, out m_utf8name, out m_flags);
- RuntimeMethodInfo? dummy;
Associates.AssignAssociates(scope, tkEvent, declaredType, reflectedType,
out m_addMethod, out m_removeMethod, out m_raiseMethod,
- out dummy, out dummy, out m_otherMethod, out isPrivate, out m_bindingFlags);
+ out _, out _, out m_otherMethod, out isPrivate, out m_bindingFlags);
}
#endregion
{
Debug.Assert(method is RuntimeMethodInfo || method is RuntimeConstructorInfo);
- ParameterInfo? dummy;
- return GetParameters(method, member, sig, out dummy, false);
+ return GetParameters(method, member, sig, out _, false);
}
internal static unsafe ParameterInfo GetReturnParameter(IRuntimeMethodInfo method, MemberInfo member, Signature sig)
m_reflectedTypeCache = reflectedTypeCache;
m_declaringType = declaredType;
- ConstArray sig;
- scope.GetPropertyProps(tkProperty, out m_utf8name, out m_flags, out sig);
+ scope.GetPropertyProps(tkProperty, out m_utf8name, out m_flags, out _);
- RuntimeMethodInfo? dummy;
Associates.AssignAssociates(scope, tkProperty, declaredType, reflectedTypeCache.GetRuntimeType(),
- out dummy, out dummy, out dummy,
+ out _, out _, out _,
out m_getterMethod, out m_setterMethod, out m_otherMethod,
out isPrivate, out m_bindingFlags);
}
{
if (m_signature == null)
{
- PropertyAttributes flags;
ConstArray sig;
- void* name;
GetRuntimeModule().MetadataImport.GetPropertyProps(
- m_token, out name, out flags, out sig);
+ m_token, out _, out _, out sig);
- m_signature = new Signature(sig.Signature.ToPointer(), (int)sig.Length, m_declaringType);
+ m_signature = new Signature(sig.Signature.ToPointer(), sig.Length, m_declaringType);
}
return m_signature;
{
IBindableVector _this = Unsafe.As<IBindableVector>(this);
- uint index;
- return _this.IndexOf(item, out index);
+ return _this.IndexOf(item, out _);
}
// void Clear()
}
- public int Count
- {
- get
- {
- return lastItemIndex - firstItemIndex + 1;
- }
- }
-
+ public int Count => lastItemIndex - firstItemIndex + 1;
// [CLSCompliant(false)]
- public uint Size
- {
- get
- {
- return (uint)(lastItemIndex - firstItemIndex + 1);
- }
- }
-
+ public uint Size => (uint)(lastItemIndex - firstItemIndex + 1);
public TValue Lookup(TKey key)
{
}
- public bool HasKey(TKey key)
- {
- TValue value;
- bool hasKey = TryGetValue(key, out value);
- return hasKey;
- }
+ public bool HasKey(TKey key) =>
+ TryGetValue(key, out _);
- IEnumerator IEnumerable.GetEnumerator()
- {
- return ((IEnumerable<IKeyValuePair<TKey, TValue>>)this).GetEnumerator();
- }
+ IEnumerator IEnumerable.GetEnumerator() =>
+ ((IEnumerable<IKeyValuePair<TKey, TValue>>)this).GetEnumerator();
- public IIterator<IKeyValuePair<TKey, TValue>> First()
- {
- return new EnumeratorToIteratorAdapter<IKeyValuePair<TKey, TValue>>(GetEnumerator());
- }
+ public IIterator<IKeyValuePair<TKey, TValue>> First() =>
+ new EnumeratorToIteratorAdapter<IKeyValuePair<TKey, TValue>>(GetEnumerator());
- public IEnumerator<IKeyValuePair<TKey, TValue>> GetEnumerator()
- {
- return new IKeyValuePairEnumerator(items, firstItemIndex, lastItemIndex);
- }
+ public IEnumerator<IKeyValuePair<TKey, TValue>> GetEnumerator() =>
+ new IKeyValuePairEnumerator(items, firstItemIndex, lastItemIndex);
public void Split(out IMapView<TKey, TValue>? firstPartition, out IMapView<TKey, TValue>? secondPartition)
{
}
}
- object? IEnumerator.Current
- {
- get
- {
- return Current;
- }
- }
+ object? IEnumerator.Current => Current;
- void IEnumerator.Reset()
- {
+ void IEnumerator.Reset() =>
_current = _start - 1;
- }
public void Dispose()
{
// take a dependency upon it. (Simply applying the hash-value algorithm directly won't work in the
// case of collisions, where we'll use a different token value).
- uint handlerHashCode = 0;
+ uint handlerHashCode;
Delegate[] invocationList = ((Delegate)(object)handler).GetInvocationList();
if (invocationList.Length == 1)
{
{
IVector<KeyValuePair<K, V>> _this_vector = Unsafe.As<IVector<KeyValuePair<K, V>>>(this);
- uint index;
- return _this_vector.IndexOf(item, out index);
+ return _this_vector.IndexOf(item, out _);
}
}
{
IVector<T> _this = Unsafe.As<IVector<T>>(this);
- uint index;
- return _this.IndexOf(item, out index);
+ return _this.IndexOf(item, out _);
}
// void CopyTo(T[] array, int arrayIndex)
for (int i = 0; i < tkNestedClasses.Length; i++)
{
- RuntimeType? nestedType = null;
+ RuntimeType nestedType;
try
{
}
// Used by the singular GetXXX APIs (Event, Field, Interface, NestedType) where prefixLookup is not supported.
- private static void FilterHelper(BindingFlags bindingFlags, ref string name, out bool ignoreCase, out MemberListType listType)
- {
- bool prefixLookup;
- FilterHelper(bindingFlags, ref name!, false, out prefixLookup, out ignoreCase, out listType);
- }
+ private static void FilterHelper(BindingFlags bindingFlags, ref string name, out bool ignoreCase, out MemberListType listType) =>
+ FilterHelper(bindingFlags, ref name!, false, out _, out ignoreCase, out listType);
// Only called by GetXXXCandidates, GetInterfaces, and GetNestedTypes when FilterHelper has set "prefixLookup" to true.
// Most of the plural GetXXX methods allow prefix lookups while the singular GetXXX methods mostly do not.
private ListBuilder<Type> GetNestedTypeCandidates(string? fullname, BindingFlags bindingAttr, bool allowPrefixLookup)
{
- bool prefixLookup, ignoreCase;
+ bool prefixLookup;
bindingAttr &= ~BindingFlags.Static;
string? name, ns;
MemberListType listType;
SplitName(fullname, out name, out ns);
- FilterHelper(bindingAttr, ref name, allowPrefixLookup, out prefixLookup, out ignoreCase, out listType);
+ FilterHelper(bindingAttr, ref name, allowPrefixLookup, out prefixLookup, out _, out listType);
RuntimeType[] cache = Cache.GetNestedTypeList(listType, name);
}
// Get native two digit year max
- internal static int GetTwoDigitYearMax(CalendarId calendarId)
- {
- if (GlobalizationMode.Invariant)
- {
- return Invariant.iTwoDigitYearMax;
- }
-
- int twoDigitYearMax = -1;
-
- if (!CallGetCalendarInfoEx(null, calendarId, (uint)CAL_ITWODIGITYEARMAX, out twoDigitYearMax))
- {
- twoDigitYearMax = -1;
- }
-
- return twoDigitYearMax;
- }
+ internal static int GetTwoDigitYearMax(CalendarId calendarId) =>
+ GlobalizationMode.Invariant ? Invariant.iTwoDigitYearMax :
+ CallGetCalendarInfoEx(null, calendarId, CAL_ITWODIGITYEARMAX, out int twoDigitYearMax) ? twoDigitYearMax :
+ -1;
// Call native side to figure out which calendars are allowed
internal static int GetCalendars(string localeName, bool useUserOverride, CalendarId[] calendars)
{
Debug.Assert(!GlobalizationMode.Invariant);
- string data;
// Taiwanese calendar get listed as one of the optional zh-TW calendars only when having zh-TW UI
- return CallGetCalendarInfoEx("zh-TW", CalendarId.TAIWAN, CAL_SCALNAME, out data);
+ return CallGetCalendarInfoEx("zh-TW", CalendarId.TAIWAN, CAL_SCALNAME, out _);
}
// PAL Layer ends here
////////////////////////////////////////////////////////////////////////
private static void CheckSpecialCalendar(ref CalendarId calendar, ref string localeName)
{
- string data;
// Gregorian-US isn't always available in the OS, however it is the same for all locales
switch (calendar)
{
case CalendarId.GREGORIAN_US:
// See if this works
- if (!CallGetCalendarInfoEx(localeName, calendar, CAL_SCALNAME, out data))
+ if (!CallGetCalendarInfoEx(localeName, calendar, CAL_SCALNAME, out _))
{
// Failed, set it to a locale (fa-IR) that's alway has Gregorian US available in the OS
localeName = "fa-IR";
}
// See if that works
- if (!CallGetCalendarInfoEx(localeName, calendar, CAL_SCALNAME, out data))
+ if (!CallGetCalendarInfoEx(localeName, calendar, CAL_SCALNAME, out _))
{
// Failed again, just use en-US with the gregorian calendar
localeName = "en-US";
internal static DateTime ParseExact(ReadOnlySpan<char> s, ReadOnlySpan<char> format, DateTimeFormatInfo dtfi, DateTimeStyles style)
{
- DateTimeResult result = new DateTimeResult(); // The buffer to store the parsing result.
+ DateTimeResult result = default; // The buffer to store the parsing result.
result.Init(s);
if (TryParseExact(s, format, dtfi, style, ref result))
{
internal static DateTime ParseExact(ReadOnlySpan<char> s, ReadOnlySpan<char> format, DateTimeFormatInfo dtfi, DateTimeStyles style, out TimeSpan offset)
{
- DateTimeResult result = new DateTimeResult(); // The buffer to store the parsing result.
- offset = TimeSpan.Zero;
+ DateTimeResult result = default; // The buffer to store the parsing result.
result.Init(s);
result.flags |= ParseFlags.CaptureOffset;
if (TryParseExact(s, format, dtfi, style, ref result))
DateTimeFormatInfo dtfi, DateTimeStyles style, out TimeSpan offset)
{
DateTimeResult result = new DateTimeResult(); // The buffer to store the parsing result.
- offset = TimeSpan.Zero;
result.Init(s);
result.flags |= ParseFlags.CaptureOffset;
if (TryParseExactMultiple(s, formats, dtfi, style, ref result))
private static bool ParseTimeZone(ref __DTString str, ref TimeSpan result)
{
// The hour/minute offset for timezone.
- int hourOffset = 0;
+ int hourOffset;
int minuteOffset = 0;
DTSubString sub;
return;
}
- tokenType = TokenType.UnknownToken;
-
Start:
if (DateTimeParse.IsDigit(m_current))
{
if (!DateTimeParse.IsDigit(m_current))
{
// Not a digit. Tokenize it.
- int tokenValue;
- bool found = dtfi.Tokenize(TokenType.SeparatorTokenMask, out tokenType, out tokenValue, ref this);
+ bool found = dtfi.Tokenize(TokenType.SeparatorTokenMask, out tokenType, out _, ref this);
if (!found)
{
tokenType = TokenType.SEP_Space;
// This will store the result of the parsing. And it will be eventually
// used to construct a DateTime instance.
//
- internal
- ref struct DateTimeResult
+ internal ref struct DateTimeResult
{
internal int Year;
internal int Month;
{
CheckTicksRange(time.Ticks);
- TimeToLunar(time, out int year, out int month, out int day);
+
+ TimeToLunar(time, out int year, out _, out _);
return ((year - 4) % 60) + 1;
}
public override int GetDayOfMonth(DateTime time)
{
CheckTicksRange(time.Ticks);
- TimeToLunar(time, out int y, out int m, out int d);
+
+ TimeToLunar(time, out _, out _, out int d);
return d;
}
public override int GetMonth(DateTime time)
{
CheckTicksRange(time.Ticks);
- TimeToLunar(time, out int y, out int m, out int d);
+
+ TimeToLunar(time, out _, out int m, out _);
return m;
}
public override int GetYear(DateTime time)
{
CheckTicksRange(time.Ticks);
- TimeToLunar(time, out int y, out int m, out int d);
+
+ TimeToLunar(time, out int y, out _, out _);
return GetYear(y, time);
}
// Returns the number of months in the specified year and era.
public int GetMonthsInYear(int year, int era)
{
- year = GetGregorianYear(year, era);
- return (12);
+ GetGregorianYear(year, era);
+ return 12;
}
// Returns the year part of the specified DateTime. The returned value is an
//
public int GetLeapMonth(int year, int era)
{
- year = GetGregorianYear(year, era);
- return (0);
+ GetGregorianYear(year, era);
+ return 0;
}
// Checks whether a given month in the specified era is a leap month. This method returns true if
ThrowIfDisposed();
int bytesRead = 0;
- int n = 0;
-
do
{
- n = _stream.Read(_buffer, bytesRead, numBytes - bytesRead);
+ int n = _stream.Read(_buffer, bytesRead, numBytes - bytesRead);
if (n == 0)
{
throw Error.GetEndOfFile();
public void Dispose()
{
- uint ignore;
if (_disableSuccess)
- Interop.Kernel32.SetThreadErrorMode(_oldMode, out ignore);
+ Interop.Kernel32.SetThreadErrorMode(_oldMode, out _);
}
}
}
uint fileMode;
+
int status = Interop.NtDll.NtQueryInformationFile(
FileHandle: fileHandle,
- IoStatusBlock: out Interop.NtDll.IO_STATUS_BLOCK ioStatus,
+ IoStatusBlock: out _,
FileInformation: &fileMode,
Length: sizeof(uint),
FileInformationClass: Interop.NtDll.FileModeInformation);
private unsafe long GetLengthInternal()
{
- Interop.Kernel32.FILE_STANDARD_INFO info = new Interop.Kernel32.FILE_STANDARD_INFO();
+ Interop.Kernel32.FILE_STANDARD_INFO info;
if (!Interop.Kernel32.GetFileInformationByHandleEx(_fileHandle, Interop.Kernel32.FILE_INFO_BY_HANDLE_CLASS.FileStandardInfo, out info, (uint)sizeof(Interop.Kernel32.FILE_STANDARD_INFO)))
throw Win32Marshal.GetExceptionForLastWin32Error(_path);
long len = info.EndOfFile;
+
// If we're writing near the end of the file, we must include our
// internal buffer in our Length calculation. Don't flush because
// we use the length of the file in our async write method.
if (_writePos > 0 && _filePosition + _writePos > len)
len = _writePos + _filePosition;
+
return len;
}
private static void GetTempPath(ref ValueStringBuilder builder)
{
- uint result = 0;
+ uint result;
while ((result = Interop.Kernel32.GetTempPathW(builder.Capacity, ref builder.GetPinnableReference())) > builder.Capacity)
{
// Reported size is greater than the buffer size. Increase the capacity.
// it doesn't root extended paths correctly. We don't currently resolve extended paths, so we'll just assert here.
Debug.Assert(PathInternal.IsPartiallyQualified(path) || !PathInternal.IsExtended(path));
- uint result = 0;
+ uint result;
while ((result = Interop.Kernel32.GetFullPathNameW(ref MemoryMarshal.GetReference(path), (uint)builder.Capacity, ref builder.GetPinnableReference(), IntPtr.Zero)) > builder.Capacity)
{
// Reported size is greater than the buffer size. Increase the capacity.
ulong mantissa = ExtractFractionAndBiasedExponent(value, out int exponent);
- uint mantissaHighBitIdx = 0;
+ uint mantissaHighBitIdx;
bool hasUnequalMargins = false;
if ((mantissa >> DiyFp.DoubleImplicitBitIndex) != 0)
uint mantissa = ExtractFractionAndBiasedExponent(value, out int exponent);
- uint mantissaHighBitIdx = 0;
+ uint mantissaHighBitIdx;
bool hasUnequalMargins = false;
if ((mantissa >> DiyFp.SingleImplicitBitIndex) != 0)
Debug.Assert(v > 0);
Debug.Assert(double.IsFinite(v));
- int length = 0;
- int decimalExponent = 0;
- bool result = false;
+ int length;
+ int decimalExponent;
+ bool result;
if (requestedDigits == -1)
{
Debug.Assert(v > 0);
Debug.Assert(float.IsFinite(v));
- int length = 0;
- int decimalExponent = 0;
- bool result = false;
+ int length;
+ int decimalExponent;
+ bool result;
if (requestedDigits == -1)
{
uint middleBlockIndex = topBlockIndex - 1;
uint bottomBlockIndex = middleBlockIndex - 1;
- ulong mantissa = 0;
+ ulong mantissa;
int exponent = baseExponent + ((int)(bottomBlockIndex) * 32);
bool hasZeroTail = !hasNonZeroFractionalPart;
int index = 0;
int num = value[0];
- uint numValue;
// Skip past any whitespace at the beginning.
if ((styles & NumberStyles.AllowLeadingWhite) != 0 && IsWhite(num))
if ((uint)index >= (uint)value.Length)
goto DoneAtEnd;
num = value[index];
+
+ uint numValue;
if ((uint)num >= (uint)charToHexLookup.Length || (numValue = charToHexLookup[num]) == 0xFF)
goto HasTrailingChars;
index++;
if ((uint)index >= (uint)value.Length)
goto DoneAtEnd;
num = value[index];
- if ((uint)num >= (uint)charToHexLookup.Length || (numValue = charToHexLookup[num]) == 0xFF)
+ if ((uint)num >= (uint)charToHexLookup.Length || charToHexLookup[num] == 0xFF)
goto HasTrailingChars;
// At this point, we're either overflowing or hitting a formatting error.
int index = 0;
int num = value[0];
- uint numValue;
// Skip past any whitespace at the beginning.
if ((styles & NumberStyles.AllowLeadingWhite) != 0 && IsWhite(num))
if ((uint)index >= (uint)value.Length)
goto DoneAtEnd;
num = value[index];
+
+ uint numValue;
if ((uint)num >= (uint)charToHexLookup.Length || (numValue = charToHexLookup[num]) == 0xFF)
goto HasTrailingChars;
index++;
if ((uint)index >= (uint)value.Length)
goto DoneAtEnd;
num = value[index];
- if ((uint)num >= (uint)charToHexLookup.Length || (numValue = charToHexLookup[num]) == 0xFF)
+ if ((uint)num >= (uint)charToHexLookup.Length || charToHexLookup[num] == 0xFF)
goto HasTrailingChars;
// At this point, we're either overflowing or hitting a formatting error.
}
_inext = 0;
_inextp = 21;
- Seed = 1;
}
//
{
if (_version == 1)
return LoadObjectV1(pos);
- ResourceTypeCode typeCode;
- return LoadObjectV2(pos, out typeCode);
+ return LoadObjectV2(pos, out _);
}
internal object? LoadObject(int pos, out ResourceTypeCode typeCode)
{
private static ulong GetTopOfMemory()
{
- Interop.Kernel32.SYSTEM_INFO info = new Interop.Kernel32.SYSTEM_INFO();
- Interop.Kernel32.GetSystemInfo(out info);
+ Interop.Kernel32.GetSystemInfo(out Interop.Kernel32.SYSTEM_INFO info);
return (ulong)info.lpMaximumApplicationAddress;
}
// 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.CodeAnalysis;
using System.Globalization;
using System.Runtime.Serialization;
{
public sealed class DecoderExceptionFallback : DecoderFallback
{
- // Construction
- public DecoderExceptionFallback()
- {
- }
-
- public override DecoderFallbackBuffer CreateFallbackBuffer()
- {
- return new DecoderExceptionFallbackBuffer();
- }
+ public override DecoderFallbackBuffer CreateFallbackBuffer() =>
+ new DecoderExceptionFallbackBuffer();
// Maximum number of characters that this instance of this fallback could return
- public override int MaxCharCount
- {
- get
- {
- return 0;
- }
- }
+ public override int MaxCharCount => 0;
- public override bool Equals(object? value)
- {
- if (value is DecoderExceptionFallback that)
- {
- return (true);
- }
- return (false);
- }
+ public override bool Equals(object? value) =>
+ value is DecoderExceptionFallback;
- public override int GetHashCode()
- {
- return 879;
- }
+ public override int GetHashCode() => 879;
}
return true;
}
- public override char GetNextChar()
- {
- return (char)0;
- }
+ public override char GetNextChar() => (char)0;
- public override bool MovePrevious()
- {
- // Exception fallback doesn't have anywhere to back up to.
- return false;
- }
+ // Exception fallback doesn't have anywhere to back up to.
+ public override bool MovePrevious() => false;
// Exceptions are always empty
- public override int Remaining
- {
- get
- {
- return 0;
- }
- }
+ public override int Remaining => 0;
[DoesNotReturn]
private void Throw(byte[] bytesUnknown, int index)
{
}
- public byte[]? BytesUnknown
- {
- get
- {
- return _bytesUnknown;
- }
- }
+ public byte[]? BytesUnknown => _bytesUnknown;
- public int Index
- {
- get
- {
- return _index;
- }
- }
+ public int Index => _index;
}
}
// 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.Serialization;
namespace System.Text
{
}
- public override EncoderFallbackBuffer CreateFallbackBuffer()
- {
- return new EncoderExceptionFallbackBuffer();
- }
+ public override EncoderFallbackBuffer CreateFallbackBuffer() =>
+ new EncoderExceptionFallbackBuffer();
// Maximum number of characters that this instance of this fallback could return
- public override int MaxCharCount
- {
- get
- {
- return 0;
- }
- }
+ public override int MaxCharCount => 0;
- public override bool Equals(object? value)
- {
- if (value is EncoderExceptionFallback that)
- {
- return true;
- }
- return false;
- }
+ public override bool Equals(object? value) =>
+ value is EncoderExceptionFallback;
- public override int GetHashCode()
- {
- return 654;
- }
+ public override int GetHashCode() => 654;
}
SR.Format(SR.Argument_InvalidCodePageConversionIndex, iTemp, index), charUnknownHigh, charUnknownLow, index);
}
- public override char GetNextChar()
- {
- return (char)0;
- }
+ public override char GetNextChar() => (char)0;
- public override bool MovePrevious()
- {
- // Exception fallback doesn't have anywhere to back up to.
- return false;
- }
+ // Exception fallback doesn't have anywhere to back up to.
+ public override bool MovePrevious() => false;
// Exceptions are always empty
- public override int Remaining
- {
- get
- {
- return 0;
- }
- }
+ public override int Remaining => 0;
}
[Serializable]
{
}
- public char CharUnknown
- {
- get
- {
- return _charUnknown;
- }
- }
+ public char CharUnknown => _charUnknown;
- public char CharUnknownHigh
- {
- get
- {
- return _charUnknownHigh;
- }
- }
+ public char CharUnknownHigh => _charUnknownHigh;
- public char CharUnknownLow
- {
- get
- {
- return _charUnknownLow;
- }
- }
+ public char CharUnknownLow => _charUnknownLow;
- public int Index
- {
- get
- {
- return _index;
- }
- }
+ public int Index => _index;
// Return true if the unknown character is a surrogate pair.
- public bool IsUnknownSurrogate()
- {
- return _charUnknownHigh != '\0';
- }
+ public bool IsUnknownSurrogate() => _charUnknownHigh != '\0';
}
}
ReadOnlySpan<byte> bytes = new ReadOnlySpan<byte>(pOriginalBytes, originalByteCount).Slice(bytesConsumedSoFar);
- int bytesConsumedJustNow = 0;
+ int bytesConsumedJustNow;
int totalCharCount = 0;
if (decoder.HasLeftoverData)
ReadOnlySpan<byte> bytes = new ReadOnlySpan<byte>(pOriginalBytes, originalByteCount).Slice(bytesConsumedSoFar);
Span<char> chars = new Span<char>(pOriginalChars, originalCharCount).Slice(charsWrittenSoFar);
- int bytesConsumedJustNow = 0;
- int charsWrittenJustNow = 0;
+ int bytesConsumedJustNow;
+ int charsWrittenJustNow;
if (decoder.HasLeftoverData)
{
/// </summary>
internal ThreadPoolTaskScheduler()
{
- int id = base.Id; // force ID creation of the default scheduler
+ _ = base.Id; // force ID creation of the default scheduler
}
// static delegate for threads allocated to handle LongRunning tasks.
//
// Try using the "kernel32!GetDynamicTimeZoneInformation" API to get the "id"
//
- var dynamicTimeZoneInformation = new TIME_DYNAMIC_ZONE_INFORMATION();
+ TIME_DYNAMIC_ZONE_INFORMATION dynamicTimeZoneInformation;
// call kernel32!GetDynamicTimeZoneInformation...
uint result = Interop.Kernel32.GetDynamicTimeZoneInformation(out dynamicTimeZoneInformation);
if (result == Interop.Kernel32.TIME_ZONE_ID_INVALID)
// DateTime.Now fast path that avoids allocating an historically accurate TimeZoneInfo.Local and just creates a 1-year (current year) accurate time zone
internal static TimeSpan GetDateTimeNowUtcOffsetFromUtc(DateTime time, out bool isAmbiguousLocalDst)
{
- bool isDaylightSavings = false;
isAmbiguousLocalDst = false;
- TimeSpan baseOffset;
int timeYear = time.Year;
OffsetAndRule match = s_cachedData.GetOneYearLocalFromUtc(timeYear);
- baseOffset = match.Offset;
+ TimeSpan baseOffset = match.Offset;
if (match.Rule != null)
{
baseOffset = baseOffset + match.Rule.BaseUtcOffsetDelta;
if (match.Rule.HasDaylightSaving)
{
- isDaylightSavings = GetIsDaylightSavingsFromUtc(time, timeYear, match.Offset, match.Rule, null, out isAmbiguousLocalDst, Local);
+ bool isDaylightSavings = GetIsDaylightSavingsFromUtc(time, timeYear, match.Offset, match.Rule, null, out isAmbiguousLocalDst, Local);
baseOffset += (isDaylightSavings ? match.Rule.DaylightDelta : TimeSpan.Zero /* FUTURE: rule.StandardDelta */);
}
}
+
return baseOffset;
}
/// Helper function that calculates the UTC offset for a UTC-dateTime in a timeZone.
/// This function assumes that the dateTime is represented in UTC and has *not* already been converted into the timeZone.
/// </summary>
- private static TimeSpan GetUtcOffsetFromUtc(DateTime time, TimeZoneInfo zone)
- {
- bool isDaylightSavings;
- return GetUtcOffsetFromUtc(time, zone, out isDaylightSavings);
- }
+ private static TimeSpan GetUtcOffsetFromUtc(DateTime time, TimeZoneInfo zone) =>
+ GetUtcOffsetFromUtc(time, zone, out _);
/// <summary>
/// Helper function that calculates the UTC offset for a UTC-dateTime in a timeZone.
/// This function assumes that the dateTime is represented in UTC and has *not* already been converted into the timeZone.
/// </summary>
- private static TimeSpan GetUtcOffsetFromUtc(DateTime time, TimeZoneInfo zone, out bool isDaylightSavings)
- {
- bool isAmbiguousLocalDst;
- return GetUtcOffsetFromUtc(time, zone, out isDaylightSavings, out isAmbiguousLocalDst);
- }
+ private static TimeSpan GetUtcOffsetFromUtc(DateTime time, TimeZoneInfo zone, out bool isDaylightSavings) =>
+ GetUtcOffsetFromUtc(time, zone, out isDaylightSavings, out _);
/// <summary>
/// Helper function that calculates the UTC offset for a UTC-dateTime in a timeZone.
TimeZoneInfoResult result = TimeZoneInfoResult.Success;
e = null;
- TimeZoneInfo? match = null;
// check the cache
if (cachedData._systemTimeZones != null)
{
- if (cachedData._systemTimeZones.TryGetValue(id, out match))
+ if (cachedData._systemTimeZones.TryGetValue(id, out TimeZoneInfo? match))
{
if (dstDisabled && match._supportsDaylightSavingTime)
{
value = new TimeZoneInfo(match._id, match._baseUtcOffset, match._displayName, match._standardDisplayName,
match._daylightDisplayName, match._adjustmentRules, disableDaylightSavingTime: false);
}
+
return result;
}
}
// Returns the enum values as an object array.
private Array GetEnumRawConstantValues()
{
- string[] names;
- Array values;
- GetEnumData(out names, out values);
+ GetEnumData(out _, out Array values);
return values;
}
EventInfo?[]? e = null;
Type?[]? t = null;
- int i = 0;
+ int i;
int cnt = 0; // Total Matchs
// Check the methods