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

unity 2018 could not use unity-net #399

Open
springlight opened this issue Jun 11, 2018 · 11 comments
Open

unity 2018 could not use unity-net #399

springlight opened this issue Jun 11, 2018 · 11 comments

Comments

@springlight
Copy link

when i put the unit-net folder into my unity project ,some errors occurs ,like below

Assets/Plugins/protobuf-net/BclHelpers.cs(212,56): error CS1644: Feature `out variable declaration' cannot be used because it is not part of the C# 4.0 language specification

public static void WriteDuration(TimeSpan value, ProtoWriter dest) { var seconds = ToDurationSeconds(value, out int nanos); WriteSecondsNanos(seconds, nanos, dest); }

@mgravell
Copy link
Member

Yes, the code is currently written with "latest" in mind. I've done a quick check, and adding <LangVersion>4.0</LangVersion> requires somewhere in the region of 100 changes.

I'm uncertain of the wisdom of forcing the library to adopt down-level C#; my understanding - right or wrong - is that unity should be able to consume the code as a library, in which case: the language version used does not matter. Is there a blocking issue with consuming the library as a library? Is there some additional build target / TFM that we should add, for example?

@mgravell
Copy link
Member

lol; if you fix the first 100-or-so, you get more - as the compiler realises there are more invalid things

@mgravell
Copy link
Member

I pushed a branch there ^^^ to investigate what the impact of this would be; frankly, I consider many of those changes serious regressions, and I'd rather pursue just about any alternative than to merge that branch.

So: what is the issue that prevents Unity consuming this as a library package? That is my ideal solution here.

@springlight
Copy link
Author

thanks for reply,using the src code as a library works perfect on android platform.but on IOS,it goes wrong JIT in unity does not work on IOS,cause some Serialization error

@mgravell
Copy link
Member

Have you tried 2.3.10? Some changes went out over the weekend that might help with some categories of errors.

@mgravell
Copy link
Member

You might also get better experiences if you limit it to the NETStandard1.0 target - this omits the entire IL generation part of the codebase, which is probably where most of the iOS problems come in.

@springlight
Copy link
Author

ok,I'll try 2.3.10 then

@gamemachine
Copy link

Unity supports two different runtimes one for 3.5 and under and another for 4.x and above. On top of that if you choose 4.x you have a choice of 4.x api or standard 2 api.

If you are on Unity 2018 you should be using the 4.x runtime unless there are other reasons not to.

@kushinn
Copy link

kushinn commented Sep 16, 2018

image
image

It's C# 7.0 language feature.

And the readonly struct is C# 7.2 language feature.

@OptrixAU
Copy link

Using it as a library has issues for cross-platform use - Unity only uses the latest version of .NET on WIndows platforms. Otherwise, you're restricted to .NET 2.0 via MONO on Linux and MacOS, and nothing at all of WebGL, IOS and Android platforms.

Adding the source however allows it to operate on every platform.

@mgravell
Copy link
Member

That's all well and good, but the usage of latest-C#-version features is likely to increase, not decrease, especially as I try to finish up the "span"/"sequence" work. There are language features in C#7/8 specifically for these scenarios - features that I kinda want.

So: it would be a massive problem to restrict language version, at least for the core lib. For generated code (protogen), sure: down-level is fine. I would still rather focus on what target platforms can be maintained to allow it to be used effectively as a library, if unity isn't going to use an up-to-date compiler.

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

No branches or pull requests

5 participants