OneOf
OneOf copied to clipboard
Compatibility w/ C# versions below 8
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.
How come you ran into this? Are you using the source in Unity, or are you using the Nuget package?
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?
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.
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!
The intended way to consume nuget package with unity is by downloading the dlls and then placing them under the assets folder.
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.