-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #763 from aws/longachr-fixes
- Loading branch information
Showing
9 changed files
with
130 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Codelyzer.Analysis; | ||
using Codelyzer.Analysis.Model; | ||
using CTA.Rules.Models; | ||
|
||
namespace CTA.Rules.PortCore; | ||
|
||
public class PortCoreUtils | ||
{ | ||
public static HashSet<string> GetReferencesForProject(AnalyzerResult analyzerResult) | ||
{ | ||
var allReferences = new HashSet<string>(); | ||
var projectResult = analyzerResult.ProjectResult; | ||
|
||
projectResult?.SourceFileResults?.SelectMany(s => s.References)?.Select(r => r.Namespace).Distinct().ToList().ForEach(currentReference=> { | ||
if (currentReference != null && !allReferences.Contains(currentReference)) | ||
{ | ||
allReferences.Add(currentReference); | ||
} | ||
}); | ||
|
||
projectResult?.SourceFileResults?.SelectMany(s => s.Children.OfType<UsingDirective>())?.Select(u=>u.Identifier).Distinct().ToList().ForEach(currentReference => { | ||
if (currentReference != null && !allReferences.Contains(currentReference)) | ||
{ | ||
allReferences.Add(currentReference); | ||
} | ||
}); | ||
|
||
projectResult?.SourceFileResults?.SelectMany(s => s.Children.OfType<ImportsStatement>())?.Select(u => u.Identifier).Distinct().ToList().ForEach(currentReference => | ||
{ | ||
if (currentReference != null && !allReferences.Contains(currentReference)) | ||
{ | ||
allReferences.Add(currentReference); | ||
} | ||
}); | ||
|
||
return allReferences; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters