Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ private static Attribute[] InternalGetCustomAttributes(EventInfo element, Type t
{
rtAdd = rtAdd.GetParentDefinition();
if (rtAdd != null)
return rtAdd.DeclaringType!.GetEvent(ev.Name!);
return rtAdd.DeclaringType!.GetEvent(ev.Name);
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ internal void InitializeSourceInfo(bool fNeedFileInfo, Exception? exception)
// ENC or the source/line info was already retrieved, the method token is 0.
if (rgiMethodToken![index] != 0)
{
GetSourceLineInfo(s_stackTraceSymbolsCache!, rgAssembly![index], rgAssemblyPath![index]!, rgLoadedPeAddress![index], rgiLoadedPeSize![index], rgiIsFileLayout![index],
GetSourceLineInfo(s_stackTraceSymbolsCache, rgAssembly![index], rgAssemblyPath![index], rgLoadedPeAddress![index], rgiLoadedPeSize![index], rgiIsFileLayout![index],
rgInMemoryPdbAddress![index], rgiInMemoryPdbSize![index], rgiMethodToken![index],
rgiILOffset![index], out rgFilename![index], out rgiLineNumber![index], out rgiColumnNumber![index]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ private static unsafe void ConfigCallback(void* configurationContext, void* name

ref GCConfigurationContext context = ref Unsafe.As<byte, GCConfigurationContext>(ref *(byte*)configurationContext);
Debug.Assert(context.Configurations != null);
Dictionary<string, object> configurationDictionary = context.Configurations!;
Dictionary<string, object> configurationDictionary = context.Configurations;

string nameAsString = Marshal.PtrToStringUTF8((IntPtr)name)!;
switch (type)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ private static MethodBase GetGenericMethodBaseDefinition(MethodBase methodBase)
{
Debug.Assert(masmi != null);

methDef = masmi.GetGenericMethodDefinition()!;
methDef = masmi.GetGenericMethodDefinition();
methDef = methDef.Module.ResolveMethod(
methodBase.MetadataToken,
methDef.DeclaringType?.GetGenericArguments(),
Expand Down Expand Up @@ -1070,7 +1070,7 @@ internal int GetMethodTokenInternal(MethodBase method, Type[]? optionalParameter

if (!isGenericMethodDef)
{
methodInfoUnbound = methodInfo.GetGenericMethodDefinition()!;
methodInfoUnbound = methodInfo.GetGenericMethodDefinition();
}

if (!Equals(methodInfoUnbound.Module)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,10 @@ private RuntimeCustomAttributeData(RuntimeModule scope, MetadataToken caCtorToke
m_scope = scope;
m_ctor = (RuntimeConstructorInfo)RuntimeType.GetMethodBase(m_scope, caCtorToken)!;

if (m_ctor!.DeclaringType!.IsGenericType)
if (m_ctor.DeclaringType!.IsGenericType)
{
MetadataImport metadataScope = m_scope.MetadataImport;
Type attributeType = m_scope.ResolveType(metadataScope.GetParentToken(caCtorToken), null, null)!;
Type attributeType = m_scope.ResolveType(metadataScope.GetParentToken(caCtorToken), null, null);
m_ctor = (RuntimeConstructorInfo)m_scope.ResolveMethod(caCtorToken, attributeType.GenericTypeArguments, null)!.MethodHandle.GetMethodInfo();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ internal ReadOnlySpan<ParameterInfo> GetIndexParametersSpan()
Array.Empty<ParameterInfo>();

for (int i = 0; i < propParams.Length; i++)
propParams[i] = new RuntimeParameterInfo((RuntimeParameterInfo)methParams![i], this);
propParams[i] = new RuntimeParameterInfo((RuntimeParameterInfo)methParams[i], this);

m_parameters = propParams;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,7 @@ internal bool IsNullHandle()

public IntPtr GetFunctionPointer()
{
IntPtr ptr = GetFunctionPointer(EnsureNonNullMethodInfo(m_value!).Value);
IntPtr ptr = GetFunctionPointer(EnsureNonNullMethodInfo(m_value).Value);
GC.KeepAlive(m_value);
return ptr;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ private void MergeWithGlobalList(T[] list)
cachedMembers = cachedMembers2;
}

Debug.Assert(cachedMembers![freeSlotIndex] == null);
Debug.Assert(cachedMembers[freeSlotIndex] == null);
Volatile.Write(ref cachedMembers[freeSlotIndex], newMemberInfo); // value may be read outside of lock
freeSlotIndex++;
}
Expand Down Expand Up @@ -1357,7 +1357,7 @@ private void PopulateProperties(

for (int j = 0; j < list.Count; j++)
{
if (propertyInfo.EqualsSig(list[j]!))
if (propertyInfo.EqualsSig(list[j]))
{
duplicate = true;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static string Intern(string str)
{
ArgumentNullException.ThrowIfNull(str);
Intern(new StringHandleOnStack(ref str!));
return str!;
return str;
}

[LibraryImport(RuntimeHelpers.QCall, EntryPoint = "String_IsInterned")]
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/Common/src/System/IO/PathInternal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ internal static bool RemoveRelativeSegments(ReadOnlySpan<char> path, int rootLen
[return: NotNullIfNotNull(nameof(path))]
internal static string? TrimEndingDirectorySeparator(string? path) =>
EndsInDirectorySeparator(path) && !IsRoot(path.AsSpan()) ?
path!.Substring(0, path.Length - 1) :
path.Substring(0, path.Length - 1) :
path;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ private static IntPtr InternalGetFunctionPointer(AssemblyLoadContext alc,
}
else
{
Delegate d = Delegate.CreateDelegate(delegateType, type, methodName)!;
Delegate d = Delegate.CreateDelegate(delegateType, type, methodName);

functionPtr = Marshal.GetFunctionPointerForDelegate(d);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ private bool Init(string path, FileMode mode, FileAccess access, FileShare share

// Delete the file we've created.
Debug.Assert(mode == FileMode.Create || mode == FileMode.CreateNew);
Interop.Sys.Unlink(path!);
Interop.Sys.Unlink(path);

throw new IOException(SR.Format(errorInfo.Error == Interop.Error.EFBIG
? SR.IO_FileTooLarge_Path_AllocationSize
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ public bool Add(TAlternate item)
{
index = set._freeList;
set._freeCount--;
Debug.Assert((StartOfFreeList - entries![set._freeList].Next) >= -1, "shouldn't overflow because `next` cannot underflow");
Debug.Assert((StartOfFreeList - entries[set._freeList].Next) >= -1, "shouldn't overflow because `next` cannot underflow");
set._freeList = StartOfFreeList - entries[set._freeList].Next;
}
else
Expand Down Expand Up @@ -551,7 +551,7 @@ public bool Remove(TAlternate item)
uint collisionCount = 0;
int last = -1;

int hashCode = item is not null ? comparer!.GetHashCode(item) : 0;
int hashCode = item is not null ? comparer.GetHashCode(item) : 0;

ref int bucket = ref set.GetBucketRef(hashCode);
int i = bucket - 1; // Value in buckets is 1-based
Expand Down Expand Up @@ -1481,7 +1481,7 @@ private bool AddIfNotPresent(T value, out int location)
{
index = _freeList;
_freeCount--;
Debug.Assert((StartOfFreeList - entries![_freeList].Next) >= -1, "shouldn't overflow because `next` cannot underflow");
Debug.Assert((StartOfFreeList - entries[_freeList].Next) >= -1, "shouldn't overflow because `next` cannot underflow");
_freeList = StartOfFreeList - entries[_freeList].Next;
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public List(IEnumerable<T> collection)
else
{
_items = s_emptyArray;
using (IEnumerator<T> en = collection!.GetEnumerator())
using (IEnumerator<T> en = collection.GetEnumerator())
{
while (en.MoveNext())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void OnStart(string providerName, string activityName, int task, ref Guid
if (tplDebug)
{
log!.DebugFacilityMessage("OnStartEnter", fullActivityName);
log!.DebugFacilityMessage("OnStartEnterActivityState", ActivityInfo.LiveActivities(currentActivity));
log.DebugFacilityMessage("OnStartEnterActivityState", ActivityInfo.LiveActivities(currentActivity));
}

if (currentActivity != null)
Expand Down Expand Up @@ -114,7 +114,7 @@ public void OnStart(string providerName, string activityName, int task, ref Guid
if (tplDebug)
{
log!.DebugFacilityMessage("OnStartRetActivityState", ActivityInfo.LiveActivities(newActivity));
log!.DebugFacilityMessage1("OnStartRet", activityId.ToString(), relatedActivityId.ToString());
log.DebugFacilityMessage1("OnStartRet", activityId.ToString(), relatedActivityId.ToString());
}
}

Expand All @@ -136,7 +136,7 @@ public void OnStop(string providerName, string activityName, int task, ref Guid
if (tplDebug)
{
log!.DebugFacilityMessage("OnStopEnter", fullActivityName);
log!.DebugFacilityMessage("OnStopEnterActivityState", ActivityInfo.LiveActivities(m_current.Value));
log.DebugFacilityMessage("OnStopEnterActivityState", ActivityInfo.LiveActivities(m_current.Value));
}

while (true) // This is a retry loop.
Expand Down Expand Up @@ -195,7 +195,7 @@ public void OnStop(string providerName, string activityName, int task, ref Guid
if (tplDebug)
{
log!.DebugFacilityMessage("OnStopRetActivityState", ActivityInfo.LiveActivities(newCurrentActivity));
log!.DebugFacilityMessage("OnStopRet", activityId.ToString());
log.DebugFacilityMessage("OnStopRet", activityId.ToString());
}
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4458,7 +4458,7 @@ private static void RemoveReferencesToListenerInEventSources(EventListener liste
{
if (cur.m_Listener == listenerToRemove)
{
CallDisableEventsIfNecessary(cur!, eventSource);
CallDisableEventsIfNecessary(cur, eventSource);
}

cur = cur.m_Next;
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/System.Private.CoreLib/src/System/Enum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,7 @@ private static bool TryParseRareTypeByValueOrName<TUnderlying, TStorage>(

try
{
result = (TUnderlying)ToObject(enumType, Convert.ChangeType(value.ToString(), underlyingType, CultureInfo.InvariantCulture)!);
result = (TUnderlying)ToObject(enumType, Convert.ChangeType(value.ToString(), underlyingType, CultureInfo.InvariantCulture));
return true;
}
catch (FormatException)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ private static bool EnumEraNames(string localeName, CalendarId calendarId, Calen
// So for other calendars, only return the latest era.
if (calendarId != CalendarId.JAPAN && calendarId != CalendarId.JAPANESELUNISOLAR && eraNames?.Length > 0)
{
eraNames = [eraNames![^1]];
eraNames = [eraNames[^1]];
}

return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ private static string NormalizeCultureName(string name, out bool isNeutralName)
private bool InitCompatibilityCultureData()
{
// for compatibility handle the deprecated ids: zh-chs, zh-cht
string cultureName = _sRealName!;
string cultureName = _sRealName;

string fallbackCultureName;
string realCultureName;
Expand Down Expand Up @@ -931,7 +931,7 @@ internal string CultureName

// Parent name (which may be a custom locale/culture)
// Ask using the real name, so that we get parents of neutrals
internal string ParentName => _sParent ??= GetLocaleInfoCore(_sRealName!, LocaleStringData.ParentName);
internal string ParentName => _sParent ??= GetLocaleInfoCore(_sRealName, LocaleStringData.ParentName);

// Localized pretty name for this locale (ie: Inglis (estados Unitos))
internal string DisplayName
Expand Down Expand Up @@ -960,7 +960,7 @@ internal string DisplayName
}
}

return localizedDisplayName!;
return localizedDisplayName;
}
}

Expand Down Expand Up @@ -1110,8 +1110,8 @@ internal string SpecificCultureName
/// abbreviated windows language name (ie: enu) (non-standard, avoid this)
/// </summary>
internal string ThreeLetterWindowsLanguageName => _sAbbrevLang ??= GlobalizationMode.UseNls ?
NlsGetThreeLetterWindowsLanguageName(_sRealName!) :
IcuGetThreeLetterWindowsLanguageName(_sRealName!);
NlsGetThreeLetterWindowsLanguageName(_sRealName) :
IcuGetThreeLetterWindowsLanguageName(_sRealName);

/// <summary>
/// Localized name for this language
Expand Down Expand Up @@ -1155,7 +1155,7 @@ internal int GeoId
{
if (_iGeoId == undef && !GlobalizationMode.Invariant)
{
_iGeoId = GlobalizationMode.UseNls ? NlsGetLocaleInfo(LocaleNumberData.GeoId) : IcuGetGeoId(_sRealName!);
_iGeoId = GlobalizationMode.UseNls ? NlsGetLocaleInfo(LocaleNumberData.GeoId) : IcuGetGeoId(_sRealName);
}
return _iGeoId;
}
Expand Down Expand Up @@ -1232,8 +1232,8 @@ internal int KeyboardLayoutId
/// Console fallback name (ie: locale to use for console apps for unicode-only locales)
/// </summary>
internal string SCONSOLEFALLBACKNAME => _sConsoleFallbackName ??= GlobalizationMode.UseNls ?
NlsGetConsoleFallbackName(_sRealName!) :
IcuGetConsoleFallbackName(_sRealName!);
NlsGetConsoleFallbackName(_sRealName) :
IcuGetConsoleFallbackName(_sRealName);

/// <summary>
/// grouping of digits
Expand Down Expand Up @@ -1818,7 +1818,7 @@ internal int ANSICodePage
{
if (_iDefaultAnsiCodePage == undef && !GlobalizationMode.Invariant)
{
_iDefaultAnsiCodePage = GetAnsiCodePage(_sRealName!);
_iDefaultAnsiCodePage = GetAnsiCodePage(_sRealName);
}
return _iDefaultAnsiCodePage;
}
Expand All @@ -1833,7 +1833,7 @@ internal int OEMCodePage
{
if (_iDefaultOemCodePage == undef && !GlobalizationMode.Invariant)
{
_iDefaultOemCodePage = GetOemCodePage(_sRealName!);
_iDefaultOemCodePage = GetOemCodePage(_sRealName);
}
return _iDefaultOemCodePage;
}
Expand All @@ -1848,7 +1848,7 @@ internal int MacCodePage
{
if (_iDefaultMacCodePage == undef && !GlobalizationMode.Invariant)
{
_iDefaultMacCodePage = GetMacCodePage(_sRealName!);
_iDefaultMacCodePage = GetMacCodePage(_sRealName);
}
return _iDefaultMacCodePage;
}
Expand All @@ -1863,7 +1863,7 @@ internal int EBCDICCodePage
{
if (_iDefaultEbcdicCodePage == undef && !GlobalizationMode.Invariant)
{
_iDefaultEbcdicCodePage = GetEbcdicCodePage(_sRealName!);
_iDefaultEbcdicCodePage = GetEbcdicCodePage(_sRealName);
}
return _iDefaultEbcdicCodePage;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,13 @@ private static void AsyncLocalSetCurrentUICulture(AsyncLocalValueChangedArgs<Cul
private static CultureInfo InitializeUserDefaultCulture()
{
Interlocked.CompareExchange(ref s_userDefaultCulture, GetUserDefaultCulture(), null);
return s_userDefaultCulture!;
return s_userDefaultCulture;
}

private static CultureInfo InitializeUserDefaultUICulture()
{
Interlocked.CompareExchange(ref s_userDefaultUICulture, GetUserDefaultUICulture(), null);
return s_userDefaultUICulture!;
return s_userDefaultUICulture;
}

private static string GetCultureNotSupportedExceptionMessage() => GlobalizationMode.Invariant ? SR.Argument_CultureNotSupportedInInvariantMode : SR.Argument_CultureNotSupported;
Expand Down Expand Up @@ -377,7 +377,7 @@ public static CultureInfo CurrentCulture
{
Interlocked.CompareExchange(ref s_asyncLocalCurrentCulture, new AsyncLocal<CultureInfo>(AsyncLocalSetCurrentCulture), null);
}
s_asyncLocalCurrentCulture!.Value = value;
s_asyncLocalCurrentCulture.Value = value;
}
}

Expand All @@ -401,7 +401,7 @@ public static CultureInfo CurrentUICulture
}

// this one will set s_currentThreadUICulture too
s_asyncLocalCurrentUICulture!.Value = value;
s_asyncLocalCurrentUICulture.Value = value;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ private static EraInfo[] TrimEras(EraInfo[] baseEras)
// If we didn't copy any then something was wrong, just return base
if (newIndex == 0) return baseEras;

Array.Resize(ref newEras!, newIndex);
Array.Resize(ref newEras, newIndex);
return newEras;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ public static Assembly LoadFile(string path)
// Requestor assembly was loaded using loadFrom, so look for its dependencies
// in the same folder as it.
// Form the name of the assembly using the path of the assembly that requested its load.
AssemblyName requestedAssemblyName = new AssemblyName(args.Name!);
AssemblyName requestedAssemblyName = new AssemblyName(args.Name);
string requestedAssemblyPath = Path.Combine(Path.GetDirectoryName(requestorPath)!, requestedAssemblyName.Name + ".dll");
#if CORECLR
if (AssemblyLoadContext.IsTracingEnabled())
Expand Down Expand Up @@ -384,7 +384,7 @@ public static Assembly LoadFrom(string assemblyFile)
{
if (!s_loadFromHandlerSet)
{
AssemblyLoadContext.AssemblyResolve += LoadFromResolveHandler!;
AssemblyLoadContext.AssemblyResolve += LoadFromResolveHandler;
s_loadFromHandlerSet = true;
}
}
Expand Down
Loading
Loading