Skip to content

Add Single and Double overloads to BinaryPrimitives - #6864

Merged
eerhardt merged 5 commits into
dotnet:masterfrom
eerhardt:Fix35791
Feb 3, 2020
Merged

eerhardt merged 5 commits into
dotnet:masterfrom
eerhardt:Fix35791

Conversation

@eerhardt

Copy link
Copy Markdown
Member

Fix #2365

Comment thread src/libraries/System.Memory/ref/System.Memory.cs Outdated
Comment thread src/libraries/System.Private.CoreLib/src/System/Buffers/Binary/ReaderBigEndian.cs Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for catching these. :)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Unfortunately, it doesn't look like the docs are generated from this source. The stuff at https://docs.microsoft.com/en-us/dotnet/api/system.buffers.binary.binaryprimitives.trywriteint16bigendian is much better than what we have here.

@ahsonkhan ahsonkhan Jan 31, 2020

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The docs commented started with the comments from source but then went through doc review and got fixed up (see dotnet/dotnet-api-docs#2693). For new APIs, if you fix them in source, it will make porting them easier.

cc @carlossanlop

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Why don't the fixes from the doc review get ported back into the source?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We do not have a automated tooling to do that. If we did have one, it would likely require a lot of manual interventions and be expensive to keep running on ongoing basis.

IMHO, the best way to address this would be to make the docs live in just one place, and avoid the duplication.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

the best way to address this would be to make the docs live in just one place, and avoid the duplication.

Totally agree. IMO that one place should be in the source.

@jkotas jkotas Jan 31, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

that one place should be in the source.

It is not obvious that it would be the right choice. The documentation is version-agnostic (spans all released and supported versions of .NET Framework and .NET Core), but the sources are version specific.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We had similar discussions previously with the docs team and given the constraints, decided as having the docs site be the single source of truth. It does have the side effect that you are seeing @eerhardt, but as @jkotas mentioned, trying to keep source and docs in sync is challenging, potentially flaky and may not be a tenable, especially since both the docs and source get updated all the time (from various parties). Given the real customer value is having the docs and Intellisense, we prioritized that as the source of truth and only "seed" them with the xml comments from source once. The higher order bit is to encourage and ensure that we are writing useful, customer facing xml comments that are complete, whenever we add new APIs and make sure the customer benefits from it. Area owners and those adding API/source contribution can manually sync them back if they choose to, but it isn't mandatory.

Comment thread src/libraries/System.Private.CoreLib/src/System/Buffers/Binary/Reader.cs Outdated
Comment thread src/libraries/System.Private.CoreLib/src/System/Buffers/Binary/ReaderBigEndian.cs Outdated
@jkotas

jkotas commented Jan 31, 2020

Copy link
Copy Markdown
Member

@marek-safar Is it important to have endianess agnostic CoreLib for Mono?

If not, we can use ifdefs for all these instead that will make the code leaner and easier for the JIT to optimize.

@eerhardt
eerhardt requested a review from jkotas January 31, 2020 03:53
Comment thread src/libraries/System.Memory/tests/Binary/BinaryReaderUnitTests.cs Outdated

@ahsonkhan ahsonkhan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Docs suggestions

Comment thread src/libraries/System.Private.CoreLib/src/System/Buffers/Binary/ReaderBigEndian.cs Outdated
Comment thread src/libraries/System.Private.CoreLib/src/System/Buffers/Binary/ReaderBigEndian.cs Outdated
Comment thread src/libraries/System.Private.CoreLib/src/System/Buffers/Binary/ReaderBigEndian.cs Outdated
Comment thread src/libraries/System.Private.CoreLib/src/System/Buffers/Binary/ReaderBigEndian.cs Outdated
@ahsonkhan ahsonkhan modified the milestones: 2.1.15, 5.0 Jan 31, 2020
@eerhardt

Copy link
Copy Markdown
Member Author

Is it important to have endianess agnostic CoreLib for Mono?
If not, we can use ifdefs for all these instead that will make the code leaner and easier for the JIT to optimize.

My understanding was that JIT treats BitConverter.IsLittleEndian as a constant, and it eliminates unused code paths automatically. Is that good enough? Or do you think putting #if BIGENDIAN on all these methods is better?

See

#if BIGENDIAN
[Intrinsic]
public static readonly bool IsLittleEndian /* = false */;
#else
[Intrinsic]
public static readonly bool IsLittleEndian = true;
#endif

@eerhardt

Copy link
Copy Markdown
Member Author

I believe I have addressed the current feedback. PTAL and let me know if you have more feedback.

@ahsonkhan ahsonkhan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Some doc fix an -> a. Left suggestions to make it easier to fixup. Otherwise, LGTM!

Comment thread src/libraries/System.Private.CoreLib/src/System/Buffers/Binary/WriterBigEndian.cs Outdated
Comment thread src/libraries/System.Private.CoreLib/src/System/Buffers/Binary/WriterBigEndian.cs Outdated
Comment thread src/libraries/System.Private.CoreLib/src/System/Buffers/Binary/WriterBigEndian.cs Outdated
Comment thread src/libraries/System.Private.CoreLib/src/System/Buffers/Binary/ReaderBigEndian.cs Outdated
Comment thread src/libraries/System.Private.CoreLib/src/System/Buffers/Binary/ReaderBigEndian.cs Outdated
Comment thread src/libraries/System.Private.CoreLib/src/System/Buffers/Binary/WriterBigEndian.cs Outdated
@marek-safar

Copy link
Copy Markdown
Contributor

Is it important to have endianess agnostic CoreLib for Mono?

It's not, CoreLib is runtime specific and we will distribute it with runtime anyway. However, libraries are so I am not sure if it's worth to have different code pattern used there especially if illinker is able to remove the condition

@eerhardt
eerhardt merged commit e0a8bb4 into dotnet:master Feb 3, 2020
@eerhardt
eerhardt deleted the Fix35791 branch February 3, 2020 23:48
@jkotas

jkotas commented Feb 5, 2020

Copy link
Copy Markdown
Member

if it's worth to have different code pattern used there especially if illinker is able to remove the condition

I have opened #31785 on this.

@ghost ghost locked as resolved and limited conversation to collaborators Dec 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Single and Double overloads to BinaryPrimitives

7 participants