mirror of
https://github.com/github/codeql.git
synced 2026-03-17 04:56:58 +01:00
C#: Extractor- and library support for explicit interface implementations for operators.
This commit is contained in:
@@ -10,6 +10,8 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
private Conversion(Context cx, IMethodSymbol init)
|
||||
: base(cx, init) { }
|
||||
|
||||
protected override MethodKind ExplicitlyImplementsKind => MethodKind.Conversion;
|
||||
|
||||
public static new Conversion Create(Context cx, IMethodSymbol symbol) =>
|
||||
ConversionFactory.Instance.CreateEntityFromSymbol(cx, symbol);
|
||||
|
||||
|
||||
@@ -83,10 +83,12 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual MethodKind ExplicitlyImplementsKind => MethodKind.Ordinary;
|
||||
|
||||
public void Overrides(TextWriter trapFile)
|
||||
{
|
||||
foreach (var explicitInterface in Symbol.ExplicitInterfaceImplementations
|
||||
.Where(sym => sym.MethodKind == MethodKind.Ordinary)
|
||||
.Where(sym => sym.MethodKind == ExplicitlyImplementsKind)
|
||||
.Select(impl => Type.Create(Context, impl.ContainingType)))
|
||||
{
|
||||
trapFile.explicitly_implements(this, explicitInterface.TypeRef);
|
||||
|
||||
@@ -11,6 +11,8 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
protected UserOperator(Context cx, IMethodSymbol init)
|
||||
: base(cx, init) { }
|
||||
|
||||
protected override MethodKind ExplicitlyImplementsKind => MethodKind.UserDefinedOperator;
|
||||
|
||||
public override void Populate(TextWriter trapFile)
|
||||
{
|
||||
PopulateMethod(trapFile);
|
||||
@@ -37,6 +39,7 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
}
|
||||
|
||||
ContainingType.PopulateGenerics();
|
||||
Overrides(trapFile);
|
||||
}
|
||||
|
||||
public override bool NeedsPopulation => Context.Defines(Symbol) || IsImplicitOperator(out _);
|
||||
|
||||
@@ -434,7 +434,7 @@ class Destructor extends DotNet::Destructor, Callable, Member, Attributable, @de
|
||||
* Either a unary operator (`UnaryOperator`), a binary operator
|
||||
* (`BinaryOperator`), or a conversion operator (`ConversionOperator`).
|
||||
*/
|
||||
class Operator extends Callable, Member, Attributable, @operator {
|
||||
class Operator extends Callable, Member, Attributable, Overridable, @operator {
|
||||
/**
|
||||
* DEPRECATED: use `getFunctionName()` instead.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user