Hi, I'm converting a C# addin to F# and I'm having trouble with `params` parameters. In C#, this works fine-- I get the expected behavior in Excel where I can add any number of comma separated parameters. But with the F# version, I just get 1 parameter that's an array.
Thanks,
Tom
[<AbstractClass>][<Sealed>]
type Udf =
[<ExcelFunction(Name = "VarParamTest")>]
static member VariablParams([<ExcelArgument(Name = "Params")>][<ParamArray>] p: obj[]) = p
And here's the AutoOpen function I'm using:
open ExcelDna.Registration.FSharp
open ExcelDna.IntelliSense
type FsAsyncAddIn() =
interface IExcelAddIn with
member _.AutoOpen() =
// The overload selection and delegate conversions performed by F# are not intuitive.
let paramConvertConfig =
ParameterConversionConfiguration()
.AddParameterConversion(
Func<Type, ExcelParameterRegistration, LambdaExpression>(
FsParameterConversions.FsOptionalParameterConversion
),
null
)
ExcelRegistration.GetExcelFunctions()
|> fun fns -> ParameterConversionRegistration.ProcessParameterConversions(fns, paramConvertConfig)
|> FsAsyncRegistration.ProcessFsAsyncRegistrations
|> AsyncRegistration.ProcessAsyncRegistrations
|> MapArrayFunctionRegistration.ProcessMapArrayFunctions
|> ExcelRegistration.RegisterFunctions
IntelliSenseServer.Install()
member _.AutoClose() = IntelliSenseServer.Uninstall()