Closed cdanek closed 2 years ago
mpc's Roslyn version is now 3.10.0 C#10 seems to be supported since 4.
To solve this problem we need to update the version. I am worried that the VS2019 16.11users will not be able to use mpc aot.
Thank you for the comment. Is it possible to upgrade to a higher Roslyn version for my own MPC use in C#10 projects?
Ready to merge
mpc carries its own roslyn dependencies with it, so it shouldn't be a problem to raise the target roslyn version. When/if we add roslyn Source Generators support though, such a thing would be of more concern. But I don't expect that to play well with Unity.
Does #1368 finish fixing this, @pCYSl5EDgo?
I think the fix is done. The C#10 feature test should be added to Sandbox or TestData2.
Great. Are you planning to add the test, @pCYSl5EDgo ?
@AArnott Yes. #1371
Is your feature request related to a problem? Please describe.
I have a class library targeting .NET 4.7.2, for which I'm leveraging the AOT generation from MPC so that the library is usable in Unity with IL2CPP. I thought I'd be smarter than I am and leverage the new language features in C#10 (which I really like to use in other projects) by setting the langversion to 10.0 in the csproj file. Unfortunately, after quite a bit of hacking and experimentation, I've discovered that classes that do not have usings (and instead leverage global usings elsewhere) behave erratically / not at all when using MPC.
Describe the solution you'd like
MPC generates code for objects that are contained in files that have global usings.
Additional context
Here is a minimal reproduction of the problem.
Normal behaviour:
Generating code (using
dotnet mpc -i myproj.csproj -o generated.cs
) works as expected:Changing this to the following 2 files:
Yields:
Other erratic examples (not as easy to reproduce, but similar setup) have error messages like:
In each of the 3 above examples, the classes were (I presume) formatted correctly, as changing the lang version to 8.0 or "default" and reverting use of
global using
resolved the MPC errors.