Skip to content

Commit

Permalink
C#: Do not extractor private or internal types from reference assembl…
Browse files Browse the repository at this point in the history
…ies.
  • Loading branch information
michaelnebel committed Nov 26, 2024
1 parent 7675aa3 commit 374f398
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,9 @@ public void AnalyseCompilation()
extractionTasks.Add(() => DoAnalyseCompilation());
}

private static bool IsPrivateOrInternal(ISymbol symbol) =>
symbol.DeclaredAccessibility == Accessibility.Private || symbol.DeclaredAccessibility == Accessibility.Internal;

private static void AnalyseNamespace(Context cx, INamespaceSymbol ns)
{
foreach (var memberNamespace in ns.GetNamespaceMembers())
Expand All @@ -271,7 +274,10 @@ private static void AnalyseNamespace(Context cx, INamespaceSymbol ns)

foreach (var memberType in ns.GetTypeMembers())
{
Entities.Type.Create(cx, memberType).ExtractRecursive();
if (!IsPrivateOrInternal(memberType))
{
Entities.Type.Create(cx, memberType).ExtractRecursive();
}
}

Check notice

Code scanning / CodeQL

Missed opportunity to use Where Note

This foreach loop
implicitly filters its target sequence
- consider filtering the sequence explicitly using '.Where(...)'.
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,6 @@ private static ExitCode AnalyseTracing(
compilerArguments.CompilationOptions
.WithAssemblyIdentityComparer(DesktopAssemblyIdentityComparer.Default)
.WithStrongNameProvider(new DesktopStrongNameProvider(compilerArguments.KeyFileSearchPaths))
.WithMetadataImportOptions(MetadataImportOptions.All)
);
},
(compilation, options) => analyser.EndInitialize(compilerArguments, options, compilation, cwd, args),
Expand Down

0 comments on commit 374f398

Please sign in to comment.