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

C#: add System.Memory dependency #5835

Merged
merged 1 commit into from
Mar 18, 2019

Conversation

jtattermusch
Copy link
Contributor

@jtattermusch jtattermusch commented Mar 5, 2019

Also add useful Span-based methods for ByteString

System.Memory dependency is only added for netstandard2.0 target, netstandard1.0 and net45 stay unchanged (we actually could add System.Memory dependency for net45 too, but it seems that most users that will benefit from Span optimizations will already have access to netstandard2.0).

This PR is mostly preparation for future span-based optimizations, but to make at least some use of the new dependency, two utility ByteString methods are being added.

See grpc/grpc-dotnet#30 for more details about the planned serialization/deserialization API.

@jtattermusch
Copy link
Contributor Author

@jskeet WDYT about changing the target from netstandard1.0 to netstandard1.1?

CC @JunTaoLuo @davidfowl @JamesNK

@jtattermusch
Copy link
Contributor Author

Looks like this change is mutually exclusive with #5445. I'll reach out to the internal user that requested downgrading LangVersion to see what we can do.

@jskeet
Copy link
Contributor

jskeet commented Mar 5, 2019

I think I'd prefer to add a netstandard2.0 target (which comes with a bunch of benefits for 2.0+ users) and only conditionally include System.Memory things.

(Jan, I know a bit more about the LangVersion change - ping me if you need to.)

@@ -7,7 +7,7 @@
<VersionPrefix>3.7.0</VersionPrefix>
<LangVersion>6</LangVersion>
<Authors>Google Inc.</Authors>
<TargetFrameworks>netstandard1.0;net45</TargetFrameworks>
<TargetFrameworks>netstandard1.1;net45</TargetFrameworks>

Choose a reason for hiding this comment

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

This would be considered a breaking change no? Adding another target for netstandard2.0 (or netstandard 1.1 if you want) would probably be better here.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1

</PropertyGroup>

<ItemGroup>
<PackageReference Include="SourceLink.Create.CommandLine" PrivateAssets="All" Version="2.7.6"/>
<PackageReference Include="SourceLink.Create.CommandLine" PrivateAssets="All" Version="2.7.6" />
<PackageReference Include="System.Memory" Version="4.5.2" />

Choose a reason for hiding this comment

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

Adding a new dependency is also usually considered a "breaking change". Maybe make this conditional on the target framework?

Choose a reason for hiding this comment

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

Adding a new dependency is also usually considered a "breaking change". Maybe make this conditional on the target framework?

Adding a new dependency isn't a breaking change. Removing one is though. I think we should potentially bump the minor version here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Minor version will be bumped because this change won't be available before protobuf v3.8.x is out.

@jtattermusch
Copy link
Contributor Author

I'll wait for #5838 to be merged first.

@jtattermusch
Copy link
Contributor Author

I added netstandard2.0 target and added conditional dependency on System.Memory for netstandard2.0 (It would have been possible to add also for net45, but I'm not sure how useful that would be).

@JamesNK
Copy link
Contributor

JamesNK commented Mar 12, 2019

FYI I'm halfway through a large PR to add span-based reader and writer for protobuf. Should be able to create a PR in the next day or two.

also add useful Span-based methods for ByteString
@jtattermusch
Copy link
Contributor Author

@anandolee @jskeet can we review and merge?

@jtattermusch jtattermusch requested a review from anandolee March 15, 2019 18:04
@anon17
Copy link

anon17 commented Feb 13, 2020

I think in the FromStream method you can use the "avoid a copy" branch on netstandard2.0, MemoryStream supports GetBuffer there.

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.

9 participants