Skip to content
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

Simplify unnecessary condition #54133

Merged

Conversation

Youssef1313
Copy link
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
@Youssef1313 Youssef1313 reopened this Jun 16, 2021
@Youssef1313 Youssef1313 reopened this Jun 16, 2021
@Youssef1313 Youssef1313 reopened this Jun 16, 2021
@333fred
Copy link
Member

333fred commented Jun 17, 2021

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

Copy link
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
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