Skip to content

Add [MemberNotNullWhen] to PatchResult#611

Merged
gregsdennis merged 1 commit into
json-everything:native-aotfrom
ivarne:memberNotNullWhen
Jan 31, 2024
Merged

Add [MemberNotNullWhen] to PatchResult#611
gregsdennis merged 1 commit into
json-everything:native-aotfrom
ivarne:memberNotNullWhen

Conversation

@ivarne

@ivarne ivarne commented Jan 15, 2024

Copy link
Copy Markdown
Contributor

This removes the nullability warning when writing code like

if(!result.IsSuccess)
{
   bool testOperationFailed = patchResult.Error.Contains("is not equal to the indicated value.");
}

This won't word before the library starts to (multi) target net5 or greater, but I still think it makes sense to have it ready as soon as that happens.

@gregsdennis

Copy link
Copy Markdown
Collaborator

Thanks for the suggestion, but this library is .Net Standard 2.0, and that compiler directive will never be triggered.

I actually just had a conversation on Twitter regarding things like this that make the code harder to maintain. I prefer to avoid them.

@ivarne

ivarne commented Jan 15, 2024

Copy link
Copy Markdown
Contributor Author

and that compiler directive will never be triggered.

OK, I just found #460 which seems to indicate that you were having plans to upgrade or multi target at some point.

@gregsdennis

gregsdennis commented Jan 15, 2024

Copy link
Copy Markdown
Collaborator

Upgrade eventually, yes, but not multi-target. As it stands, I apparently have some consumers at Microsoft that are still using Framework, so moving off of Standard probably won't be for a bit (or at least until I can articulate a convincing reason to get them to update our leave them behind).

@gregsdennis

Copy link
Copy Markdown
Collaborator

I'm going to close this for now, but I'll definitely make these kinds of updates in the future. Thanks for the suggestion.

@gregsdennis

Copy link
Copy Markdown
Collaborator

@ivarne it looks like I might be moving toward updating sooner than I expected. The demand for Native AOT support is growing. If I need to do that I might as well do this as well.

See #618 for progress.

@gregsdennis gregsdennis mentioned this pull request Jan 24, 2024
17 tasks
@gregsdennis gregsdennis reopened this Jan 31, 2024
@gregsdennis gregsdennis changed the base branch from master to native-aot January 31, 2024 07:47
@gregsdennis

Copy link
Copy Markdown
Collaborator

@ivarne I've retargeted this PR to native-aot, where this would be useful. Yeah, I could just add the attribute myself, but I thought you'd like to have the commit.

@ivarne

ivarne commented Jan 31, 2024

Copy link
Copy Markdown
Contributor Author

Thanks!

This isn't my first PR, but if it was it would have mattered a lot.

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.

2 participants