<commit_before>using System;
using DotVVM.Framework.Binding.Expressions;
using DotVVM.Framework.Compilation.ControlTree;
using DotVVM.Framework.Compilation.Javascript;
using DotVVM.Framework.Compilation.Javascript.Ast;

namespace DotVVM.Framework.Binding.HelperNamespace
{
    public class JsBindingApi
    {
        public void Invoke(string name, params object[] args) =>
            throw new Exception("Can not invoke JS command server-side.");
        public T Invoke<T>(string name, params object[] args) =>
            throw new Exception("Can not invoke JS command server-side.");

        internal static void RegisterJavascriptTranslations(JavascriptTranslatableMethodCollection collection)
        {
            collection.AddMethodTranslator(typeof(JsBindingApi), nameof(Invoke), new GenericMethodCompiler(
                a => {
                    var annotation = a[0].Annotation<JsExtensionParameter.ViewModuleAnnotation>();
                    var viewIdExpr = annotation.IsMarkupControl ? new JsSymbolicParameter(CommandBindingExpression.ControlUniqueIdParameter) : (JsExpression)new JsLiteral(annotation.Id);

                    return a[0].Member("call").Invoke(viewIdExpr, a[1], a[2]);
                }), null, true, true);
        }
    }
}<commit_msg>More helpful error message for server side invocation of _js.Invoke<commit_after>using System;
using DotVVM.Framework.Binding.Expressions;
using DotVVM.Framework.Compilation.ControlTree;
using DotVVM.Framework.Compilation.Javascript;
using DotVVM.Framework.Compilation.Javascript.Ast;

namespace DotVVM.Framework.Binding.HelperNamespace
{
    public class JsBindingApi
    {
        public void Invoke(string name, params object[] args) =>
            throw new Exception($"Can not invoke JS command server-side: {name}({string.Join(", ", args)}).");
        public T Invoke<T>(string name, params object[] args) =>
            throw new Exception($"Can not invoke JS command server-side: {name}({string.Join(", ", args)}) -> {typeof(T).Name}.");

        internal static void RegisterJavascriptTranslations(JavascriptTranslatableMethodCollection collection)
        {
            collection.AddMethodTranslator(typeof(JsBindingApi), nameof(Invoke), new GenericMethodCompiler(
                a => {
                    var annotation = a[0].Annotation<JsExtensionParameter.ViewModuleAnnotation>();
                    var viewIdExpr = annotation.IsMarkupControl ? new JsSymbolicParameter(CommandBindingExpression.ControlUniqueIdParameter) : (JsExpression)new JsLiteral(annotation.Id);

                    return a[0].Member("call").Invoke(viewIdExpr, a[1], a[2]);
                }), null, true, true);
        }
    }
}
{'fraction_non_alphanumeric': 0.10378057820607858, 'fraction_numerical': 0.0029651593773165306, 'mean_word_length': 3.374392220421394, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '372483', 'n_tokens_mistral': 724, 'n_tokens_neox': 683, 'n_words': 158}