mob-sakai / csharpcompilersettingsforunity Goto Github PK
View Code? Open in Web Editor NEWChange the C# compiler (csc) used on your Unity project, as you like!
License: MIT License
Change the C# compiler (csc) used on your Unity project, as you like!
License: MIT License
Description
Fails to compile in any 2022 version of Unity, such as 2022.2.0b8
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Compiles without any issues.
Environment (please complete the following information):
Additional context
Warning:
System.Exception: Reflection not found: Driver in Bee.BeeDriver.ActiveBuild
at Coffee.CSharpCompilerSettings.ReflectionExtensions.Get (System.Object self, System.String memberName, System.Reflection.MemberInfo mi) [0x00072] in <1953dcd1da5444c992e14e6e66b4207b>:0
at Coffee.CSharpCompilerSettings.CustomCompiler_2021.OnCompilationStarted (System.Object state) [0x00006] in <1953dcd1da5444c992e14e6e66b4207b>:0
at (wrapper delegate-invoke) System.Action`1[System.Object].invoke_void_T(object)
at UnityEditor.Compilation.CompilationPipeline+<>c.b__26_0 (System.Object context) [0x0000b] in :0
0x00007ff650443bcd (Unity) StackWalker::GetCurrentCallstack
0x00007ff650448c99 (Unity) StackWalker::ShowCallstack
0x00007ff651402a81 (Unity) GetStacktrace
0x00007ff651abc3e2 (Unity) DebugStringToFile
0x00007ff64f3707b6 (Unity) DebugLogHandler_CUSTOM_Internal_Log
0x0000015b867f353a (Mono JIT Code) (wrapper managed-to-native) UnityEngine.DebugLogHandler:Internal_Log (UnityEngine.LogType,UnityEngine.LogOption,string,UnityEngine.Object)
0x0000015b867f33cb (Mono JIT Code) UnityEngine.DebugLogHandler:LogFormat (UnityEngine.LogType,UnityEngine.Object,string,object[])
0x0000015b867f28ee (Mono JIT Code) UnityEngine.Logger:Log (UnityEngine.LogType,object)
0x0000015b867f257d (Mono JIT Code) UnityEngine.Debug:Log (object)
0x0000015c8cdbd81b (Mono JIT Code) UnityEditor.Compilation.CompilationPipeline/<>c:b__26_0 (object)
0x0000015c8cdbd5f8 (Mono JIT Code) UnityEditor.Scripting.ScriptCompilation.EditorCompilation:InvokeCompilationStarted (object)
0x0000015c8cd0765b (Mono JIT Code) UnityEditor.Scripting.ScriptCompilation.EditorCompilation:CompileScriptsWithSettings (UnityEditor.Scripting.ScriptCompilation.ScriptAssemblySettings)
0x0000015c8cd0530b (Mono JIT Code) UnityEditor.Scripting.ScriptCompilation.EditorCompilation:CompileScripts (UnityEditor.Scripting.ScriptCompilation.EditorScriptCompilationOptions,UnityEditor.BuildTargetGroup,UnityEditor.BuildTarget,int,string[])
0x0000015c8f259b83 (Mono JIT Code) UnityEditor.Scripting.ScriptCompilation.EditorCompilation:TickCompilationPipeline (UnityEditor.Scripting.ScriptCompilation.EditorScriptCompilationOptions,UnityEditor.BuildTargetGroup,UnityEditor.BuildTarget,int,string[],bool)
0x0000015c8f258f7b (Mono JIT Code) UnityEditor.Scripting.ScriptCompilation.EditorCompilationInterface:TickCompilationPipeline (UnityEditor.Scripting.ScriptCompilation.EditorScriptCompilationOptions,UnityEditor.BuildTargetGroup,UnityEditor.BuildTarget,int,string[],bool)
0x0000015c8f25934f (Mono JIT Code) (wrapper runtime-invoke) :runtime_invoke_EditorCompilation/CompileStatus_int_int_int_int_object_byte (object,intptr,intptr,intptr)
0x00007ffb223a0304 (mono-2.0-bdwgc) [mini-runtime.c:3445] mono_jit_runtime_invoke
0x00007ffb222deb44 (mono-2.0-bdwgc) [object.c:3066] do_runtime_invoke
0x00007ffb222decdc (mono-2.0-bdwgc) [object.c:3113] mono_runtime_invoke
0x00007ff65036bd14 (Unity) scripting_method_invoke
0x00007ff65034c6b4 (Unity) ScriptingInvocation::Invoke
0x00007ff6503471aa (Unity) ScriptingInvocation::Invoke
0x00007ff650488c7d (Unity) Scripting::UnityEditor::Scripting::ScriptCompilation::EditorCompilationInterfaceProxy::TickCompilationPipeline
0x00007ff6512afc9b (Unity) TickCompilationPipeline
0x00007ff6512afe3a (Unity) TickCompilationPipeline
0x00007ff650f886b8 (Unity) Application::TickTimer
0x00007ff6514092ca (Unity) MainMessageLoop
0x00007ff65140e240 (Unity) WinMain
0x00007ff6527be5fe (Unity) __scrt_common_main_seh
0x00007ffbd8747034 (KERNEL32) BaseThreadInitThunk
0x00007ffbda5226a1 (ntdll) RtlUserThreadStart
Error:
ArgumentNullException: Value cannot be null.
Parameter name: source
System.Linq.Enumerable.TryGetFirst[TSource] (System.Collections.Generic.IEnumerable1[T] source, System.Func
2[T,TResult] predicate, System.Boolean& found) (at :0)
System.Linq.Enumerable.First[TSource] (System.Collections.Generic.IEnumerable1[T] source, System.Func
2[T,TResult] predicate) (at :0)
Coffee.CSharpCompilerSettings.CustomCompiler_2021.OnAssemblyCompilationFinished (System.String dllPath, UnityEditor.Compilation.CompilerMessage[] messages) (at <1953dcd1da5444c992e14e6e66b4207b>:0)
UnityEngine.Debug:LogException(Exception)
Coffee.CSharpCompilerSettings.CustomCompiler_2021:OnAssemblyCompilationFinished(String, CompilerMessage[])
UnityEditor.Scripting.ScriptCompilation.EditorCompilationInterface:TickCompilationPipeline(EditorScriptCompilationOptions, BuildTargetGroup, BuildTarget, Int32, String[], Boolean)
Describe the bug
Updated my project from 1.3.0 to 1.4.0 with Unity 2020.1.17 and not all of my sources are compiled
To Reproduce
Can't really
Expected behavior
All sources compile
Environment (please complete the following information):
Additional context
The problem might come from the fact that we are using external .cs files added as unity packages. We have several projects included like:
[package.json]
"bimvisualizer.shared": "file:../../BimVisualizer.Shared",
These point to folders with .net standard 2.0 projects (which are using C#9.0) (also the bin and obj folders are renamed to .bin and .obj so unity will not try to use the dlls inside them). The errors seem to only come from one project where c# 9 and 8 are used, and not from the unity project.
Should I include another folder for assemblies in the settings?
Describe the bug
"global using directive" not work.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/using-directive
Environment (please complete the following information):
The following tags and branches will be supported until 2020/12/31.
Use OpenUPM instead, or use SHA1.
The note on OpenSesameCompilerForUnity said it had been integrated into this project, but I can't find any setting to allow accessing privates & internals.
So I actually tested this out today, but somehow I can't get it to work?
It seems like it should allow C#10 Compilation etc... as the project says but it just won't work!
There was a section about Unity 2021.1 and later...
mob-sakai/CSharpCompilerSettingsForUnity: Change the C# compiler (csc) used on your Unity project, as you like!
I followed exactly what was said, used the CUSTOM_COMPILE compiler directive and had also an #else flow...
Why isn't it working? Even when building the project into an executable the defaut compiler for Unity is still used...
Help!
So the UI Object doesn't become red neither on build nor in the Unity Player...
Thanks in advance
Compiler fails to compile the file with error.
error CS1504: Source file '***/Assets/TrueSync/Physics/Farseer/Common/PhysicsLogic/RealExplosion.cs' could not be opened -- GetCPInfoExW
To Reproduce
Steps to reproduce the behavior:
Environment:
Additional context
Probably it's related to this issue
mono/mono#12603
ILSpy shows that System.Text.Encoding.CodePages.dll library inside Microsoft.Net.Compiler package use WinApi
Note: Can't share the original project but only part of it enough to reproduce the error.
Note: Error will also occure if you try to directly call mono <path to downloaded csc.exe> <path to RealExplosion.cs>
Is your feature request related to a problem? Please describe.
If you want to use nullable reference types after C#8.0 you either have to manually add the
<Nullable>enable</Nullable>
property to enable nrt or you have to annotate each file with
#nullable enable
Describe the solution you'd like
In the settings there should be an option for adding the Nullable property when adding the desired LangVersion property. One problem might be is when you want only some projects to have the Nullable property but that would require porject-by-project settings which are as of yet not supported anyway.
Thanks for building this great project.
I tried this project and it works great with C# 9 syntax.
However, I cannot make it work with C# 9 Source Generators. May I know if this support?
I am using Unity 2020.3.
NOTE: Your issue may already be reported! Please search on the issue tracker before creating one.
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Steps to reproduce the behavior:
stdout:
stderr:
Specify which project file to use because this 'D:\GitHubs\example' contains more than one project file.
Environment
Platform: Editor(Windows)
Unity version: 2021.2.11f1
Build options:
Additional context
The BuiltIn Compiler worked perfect in Unity Editor for MacOs.
Suggest solution
Change the Setup function inside CompilerInfo to this:
public void Setup(ProcessStartInfo psi, string responseFile, RuntimePlatform platform)
{
if (platform == RuntimePlatform.WindowsEditor
&& Path.EndsWith(".exe"))
{
psi.FileName = System.IO.Path.GetFullPath(Path);
psi.Arguments = "/shared /noconfig @" + responseFile;
}
else
{
psi.FileName = System.IO.Path.GetFullPath(RuntimePath);
psi.Arguments = "\"" + Path + "\"" + " /noconfig @" + responseFile;
}
psi.CreateNoWindow = true;
psi.UseShellExecute = false;
}
I changed the Path
to "\"" + Path + "\""
to avoid problem with Windows file path since C:\Program Files\Unity\Hub\Editor\2021.2.11f1\Editor\Data\DotNetSdkRoslyn\csc.dll
has space in the path string.
I also found that CustomCompiler_2021
need to change in this function
private string GetOutDir(string dagName)
{
if (dagName.EndsWith("E")) return "Library/ScriptAssemblies";
var unityVersions = Application.unityVersion.Split('.');
if (int.Parse(unityVersions[0]) == 2021)
//return "Library/PlayerScriptAssemblies";
return "Library/ScriptAssemblies";
else
return "Library/Bee/PlayerScriptAssemblies";
}
since the Library/PlayerScriptAssemblies
was not found.
Library
directory
dotnet
or nuget
Project Settings
window
Temp/UnityTempFile-***
Describe the bug
When adding a UPM package locally, and then generating a csproj for it through unity, de generated project for the upm package does not get updated when generating.
To Reproduce
Steps to reproduce the behavior:
Unity does not report any compile errors(correctly), while Visual Studio shows an error in CCFUBugSample.SampleService.TestSwitch. This is because in the unity generated CCFUBugSample.csproj the LangVersion property is set to 7.3 instead of 8.
Expected behavior
Any generated csproj gets the desired LangVersion property value
Environment (please complete the following information):
Additional context
If this would cause problems for some users, maybe consider making this behavior optional through settings
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
Originally posted by @SugoiDev in #6 (comment)
Plugin do something and adds Compilation directives CSHARP_8_OR_LATER...
but actually can not compile any C# 8 code
even csc.rsp -langversion:8.0 stop compiler function with error of uncompatible lang version
Environment (please complete the following information):
NOTE: Your issue may already be reported! Please search on the issue tracker before creating one.
When I use any Compiler and click 'apply',editor will start the progress not be done.I can see from the task manager that there is network traffic going through and after a while it doesn't. But progress is still stuck.
To Reproduce
Steps to reproduce the behavior:
[CscSettings] Install package: OpenSesame.Net.Compilers.Toolset.4.0.1
UnityEngine.Debug:Log (object)
Coffee.CSharpCompilerSettings.Logger:LogInfo (string,object[])
Coffee.CSharpCompilerSettings.Utils:InstallPackage (string,string)
Coffee.CSharpCompilerSettings.Utils:InstallNugetPackage (string)
Coffee.CSharpCompilerSettings.CompilerInfo:GetInstalledInfo (string)
Coffee.CSharpCompilerSettings.Core:Initialize ()
UnityEditor.EditorAssemblies:ProcessInitializeOnLoadMethodAttributes ()
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Exception: Package 'OpenSesame.Net.Compilers.Toolset.4.0.1' installation failed.
at Coffee.CSharpCompilerSettings.Utils.InstallPackage (System.String packageId, System.String url) [0x000a6] in <1953dcd1da5444c992e14e6e66b4207b>:0
at Coffee.CSharpCompilerSettings.Utils.InstallNugetPackage (System.String packageId) [0x00016] in <1953dcd1da5444c992e14e6e66b4207b>:0
at Coffee.CSharpCompilerSettings.CompilerInfo.GetInstalledInfo (System.String packageId) [0x00000] in <1953dcd1da5444c992e14e6e66b4207b>:0
at Coffee.CSharpCompilerSettings.Core.Initialize () [0x001d1] in <1953dcd1da5444c992e14e6e66b4207b>:0
at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in <695d1cc93cca45069c528c15c9fdd749>:0
--- End of inner exception stack trace ---
at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00048] in <695d1cc93cca45069c528c15c9fdd749>:0
at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <695d1cc93cca45069c528c15c9fdd749>:0
at UnityEditor.EditorAssemblies.ProcessInitializeOnLoadMethodAttributes () [0x00047] in <2cd7ebc9c2ef4276a8edbc7de85c89ce>:0
UnityEditor.EditorAssemblies:ProcessInitializeOnLoadMethodAttributes ()
Environment (please complete the following information):
Additional context
Add any other context about the problem here.
the NugetPackageDrawer class is trying to reference id
and version
from a json that didnt have it:
.Concat(obj.items).SelectMany(x => x.items)
.Select(x => new(x.catalogEntry.id, x.catalogEntry.version, ...)
my first change was to make it work requried to add a @id
field to the catalog page class and an upper
field (for version), the items array was left unused and the select becomes:
.Concat(obj.items).
.Select(x => new(x.@id, x.upper, ...)
and here is the json that I would normally get for Microsoft.Net.Compilers.
however, this wont show all of the versions for open sesame because the json for those actually matches, so a better fix for me locally is to init the items variables for catalog root and page to a new blank array s o that linq could keep going.
public CatalogPage[] items = { };
public Package[] items = { };
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.