Great catch. You weren't overlooking anything. StudioSelectedMember in the initial Scripting API exposed Name, Kind, and Range only, and there was no other route to a method's signature from a script. Parsing source text ourselves was not a solution we wanted to push on you, so we've closed the gap properly.
This is now available in the Studio Scripting API 1.1. StudioSelectedMember has two new read-only members:
Parameters As StudioParameter() - every declared parameter, in declaration order
ReturnType As String - the declared return type for Functions and return-capable Events, or an empty string when no return type applies
StudioParameter exposes the complete declared shape of each parameter:
| Member | Description |
Name As String | The parameter name |
TypeName As String | The declared parameter type |
DefaultValue As String | The default value text (empty when none) |
IsOptional As Boolean | Declared Optional |
IsByRef As Boolean | Passed ByRef |
IsParamArray As Boolean | Declared ParamArray |
IsExtends As Boolean | The Extends receiver of an extension method |
IsAssigns As Boolean | The Assigns value parameter of a setter-style method |
IsArray As Boolean | Declared as an array using name() |
So your header script can now fill in Type, Name, Parameters, and Return type automatically:
Var member As StudioSelectedMember = Studio.Editor.Context.SelectedMember
Var typeLabel As String = member.Kind.Capitalise()
Var parameterLines() As String = []
For Each parameter As StudioParameter In member.Parameters
Var line As String = parameter.Name
If Not parameter.TypeName.IsEmpty() Then
line = line + " As " + parameter.TypeName
End If
If parameter.IsOptional Then
line = line + " (Optional)"
End If
parameterLines.Append(line)
Next
The bundled Add Standard Header sample has been updated to demonstrate exactly this. It builds the Type, Parameters, and Return type lines from the structured metadata and stays robust when a method has no parameters or no return value. The full API reference is in the Studio Scripting API reference (or will be after the next release), with the new members marked as introduced in 1.1; existing scripts keep working unchanged.
Thanks for the report. This is exactly the kind of real-world feedback the Scripting API needed.
https://feedback.objo.dev/feature/1089