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

Use BinaryPrimitives #366

Merged
merged 5 commits into from
Jan 21, 2024
Merged

Use BinaryPrimitives #366

merged 5 commits into from
Jan 21, 2024

Conversation

iamcarbon
Copy link
Collaborator

@iamcarbon iamcarbon commented Jan 20, 2024

Ready for review.

@iamcarbon iamcarbon changed the title Use BinaryPrimitives [Draft] Use BinaryPrimitives Jan 20, 2024
@iamcarbon iamcarbon changed the title [Draft] Use BinaryPrimitives Use BinaryPrimitives Jan 20, 2024
Copy link
Owner

@drewnoakes drewnoakes left a comment

Choose a reason for hiding this comment

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

Looks good. I wonder if we could reformat one pattern around collection expressions. Can merge once we resolve that question.

I'm spanifying the reader classes at the moment so please hold off on touching those in any significant way.

Thanks for the great PRs. They add clear value and are the perfect size for quick review.

@@ -49,8 +49,8 @@ public void UnderlyingInt()
Assert.Equal(value.ToString(), _directory.GetString(tagType));
Assert.True(_directory.TryGetRational(tagType, out Rational rational));
Assert.Equal(new Rational(value, 1), rational);
Assert.Equal([value], _directory.GetInt32Array(tagType));
Assert.Equal(new[] { unchecked((byte)value) }, _directory.GetByteArray(tagType));
Assert.Equal((int[])[value], _directory.GetInt32Array(tagType));
Copy link
Owner

Choose a reason for hiding this comment

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

I'm curious. Did Visual Studio recommend the original conversation to a collection literal? If so I'll file a big against the analyser for suggesting code that changes semantics.

Copy link
Owner

Choose a reason for hiding this comment

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

I'm on my phone so haven't investigated, but can we write this instead:

Assert.Equal<int>([1, 2], foo);

If not then maybe the original form would be more common.

new int[] { 1, 2 }

Copy link
Collaborator Author

@iamcarbon iamcarbon Jan 21, 2024

Choose a reason for hiding this comment

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

I'm curious. Did Visual Studio recommend the original conversation to a collection literal? If so I'll file a big against the analyser for suggesting code that changes semantics.

Yep, it was recommended by VS. I agree that we should update the analyzer rules here.

--

I'll update this call to use the original explicit form. This is the one call site that became ambiguous with the new collection expression target typing + xunit update (adding support for readonly span overloads on certain, but not all frameworks), that caused an ambiguous method call.

@iamcarbon iamcarbon mentioned this pull request Jan 21, 2024
@drewnoakes drewnoakes merged commit 1aaf7b2 into drewnoakes:master Jan 21, 2024
4 checks passed
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.

None yet

2 participants