public void ClassUnitTestRoundtrip() { // formatted class doesn't match the converted class because of the testMethod modifiers CompareLineByLine(ApexSharpParser.IndentApex(ClassUnitTest_Original), ClassUnitTest_Formatted); CompareLineByLine(ApexSharpParser.ConvertApexToCSharp(ClassUnitTest_Original), ClassUnitTest_CSharp1); CompareLineByLine(ApexSharpParser.ToApex(ClassUnitTest_CSharp1)[0], ClassUnitTest_Converted); }
private void Check(string apexOriginal, string apexFormatted, string csharp) { Assert.Multiple(() => { CompareLineByLine(ApexSharpParser.IndentApex(apexOriginal), apexFormatted); CompareLineByLine(ApexSharpParser.ConvertApexToCSharp(apexOriginal), csharp); CompareLineByLine(ApexSharpParser.ToApex(csharp)[0], apexFormatted); }); }
private string ToCSharp(string s) { try { return(ApexSharpParser.ConvertApexToCSharp(s)); } catch (ParseException) { return(string.Empty); } }
public Dictionary <string, ClassReference> ProcessApexClasses(params string[] apexTexts) { if (apexTexts == null || !apexTexts.Any(t => !string.IsNullOrWhiteSpace(t))) { return(ProcessCSharpClasses()); } var csharpClasses = apexTexts.Select(c => ApexSharpParser.ConvertApexToCSharp(c)).ToArray(); return(ProcessCSharpClasses(csharpClasses)); }
public static void ConvertToCSharp(FileInfo apexFile, DirectoryInfo cSharpLocation, string nameSpace) { if (!apexFile.Exists) { throw new FileNotFoundException(apexFile.FullName); } if (!cSharpLocation.Exists) { throw new DirectoryNotFoundException(cSharpLocation.FullName); } // Convert APEX to C# var apexClass = File.ReadAllText(apexFile.FullName); var csharpClass = ApexSharpParser.ConvertApexToCSharp(apexClass, nameSpace); // Write the converted file to the target directory var csharpClassName = Path.ChangeExtension(apexFile.Name, "cs"); var csharpFullName = Path.Combine(cSharpLocation.FullName, csharpClassName); File.WriteAllText(csharpFullName, csharpClass); }
private void Check(string apex, string csharp) => CompareLineByLine(ApexSharpParser.ConvertApexToCSharp(apex), csharp);