csharpier
csharpier copied to clipboard
Long expression IsPattern breaking
The following
if (
someLongName____________________________________________________ is
{ } anotherLongName______________________
) {
return;
}
Is more readable as
if (
someLongName____________________________________________________
is { } anotherLongName______________________
) {
return;
}
real world example
if (
parameterCustomAttributes.OfType<IFromRouteMetadata>().FirstOrDefault() is
{ } routeAttribute
) {
make sure to test with
if (
context.ActionDescriptor is ControllerActionDescriptor
{
ActionName: "Post" or "Patch" or "Delete"
}
) { }
if (
context.ActionDescriptor is ControllerActionDescriptor
{
ActionName: "MuchLongerStringValue"
or "MuchLongerStringValue"
or "MuchLongerStringValue"
}
) { }