public void Run(RegressionEnvironment env) { var @namespace = NamespaceGenerator.Create(); var epl = "@Name('s0') inlined_class \"\"\"\n" + " namespace " + @namespace + " {\n" + " [" + typeof(ExtensionSingleRowFunctionAttribute).FullName + "(\n" + " Name=\"multiply\", MethodName=\"MultiplyIfPositive\",\n" + " ValueCache=" + typeof(ConfigurationCompilerPlugInSingleRowFunction.ValueCacheEnum).FullName.CodeInclusionTypeName() + ".DISABLED,\n" + " FilterOptimizable=" + typeof(ConfigurationCompilerPlugInSingleRowFunction.FilterOptimizableEnum).FullName.CodeInclusionTypeName() + ".DISABLED,\n" + " RethrowExceptions=false,\n" + " EventTypeName=\"abc\"\n" + " )]\n" + " public class MultiplyHelper {\n" + " public static int MultiplyIfPositive(int a, int b) {\n" + " return a*b;\n" + " }\n" + " }\n" + " }\n" + "\"\"\" " + "select multiply(IntPrimitive,IntPrimitive) as c0 from SupportBean"; env.CompileDeploy(epl).AddListener("s0"); SendAssertIntMultiply(env, 5, 25); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var @namespace = NamespaceGenerator.Create(); var epl = "@Name('s0') inlined_class \"\"\"\n" + " namespace " + @namespace + " {\n" + " [" + typeof(ExtensionSingleRowFunctionAttribute).FullName + "(Name=\"multiply\", MethodName=\"Multiply\")]\n" + " public class MultiplyHelper {\n" + " public static int Multiply(int a, int b) {\n" + " return a*b;\n" + " }\n" + " }\n" + " }\n" + "\"\"\" " + "select multiply(IntPrimitive,IntPrimitive) as c0 from SupportBean"; env.CompileDeploy(soda, epl).AddListener("s0"); SendAssertIntMultiply(env, 5, 25); env.Milestone(0); SendAssertIntMultiply(env, 6, 36); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var @namespace = NamespaceGenerator.Create(); var epl = "@Name('s0') inlined_class \"\"\"\n" + " using com.espertech.esper.common.client.hook.singlerowfunc;\n" + " namespace " + @namespace + " {\n" + " [ExtensionSingleRowFunction(Name=\"multiply\", MethodName=\"MultiplyIt\")]\n" + " public class MultiplyHelper {\n" + " public static int MultiplyIt(int a, int b) {\n" + " return a*b;\n" + " }\n" + " public static int MultiplyIt(int a, int b, int c) {\n" + " return a*b*c;\n" + " }\n" + " }\n" + " }\n" + "\"\"\" " + "select multiply(IntPrimitive,IntPrimitive) as c0, multiply(IntPrimitive,IntPrimitive,IntPrimitive) as c1 \n" + " from SupportBean"; env.CompileDeploy(epl).AddListener("s0"); env.SendEventBean(new SupportBean("E1", 4)); EPAssertionUtil.AssertProps(env.Listener("s0").AssertOneGetNewAndReset(), "c0,c1".SplitCsv(), new object[] { 16, 64 }); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var ns = NamespaceGenerator.Create(); var inlined = INLINEDCLASS_CONCAT.Replace("${NAMESPACE}", ns); var eplCreateInlined = "@Name('clazz') @public create " + inlined + ";\n"; var path = new RegressionPath(); env.Compile(eplCreateInlined.Replace("builder.ToString()", "null"), path); var eplSelect = "@Name('s0') select concat(TheString) as c0 from SupportBean"; var compiledSelect = env.Compile(eplSelect, path); env.CompileDeploy(eplCreateInlined); env.Deploy(compiledSelect).AddListener("s0"); SendAssertConcat(env, "A", "A"); env.Milestone(0); SendAssertConcat(env, "B", "A,B"); // assert dependencies SupportDeploymentDependencies.AssertSingle(env, "s0", "clazz", EPObjectType.CLASSPROVIDED, "ConcatAggForge"); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var path = new RegressionPath(); var eplWindow = "create window MyWindow#keepall as (TheString string);\n" + "on SupportBean merge MyWindow insert select TheString;\n"; env.CompileDeploy(eplWindow, path); env.SendEventBean(new SupportBean("E1", 1)); var eplFAF = "inlined_class \"\"\"\n" + "namespace ${NAMESPACE} {\n" + " public class MyClass {\n" + " public static string DoIt(string parameter) {\n" + " return '>' + parameter + '<';\n" + " }\n" + " }\n" + "}\n" + "\"\"\"\n select ${NAMESPACE}.MyClass.DoIt(TheString) as c0 from MyWindow"; var result = env.CompileExecuteFAF( eplFAF.Replace("${NAMESPACE}", NamespaceGenerator.Create()), path); Assert.AreEqual(">E1<", result.Array[0].Get("c0")); env.Milestone(0); result = env.CompileExecuteFAF( eplFAF.Replace("${NAMESPACE}", NamespaceGenerator.Create()), path); Assert.AreEqual(">E1<", result.Array[0].Get("c0")); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var ns = NamespaceGenerator.Create(); var prefix = INLINEDCLASS_PREFIXMAP.Replace("${NAMESPACE}", ns); var eplCreateInlined = "@Name('clazz') @public create " + prefix + ";\n"; var path = new RegressionPath(); env.Compile(eplCreateInlined, path); var epl = "@public @buseventtype create schema PersonEvent(name string, id string);" + "@Name('table') create table TableWithTrie(nameTrie trieState(string));\n" + "into table TableWithTrie select trieEnter(name) as nameTrie from PersonEvent;\n"; var compiledTable = env.Compile(epl, path); env.CompileDeploy(eplCreateInlined); env.Deploy(compiledTable); MakeSendPerson(env, "Andreas", "P1"); MakeSendPerson(env, "Andras", "P2"); MakeSendPerson(env, "Andras", "P3"); MakeSendPerson(env, "And", "P4"); var trie = (SupportTrie <string, IList <object> >)env.GetEnumerator("table").Advance().Get("nameTrie"); Assert.AreEqual(3, trie.PrefixMap("And").Count); // assert dependencies SupportDeploymentDependencies.AssertSingle(env, "table", "clazz", EPObjectType.CLASSPROVIDED, ns + ".TrieAggForge"); env.UndeployAll(); }
/// <summary> /// Initializes a new instance of the <see cref="ClassGenerator"/> class for the specified <see cref="IndentedStreamWriter"/> /// </summary> /// <param name="class"><see cref="CSharpClass"/> to generate</param> /// <param name="writer"><see cref="IndentedStreamWriter"/> used to write to</param> public ClassGenerator(CSharpClass @class, IndentedStreamWriter writer) : base(writer) { _class = @class; _usingGenerator = new UsingGenerator(_class.Usings, writer); _namespaceGenerator = new NamespaceGenerator(_class.Namespace, writer); _classDefinitionGenerator = new ClassDefinitionGenerator(_class, writer); }
public void Given_Class_Name_Person_When_Testing_Generating_Interface_IPerson() { var solution_dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); var path = solution_dir.Replace("bin/Debug/netcoreapp2.0", ""); var expectedFileName = path + "IPerson.cs"; var dependencies = new List <string> { "System", "System.Collections.Generic" }; var personEntityDto = new EntityDto { Name = "Person", Fields = new List <FieldTypePairDto> { { new FieldTypePairDto { FieldName = "Name", Type = "string" } }, { new FieldTypePairDto { FieldName = "Age", Type = "int" } }, { new FieldTypePairDto { FieldName = "Friends", Type = "IEnumerable<IPerson>" } } } }; var dependencyGen = new DependenciesGenerator(dependencies); var namespaceGen = new NamespaceGenerator(); var fieldsGen = new FieldTypePairGenerator(); var bracketGen = new ClosedCurlyBracketGenerator(); var sut = new InterfaceFileGenerator( path, "Autogeneration.Entities.Test.Contracts", dependencyGen, namespaceGen, fieldsGen, bracketGen); sut.GenerateFile("Person", personEntityDto); Assert.True(File.Exists(expectedFileName)); }
public void SetUp() { Configuration = new CodeGeneratorConfiguration().MediaTypes; Configuration.Namespace = "MyWeb.Models"; ContentType = new MediaType(); Generator = new NamespaceGenerator(Configuration); compileUnit = new CodeCompileUnit(); }
public override string Generate(int indent) { if (Data != null) { var output = string.Empty; NamespaceGenerator @namespace = null; EnumGenerator @enum = null; if (string.IsNullOrEmpty(Data.title)) { return(output); } if (!string.IsNullOrEmpty(Data.category)) { @namespace = NamespaceGenerator.Namespace(Data.category); } @enum = EnumGenerator.Enum(Data.title.LegalMemberName()); indices.Clear(); for (int i = 0; i < Data.items.Count; i++) { if (!string.IsNullOrEmpty(Data.items[i].name)) { while (indices.Contains(Data.items[i].index)) { Data.items[i].index++; } indices.Add(Data.items[i].index); @enum.AddItem(Data.items[i].name, Data.items[i].index); } } @enum.indexing = Data.useIndex; #if VISUAL_SCRIPTING_1_7 if (Data.lastCompiledName != Data.GetFullTypeName()) { @enum.AddAttribute(AttributeGenerator.Attribute <RenamedFromAttribute>().AddParameter(Data.lastCompiledName)); } #endif if (@namespace != null) { @namespace.AddEnum(@enum); return(@namespace.Generate(indent)); } return(@enum.Generate(indent)); } return(string.Empty); }
private void BeforeGeneration() { if (!(string.IsNullOrEmpty(decorated.@namespace) || string.IsNullOrWhiteSpace(decorated.@namespace))) { @namespace = NamespaceGenerator.Namespace([email protected]()); } @enum = EnumGenerator.Enum(decorated.title); guid = decorated.GetGUID(); }
public void CallsMemberGenerators() { var spies = new[] { new SpyGenerator(), new SpyGenerator() }; var memberGenerators = spies.Cast <CodeGeneratorBase>().ToArray(); Generator = new NamespaceGenerator(Configuration, memberGenerators); Generator.Generate(compileUnit, ContentType); Assert.That(spies.All(s => s.Called)); }
public void Run(RegressionEnvironment env) { var namespc = NamespaceGenerator.Create(); var createEPL = CREATE_EPL .Replace("${PREFIX}", "@private") .Replace("${NAMESPACE}", namespc); var userEPL = USER_EPL.Replace("${NAMESPACE}", namespc); var epl = createEPL + userEPL; var compiled = env.Compile(epl); TryInvalidNotVisible(env, compiled); }
internal static void GenerateSerializers(Assembly grainAssembly, Dictionary <string, NamespaceGenerator> namespaceDictionary, string outputAssemblyName, Language language) { Type toGen; NamespaceGenerator extraNamespace = null; var first = true; while (GetNextTypeToProcess(out toGen)) { if (first) { ConsoleText.WriteStatus("ClientGenerator - Generating serializer classes for types:"); first = false; } ConsoleText.WriteStatus("\ttype " + toGen.FullName + " in namespace " + toGen.Namespace + " defined in Assembly " + toGen.Assembly.GetName()); NamespaceGenerator typeNamespace; string nspace = toGen.Namespace ?? string.Empty; if (!namespaceDictionary.TryGetValue(nspace, out typeNamespace)) { if (extraNamespace == null) { // Calculate a unique namespace name based on the output assembly name extraNamespace = new NamespaceGenerator(grainAssembly, outputAssemblyName + "Serializers", language); namespaceDictionary.Add("OrleansSerializers", extraNamespace); } typeNamespace = extraNamespace; typeNamespace.RecordReferencedAssembly(toGen); foreach (var info in toGen.GetFields()) { typeNamespace.RecordReferencedNamespaceAndAssembly(info.FieldType); } foreach (var info in toGen.GetProperties()) { typeNamespace.RecordReferencedNamespaceAndAssembly(info.PropertyType); } foreach (var info in toGen.GetMethods()) { typeNamespace.RecordReferencedNamespaceAndAssembly(info.ReturnType); foreach (var arg in info.GetParameters()) { typeNamespace.RecordReferencedNamespaceAndAssembly(arg.ParameterType); } } } SerializationGenerator.GenerateSerializationForClass(grainAssembly, toGen, typeNamespace.ReferencedNamespace, typeNamespace.ReferencedNamespaces, language); } }
public void Run(RegressionEnvironment env) { var namespc = NamespaceGenerator.Create(); var createEPL = CREATE_EPL .Replace("${PREFIX}", "@public") .Replace("${NAMESPACE}", namespc); var epl = "module a.b.c;\n" + createEPL.Replace("${PREFIX}", "@public"); var compiled = env.Compile(epl); var userEPL = USER_EPL.Replace("${NAMESPACE}", namespc); var path = new RegressionPath(); path.Add(compiled); env.Compile("module x;\n" + userEPL, path); }
protected override TypeGenerator OnGenerateType(ref string output, NamespaceGenerator @namespace) { var @struct = StructGenerator.Struct(RootAccessModifier.Public, StructModifier.None, Data.title.LegalMemberName()); if (Data.definedEvent) { @struct.ImplementInterface(typeof(IDefinedEvent)); } if (Data.inspectable) { @struct.AddAttribute(AttributeGenerator.Attribute <InspectableAttribute>()); } if (Data.serialized) { @struct.AddAttribute(AttributeGenerator.Attribute <SerializableAttribute>()); } if (Data.includeInSettings) { @struct.AddAttribute(AttributeGenerator.Attribute <IncludeInSettingsAttribute>().AddParameter(true)); } for (int i = 0; i < Data.variables.Count; i++) { if (!string.IsNullOrEmpty(Data.variables[i].name) && Data.variables[i].type != null) { var field = FieldGenerator.Field(AccessModifier.Public, FieldModifier.None, Data.variables[i].type, Data.variables[i].name); if (Data.serialized) { if (Data.variables[i].inspectable) { field.AddAttribute(AttributeGenerator.Attribute <InspectableAttribute>()); } if (!Data.variables[i].serialized) { field.AddAttribute(AttributeGenerator.Attribute <NonSerializedAttribute>()); } } @struct.AddField(field); } } if (@namespace != null) { @namespace.AddStruct(@struct); } return(@struct); }
public void Run(RegressionEnvironment env) { var ns = NamespaceGenerator.Create(); var inlined = INLINEDCLASS_CONCAT.Replace("${NAMESPACE}", ns); var epl = "@Name('s0')\n" + inlined + "select concat(TheString) as c0 from SupportBean"; env.CompileDeploy(epl).AddListener("s0"); SendAssertConcat(env, "A", "A"); SendAssertConcat(env, "B", "A,B"); env.Milestone(0); SendAssertConcat(env, "C", "A,B,C"); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var namespc = NamespaceGenerator.Create(); var createEPL = CREATE_EPL .Replace("${PREFIX}", "@protected") .Replace("${NAMESPACE}", namespc); var epl = "module a.b.c;\n" + createEPL; var compiled = env.Compile(epl); TryInvalidNotVisible(env, compiled); var userEPL = USER_EPL.Replace("${NAMESPACE}", namespc); var path = new RegressionPath(); path.Add(compiled); env.Compile("module a.b.c;\n" + userEPL, path); TryInvalidCompile(env, path, "module a.b.d;\n" + userEPL, FIRST_MESSAGE); }
public void Run(RegressionEnvironment env) { var namespc = NamespaceGenerator.Create(); var epl = "@Name('s0') inlined_class \"\"\"\n" + " using com.espertech.esper.common.client.hook.singlerowfunc;\n" + " namespace " + namespc + " {\n" + " [ExtensionSingleRowFunction(Name=\"toArray\", MethodName=\"ToArray\")]\n" + " public class Helper {\n" + " public static int[] ToArray(int a, int b) {\n" + " return new int[] {a, b};\n" + " }\n" + " }\n" + " }\n" + "\"\"\" " + "select " + typeof(ExprCoreArrayAtElement).FullName + ".GetIntArray()[IntPrimitive] as c0, " + typeof(ExprCoreArrayAtElement).FullName + ".GetIntArray2Dim()[IntPrimitive][IntPrimitive] as c1, " + "toArray(3,30)[IntPrimitive] as c2 " + "from SupportBean"; env.CompileDeploy(soda, epl).AddListener("s0"); var fields = "c0,c1,c2".SplitCsv(); var eventType = env.Statement("s0").EventType; foreach (var field in fields) { Assert.AreEqual(typeof(int?), eventType.GetPropertyType(field)); } env.SendEventBean(new SupportBean("E1", 1)); EPAssertionUtil.AssertProps(env.Listener("s0").AssertOneGetNewAndReset(), fields, 10, 20, 30); env.SendEventBean(new SupportBean("E2", 0)); EPAssertionUtil.AssertProps(env.Listener("s0").AssertOneGetNewAndReset(), fields, 1, 1, 3); env.SendEventBean(new SupportBean("E3", 2)); EPAssertionUtil.AssertProps(env.Listener("s0").AssertOneGetNewAndReset(), fields, null, null, null); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var eplCreateInlined = "@Name('clazz') @public create inlined_class \"\"\"\n" + " namespace %NAMESPACE% {\n" + " [" + typeof(ExtensionSingleRowFunctionAttribute).FullName + "(Name=\"multiply\", MethodName=\"Multiply\")]\n" + " public class MultiplyHelper {\n" + " public static int Multiply(int a, int b) {\n" + " %BEHAVIOR%\n" + " }\n" + " }\n" + " }\n" + "\"\"\"\n;"; var path = new RegressionPath(); var ns1 = NamespaceGenerator.Create(); env.Compile( eplCreateInlined .Replace("%NAMESPACE%", ns1) .Replace("%BEHAVIOR%", "return -1;"), path); var eplSelect = "@Name('s0') select multiply(IntPrimitive,IntPrimitive) as c0 from SupportBean"; var compiledSelect = env.Compile(eplSelect, path); var ns2 = NamespaceGenerator.Create(); env.CompileDeploy( eplCreateInlined .Replace("%NAMESPACE%", ns2) .Replace("%BEHAVIOR%", "return a*b;")); env.Deploy(compiledSelect).AddListener("s0"); SendAssertIntMultiply(env, 3, 9); env.Milestone(0); SendAssertIntMultiply(env, 13, 13 * 13); // assert dependencies SupportDeploymentDependencies.AssertSingle(env, "s0", "clazz", EPObjectType.CLASSPROVIDED, "MultiplyHelper"); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var path = new RegressionPath(); var namespc = NamespaceGenerator.Create(); env.CompileDeploy( "@Name('clazz') create inlined_class \"\"\" " + "namespace " + namespc + " {" + " public class MyClass {" + " public static string DoIt() {" + " return \"def\";" + " }" + " }" + "}\"\"\"", path); var text = "Application-inlined class 'MyClass'"; TryDeployInvalidUndeploy(env, path, "clazz", $"@Name('A') select {namespc}.MyClass.DoIt() as col from SupportBean", "A", text); env.UndeployModuleContaining("clazz"); }
public void Run(RegressionEnvironment env) { var nsp = NamespaceGenerator.Create(); var epl = "@Name('s0') inlined_class \"\"\"\n" + $"namespace {nsp} {{\n" + " public class MyClass {\n" + " public static string DoIt(string parameter) {\n" + " return \"|\" + parameter + \"|\";\n" + " }\n" + " }\n" + "}\n" + "\"\"\" " + $"select {nsp}.MyClass.DoIt(TheString) as c0 from SupportBean\n"; env.CompileDeploy(_soda, epl).AddListener("s0"); SendSBAssert(env, "E1", 0, "|E1|"); env.Milestone(0); SendSBAssert(env, "E2", 0, "|E2|"); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { var path = new RegressionPath(); var ns = NamespaceGenerator.Create(); var prefix = INLINEDCLASS_PREFIXMAP.Replace("${NAMESPACE}", ns); var epl = "@public @buseventtype create schema PersonEvent(name string, id string);" + "create " + prefix + ";\n" + "@Name('table') create table TableWithTrie(nameTrie trieState(string));\n" + "@Priority(1) into table TableWithTrie select trieEnter(name) as nameTrie from PersonEvent;\n" + "@Priority(0) @name('s0') select TableWithTrie.nameTrie.triePrefixMap(name) as c0 from PersonEvent;\n"; env.CompileDeploy(epl, path).AddListener("s0"); var p1 = MakeSendPerson(env, "Andreas", "P1"); AssertReceived(env, CollectionUtil.BuildMap("Andreas", SingletonList(p1))); var p2 = MakeSendPerson(env, "Andras", "P2"); AssertReceived(env, CollectionUtil.BuildMap("Andras", SingletonList(p2))); var p3 = MakeSendPerson(env, "Andras", "P3"); AssertReceived(env, CollectionUtil.BuildMap("Andras", Arrays.AsList(p2, p3))); var p4 = MakeSendPerson(env, "And", "P4"); AssertReceived(env, CollectionUtil.BuildMap("Andreas", SingletonList(p1), "Andras", Arrays.AsList(p2, p3), "And", SingletonList(p4))); var eplFAF = "select nameTrie as c0 from TableWithTrie"; var result = env.CompileExecuteFAF(eplFAF, path); var trie = (SupportTrie <string, IList <object> >)result.Array[0].Get("c0"); Assert.AreEqual(3, trie.PrefixMap("And").Count); trie = (SupportTrie <string, IList <object> >)env.GetEnumerator("table").Advance().Get("nameTrie"); Assert.AreEqual(3, trie.PrefixMap("And").Count); env.UndeployAll(); }
public DocumentModel(ICommentParser commentParser, IEventAggregator eventAggregator) { Namespaces = new NamespaceGenerator(matchedAssociations); Types = new TypeGenerator(matchedAssociations, commentParser); Methods = new MethodGenerator(matchedAssociations, commentParser); Properties = new PropertyGenerator(matchedAssociations, commentParser); Events = new EventGenerator(matchedAssociations, commentParser); Fields = new FieldGenerator(matchedAssociations, commentParser); this.eventAggregator = eventAggregator; steps = new List <IGenerationStep> { new GenerationStep <IDocumentationMember>(Namespaces.Add), new GenerationStep <DocumentedType>(Types.Add), new GenerationStep <DocumentedMethod>(Methods.Add), new GenerationStep <DocumentedProperty>(Properties.Add), new GenerationStep <DocumentedEvent>(Events.Add), new GenerationStep <DocumentedField>(Fields.Add), }; }
public void Run(RegressionEnvironment env) { var ns = NamespaceGenerator.Create(); var inlined = INLINEDCLASS_CONCAT.Replace("${NAMESPACE}", ns); var path = new RegressionPath(); var eplWindow = "create window MyWindow#keepall as (TheString string);\n" + "on SupportBean merge MyWindow insert select TheString;\n"; env.CompileDeploy(eplWindow, path); env.SendEventBean(new SupportBean("E1", 1)); env.SendEventBean(new SupportBean("E2", 1)); var eplFAF = inlined + "select concat(TheString) as c0 from MyWindow"; var result = env.CompileExecuteFAF(eplFAF, path); Assert.AreEqual("E1,E2", result.Array[0].Get("c0")); env.UndeployAll(); }
public void Run(RegressionEnvironment env) { RegressionPath path = new RegressionPath(); string namespc = NamespaceGenerator.Create(); string objects = "@public create variable string MYVARIABLE_NONCONSTANT = 'abc';\n" + "@public create table MyTable(tablecol string);\n" + "@public create window MyWindow#keepall as SupportBean;\n" + "@public create inlined_class \"\"\"\n" + "namespace " + namespc + " {\n" + " public class Helper {\n" + " public static string Doit(object param) {\n" + " return null;\n" + " }\n" + " }\n" + "}\n" + "\"\"\";\n" + "@public create expression MyDeclaredExpr { (select TheString from MyWindow) };\n" + "@public create expression MyHandThrough {v => v};\n" + "@public create expression string js:MyJavaScript(param) [\"a\"];\n"; env.Compile(objects, path); AssertDisqualified(env, path, "SupportBean", "TheString=Convert.ToString(IntPrimitive)"); AssertDisqualified(env, path, "SupportBean", "TheString=MYVARIABLE_NONCONSTANT"); AssertDisqualified(env, path, "SupportBean", "TheString=MyTable.tablecol"); AssertDisqualified(env, path, "SupportBean", "TheString=(select TheString from MyWindow)"); AssertDisqualified(env, path, "SupportBeanArrayCollMap", "Id = SetOfString.where(v => v=Id).firstOf()"); AssertDisqualified(env, path, "SupportBean", $"TheString={namespc}.Helper.Doit(*)"); AssertDisqualified(env, path, "SupportBean", $"TheString={namespc}.Helper.Doit(me)"); AssertDisqualified(env, path, "SupportBean", "BoolPrimitive=event_identity_equals(me, me)"); AssertDisqualified(env, path, "SupportBean", "TheString=MyDeclaredExpr()"); AssertDisqualified(env, path, "SupportBean", "IntPrimitive=me.TheString.Length"); AssertDisqualified(env, path, "SupportBean", "IntPrimitive = funcOne('hello')"); AssertDisqualified(env, path, "SupportBean", "BoolPrimitive = exists(TheString)"); AssertDisqualified(env, path, "SupportBean", "TheString = MyJavaScript('a')"); AssertDisqualified(env, path, "SupportBean", "TheString = MyHandThrough('a')"); }
public void Run(RegressionEnvironment env) { var @namespace = NamespaceGenerator.Create(); var epl = "@Name('s0') inlined_class \"\"\"\n" + " namespace " + @namespace + " {\n" + " [" + typeof(ExtensionSingleRowFunctionAttribute).FullName + "(Name=\"multiply\", MethodName=\"Multiply\")]\n" + " public class MultiplyHelperOne {\n" + " public static int Multiply(int a, int b) { return 0; }\n" + " }\n" + " [" + typeof(ExtensionSingleRowFunctionAttribute).FullName + "(Name=\"multiply\", MethodName=\"Multiply\")]\n" + " public class MultiplyHelperTwo {\n" + " public static int Multiply(int a, int b, int c) { return 0; }\n" + " }\n" + " }\n" + "\"\"\" " + "select multiply(IntPrimitive,IntPrimitive) as c0 from SupportBean"; TryInvalidCompile( env, epl, "The plug-in single-row function 'multiply' occurs multiple times"); }
public override string Generate(int indent) { if (decorated != null) { var output = string.Empty; NamespaceGenerator @namespace = NamespaceGenerator.Namespace(string.Empty); if (string.IsNullOrEmpty(Data.title)) { return(output); } if (!string.IsNullOrEmpty(Data.category)) { @namespace = NamespaceGenerator.Namespace(Data.category); } TypeGenerator type = OnGenerateType(ref output, @namespace); ClassGenerator classType = type as ClassGenerator; StructGenerator structType = type as StructGenerator; if (Data.lastCompiledName != Data.GetFullTypeName() && !string.IsNullOrEmpty(Data.lastCompiledName)) { if (classType != null) { classType.AddAttribute(AttributeGenerator.Attribute <RenamedFromAttribute>().AddParameter(Data.lastCompiledName)); } if (structType != null) { structType.AddAttribute(AttributeGenerator.Attribute <RenamedFromAttribute>().AddParameter(Data.lastCompiledName)); } } return(@namespace.Generate(indent)); } return(string.Empty); }
public void Run(RegressionEnvironment env) { var ns = NamespaceGenerator.Create(); var inlined = INLINEDCLASS_CONCAT.Replace("${NAMESPACE}", ns); var eplTwiceLocal = inlined.Replace("ConcatAggForge", "ConcatAggForgeOne") + inlined.Replace("ConcatAggForge", "ConcatAggForgeTwo") + "select concat(TheString) from SupportBean"; TryInvalidCompile( env, eplTwiceLocal, "The plug-in aggregation function 'concat' occurs multiple times"); var eplTwiceCreate = "create " + inlined.Replace("ConcatAggForge", "ConcatAggForgeOne") + ";\n" + "create " + inlined.Replace("ConcatAggForge", "ConcatAggForgeTwo") + ";\n" + "select concat(TheString) from SupportBean"; TryInvalidCompile( env, eplTwiceCreate, "The plug-in aggregation function 'concat' occurs multiple times"); var path = new RegressionPath(); env.Compile("@public create " + inlined.Replace("ConcatAggForge", "ConcatAggForgeOne"), path); env.Compile("@public create " + inlined.Replace("ConcatAggForge", "ConcatAggForgeTwo"), path); var eplTwiceInPath = "select concat(TheString) from SupportBean"; TryInvalidCompile( env, path, eplTwiceInPath, "The plug-in aggregation function 'concat' occurs multiple times"); }
public void Run(RegressionEnvironment env) { var path = new RegressionPath(); var ns = NamespaceGenerator.Create(); var inlined = INLINEDCLASS_CONCAT.Replace("${NAMESPACE}", ns); foreach (var module in new string[] { "XXX", "YYY", "ZZZ" }) { var epl = "module " + module + "; " + "@public create " + inlined .Replace("ConcatAggForge", $"ConcatAggForge{module}") .Replace("builder.ToString()", $"\"{module}\""); env.CompileDeploy(epl, path); } var eplSelect = "uses YYY; @Name('s0') select concat(TheString) as c0 from SupportBean"; env.CompileDeploy(eplSelect, path).AddListener("s0"); SendAssertConcat(env, "A", "YYY"); env.UndeployAll(); }
internal static void GenerateSerializers(Assembly grainAssembly, Dictionary<string, NamespaceGenerator> namespaceDictionary, string outputAssemblyName, Language language) { Type toGen; NamespaceGenerator extraNamespace = null; ConsoleText.WriteStatus("ClientGenerator - Generating serializer classes for types:"); while (GetNextTypeToProcess(out toGen)) { ConsoleText.WriteStatus("\ttype " + toGen.FullName + " in namespace " + toGen.Namespace + " defined in Assembly " + toGen.Assembly.GetName()); NamespaceGenerator typeNamespace; string nspace = toGen.Namespace ?? String.Empty; if (!namespaceDictionary.TryGetValue(nspace, out typeNamespace)) { if (extraNamespace == null) { // Calculate a unique namespace name based on the output assembly name extraNamespace = new NamespaceGenerator(grainAssembly, outputAssemblyName + "Serializers", language); namespaceDictionary.Add("OrleansSerializers", extraNamespace); } typeNamespace = extraNamespace; typeNamespace.RecordReferencedAssembly(toGen); foreach (var info in toGen.GetFields()) { typeNamespace.RecordReferencedNamespaceAndAssembly(info.FieldType); } foreach (var info in toGen.GetProperties()) { typeNamespace.RecordReferencedNamespaceAndAssembly(info.PropertyType); } foreach (var info in toGen.GetMethods()) { typeNamespace.RecordReferencedNamespaceAndAssembly(info.ReturnType); foreach (var arg in info.GetParameters()) { typeNamespace.RecordReferencedNamespaceAndAssembly(arg.ParameterType); } } } SerializationGenerator.GenerateSerializationForClass(grainAssembly, toGen, typeNamespace.ReferencedNamespace, typeNamespace.ReferencedNamespaces, language); } }