Skip to content

Commit c118d9b

Browse files
committed
C#: Add support for the global modifier for using directives.
1 parent e305a8a commit c118d9b

File tree

4 files changed

+15
-0
lines changed

4 files changed

+15
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ protected override void Populate(TextWriter trapFile)
4747
trapFile.using_directive_location(this, Context.CreateLocation(ReportingLocation));
4848
}
4949

50+
if (node.GlobalKeyword.Kind() == SyntaxKind.GlobalKeyword)
51+
{
52+
trapFile.using_global(this);
53+
}
54+
5055
if (parent is not null)
5156
{
5257
trapFile.parent_namespace_declaration(this, parent);

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,9 @@ internal static void using_directive_location(this TextWriter trapFile, UsingDir
371371
internal static void using_static_directives(this TextWriter trapFile, UsingDirective @using, Type type) =>
372372
trapFile.WriteTuple("using_static_directives", @using, type);
373373

374+
internal static void using_global(this TextWriter trapFile, UsingDirective @using) =>
375+
trapFile.WriteTuple("using_global", @using);
376+
374377
internal static void preprocessor_directive_location<TDirective>(this TextWriter trapFile,
375378
PreprocessorDirective<TDirective> directive, Location location)
376379
where TDirective : DirectiveTriviaSyntax =>

csharp/ql/lib/semmle/code/csharp/Using.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ class UsingDirective extends Element, @using_directive {
3636
}
3737

3838
override Location getALocation() { using_directive_location(this, result) }
39+
40+
/** Holds if this directive is `global`. */
41+
predicate isGlobal() { using_global(this) }
3942
}
4043

4144
/**

csharp/ql/lib/semmlecode.csharp.dbscheme

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,10 @@ parent_namespace_declaration(
324324

325325
@using_directive = @using_namespace_directive | @using_static_directive;
326326

327+
using_global(
328+
unique int id: @using_directive ref
329+
);
330+
327331
using_namespace_directives(
328332
unique int id: @using_namespace_directive,
329333
int namespace_id: @namespace ref);

0 commit comments

Comments
 (0)