Skip to content

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

@rpmrmartin

Description

@rpmrmartin

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

Consider the following C# program:

Console.WriteLine("Hello world!");

interface IService<T>
{
    T GetValue();
}

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

If I run the following query on it, IService<string?> does not appear in the list of annotated types:

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:

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?

Metadata

Metadata

Assignees

Labels

questionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions