How to define method?

I try to create a method in the editor, i.e. add to the end of the file a method.

But in the compile I always get an Type or namespace definition, or end-of-file expected
error.

I am not a C# expert, but maybe the editor automagically adds some decoration to the beginning (or end) of my source code that makes the code imbalanced if I add a method?

Thanks,

Joseph

Hello!

I am not a C# expert, but maybe the editor automagically adds some decoration to the beginning (or end) of my source code that makes the code imbalanced if I add a method?

Exactly. Your code is injected into a “template”, compiled and running then.

This is that template:

using System;
using System.Collections.Generic;
using System.Linq;
// ... and other namespaces here 

namespace C2ExplorerServiceStack.Logic.Implementation
{
    class Script : QueryRunner { 

        override void ExecuteUserCode() 
        {
            ------ Your code is injected here. ----- 
        }
    }
}

It means you can’t define your own methods.

Thanks a lot for this explanation.

This limits the available language features considerably.

No classes, no methods, no libraries, no arguments, no command line parameters, etc.

(And of course this is still compiled as opposed to scripted language. The worst of both worlds.)

Do you have a bugs database where feature requests can be posted?

Thanks again!

Yes. Correct. All that is intentional.
Simplicity has the highest priority.

Yes. C# is a compiled language. We are not going to develop C2Explorer in other languages.

No. Feel free to post it here or send an e-mail to help@collective2.com.

Thanks.