OneOf icon indicating copy to clipboard operation
OneOf copied to clipboard

Compatibility w/ C# versions below 8

Open sarietta opened this issue 3 years ago • 6 comments

Updated the generator to be compliant with C# versions below 8, which do not support switch expressions. I'm not sure what (if any) performance issues there may be w/ that change, but it seems like it's strictly better to be more compatible than not over using language features.

This exact issue came up for me as I was attempting to use OneOf in Unity, which doesn't support version 8.

As a bonus, I also updated the generator to use system paths so it's compatible w/ non-Windows systems.

sarietta avatar Apr 21 '21 18:04 sarietta

How come you ran into this? Are you using the source in Unity, or are you using the Nuget package?

mcintyre321 avatar Apr 22 '21 11:04 mcintyre321

I was attempting to use the source directly in Unity. Does the nuget package automatically handle making the *.generated.cs files compliant with lower versions?

sarietta avatar Apr 22 '21 16:04 sarietta

When you use a nuget package, you get a compiled assembly (there are several, for different framework versions in side the package). One of them should work with Unity. I'm not very familiar with Unity, but maybe installing OneOf via https://github.com/GlitchEnzo/NuGetForUnity would work for you, and you wouldn't need to include the source files in your project.

mcintyre321 avatar Apr 23 '21 09:04 mcintyre321

I can look into that, but the normal way packages are used, in my experience, in Unity is either through the Unity Asset Store or by direct source inclusion. nuget rarely comes into play for me, but thank you very much for that link!

You can feel free to close #83 if it doesn't work with your vision of this library, but I can imagine this may come up again for others. I know personally I'll be maintaining my own fork if that's the case, but it really is up to you.

Thanks for being responsive either way!

sarietta avatar Apr 23 '21 21:04 sarietta

The intended way to consume nuget package with unity is by downloading the dlls and then placing them under the assets folder.

KuraiAndras avatar Jun 01 '21 07:06 KuraiAndras

That is until unity completely ports to an .NET SDK workload which allows using the official builds of the compiler, runtime, and frameworks which would allow nuget support for free.

AraHaan avatar Jun 25 '22 09:06 AraHaan