Repository: dotnet/aspnetcore
File: src/Shared/RoslynUtils/SymbolExtensions.cs (C#)

Code before:
        }
        return false;
    }

    public static string GetParameterInfoFromConstructorCode(this IParameterSymbol parameterSymbol)
    {
        if (parameterSymbol is { ContainingSymbol: IMethodSymbol constructor })
        {
            var constructedType = $"typeof({parameterSymbol.ContainingType.ToDisplayString()})";
            var parameterTypes = constructor.Parameters.Select(parameter => $"typeof({parameter.Type.ToDisplayString()})");
            var parameterTypesString = string.Join(", ", parameterTypes);
            var getConstructorParameters = $$"""new[] { {{parameterTypesString}} }""";
            return $"{constructedType}.GetConstructor({getConstructorParameters})?.GetParameters()[{parameterSymbol.Ordinal}]";
        }
        return "null";
    }

    private static bool IsEnumType(ITypeSymbol typeSymbol, out ITypeSymbol enumType)
    {
        enumType = typeSymbol;
        return typeSymbol.TypeKind == TypeKind.Enum;
    }

    private static bool IsNullableEnumType(ITypeSymbol typeSymbol, out ITypeSymbol underlyingEnumType)
    {
        underlyingEnumType = null!;
        if (typeSymbol.OriginalDefinition?.SpecialType == SpecialType.System_Nullable_T &&
            typeSymbol is INamedTypeSymbol namedType)
        {
            var underlyingType = namedType.TypeArguments.FirstOrDefault();
            if (underlyingType?.TypeKind == TypeKind.Enum)
            {
                underlyingEnumType = underlyingType;
                return true;
            }
        }
        return false;
    }
}


Review comment (suggestion):
```suggestion
    private static bool IsNullableEnumType(ITypeSymbol typeSymbol, [NotNullWhen(true)] out ITypeSymbol? underlyingEnumType)
    {
        underlyingEnumType = null;
```

Code after:
        }
        return false;
    }

    public static string GetParameterInfoFromConstructorCode(this IParameterSymbol parameterSymbol)
    {
        if (parameterSymbol is { ContainingSymbol: IMethodSymbol constructor })
        {
            var constructedType = $"typeof({parameterSymbol.ContainingType.ToDisplayString()})";
            var parameterTypes = constructor.Parameters.Select(parameter => $"typeof({parameter.Type.ToDisplayString()})");
            var parameterTypesString = string.Join(", ", parameterTypes);
            var getConstructorParameters = $$"""new[] { {{parameterTypesString}} }""";
            return $"{constructedType}.GetConstructor({getConstructorParameters})?.GetParameters()[{parameterSymbol.Ordinal}]";
        }
        return "null";
    }

    private static bool IsEnumType(ITypeSymbol typeSymbol, out ITypeSymbol enumType)
    {
        enumType = typeSymbol;
        return typeSymbol.TypeKind == TypeKind.Enum;
    }

    private static bool IsNullableEnumType(ITypeSymbol typeSymbol, [NotNullWhen(true)] out ITypeSymbol? underlyingEnumType)
    {
        underlyingEnumType = null;
        if (typeSymbol.OriginalDefinition?.SpecialType == SpecialType.System_Nullable_T &&
            typeSymbol is INamedTypeSymbol namedType)
        {
            var underlyingType = namedType.TypeArguments.FirstOrDefault();
            if (underlyingType?.TypeKind == TypeKind.Enum)
            {
                underlyingEnumType = underlyingType;
                return true;
            }
        }
        return false;
    }
}