Skip to content

Commit

Permalink
Merge pull request #2038 from aws/fix-duplication
Browse files Browse the repository at this point in the history
add hashcode and equal for APIEntity class
  • Loading branch information
jonlouie authored Oct 4, 2023
2 parents da44a3c + f0fc9e2 commit 2c5f504
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/PortingAssistant.Client.Analysis/AnalysisHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -496,8 +496,20 @@ private ProjectAnalysisResult AnalyzeProject(
analyzer, targetFramework,
out sourceFileToCodeEntityDetails,
assessmentType);
var compatibilityCheckerResponse = ProcessCompatibilityCheckerRequestByApplyingCache(project, rawCompatibilityCheckerRequest);


CompatibilityCheckerResponse compatibilityCheckerResponse;
if (rawCompatibilityCheckerRequest.PackageWithApis.Any())
{
compatibilityCheckerResponse =
ProcessCompatibilityCheckerRequestByApplyingCache(project, rawCompatibilityCheckerRequest);
}
else
{
_logger.LogInformation($"no package with api entities found in project {project}. " +
$"Return empty CompatibilityCheckerResponse");
compatibilityCheckerResponse = new CompatibilityCheckerResponse();
}

var portingActionResults = ProjectActionsToRecommendedActions.Convert(projectActions);

var nugets = analyzer.ProjectResult.ExternalReferences.NugetReferences
Expand Down
13 changes: 13 additions & 0 deletions src/PortingAssistant.Compatibility.Common/Model/ApiEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,18 @@ public class ApiEntity
public CodeEntityType CodeEntityType { get; set; }
public string Namespace { get; set; }
public string OriginalDefinition { get; set; } //valid for method

public override bool Equals(object obj)
{
return obj is ApiEntity entity &&
CodeEntityType == entity.CodeEntityType &&
Namespace == entity.Namespace &&
OriginalDefinition == entity.OriginalDefinition;
}

public override int GetHashCode()
{
return HashCode.Combine(CodeEntityType, Namespace, OriginalDefinition);
}
}
}

0 comments on commit 2c5f504

Please sign in to comment.