Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add new method for analyse project #2096

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/PortingAssistant.Client.Analysis/AnalysisHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -825,5 +826,25 @@ private Dictionary<string, ProjectAnalysisResult> 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<string> {project}, targetFramework,
new List<AnalyzerResult> { analyzerResult }, solutionFilename);

var projectAnalysisResult = AnalyzeProject(
solutionFilename, project,
new List<AnalyzerResult> { analyzerResult }, analysisActions,
targetFramework, assessmentType);

return projectAnalysisResult;
}

}
}
9 changes: 9 additions & 0 deletions src/PortingAssistant.Client.Analysis/IAnalysisHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -29,5 +30,13 @@ Dictionary<string, ProjectAnalysisResult> GetCompatibilityResultsIncremental(str
string targetFramework = "net6.0");
IAsyncEnumerable<ProjectAnalysisResult> AnalyzeSolutionGeneratorAsync(string solutionFilename, List<string> 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
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Loading