获取类型名称但使用指定的用法解析它

Get Type Name BUT resolve it with specified usings

大约有 1000 篇帖子告诉我如何获取 TypeName,例如

Get type name without full namespace in C#

Get the type name

还有很多,一切正常,但我需要使用提供的 usings 解析 TypeName。

例如我有以下使用:

using Foo = System.Collections.Generic;

现在进行以下调用以获取名称:

var x = typeof (Foo.List<>);
var y = x.Name;

我想得到输出

Foo.List`1

而不仅仅是

List`1

这可能吗,还是唯一的选择字符串操作?

这是 C# 语言的语法糖,它本身并不是 .NET 的基本功能。

using 指令是纯粹的编译时构造。

那根本不可能;您想要的信息在运行时不存在。