diff --git a/src/PortingAssistant.Client.Analysis/AnalysisHandler.cs b/src/PortingAssistant.Client.Analysis/AnalysisHandler.cs index 20face5c..bd4ca54a 100644 --- a/src/PortingAssistant.Client.Analysis/AnalysisHandler.cs +++ b/src/PortingAssistant.Client.Analysis/AnalysisHandler.cs @@ -539,6 +539,7 @@ private ProjectAnalysisResult AnalyzeProject( .Select(r => CodeEntityModelToCodeEntities.ReferenceToPackageVersionPair(r)) .ToHashSet(); + var sourceFileAnalysisResults = CompatibilityCheckerHelper.AddCompatibilityCheckerResultsToCodeEntities( sourceFileToCodeEntityDetails, compatibilityCheckerResponse, portingActionResults, targetFramework); var compatibilityResults = AnalysisUtils.GenerateCompatibilityResults(sourceFileAnalysisResults, @@ -825,5 +826,25 @@ private Dictionary GetSolutionAnalysisResult( return solutionAnalysisResult; } + public ProjectAnalysisResult GetProjectAnalysisResult( + string solutionFilename, + string project, + AnalyzerResult analyzerResult, + string targetFramework = DEFAULT_TARGET, + AssessmentType assessmentType = AssessmentType.FullAssessment + ) + { + + var analysisActions = AnalyzeActions(new List {project}, targetFramework, + new List { analyzerResult }, solutionFilename); + + var projectAnalysisResult = AnalyzeProject( + solutionFilename, project, + new List { analyzerResult }, analysisActions, + targetFramework, assessmentType); + + return projectAnalysisResult; + } + } } diff --git a/src/PortingAssistant.Client.Analysis/IAnalysisHandler.cs b/src/PortingAssistant.Client.Analysis/IAnalysisHandler.cs index 55d3afd8..17fbc484 100644 --- a/src/PortingAssistant.Client.Analysis/IAnalysisHandler.cs +++ b/src/PortingAssistant.Client.Analysis/IAnalysisHandler.cs @@ -3,6 +3,7 @@ using System.Threading; using System.Threading.Tasks; using Codelyzer.Analysis.Model; +using NuGet.Protocol.Plugins; using PortingAssistant.Client.Model; using PortingAssistant.Compatibility.Common.Model; @@ -29,5 +30,13 @@ Dictionary GetCompatibilityResultsIncremental(str string targetFramework = "net6.0"); IAsyncEnumerable AnalyzeSolutionGeneratorAsync(string solutionFilename, List projects, string targetFramework = "net6.0", [EnumeratorCancellation] CancellationToken ct = default); + + ProjectAnalysisResult GetProjectAnalysisResult( + string solutionFilename, + string project, + AnalyzerResult analyzerResult, + string targetFramework = "net6.0", + AssessmentType assessmentType = AssessmentType.FullAssessment + ); } } diff --git a/src/PortingAssistant.Client.Analysis/Utils/CodeEntityModelToCodeEntities.cs b/src/PortingAssistant.Client.Analysis/Utils/CodeEntityModelToCodeEntities.cs index 575a799d..e3790c57 100644 --- a/src/PortingAssistant.Client.Analysis/Utils/CodeEntityModelToCodeEntities.cs +++ b/src/PortingAssistant.Client.Analysis/Utils/CodeEntityModelToCodeEntities.cs @@ -201,47 +201,7 @@ private static PackageVersionPair GetPackageVersionPair(Reference reference, Ext return sdk ?? nugetPackage; } - /* - public static CompatibilityResult GetCompatibilityResult(CompatibilityResult compatibilityResultWithPackage, CompatibilityResult compatibilityResultWithSdk) - { - var compatiblityResult = compatibilityResultWithPackage; - - switch (compatibilityResultWithPackage.Compatibility) - { - case Compatibility.COMPATIBLE: - break; - - case Compatibility.INCOMPATIBLE: - if (compatibilityResultWithSdk.Compatibility == Compatibility.COMPATIBLE) - { - compatiblityResult = compatibilityResultWithSdk; - } - break; - - case Compatibility.DEPRECATED: - if (compatibilityResultWithSdk.Compatibility == Compatibility.COMPATIBLE || - compatibilityResultWithSdk.Compatibility == Compatibility.INCOMPATIBLE) - { - compatiblityResult = compatibilityResultWithSdk; - } - break; - - case Compatibility.UNKNOWN: - if (compatibilityResultWithSdk.Compatibility == Compatibility.COMPATIBLE || - compatibilityResultWithSdk.Compatibility == Compatibility.INCOMPATIBLE || - compatibilityResultWithSdk.Compatibility == Compatibility.DEPRECATED) - { - compatiblityResult = compatibilityResultWithSdk; - } - break; - - default: - break; - } - - return compatiblityResult; - } - */ + public static PackageVersionPair ReferenceToPackageVersionPair(ExternalReference reference, PackageSourceType sourceType = PackageSourceType.NUGET) { if (reference != null) diff --git a/src/PortingAssistant.Client.Analysis/Utils/CompatibilityCheckerHelper.cs b/src/PortingAssistant.Client.Analysis/Utils/CompatibilityCheckerHelper.cs index e2585e68..0152ed52 100644 --- a/src/PortingAssistant.Client.Analysis/Utils/CompatibilityCheckerHelper.cs +++ b/src/PortingAssistant.Client.Analysis/Utils/CompatibilityCheckerHelper.cs @@ -312,7 +312,8 @@ public static CompatibilityCheckerRequest ConvertAnalyzeResultToCompatibilityChe } } - var fileLanguage = analyzer.ProjectResult.SourceFileResults.FirstOrDefault().Language; + var fileLanguage = analyzer.ProjectResult.SourceFileResults.Any()? + analyzer.ProjectResult.SourceFileResults.FirstOrDefault().Language: "Visual Basic"; Language language = fileLanguage == "Visual Basic"? Language.Vb: Language.CSharp; return new CompatibilityCheckerRequest() {