Omitting 'partial class Program' results in invalid script.cs generated
Khazul opened this issue · 2 comments
Reproduce:
Create new ingamescript project.
Add a new source file by means of VS Add Class/Add item etc (Class1.cs).
Do not change anything in the new class.
MDK Deploy it.
Source (defaulted namespaces and comments removed for brevity)
Program.cs:
namespace IngameScript
{
partial class Program : MyGridProgram
{
public Program()
{
}
public void Save()
{
}
public void Main(string argument, UpdateType updateSource)
{
}
}
}
Class1.cs:
namespace IngameScript
{
class Class1
{
}
}
Results in script.cs:
public Program()
{
}
public void Save()
{
}
public void Main(string argument, UpdateType updateSource)
{
}
}
class Class1
{
The problem is the resulting source closes off Ingamescript.Program, open the Ingamescript.Class1, but does not close it.
If I were to add a method to Class1, then the method would appear in script.cs, but the namespace would not be closed.
--
I suggest that an explicit build fail be issued in the case of omitting partial class Program
- ie anything other than the Program class directly in the IngameScript namespace.
The game adds its own Program class wrapper. What you're seeing is a trick to exit that class and add your own non-Program class.
All my scripts does this.