I have a web api service filter which is written in C#, if i decorate any function in my C# web api with that service filter than before executing the function, service filter gets invoked. I have exposed that filter as a package.
Now i want to use and reference that C# filter inside a kotlin web api project. What is the best and straight forward way for doing this?
Example of usage in C#
[ServiceFilter(typeof(MakerCheckerFilter))] – This is my filter
public async DoSomething()
I think it’s pretty much impossible. Kotlin does not target .NET and there is no easy way to make it interoperable with .NET. I think you are better off sticking to either JVM or .NET rather than try to mix them. If you have already committed to C#, then I recommend that you stick with that.
Agreed, the only way I can think of is this. Modify the C# library so that it can be called from C. This can be done using the
DllExport attribute I think. After that you should be able to call that from kotlin native like any other C libary (if thats your target) or use something like JNI or JNA (not sure what standard for this is) if your targeting the JVM.