github / github/codeql

General issue: Find the annotated type of a C# base interface

Offen
#20,032 6 Kommentare 0 Reaktionen 1 zugewiesene Person Beansprucht von @michaelnebel Auf GitHub ansehen
question
Vorherrschende Sprache
CodeQL
Sterne
10.1k
Forks
2.1k
Ø Merge
2 T. 15 Std.
Gemergte PRs (30 T.)
141

Beschreibung

I'm trying to get the annotated type of the constructed interface that a class implements in C#.

Consider the following C# program:
```csharp
Console.WriteLine("Hello world!");

interface IService
{
T GetValue();
}

class Service : IService
{
public string? GetValue()
{
return null;
}
}
```

If I run the following query on it, `IService` does not appear in the list of annotated types:
```codeql
import csharp

from AnnotatedType at
where at.getType().fromSource()
select at
```

First, I would like `AnnotatedType` to include constructed interfaces implemented by classes complete with the correct annotations. Second, I would like a way to associate the class with the annotated constructed interface, like:
```codeql
from Class c, AnnotatedConstructedType act
where c.fromSource() and
act.appliesTo(c.getABaseInterface())
select c, act
```

If this functionality already exists, could I please have some pointers on how to use it? If not, could it please be implemented?

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.