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

UniTask does not work in .NET Framework environment after adding UniTask.AsValueTask #535

Merged
merged 3 commits into from Jan 25, 2024

Conversation

kochounoyume
Copy link
Contributor

Probably after #533 was implemented, I started getting the following error in the .NET Framework environment of Unity2021.

Library\PackageCache\com.cysharp.unitask.........\Runtime\IUniTaskSource.cs(55,41): error CS1961: Invalid variance: The type parameter 'T' must be invariantly valid on 'IValueTaskSource'. 'T' is covariant.

This is a modification of that, revising the conditional compilation section.

However, the error itself does not seem to be a case of missing definitions, so there may be an answer that takes into account the .NET Framework environment.

Either way, the fix for this problem seems urgent.

@timcassell
Copy link

timcassell commented Jan 24, 2024

The suggested changes here breaks the nuget package. I suggest instead checking the API compatibility level. (NET_4_6 or NET_STANDARD)

@timcassell
Copy link

Also, I just tried this in 2021.3.30 and I didn't get any errors in .Net Standard 2.1 or .Net Framework. Perhaps you should start with an issue describing the exact repro steps.

@kochounoyume
Copy link
Contributor Author

@timcassell Thanks for pointing that out!

Certainly this change seems problematic.

Regarding reproducibility, here too, Unity 2021.3.34 did not show any errors in .NET Framework .

However, with Unity2021.3.16, the error occurs.

I guess the problem is caused by the changes made during this time.

@kochounoyume
Copy link
Contributor Author

Apparently the error occurs in .NET Framework environments up to Unity 2021.3.27.

The error does not seem to occur in Unity 2021.3.28 and above, so it must be caused by changes made during that time.

@timcassell
Copy link

From 2021.3.28 release notes:
Mono: Corrected handle generic parameter attributes in the .Net Framework Api Compatibility Level. (UUM-32896)

@kochounoyume
Copy link
Contributor Author

I see, that was the reason.

If that's true, it would mean that the error occurs in, say, Unity 2022.3.0 as well.

I wonder if I have to set up a conditional compilation that specifies all the relevant versions, although it would be troublesome...

@kochounoyume
Copy link
Contributor Author

I tried it on Unity 2022.3.0 with .NET Framework and it was true...

@neuecc
Copy link
Member

neuecc commented Jan 25, 2024

Thank you for the detailed investigation.
First, since this feature is not essential, let's simplify the base criteria.
We will make it LTS 2022_3 or higher.
Versions 2022.3.0 and 3.1 might be affected, but since these versions are relatively new and the impact seems minimal, I think it's okay to ignore them.
As for anything post-2023, they are previews, so I'm not concerned about those.

@kochounoyume
Copy link
Contributor Author

Thanks for setting the guidelines!

That made it a lot easier to understand. I'll be submitting my revisions right now!

@neuecc neuecc merged commit 0ef6c59 into Cysharp:master Jan 25, 2024
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

3 participants