public void Read_Comments_Methods() { var result = ALParser.Read(testPath); var actual = result.ElementAt(1).Methods.FirstOrDefault(f => f.Name == "CheckThatLabelCanBeAssignedToCustomer"); Assert.IsTrue(actual.MethodBody.Comments.Count() == 6); }
public void Read_Comments_Object() { var result = ALParser.Read(testPath); var actual = result.ElementAt(1).Comments; Assert.IsTrue(actual.Count() > 0); }
public void Read_GlobalVariables() { var result = ALParser.Read(testPath); Assert.IsTrue(result.ElementAt(0).GlobalVariables.Count() == 0); Assert.IsTrue(result.ElementAt(1).GlobalVariables.Count() == 1); }
public void Read_Sections() { var result = ALParser.Read(testPath); var actual = result.ElementAt(0).Sections; Assert.IsTrue(actual.Count() == 1); Assert.IsTrue(actual.ElementAt(0).Sections.Count() == 2); }
public void Read_ID_Name() { var result = ALParser.Read(testPath); Assert.AreEqual(result.Count(), 2); Assert.AreEqual(81000, result.ElementAt(1).Id); Assert.AreEqual(@"LookupValue UT Customer", result.ElementAt(1).Name); }
public void WriteBackExistingObject_UpdatedParameter() { var alobjects = ALParser.Read(testPath); var alobject = alobjects.ElementAt(1); alobject.Methods.ElementAt(0).Parameters.ElementAt(0).Name = "UpdatedParameter_NewNameGiven"; var result = ALParser.Write(alobjects); Assert.IsNotEmpty(result); Assert.IsTrue(result.Contains("UpdatedParameter_NewNameGiven")); }
public ICollection<CollectorItem> DiscoverLocalFiles(List<string> wkspcePaths) { var projects = ALProjectCollector.Discover(wkspcePaths); var srcDirs = projects.Select(s => Directory.GetParent(s.FilePath).FullName).ToArray(); var result = new List<CollectorItem>().AsQueryable(); foreach (var project in projects) { var path = Directory.GetParent(project.FilePath).FullName; var localSymbols = Directory .GetDirectories(path) .SelectMany(s => Directory.GetFiles(s, "*.al", SearchOption.AllDirectories)) .SelectMany(item => { var collectorItems = new List<CollectorItem>(); var alobjects = ALParser.Read(item); foreach (var alobject in alobjects) { collectorItems.Add(new CollectorItem { TypeId = alobject.Type, Id = alobject.Id, Type = $"{alobject.Type}", Publisher = project.publisher, //Version = project.version //Symbol = item, FsPath = item, Name = alobject.Name, Application = project.name, CanExecute = (new string[] { "Table", "Page", "PageExtension", "TableExtension", "PageCustomization", "Report" }).Contains($"{alobject.Type}"), CanDesign = (new string[] { "Table", "Page" }).Contains($"{alobject.Type}"), CanCreatePage = (new string[] { "Table", "TableExtension" }).Contains($"{alobject.Type}"), EventName = "not_an_event", IsEvent = false, SymbolData = new SymbolData { Index = alobject.Id, Path = item, Type = alobject.Type } }); } return collectorItems; }); result = result.Concat(localSymbols); } return result.ToList(); }
public List <CollectorItem> DiscoverLocalFile(string itemPath, ALProject project = null) { if (project is null) { project = ALProjectCollector.Discover(itemPath); } var collectorItems = new List <CollectorItem>(); var alobjects = ALParser.Read(itemPath); foreach (var alobject in alobjects) { if (alobject.Type == ALObjectType.codeunit) { bool isTestCodeunit = alobject .Properties .Any(p => p.Name.ToLower() == "subtype" && p.Value.ToLower() == "test"); if (isTestCodeunit) { var testCodeunit = ALParser.Read <ALTestCodeunitReader>(itemPath).FirstOrDefault(); collectorItems.Add(new CollectorItem { TypeId = alobject.Type, Id = alobject.Id, Type = $"{alobject.Type}", Publisher = project.publisher, Version = project.version.ToString(), Symbol = testCodeunit, FsPath = itemPath, Name = alobject.Name, Application = project.name, IsLocal = true, ProjectPath = project.FilePath, SymbolData = new SymbolData { Index = alobject.Id, Path = itemPath, Type = alobject.Type, Name = alobject.Name } }); } } } //alobjects.ToList().Clear(); return(collectorItems); }
public void WriteBackExistingObject_NoChange() { var alobjects = ALParser.Read(testPath); foreach (var obj in alobjects) { var result = ALParser.Write(obj); Assert.IsNotEmpty(result); } var allobjStr = ALParser.Write(alobjects); Assert.IsNotEmpty(allobjStr); }
public async Task<IALObject> GetSymbolObject(SymbolData data) { FileInfo info = new FileInfo(data.Path); if (info.Extension == ".al") { var alobjects = ALParser.Read(data.Path); var alobject = alobjects.FirstOrDefault(f => f.Type == data.Type && f.Id == data.Index); return alobject; } var symbols = await GetSymbolReference(data.Path); var packType = ALTypeMap[data.Type]; var objects = symbols.GetType().GetProperty(packType)?.GetValue(symbols) as IEnumerable<IALObject>; var result = objects.Where(w => w.Id == data.Index).FirstOrDefault(); return result; }
public async Task <IALObject> GetSymbolObject(SymbolData data, bool mapSourcePath = true) { FileInfo info = new FileInfo(data.Path); if (info.Extension == ".al") { var alobjects = ALParser.Read(data.Path); var alobject = alobjects.FirstOrDefault(f => f.Type == data.Type && f.Name == data.Name); var project = ALProjectCollector.Discover(data.Path); return(alobject); } var symbols = await GetSymbolReference(data.Path, mapSourcePath); var result = symbols.Symbols.Where(w => w.Type == data.Type && w.Name == data.Name).FirstOrDefault(); return(await Task.FromResult(result)); }