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

Compatibility w/ C# versions below 8 #83

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sarietta
Copy link

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.

… do not support switch expressions. Also update the generator to use system paths to be compatible w/ non-Windows systems.
@mcintyre321
Copy link
Owner

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

@sarietta
Copy link
Author

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?

@mcintyre321
Copy link
Owner

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.

@sarietta
Copy link
Author

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!

@KuraiAndras
Copy link

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

@AraHaan
Copy link

AraHaan commented Jun 25, 2022

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.

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.

4 participants