vmware-archive/runtimes

Class name in C# must be module

patnaikshekhar opened this issue · 4 comments

I've been testing with the Dot Net Core runtime and I've noticed that if the class name is set to anything other than "module" it doesn't seem to execute the function and exits with an error "Unhandled Exception: System.InvalidOperationException: Your module (Program) was not found in this assembly.". I had passed the class name when calling the kubeless command

kubeless function deploy hello --from-file .\Program.cs --handler Program.Run --dependencies .\HelloKubeless.csproj --runtime dotnetcore2.1

Program.cs

using System;
using Kubeless.Functions;

namespace HelloKubeless
{
    public class Program
    {
        public string Run(Event evt, Context context)
        {
            return "Hello World";
        }
    }
}

Hi @patnaikshekhar,

Thanks for pointing this out. I just reproduced the describe behavior, throwing at:
https://github.com/kubeless/runtimes/blob/31b42a99b0827170ce36833a4dcce95e09bfdda3/stable/dotnetcore/src/Kubeless.Core/Invokers/CompiledFunctionInvoker.cs#L68

I believe it is a bug related to namespaced-functions. I will take a look at that.

Hi @patnaikshekhar, with .NET core 3.1 runtime if you declare your class in the default namespace you can name it however you want. (following code not tested)

kubeless function deploy hello --from-file .\Program.cs --handler Program.Run --dependencies .\HelloKubeless.csproj --runtime dotnetcore3.1

using System;
using Kubeless.Functions;

public class Program
{
    public async Task<object> Run(Event evt, Context context)
    {
        return "Hello World";
    }
}

Hi @andresmgot , as explained in the comment above, with the .NET core 3.1 runtime this issue has been resolved, can we close this?

Sure, please re-open it if you find any issue.