Crash in ssc.exe when using partial classes.
I have a (close to) minimal example capable of producing a crash in ssc.exe, and a workaround.
Crash:
Script# Compiler v0.7.0.0 (C# to JavaScript compiler)
Written by Nikhil Kothari.
More information at http://projects.nikhilk.net/ScriptSharp.
Unhandled Exception: System.NullReferenceException: Object reference not set to
an instance of an object.
at ScriptSharp.Compiler.MetadataBuilder.BuildTypeInheritance(ClassSymbol clas
sSymbol)
at ScriptSharp.Compiler.MetadataBuilder.BuildMetadata(ParseNodeList compilati
onUnits, SymbolSet symbols, ResourceSet resources, CompilerOptions options)
at ScriptSharp.ScriptCompiler.BuildMetadata()
at ScriptSharp.ScriptCompiler.Compile(CompilerOptions options)
at ScriptSharp.ScriptCompilerApplication.Execute(String[] args)
at ScriptSharp.Application.Main(String[] args)
Input (command line):
C:\Program Files\ScriptSharp\v1.0>ssc /debug /ref:.\Framework\mscorlib.dll /ref:.\Framework\Script.jQuery.dll ref:.\Framework\Script.web.dll /out:.\SomeScript.js c:\projects\Repros\AssemblyInfo.cs c:\Projects\Repros\BaseClass.cs c:\Projects\Repros\Partial1.cs c:\Projects\Repros\Partial2.cs
Input (files):
AssemblyInfo.cs
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
[assembly: ScriptAssembly("SomeScript")]
BaseClass.cs
using System;
namespace ABC
{
public class MyBaseClass
{
public MyBaseClass()
{
}
}
}
Partial1.cs
using System;
namespace XYZ
{
public partial class MyClass
{
public string _someField;
}
}
Partial2.cs
using System;
using ABC;
namespace XYZ
{
public partial class MyClass : MyBaseClass
{
public MyClass()
{
}
}
}
Workaround:
Change the input order so that Partial2.cs comes before Partial1.cs. Of note, Partial1 lacks the base class reference while Partial2 specifies the base class. The workaround if using a csproj is to edit the order the < compile > elements so that Partial2.cs comes before Partial1.cs.
C:\Program Files\ScriptSharp\v1.0>ssc /debug /ref:.\Framework\mscorlib.dll /ref:.\Framework\Script.jQuery.dll ref:.\Framework\Script.web.dll /out:.\SomeScript.js c:\projects\Repros\AssemblyInfo.cs c:\Projects\Repros\BaseClass.cs c:\Projects\Repros\Partial2.cs c:\Projects\Repros\Partial1.cs
I'm guessing, but a simpler workaround is probably specifying the derivation in each partial class. Can you give that a quick try?
That works too. In fact if I merely add the namespace for the base class (using ABC;) that avoids the crash.