Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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 @@ -8497,4 +8497,62 @@ void M(object[] p)
}
""",
new(parseOptions: TestOptions.Regular));

[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/80982")]
public Task TestFunctionPointerType()
=> TestInRegularAndScriptAsync(
"""
unsafe class C
{
public delegate* managed<void> D
{
get
{
return [|field|];
}
}
}
""",
"""
unsafe class C
{
public delegate* managed<void> D
{
get
{
delegate*<void> {|Rename:value|} = field;
return value;
}
}
}
""");

[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/80982")]
public Task TestPointerType()
=> TestInRegularAndScriptAsync(
"""
unsafe class C
{
public void* D
{
get
{
return [|field|];
}
}
}
""",
"""
unsafe class C
{
public void* D
{
get
{
void* {|Rename:value|} = field;
return value;
}
}
}
""");
}
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,11 @@ public static string CreateParameterName(this ITypeSymbol type, bool capitalize
case IArrayTypeSymbol arrayType:
type = arrayType.ElementType;
continue;
case IPointerTypeSymbol pointerType:
type = pointerType.PointedAtType;
continue;
case IPointerTypeSymbol:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot undo the change to pointers. If the user has Customer* we want to still make that as if it was just Customer. Add tests for this as well and add a 'why, not what's comment for this in the code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in b81b069. Restored pointer unwrapping so Customer* generates "customer". Added "why" comments explaining that normal pointers unwrap to get meaningful names while function pointers use the default. Updated test to use Customer*customer.

case IFunctionPointerTypeSymbol:
// Pointer types like "void*" and function pointer types like "delegate*<void>"
// don't have meaningful names, so use the default parameter name
return capitalize ? DefaultParameterName.ToPascalCase() : DefaultParameterName;
}

break;
Expand Down
Loading