Skip to content

Simplify unnecessary condition#54133

Merged
jcouv merged 2 commits intodotnet:features/caller-argument-expressionfrom
Youssef1313:patch-21
Jun 17, 2021
Merged

Simplify unnecessary condition#54133
jcouv merged 2 commits intodotnet:features/caller-argument-expressionfrom
Youssef1313:patch-21

Conversation

@Youssef1313
Copy link
Copy Markdown
Member

@Youssef1313 Youssef1313 commented Jun 16, 2021

I think the length should be guaranteed to be 1 in this code path since we check for AttributeDescription.CallerArgumentExpressionAttribute.

Note: I initially wrote it that way since it was nearly a copy/paste from other code here:

private static bool? DecodeMaybeNullWhenOrNotNullWhenOrDoesNotReturnIfAttribute(AttributeDescription description, CSharpAttributeData attribute)
{
var arguments = attribute.CommonConstructorArguments;
return arguments.Length == 1 && arguments[0].TryDecodeValue(SpecialType.System_Boolean, out bool value) ?
(bool?)value :
null;
}

If my thought is correct, the other code could be simplified as well.

Test plan: #52745

@Youssef1313 Youssef1313 requested a review from a team as a code owner June 16, 2021 07:09
@ghost ghost added the Area-Compilers label Jun 16, 2021
@Youssef1313 Youssef1313 reopened this Jun 16, 2021
@Youssef1313 Youssef1313 reopened this Jun 16, 2021
@Youssef1313 Youssef1313 reopened this Jun 16, 2021
@333fred
Copy link
Copy Markdown
Member

333fred commented Jun 17, 2021

@dotnet/roslyn-compiler for a second small review.

Copy link
Copy Markdown
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM Thanks (iteration 2)

@jcouv jcouv merged commit 5f44ff6 into dotnet:features/caller-argument-expression Jun 17, 2021
@jcouv
Copy link
Copy Markdown
Member

jcouv commented Jun 17, 2021

Merged/squashed. Thanks @Youssef1313
Also added a link to test plan #52745

@Youssef1313 Youssef1313 deleted the patch-21 branch June 17, 2021 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants