var namedTypeSymbol = (INamedTypeSymbol)semanticModel.GetSymbolInfo(syntaxNode).Symbol; var unboundGenericTypeSymbol = namedTypeSymbol.ConstructUnboundGenericType();
var typeSyntax = SyntaxFactory.ParseTypeName("List<>"); var namedTypeSymbol = semanticModel.GetTypeInfo(typeSyntax).Type as INamedTypeSymbol; var unboundGenericTypeSymbol = namedTypeSymbol.ConstructUnboundGenericType();In this example, the ConstructUnboundGenericType method is called on an INamedTypeSymbol object that is constructed from a string representation of a type name. This returns a new INamedTypeSymbol object that represents the unbound generic type. Package library: This method is a part of the Microsoft.CodeAnalysis.CSharp package library.