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

Add Single and Double overloads to BinaryPrimitives #6864

Merged
merged 5 commits into from
Feb 3, 2020

Conversation

eerhardt
Copy link
Member

Fix #2365

/// </summary>
/// <returns>If the span is too small to contain an Int16, return false.</returns>
Copy link
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
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.

Copy link
Member

@ahsonkhan ahsonkhan Jan 31, 2020

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
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
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
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.

Copy link
Member

@jkotas jkotas Jan 31, 2020

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
Member

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.

@jkotas
Copy link
Member

jkotas commented Jan 31, 2020

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

@ahsonkhan ahsonkhan left a comment

Choose a reason for hiding this comment

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

Docs suggestions

@ahsonkhan ahsonkhan modified the milestones: 2.1.15, 5.0 Jan 31, 2020
@eerhardt
Copy link
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
Member Author

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

Copy link
Member

@ahsonkhan ahsonkhan left a comment

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!

@marek-safar
Copy link
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
Copy link
Member

jkotas commented Feb 5, 2020

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