public List <IDEFileActions> RunIncremental(List <string> updatedFiles, RootNodes projectRules) { var ideFileActions = new List <IDEFileActions>(); var allReferences = _sourceFileResults?.SelectMany(s => s.References).Distinct(); RulesFileLoader rulesFileLoader = new RulesFileLoader(allReferences, Constants.RulesDefaultPath, RulesEngineConfiguration.TargetVersions, string.Empty, RulesEngineConfiguration.AssemblyDir); projectRules = rulesFileLoader.Load(); RulesAnalysis walker = new RulesAnalysis(_sourceFileResults, projectRules); var projectActions = walker.Analyze(); CodeReplacer baseReplacer = new CodeReplacer(_sourceFileBuildResults, RulesEngineConfiguration, _metaReferences, updatedFiles); _projectResult.ExecutedActions = baseReplacer.Run(projectActions, RulesEngineConfiguration.ProjectType); ideFileActions = projectActions .FileActions .SelectMany(f => f.NodeTokens.Select(n => new IDEFileActions() { TextSpan = n.TextSpan, Description = n.Description, FilePath = f.FilePath, TextChanges = n.TextChanges })) .ToList(); return(ideFileActions); }
/// <summary> /// Initializes the project rewriter by getting a list of actions that will be run /// </summary> /// <returns>A list of project actions to be run</returns> public ProjectResult Initialize() { ProjectActions projectActions = new ProjectActions(); try { var allReferences = _sourceFileResults?.SelectMany(s => s.References) .Union(_sourceFileResults.SelectMany(s => s.Children.OfType <UsingDirective>())?.Select(u => new Reference() { Namespace = u.Identifier, Assembly = u.Identifier }).Distinct()) .Union(ProjectConfiguration.AdditionalReferences.Select(r => new Reference { Assembly = r, Namespace = r })); RulesFileLoader rulesFileLoader = new RulesFileLoader(allReferences, ProjectConfiguration.RulesDir, ProjectConfiguration.TargetVersions, string.Empty, ProjectConfiguration.AssemblyDir); var projectRules = rulesFileLoader.Load(); RulesAnalysis walker = new RulesAnalysis(_sourceFileResults, projectRules, ProjectConfiguration.ProjectType); projectActions = walker.Analyze(); _projectReferences.ForEach(p => { projectActions.ProjectReferenceActions.Add(Config.Utils.GetRelativePath(ProjectConfiguration.ProjectPath, p)); }); _projectResult.ActionPackages = projectActions.PackageActions.Distinct().ToList(); _projectResult.MetaReferences = _metaReferences; foreach (var p in ProjectConfiguration.PackageReferences) { projectActions.PackageActions.Add(new PackageAction() { Name = p.Key, OriginalVersion = p.Value.Item1, Version = p.Value.Item2 }); } MergePackages(projectActions.PackageActions); projectActions.ProjectLevelActions = projectRules.ProjectTokens.SelectMany(p => p.ProjectLevelActions).Distinct().ToList(); projectActions.ProjectLevelActions.AddRange(projectRules.ProjectTokens.SelectMany(p => p.ProjectFileActions)); projectActions.ProjectRules = projectRules; _projectResult.ProjectActions = projectActions; _projectResult.FeatureType = ProjectConfiguration.ProjectType; } catch (Exception ex) { LogHelper.LogError(ex, "Error while initializing project {0}", ProjectConfiguration.ProjectPath); } return(_projectResult); }
/// <summary> /// Initializes the project rewriter by getting a list of actions that will be run /// </summary> /// <returns>A list of project actions to be run</returns> public ProjectResult Initialize() { ProjectActions projectActions = new ProjectActions(); try { var allReferences = _sourceFileResults?.SelectMany(s => s.References).Distinct(); RulesFileLoader rulesFileLoader = new RulesFileLoader(allReferences, RulesEngineConfiguration.RulesDir, RulesEngineConfiguration.TargetVersions, string.Empty, RulesEngineConfiguration.AssemblyDir); var projectRules = rulesFileLoader.Load(); RulesAnalysis walker = new RulesAnalysis(_sourceFileResults, projectRules); projectActions = walker.Analyze(); _projectReferences.ForEach(p => { projectActions.ProjectReferenceActions.Add(Config.Utils.GetRelativePath(RulesEngineConfiguration.ProjectPath, p)); }); _projectResult.ActionPackages = projectActions.PackageActions.Distinct().ToList(); _projectResult.MetaReferences = _metaReferences; foreach (var p in RulesEngineConfiguration.PackageReferences) { projectActions.PackageActions.Add(new PackageAction() { Name = p.Key, OriginalVersion = p.Value.Item1, Version = p.Value.Item2 }); } MergePackages(projectActions.PackageActions); projectActions.ProjectLevelActions = projectRules.ProjectTokens.SelectMany(p => p.ProjectLevelActions).Distinct().ToList(); projectActions.ProjectLevelActions.AddRange(projectRules.ProjectTokens.SelectMany(p => p.ProjectFileActions)); projectActions.ProjectRules = projectRules; _projectResult.ProjectActions = projectActions; } catch (Exception ex) { LogHelper.LogError(ex, "Error while initializing project {0}", RulesEngineConfiguration.ProjectPath); } return(_projectResult); }