Return a generic value

This commit is contained in:
Adam Hathcock
2024-08-22 16:02:01 +01:00
parent 65b813f897
commit 210276406b
2 changed files with 5 additions and 0 deletions
@@ -18,5 +18,6 @@ public class SameNameClass2 : ISameNameClass2
{
public ISameNameClass Return() => throw new InvalidOperationException();
public SymbolToken Return2() => throw new InvalidOperationException();
public T GetRequiredService<T>() where T : class => throw new InvalidOperationException();
}
@@ -10,6 +10,10 @@ internal static class SymbolExtensions
private static readonly HashSet<string> _defaults = new() { "System", "Microsoft" };
public static string GetNamespaceAndType(this ITypeSymbol typeSymbol)
{
if (typeSymbol is ITypeParameterSymbol t)
{
return t.Name;
}
if (typeSymbol.SpecialType != SpecialType.None)
{
return typeSymbol.ToString();