这是一个关于 monodevelop 的“坑”

我们在用 monodevelop 编译游戏脚本时, 通常会有一些警告,一般这些警告都是无害的,

不影响游戏运行。可是突然有一天, monodevelop 发神经将一些警告标记为错误,导致unity

无法运行游戏。查看 monodevelop 的输出信息, 发现以下信息:

Unhandled Exception:
Mono.CSharp.InternalErrorException: /Player/PlayerAnimationController.cs(89,17): <ErrorIllustration>c__Iterator39 ---> System.ArgumentException: Label not marked
at System.Reflection.Emit.ILGenerator.label_fixup () [0x00000] in <filename unknown>:0
at System.Reflection.Emit.MethodBuilder.fixup () [0x00000] in <filename unknown>:0

...

恩, ErrorIllustration 是我们自己写的一个函数, 查看一下该函数的代码

 IEnumerator ErrorIllustration ()
{
yield return null; if ( false )
{
yield return null; } yield break;
}

这里面有一段 unreachable code , 难道是这里出的问题?

尝试着把这段代码删除掉, monodevelop 居然恢复正常了,

看来如果携程中有一段 unreachable code, 将会导致 monodevelop 产生内部异常。

04-14 18:28