mob-sakai / CSharpCompilerSettingsForUnity

Change the C# compiler (csc) used on your Unity project, as you like!
MIT License
289 stars 22 forks source link

Support 2020.2 #6

Closed mob-sakai closed 3 years ago

github-actions[bot] commented 4 years ago

:tada: This issue has been resolved in version 1.3.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket:

VolodymyrBS commented 3 years ago

I just try upgrade my C#9 test project to Unity 2020.2.0b11 and it's says that I have compilation errors and show safe mode pop-up. If I click "Ignore" it start compiling by compiler that I choose (in my case Microsoft.Net.compiler.Toolset 3.8.0). If I chose enter safe mode it shows c# 9 syntax features as error. also it fails if I start build in batch mode.

did I miss something?

mob-sakai commented 3 years ago

https://forum.unity.com/threads/invitation-to-try-out-unity-safe-mode.925043/page-2#post-6536662

On previous Unity versions code in precompiled assemblies marked with InitializeOnLoad could be run before compiler.

Yes. This plugin is based on this "specification." I'm looking for a workaround.

SugoiDev commented 3 years ago

It was confirmed as an intentional change: https://forum.unity.com/threads/invitation-to-try-out-unity-safe-mode.925043/page-2#post-6555160

Hi. At startup it isn't possible to run user code before compilation, if compilation is needed. It is correct that before 2019.3 that Unity at startup would load domain with user assemblies before compilation, even though if there were new scripts. This was considered a problematic and therefore the order was changed.

mob-sakai commented 3 years ago

@VolodymyrBS @SugoiDev I found a work-around! Please try to use 1.4.0-preview.1!

SugoiDev commented 3 years ago

On 2021.1.a9 the "Apply" button is causing an exception, so I couldn't test it yet.

[Exception] InvalidOperationException: Sequence contains no matching element
Enumerable.First[TSource]() at <351e49e2a5bf4fd6beabb458ce2255f3>:0

ReflectionExtensions.Call() at <26e68dbb771b4491aa5f1dc8f99cc436>:0

Utils.RequestCompilation() at <26e68dbb771b4491aa5f1dc8f99cc436>:0

CscSettingsProvider+<>c.<OnGUI>b__9_1() at Library/PackageCache/com.coffee.csharp-compiler-settings@88d8659a14/Editor/CscSettingsProvider.cs:100
98:       serializedObject.ApplyModifiedProperties();
99:       File.WriteAllText(CscSettingsAsset.k_SettingsPath, JsonUtility.ToJson(serializedObject.targetObject, true));
-->100:       Utils.RequestCompilation();
101:   },
102:   onReload: () =>

InspectorGUI.DrawControl() at Library/PackageCache/com.coffee.csharp-compiler-settings@88d8659a14/Editor/InspectorGUI.cs:175
174:       if (onApply != null && GUILayout.Button(s_ApplyText))
-->175:           onApply();
176:   }

CscSettingsProvider.OnGUI() at Library/PackageCache/com.coffee.csharp-compiler-settings@88d8659a14/Editor/CscSettingsProvider.cs:94
93:   // Controls
-->94:   InspectorGUI.DrawControl(serializedObject.hasModifiedProperties,
95:       onRevert: () => { serializedObject = new SerializedObject(CscSettingsAsset.instance); },
96:       onApply: () =>

SettingsProvider.OnGUI() at <a19e86c7bf354115a4c6a5953c0575cb>:0
mob-sakai commented 3 years ago

@SugoiDev Thanks!

VolodymyrBS commented 3 years ago

just tried with Unity 2020.2.1f1 and it's work without any errors with normal editor launch and in batch mode!🎉

also I tried Unity 2021.1.0b1 and had Enter Safe Mode message. after exiting safe mode I has same error @SugoiDev had

mob-sakai commented 3 years ago

I've create a new issue for 2021.1.0.

VolodymyrBS commented 3 years ago

do you have plan to release version 1.4.0 out of preview any time soon?

mob-sakai commented 3 years ago

@VolodymyrBS ASAP!

mob-sakai commented 3 years ago

Version 1.4.0 has been released.