using System.Collections.Generic;
using System.Threading.Tasks;
using Codelyzer.Analysis.Build;
using Microsoft.CodeAnalysis;
using Microsoft.Extensions.Logging;
namespace Codelyzer.Analysis
{
///
/// Abstract class for implementing code analyzers
///
public abstract class CodeAnalyzer
{
protected readonly AnalyzerConfiguration AnalyzerConfiguration;
protected readonly ILogger Logger;
protected CodeAnalyzer(AnalyzerConfiguration configuration, ILogger logger)
{
AnalyzerConfiguration = configuration;
Logger = logger;
}
///
/// Runs analysis on a project
///
/// The path to the project file
///
public abstract Task AnalyzeProject(string projectPath);
///
/// Runs analysis on a project
///
/// The path to the project file
///
public abstract Task AnalyzeProject(string projectPath, List originalReferences, List references);
///
/// Runs analysis on a solution
///
/// The path to the solution file
///
public abstract Task> AnalyzeSolution(string solutionPath);
///
/// Runs analysis on a solution
///
/// The path to the solution file
///
public abstract IAsyncEnumerable AnalyzeSolutionGeneratorAsync(string solutionPath);
///
/// Runs analysis on a solution
///
/// The path to the solution file
///
public abstract Task> AnalyzeSolution(string solutionPath, Dictionary> originalReferences, Dictionary> references);
///
/// Generates a graph using a previously run list of analyzerresults
///
/// A list of analayzer results
///
public abstract CodeGraph GenerateGraph(List analyzerResults);
///
/// Runs an analysis and generates a SolutionAnalyzerResult object
///
/// The path to the solution
///
public abstract Task AnalyzeSolutionWithGraph(string solutionPath);
///
/// Analyzes a code file and adds it to an existing project analysis. If the file already exists, it replaces it in the result.
///
/// The path to the code file
/// The analyzer result to be modified
///
public abstract Task AnalyzeFile(string filePath, AnalyzerResult analyzerResult);
///
/// Analyzes a code file and adds it to an existing solution analysis. If the file already exists, it replaces it in the result.
///
/// The path to the code file
/// The analyzer results to be modified
///
public abstract Task> AnalyzeFile(string filePath, List analyzerResults);
///
/// Analyzes a code file independently using the metareferences provided
///
/// The path to the code files
/// The references to be used when analyzing the file
/// The references to be used when analyzing the file
///
public abstract Task AnalyzeFile(string projectPath, string filePath, List frameworkMetaReferences, List coreMetaReferences);
public abstract Task AnalyzeFile(string projectPath, string filePath, string fileContent, List frameworkMetaReferences, List coreMetaReferences);
public abstract Task AnalyzeFile(string projectPath, List filePath, List frameworkMetaReferences, List coreMetaReferences);
public abstract Task AnalyzeFile(string projectPath, Dictionary fileInfo, List frameworkMetaReferences, List coreMetaReferences);
public abstract Task AnalyzeFile(string projectPath, Dictionary fileInfo, IEnumerable frameworkMetaReferences, List coreMetaReferences);
}
}