Skip to content

Commit

Permalink
Fix nullability warning and address PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
stephentoub committed Jul 19, 2024
1 parent 9c3f2b9 commit b409cb4
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public override int GetHashCode()

protected virtual MethodInfo GetMethodImpl()
{
if ((_methodBase == null) || _methodBase is not MethodInfo)
if (_methodBase is null or not MethodInfo)
{
IRuntimeMethodInfo method = FindMethodHandle();
RuntimeType? declaringType = RuntimeMethodHandle.GetDeclaringType(method);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ protected override MethodInfo GetMethodImpl()
{
// we handle unmanaged function pointers here because the generic ones (used for WinRT) would otherwise
// be treated as open delegates by the base implementation, resulting in failure to get the MethodInfo
if ((_methodBase == null) || _methodBase is not MethodInfo)
if (_methodBase is null or not MethodInfo)
{
IRuntimeMethodInfo method = FindMethodHandle();
RuntimeType declaringType = RuntimeMethodHandle.GetDeclaringType(method);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public partial class JapaneseCalendar : Calendar
// Check if we are getting the English Name at the end of the returned list.
// ICU usually return long list including all Era names written in Japanese characters except the recent eras which actually we support will be returned in English.
// We have the following check as older ICU versions doesn't carry the English names (e.g. ICU version 50).
if (abbrevEnglishEraNames[^1].Length == 0 || abbrevEnglishEraNames[^1][0] > '\u007F')
if (abbrevEnglishEraNames[^1] is { Length: 0 } or [> '\u007F', ..])
{
// Couldn't get English names.
abbrevEnglishEraNames = s_abbreviatedEnglishEraNames;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3252,7 +3252,8 @@ internal void RecordInternalCancellationRequest(CancellationToken tokenToRecord,
if (cancellationException != null)
{
#if DEBUG
if (cancellationException is not OperationCanceledException oce)
var oce = cancellationException as OperationCanceledException;
if (oce == null)
{
var edi = cancellationException as ExceptionDispatchInfo;
Debug.Assert(edi != null, "Expected either an OCE or an EDI");
Expand Down

0 comments on commit b409cb4

Please sign in to comment.