Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -318,16 +318,16 @@ private ImmutableArray<ConstructorDataModel> MapConstructors(INamedTypeSymbol ty
{
Debug.Assert(constructor.MethodKind is MethodKind.Constructor || constructor.IsStatic);

// Skip constructors with out parameters - they cannot be meaningfully invoked through the shape system
if (constructor.Parameters.Any(p => p.RefKind is RefKind.Out))
{
return null;
}

var parameters = new List<ParameterDataModel>();
TypeDataModelGenerationContext scopedCtx = ctx;
foreach (IParameterSymbol parameter in constructor.Parameters)
{
if (parameter.RefKind is RefKind.Out)
{
// Skip constructors with out parameters
return null;
}

if (IncludeNestedType(parameter.Type, ref scopedCtx) != TypeDataModelGenerationStatus.Success)
{
// Skip constructors with unsupported parameter types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ protected virtual TypeDataModelGenerationStatus MapMethod(ResolvedMethodSymbol r
{
if (parameter.RefKind is RefKind.Out)
{
// Methods with out parameters are not supported
result = default;
return TypeDataModelGenerationStatus.UnsupportedType;
}
Expand Down
12 changes: 10 additions & 2 deletions src/PolyType/ReflectionProvider/ReflectionObjectTypeShape.cs
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,17 @@ static MemberInitializerShapeInfo[] GetSettableMembers(PropertyShapeInfo[] allMe
}

ParameterInfo[] parameters = constructorInfo.GetParameters();
if (parameters.Any(param => param.IsOut || !param.GetEffectiveParameterType().CanBeGenericArgument()))

// Skip constructors with out parameters - they cannot be meaningfully invoked through the shape system
if (parameters.Any(param => param.IsOut))
{
continue;
}

// Filter out any unsupported parameter types
if (parameters.Any(param => !param.GetEffectiveParameterType().CanBeGenericArgument()))
{
// Skip constructors with unsupported parameter types or out parameters
// Skip constructors with unsupported parameter types
continue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,8 @@ internal static MethodShapeInfo CreateMethodShapeInfo(
}

ParameterInfo[] parameters = methodInfo.GetParameters();

// Check for unsupported parameter types including out parameters
if (parameters.FirstOrDefault(param => param.IsOut || !param.GetEffectiveParameterType().CanBeGenericArgument()) is { } param)
{
throw new NotSupportedException($"Method '{methodInfo}' contains unsupported parameter type '{param.Name}'.");
Expand Down