static CSAttribute ExportAttribute(string objcSelector) { var paramList = new CSArgumentList(); paramList.Add(CSConstant.Val(objcSelector)); return(new CSAttribute(new CSIdentifier("Export"), paramList, true)); }
static ObjCProtocolCompiler() { var arg = new CSSimpleType("NSObject").Typeof(); var argList = new CSArgumentList(); argList.Add(new CSArgument(arg)); kBaseTypeNSObject = new CSAttribute(new CSIdentifier("BaseType"), argList, true); }
public static Tuple <CSNamespace, CSUsingPackages> CreateTestClass(CodeElementCollection <ICodeElement> callingCode, string testName, string expectedOutput, string nameSpace, string testClassName, CSClass otherClass, string skipReason, PlatformName platform) { var use = GetTestClassUsings(nameSpace); // [TomSkip(skipReason)] // public class TomTesttestName : ITomTest // { // public testClassName() { } // public string TestName { get { return testName; } } // public string ExpectedOutput { get { return expectedOuput; } } // public void Run() { // callingCode; // } // } // otherClass CSNamespace ns = new CSNamespace(nameSpace); if (otherClass != null) { ns.Block.Add(otherClass); } CSCodeBlock body = new CSCodeBlock(callingCode); body.Add(CaptureSwiftOutputPostlude(testName)); CSMethod run = new CSMethod(CSVisibility.Public, CSMethodKind.None, CSSimpleType.Void, new CSIdentifier("Run"), new CSParameterList(), body); CSClass testClass = new CSClass(CSVisibility.Public, new CSIdentifier($"TomTest{testName}"), new CSMethod [] { run }); testClass.Inheritance.Add(new CSIdentifier("ITomTest")); testClass.Properties.Add(MakeGetOnlyStringProp("TestName", testName)); testClass.Properties.Add(MakeGetOnlyStringProp("ExpectedOutput", expectedOutput)); ns.Block.Add(testClass); if (skipReason != null) { CSArgumentList al = new CSArgumentList(); al.Add(CSConstant.Val(skipReason)); CSAttribute attr = new CSAttribute("TomSkip", al); attr.AttachBefore(testClass); } return(new Tuple <CSNamespace, CSUsingPackages> (ns, use)); }