Search Unity

Editor emits an exception in UnityEditor.Scripting.ScriptCompilers.GetNamespace

Discussion in 'Scripting' started by Qbit86, Nov 14, 2018.

  1. Qbit86

    Qbit86

    Joined:
    Sep 2, 2013
    Posts:
    426
    During project upgrade from Unity 5.5.0p4 to 2018.2.15, Editor emitted this error:
    Code (csharp):
    1. Updating Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonClasses.cs - GUID: f40f16a0227e5c14293e269c875c0f9b...
    2. InvalidOperationException: Stack empty.
    3. at System.Collections.Generic.Stack`1[T].ThrowForEmptyStack () [0x00000] in <ac210d81537245bc838518cc8e845861>:0
    4. at System.Collections.Generic.Stack`1[T].Pop () [0x00008] in <ac210d81537245bc838518cc8e845861>:0
    5. at UnityEditor.Scripting.ScriptCompilation.CSharpNamespaceParser.ApplyOp (System.Char op, System.Collections.Generic.Stack`1[T] values) [0x00037] in C:\buildslave\unity\build\Editor\Mono\Scripting\ScriptCompilation\CSharpNamespaceParser.cs:290
    6. at UnityEditor.Scripting.ScriptCompilation.CSharpNamespaceParser.EvaluateBool (System.String expression) [0x000c5] in C:\buildslave\unity\build\Editor\Mono\Scripting\ScriptCompilation\CSharpNamespaceParser.cs:272
    7. at UnityEditor.Scripting.ScriptCompilation.CSharpNamespaceParser.EvaluateBooleanExpression (System.String expression) [0x00065] in C:\buildslave\unity\build\Editor\Mono\Scripting\ScriptCompilation\CSharpNamespaceParser.cs:250
    8. at UnityEditor.Scripting.ScriptCompilation.CSharpNamespaceParser.EvaluateDefine (System.String expr, System.Collections.Generic.ICollection`1[T] defines) [0x001dd] in C:\buildslave\unity\build\Editor\Mono\Scripting\ScriptCompilation\CSharpNamespaceParser.cs:241
    9. at UnityEditor.Scripting.ScriptCompilation.CSharpNamespaceParser.RemoveUnusedDefines (System.String source, System.Collections.Generic.List`1[T] defines) [0x0010d] in C:\buildslave\unity\build\Editor\Mono\Scripting\ScriptCompilation\CSharpNamespaceParser.cs:182
    10. at UnityEditor.Scripting.ScriptCompilation.CSharpNamespaceParser.RemoveIfDefs (System.String source, System.Collections.Generic.IEnumerable`1[T] defines) [0x00008] in C:\buildslave\unity\build\Editor\Mono\Scripting\ScriptCompilation\CSharpNamespaceParser.cs:159
    11. at UnityEditor.Scripting.ScriptCompilation.CSharpNamespaceParser.GetNamespace (System.String sourceCode, System.String className, System.String[] defines) [0x00076] in C:\buildslave\unity\build\Editor\Mono\Scripting\ScriptCompilation\CSharpNamespaceParser.cs:42
    12. Rethrow as IllegalNamespaceParsing: Searching for classname: 'PhotonClasses' caused error in CSharpNameParser
    13. at UnityEditor.Scripting.ScriptCompilation.CSharpNamespaceParser.GetNamespace (System.String sourceCode, System.String className, System.String[] defines) [0x0008e] in C:\buildslave\unity\build\Editor\Mono\Scripting\ScriptCompilation\CSharpNamespaceParser.cs:48
    14. at UnityEditor.Scripting.Compilers.CSharpLanguage.GetNamespaceNewRuntime (System.String filePath, System.String definedSymbols) [0x000a0] in C:\buildslave\unity\build\Editor\Mono\Scripting\Compilers\CSharpLanguage.cs:73
    15. at UnityEditor.Scripting.Compilers.CSharpLanguage.GetNamespace (System.String filePath, System.String definedSymbols) [0x00010] in C:\buildslave\unity\build\Editor\Mono\Scripting\Compilers\CSharpLanguage.cs:122
    16. at UnityEditor.Scripting.ScriptCompilers.GetNamespace (System.String file, System.String definedSymbols) [0x0004c] in C:\buildslave\unity\build\Editor\Mono\Scripting\ScriptCompilers.cs:101
    17.  
    18. (Filename: <ac210d81537245bc838518cc8e845861> Line: 0)
    19.  
    20. done. [Time: 49.710300 ms]
    Not sure if it is critical, but looks like an obvious error.
     
  2. Gambit-MSplitz

    Gambit-MSplitz

    Joined:
    May 16, 2015
    Posts:
    1,220
    Your compiler could not find the class named "PhotonClasses", I recommend checking your PhotonClasses.cs file and make sure that class or namespace did not get re-named incorrectly by the automatic part of your unity version upgrade.

    It also wouldn't hurt to right-click your "Photon Unity Networking" folder and "reimport all".
     
  3. Qbit86

    Qbit86

    Joined:
    Sep 2, 2013
    Posts:
    426
    I've checked the file, it looks like usual source code, nothing special. Git does not report any silent changes on it.

    Anyway, even if the file got messed up this should be ordinary compilation error; not some “internal” failure.
     
  4. aurelien-morel-ubiant

    aurelien-morel-ubiant

    Joined:
    Sep 27, 2017
    Posts:
    235
    I have the same issue during a import on a script between one of my project between unity 2018.3b8 / 2018.3b9.

    I reported a bug and they reproduced it.

    I try to generate a smaller project to reduce the number of script to the minimum required.

    Don't hesitate to report it too, cause for me it was due to Unity 2018.3b9 but maybe not when I see yours.

    P.S : Here it's on one of our script not a photon one.
     
    Last edited: Nov 15, 2018
    Qbit86 likes this.
  5. Qbit86

    Qbit86

    Joined:
    Sep 2, 2013
    Posts:
    426
    Please let me know when things get clarified!
     
  6. aurelien-morel-ubiant

    aurelien-morel-ubiant

    Joined:
    Sep 27, 2017
    Posts:
    235
    I found my issue ! One entiere afternoon !

    Do you have something like this ?


    Code (CSharp):
    1. namespace Designer.PlanCreator.UI
    2. {
    3. using UnityEngine;
    4.     public class PlanCreatorUIManager : MonoBehaviour
    5.     {
    6. #if UNITY_EDITOR || !UNITY_WEBGL
    7. #endif
    8.     }
    9. }
    The issue come from the combination of namespace around a #if SOMETHING || !SOMETHING_ELSE

    An easy fix if you have the same pattern is to add parenthesis around second member :
    #if UNITY_EDITOR || (!UNITY_WEBGL)

    I will report my ultra light project and I think it will be good !

    I think it's an issue that appeared in 2018.2.15 and that has been backported to 2018.3b9
     
    Last edited: Nov 15, 2018
    Gerold_Meisinger and Qbit86 like this.
  7. aurelien-morel-ubiant

    aurelien-morel-ubiant

    Joined:
    Sep 27, 2017
    Posts:
    235
    @Qbit86 is it your issue ? I see you like mine but just to confirm :)
     
  8. Qbit86

    Qbit86

    Joined:
    Sep 2, 2013
    Posts:
    426
    No, I don't have exact pattern, but do have another combination of `#if` conditions. However, I failed to reproduce this on mini-project with just that file `PhotonClasses.cs` (opened in Unity 5.5 and upgraded to Unity 2018.2).
     
  9. aurelien-morel-ubiant

    aurelien-morel-ubiant

    Joined:
    Sep 27, 2017
    Posts:
    235
    oh snap :/

    Cause when I read your stacktrace it really looks like an issue with the same kind of pattern with namespace containing #if

    But maybe some other pattern can make it fails.
    Which are the pattern you have, I can maybe try them in my buggy one ?
     
  10. Qbit86

    Qbit86

    Joined:
    Sep 2, 2013
    Posts:
    426
    The default hypothesis should be that there are no relationship between observed evidences :)

    It's like `#if !UNITY_MIN_5_3` inside and outside the namespace. I will try enclose negation in parentheses next time I'll try to reimport.
     
    aurelien-morel-ubiant likes this.
  11. aurelien-morel-ubiant

    aurelien-morel-ubiant

    Joined:
    Sep 27, 2017
    Posts:
    235
    I don't think it will change something (I tried this case yesterday afternoon) I think it's another compiler parsing issue.

    But as you said default hypothesis :)
     
    Qbit86 likes this.
  12. Gerold_Meisinger

    Gerold_Meisinger

    Joined:
    Sep 8, 2015
    Posts:
    93
    @Qbit86: Thank you! I had the same pattern and the parenthesis fixed it. How can you even track it down to something like this?
     
  13. aurelien-morel-ubiant

    aurelien-morel-ubiant

    Joined:
    Sep 27, 2017
    Posts:
    235
    oh and I found another one btw :
    Code (CSharp):
    1. #if(UNITY_ANDROID)
    that you must replace by

    Code (CSharp):
    1. #if (UNITY_ANDROID)
    I submitted it, it will be fixed in rc1 or rc2 don't remember and the one that I mentionned in this forum is fixed since b12 (if I'm not wrong)
     
    Nickolauson likes this.