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

In/outgoing Span<byte> support, linux net45 build #589

Merged
merged 1 commit into from
Nov 17, 2018

Conversation

damageboy
Copy link
Contributor

@damageboy
Copy link
Contributor Author

It's worthwhile to mention it might appear that I've removed a couple of input validation checks in the generated code, but this is not really so. Those checks happen anyway inside the constructor of Span<T> and will throw essentially the same exception from inside the Span<T> ctor.

@damageboy
Copy link
Contributor Author

Any comments about this?

@billsegall
Copy link
Contributor

billsegall commented Oct 7, 2018 via email

@damageboy
Copy link
Contributor Author

I'll try figuring that out, I admin I worked under the assumption that tests run as part of gradle, I'm suddenly not so sure

@ZachBray
Copy link
Contributor

ZachBray commented Oct 8, 2018

Thanks for the PR. Looks good to me, in general. :-)

My understanding is that only the code generation happens inside the Gradle script not the building/testing of the C# solution.

I have a few questions. I'm not sure who is best placed to answer them (maybe @billsegall ?).

  1. Could the introduction of the System.Memory dependency affect anyone? I.e., could users have been using .NET Framework < 4.5 to build the SBE generated code prior to this change? I guess the lower limit is currently whatever the sbe-tool package targets. The NuGet site doesn't make this obvious for this particular package.

  2. If users are affected, are we still happy to make the change? Or should we introduce a switch into the code generation that enables Span support? I think Olivier suggested this in [C#] Support Span<T> instead of / on top of T[] for array getters/setters #587.

  3. Do we use any features in netstandard2.0 that aren't in netstandard1.1? I ask as it looks like netstandard1.1 is supported by the System.Memory package and according to the .NET Standard compatibility matrix this is supported by .NET Framework v4.5. Would this mean we could simplify the build somewhat?

@ZachBray
Copy link
Contributor

ZachBray commented Oct 8, 2018

Also...

  1. Do we keep release notes somewhere?

@billsegall
Copy link
Contributor

billsegall commented Oct 8, 2018 via email

@billsegall
Copy link
Contributor

billsegall commented Oct 8, 2018 via email

@damageboy
Copy link
Contributor Author

damageboy commented Oct 8, 2018

@billsegall @ZachBray
I was thinking about (per @mjpt777) to update the relevant wiki pages re. the new dependency post merge.

I didn't think about the README.md inside the csharp folder, and see no reason not to amend this commit to reflect that dependency as well..

As for .NET 4.5 as minimum I think its a fair limitation given that official support is practically non existent for anything below 4.5.2 on the one hand, and .NET Framework 4.5 was released on 15 August 2012 on the other hand.

This is especially true for a performance / latency oriented project like this where you practically get free perf boost just for moving to .NET Core.

In other words, to me, it seems reasonable to say optimal perf is on .NET Core, compat for whatever reason you might need it goes back to 2012.

@mjpt777
Copy link
Contributor

mjpt777 commented Oct 8, 2018

The bulk of the notes can be in the csharp/README.md which can be referenced from the wiki.

@ZachBray
Copy link
Contributor

ZachBray commented Oct 8, 2018

@billsegall

I'm happy to maintain a reasonable amount of backward compatibility but MS
made this very difficult pre 2.0

I didn't realise that. Fair enough! :-)

We're currently targeting the nuget packages at netstandard2.0

Assuming the consumers are not building from source (is this a fair assumption?), this means we support .NET Framework >= v4.6.1 according to the .NET Standard compatibility table. In which case, please can we drop the multiple targets from here?

https://github.com/real-logic/simple-binary-encoding/blob/master/csharp/sbe-dll/sbe-dll.csproj#L4

I.e., only target netstandard2.0 for the class library. I believe this will make it easier to build on unix without mono if we switch the tests to use dotnet core. We could then get the CSharp tests running as part of the Travis build matrix.

@ZachBray
Copy link
Contributor

ZachBray commented Oct 8, 2018

@damageboy apologies for polluting your PR with these comments! They probably belong somewhere else.

@damageboy
Copy link
Contributor Author

@ZachBray As I'm now knee deep in figuring out how the unit tests work, it's actually good timing I think.

To be quite honest, I think I should simply run the tests as is manually on windows and give a scout's honor promise the tests are green.

Other than that, I think the tests require their own major overhaul in a separate PR,
I've opened a different issue for this: #592

- Closes real-logic#587
- Add netfx.props and tweak sbxee-dll csproj to allow building sbe.dll
  for net45 on Linux using dotnet sdk following:
  https://andrewlock.net/building-net-framework-asp-net-core-apps-on-linux-using-mono-and-the-net-cli/
- Remove packages.config files from projects already converted to SDK style project since
  those files serve no purpose other than confusing potential contributors...
- Intoroduce minimal Span<byte> GetBytes/SetBytes implementation for copying
  to/from Span<byte> to sbe.dll itself.
- Change code generation for array types to use Span<byte> internally keeping the
  original functionality intact with no (hopefully!) visible user facing changes except
  for the addtitional Get/Set methods accepting Span<byte> being added to the mix.
- Add release notes section to README.md and some more touch ups
- Add sbe-tests.csproj netcoreapp2.1 test target
@mjpt777
Copy link
Contributor

mjpt777 commented Nov 9, 2018

Can @JPWatson, @odeheurles, or @billsegall let me know if this should be merged or not?

@billsegall
Copy link
Contributor

billsegall commented Nov 11, 2018 via email

@mjpt777 mjpt777 merged commit 1793c8a into real-logic:master Nov 17, 2018

sb.append(String.format("\n" +
indent + "public %1$s Get%2$s(int index)\n" +
indent + "{\n" +
indent + INDENT + "if (index < 0 || index >= %3$d)\n" +
indent + INDENT + "{\n" +
indent + INDENT + "if (index < 0 || index >= %3$d) {\n" +
Copy link
Contributor

Choose a reason for hiding this comment

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

Why change the generated format here? Will this not now be inconsistent?

mjpt777 added a commit that referenced this pull request Dec 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants