public void Given_LanguageExpressionToString_Should() { const string personChildName = "[[@Person.Child.Name]]"; Assert.IsNotNull(FsInteropFunctions.PositionColumn); var languageExpression = FsInteropFunctions.ParseLanguageExpressionWithoutUpdate(personChildName); var languageExpressionToString = FsInteropFunctions.LanguageExpressionToString(languageExpression); Assert.AreEqual(typeof(string), languageExpressionToString.GetType()); }
#pragma warning disable S1541 // Methods and properties should not be too complex public static string ValidateInput(string sourceName) #pragma warning restore S1541 // Methods and properties should not be too complex { try { var parsed = FsInteropFunctions.ParseLanguageExpression(sourceName, 0); if (parsed.IsComplexExpression) { var complex = (LanguageAST.LanguageExpression.ComplexExpression)parsed; if (complex.Item .Any(x => x.IsRecordSetNameExpression)) { return(ErrorResource.CannotCommaSeperateRecordset); } if (complex.Item.Count() < 3 || complex.Item.Count() % 2 != 1 || !Enumerable.Range(1, complex.Item.Count() - 1) .Where(i => i % 2 == 1) .Select(i => FsInteropFunctions.LanguageExpressionToString( complex.Item.ElementAt(i) ) == ",") .Aggregate((a, b) => a && b)) { return(ErrorResource.ExpressionMustBeCommaSeperated); } } else { if (!parsed.IsRecordSetNameExpression && !parsed.IsRecordSetExpression && !parsed.IsScalarExpression && !parsed.IsWarewolfAtomExpression) { return(ErrorResource.OnlyScalarRecordsetCommaSeperated); } } } catch (Exception) { return(ErrorResource.UnableToParseSourceName); } return(null); }
public static string ValidateInput(string sourceName) { try { var parsed = FsInteropFunctions.ParseLanguageExpression(sourceName, 0); if (parsed.IsComplexExpression) { var complex = (LanguageAST.LanguageExpression.ComplexExpression)parsed; if (complex.Item .Any(x => x.IsRecordSetNameExpression)) { return(ErrorResource.CannotCommaSeperateRecordset); } if (complex.Item.Count() < 3 || complex.Item.Count() % 2 != 1 || // ReSharper disable MaximumChainedReferences !Enumerable.Range(1, complex.Item.Count() - 1) .Where(i => i % 2 == 1) .Select(i => FsInteropFunctions.LanguageExpressionToString( complex.Item.ElementAt(i) ) == ",") .Aggregate((a, b) => a && b)) // ReSharper restore MaximumChainedReferences { return(ErrorResource.ExpressionMustBeCommaSeperated); } } else if (!parsed.IsRecordSetNameExpression && !parsed.IsRecordSetExpression && !parsed.IsScalarExpression && !parsed.IsWarewolfAtomExpression) { return(ErrorResource.OnlyScalarRecordsetCommaSeperated); } } catch (Exception) { return(ErrorResource.UnableToParseSourceName); } return(null); }