Skip to content

Commit 3a4ec90

Browse files
committed
C#: Extraction of ref modifier for fields.
1 parent f192191 commit 3a4ec90

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public override void Populate(TextWriter trapFile)
3030
PopulateAttributes();
3131
ContainingType!.PopulateGenerics();
3232
PopulateNullability(trapFile, Symbol.GetAnnotatedType());
33+
PopulateRefKind(trapFile, Symbol.RefKind);
3334

3435
var unboundFieldKey = Field.Create(Context, Symbol.OriginalDefinition);
3536
trapFile.fields(this, (Symbol.IsConst ? 2 : 1), Symbol.Name, ContainingType, Type.TypeRef, unboundFieldKey);

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,12 @@ class Field extends Variable, AssignableMember, Attributable, TopLevelExprParent
399399
/** Holds if this field is `volatile`. */
400400
predicate isVolatile() { this.hasModifier("volatile") }
401401

402+
/** Holds if this is a `ref` field. */
403+
predicate isRef() { this.getAnnotatedType().isRef() }
404+
405+
/** Holds if this is a `ref readonly` field. */
406+
predicate isReadonlyRef() { this.getAnnotatedType().isReadonlyRef() }
407+
402408
/** Holds if this field is `readonly`. */
403409
predicate isReadOnly() { this.hasModifier("readonly") }
404410

0 commit comments

Comments
 (0)