Skip to content

Commit 31b9b3a

Browse files
author
Paolo Tranquilli
committed
Merge branch 'main' into redsun82/rust-perf-measures
2 parents 4bd5cc4 + 7463c51 commit 31b9b3a

File tree

489 files changed

+6622
-4057
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

489 files changed

+6622
-4057
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ repos:
7272

7373
- id: rust-codegen
7474
name: Run Rust checked in code generation
75-
files: ^misc/codegen/|^rust/(schema.py$|codegen/|.*/generated/|ql/lib/(rust\.dbscheme$|codeql/rust/elements)|\.generated.list)
75+
files: ^misc/codegen/|^rust/(prefix\.dbscheme|schema/|codegen/|.*/generated/|ql/lib/(rust\.dbscheme$|codeql/rust/elements)|\.generated.list)
7676
language: system
7777
entry: bazel run //rust/codegen -- --quiet
7878
pass_filenames: false

csharp/extractor/Semmle.Extraction.CSharp/CodeAnalysisExtensions/SymbolExtensions.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,5 +642,40 @@ public static AnnotatedTypeSymbol GetType(this Context cx, Microsoft.CodeAnalysi
642642
/// </summary>
643643
public static IEnumerable<AnnotatedTypeSymbol> GetAnnotatedTypeArguments(this INamedTypeSymbol symbol) =>
644644
symbol.TypeArguments.Zip(symbol.TypeArgumentNullableAnnotations, (t, a) => new AnnotatedTypeSymbol(t, a));
645+
646+
/// <summary>
647+
/// Returns true if the symbol is public, protected or protected internal.
648+
/// </summary>
649+
public static bool IsPublicOrProtected(this ISymbol symbol) =>
650+
symbol.DeclaredAccessibility == Accessibility.Public
651+
|| symbol.DeclaredAccessibility == Accessibility.Protected
652+
|| symbol.DeclaredAccessibility == Accessibility.ProtectedOrInternal;
653+
654+
/// <summary>
655+
/// Returns true if the given symbol should be extracted.
656+
/// </summary>
657+
public static bool ShouldExtractSymbol(this ISymbol symbol)
658+
{
659+
// Extract all source symbols and public/protected metadata symbols.
660+
if (symbol.Locations.Any(x => !x.IsInMetadata) || symbol.IsPublicOrProtected())
661+
{
662+
return true;
663+
}
664+
if (symbol is IMethodSymbol method)
665+
{
666+
return method.ExplicitInterfaceImplementations.Any(m => m.ContainingType.ShouldExtractSymbol());
667+
}
668+
if (symbol is IPropertySymbol property)
669+
{
670+
return property.ExplicitInterfaceImplementations.Any(m => m.ContainingType.ShouldExtractSymbol());
671+
}
672+
return false;
673+
}
674+
675+
/// <summary>
676+
/// Returns the symbols that should be extracted.
677+
/// </summary>
678+
public static IEnumerable<T> ExtractionCandidates<T>(this IEnumerable<T> symbols) where T : ISymbol =>
679+
symbols.Where(symbol => symbol.ShouldExtractSymbol());
645680
}
646681
}

csharp/extractor/Semmle.Extraction.CSharp/Entities/Method.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public void Overrides(TextWriter trapFile)
101101
}
102102
}
103103

104-
if (Symbol.OverriddenMethod is not null)
104+
if (Symbol.OverriddenMethod is not null && Symbol.OverriddenMethod.ShouldExtractSymbol())
105105
{
106106
trapFile.overrides(this, Method.Create(Context, Symbol.OverriddenMethod));
107107
}

csharp/extractor/Semmle.Extraction.CSharp/Entities/Types/Type.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ private void ExtractParametersForDelegateLikeType(TextWriter trapFile, IMethodSy
225225
}
226226

227227
/// <summary>
228-
/// Called to extract all members and nested types.
228+
/// Called to extract members and nested types.
229229
/// This is called on each member of a namespace,
230230
/// in either source code or an assembly.
231231
/// </summary>
@@ -236,7 +236,7 @@ public void ExtractRecursive()
236236
Context.BindComments(this, l);
237237
}
238238

239-
foreach (var member in Symbol.GetMembers())
239+
foreach (var member in Symbol.GetMembers().ExtractionCandidates())
240240
{
241241
switch (member.Kind)
242242
{
@@ -262,16 +262,16 @@ public void PopulateGenerics()
262262

263263
var members = new List<ISymbol>();
264264

265-
foreach (var member in Symbol.GetMembers())
265+
foreach (var member in Symbol.GetMembers().ExtractionCandidates())
266266
members.Add(member);
267-
foreach (var member in Symbol.GetTypeMembers())
267+
foreach (var member in Symbol.GetTypeMembers().ExtractionCandidates())
268268
members.Add(member);
269269

270270
// Mono extractor puts all BASE interface members as members of the current interface.
271271

272272
if (Symbol.TypeKind == TypeKind.Interface)
273273
{
274-
foreach (var baseInterface in Symbol.Interfaces)
274+
foreach (var baseInterface in Symbol.Interfaces.ExtractionCandidates())
275275
{
276276
foreach (var member in baseInterface.GetMembers())
277277
members.Add(member);
@@ -288,7 +288,7 @@ public void PopulateGenerics()
288288
if (Symbol.BaseType is not null)
289289
Create(Context, Symbol.BaseType).PopulateGenerics();
290290

291-
foreach (var i in Symbol.Interfaces)
291+
foreach (var i in Symbol.Interfaces.ExtractionCandidates())
292292
{
293293
Create(Context, i).PopulateGenerics();
294294
}

csharp/extractor/Semmle.Extraction.CSharp/Extractor/Analyser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ private static void AnalyseNamespace(Context cx, INamespaceSymbol ns)
269269
AnalyseNamespace(cx, memberNamespace);
270270
}
271271

272-
foreach (var memberType in ns.GetTypeMembers())
272+
foreach (var memberType in ns.GetTypeMembers().ExtractionCandidates())
273273
{
274274
Entities.Type.Create(cx, memberType).ExtractRecursive();
275275
}

csharp/extractor/Semmle.Extraction.CSharp/Extractor/Extractor.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,6 @@ private static ExitCode AnalyseTracing(
549549
compilerArguments.CompilationOptions
550550
.WithAssemblyIdentityComparer(DesktopAssemblyIdentityComparer.Default)
551551
.WithStrongNameProvider(new DesktopStrongNameProvider(compilerArguments.KeyFileSearchPaths))
552-
.WithMetadataImportOptions(MetadataImportOptions.All)
553552
);
554553
},
555554
(compilation, options) => analyser.EndInitialize(compilerArguments, options, compilation, cwd, args),

csharp/paket.dependencies

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ source https://api.nuget.org/v3/index.json
44
# behave like nuget in choosing transitive dependency versions
55
strategy: min
66

7+
nuget MessagePack >= 2.5.187
78
nuget Basic.CompilerLog.Util
89
nuget Mono.Posix.NETStandard
910
nuget Newtonsoft.Json

csharp/paket.lock

Lines changed: 10 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)