Skip to content

Use pattern matching #56532

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 10, 2024
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
2 changes: 1 addition & 1 deletion src/Http/Http.Abstractions/src/FragmentString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public override bool Equals(object? obj)
{
return !HasValue;
}
return obj is FragmentString && Equals((FragmentString)obj);
return obj is FragmentString value && Equals(value);
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Http.Abstractions/src/HostString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ public override bool Equals(object? obj)
{
return !HasValue;
}
return obj is HostString && Equals((HostString)obj);
return obj is HostString value && Equals(value);
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Http.Abstractions/src/Internal/HeaderSegment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public override bool Equals(object? obj)
return false;
}

return obj is HeaderSegment && Equals((HeaderSegment)obj);
return obj is HeaderSegment value && Equals(value);
}

public override int GetHashCode()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public override bool Equals(object? obj)
return false;
}

return obj is HeaderSegmentCollection && Equals((HeaderSegmentCollection)obj);
return obj is HeaderSegmentCollection collection && Equals(collection);
}

public override int GetHashCode()
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Http.Abstractions/src/QueryString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public override bool Equals(object? obj)
{
return !HasValue;
}
return obj is QueryString && Equals((QueryString)obj);
return obj is QueryString query && Equals(query);
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions src/Shared/RazorViews/BaseView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,9 @@ protected void WriteAttribute(
// instead of the string 'true'. If the value is the bool 'false' we don't want to write anything.
// Otherwise the value is another object (perhaps an HtmlString) and we'll ask it to format itself.
string? stringValue;
if (value.Value is bool)
if (value.Value is bool flag)
{
if ((bool)value.Value)
if (flag)
{
stringValue = name;
}
Expand Down
Loading