Is there a workaround to make this possible in Kotlin?
open object ClientFetcherHelper
I would like to be able to mock the object in java test class using Mockito.
I now there are multiple ways of mocking final classes or static methods, but I do not want to add more external library dependencies to a big project.
Or how could I mock the methods inside an object ?
Related
If I open a Kotlin project and try to create my own template for JUnit Test Classes I get the generated template generated as a Java file instead of as a Kotlin file.
Is there any way to make this generation to happen as a Kotlin file?
I attached some images to easily show the issue I am facing.
The question marks on one of the images have to do because I don't know what that default parse function does. I tried to change it to #parse("File Header.kt") but that does not work.
The issue was I was trying to add kotlin code to the template.
All I had to do is create the template using Java code and it automatically gets generated in Java.
However, if anyone know a way to specifically use this feature using your own kotlin code instead of generated one, please let me know.
There are many ways how to define extension methods for existing types in Groovy, e.g. meta-class, categories, extension modules etc. I'd like to know, which of them are compatible with static compilation via #CompileStatic. I know that it is possible to put a pre-built extension module jar into the classpath providing an extension method for e.g. String and then write a #CompileStatic Groovy class which uses the extension methods from the extension module. However, I'd like to have a solution where I can define extension methods in the same project so that I don't have to build the extension module in advance. Is this possible in Groovy?
Answer from tim_yates in the comments: Most probably not possible, see here.
Here is scenario:
I have a VB6 project. It contains a method which receives parameter of type variant by ref.
Function GetFilledInfo(data As Variant)
This method fills the received parameter with a structure. This structure is defined in my VB6 project as follows.
Public Type DATASTRUCTMAIN
structChild As DATASTRUCTCHILD
End Type
Public Type DATASTRUCTCHILD
m_bComputeRanges As Long
End Type
I have a C# program which calls this method by referring the ActiveX dll generated by VB6 project.
I want to declare structure that is defined in VB6 inside my C# program and want to get it filled by using VB6 method.
How can I do this?
Thanks in advance.
I can't help noticing that you are only passing a Long (unless you have truncated those structure definitions for brevity). In that case, just change the VB6 so that it exposes a function that returns a Long!
If you have a real structure...
Move the structure definition to a public class in your VB6 project. Then the structure definition will become publicly available through COM for any clients who reference your VB6 project.
Hopefully you will be able to use it in your C# project and you will be able to declare instances of the structure. You do have a reference to the VB6 component in the Project References in your C# project, right? Not too familiar with .Net COM interop, so not sure about this.
If you have any problems declaring instances of the structure in your C# project, you could change the VB6 structure into a class? Apparently structures can be problematic in COM interop
I need to consume / parse .ashx files in C#. I could create strongly typed C# class by using xsd.exe and add this to my project. But the schema of the .ashx could change at anytime.
So, I don't want to create C# classes using command line utility like xsd.
Is there any way i can create C# class on the fly from a .ashx and use the class to parse the .ashx content?.
I assume that what you need to parse/consume is the XML produced by the .ashx handler.
There is no way I know of to generate a class directly using .NET functions - you could call xsd.exe and then load and compile the generated code - quite a hack.
I have a static library which uses CoreData. I've copied the .xcdatamodelId in to the IOS application that references the static library, this is so that the .mom file ends up in the main bundle.
I have created core data classes within the static library. If I run the code then the data is retrieved from Core Data correctly but the objects that are generated have the type NSManagedObject.
I've tried copying the generated core data classes in to the main app, this fixes the problem and means that the object is no longer of type NSManagedObject (Since they are in the same bundle.) However the entire static library is based on these Core Data classes and I'd prefer not to move them.
Is there any way that I can tell Core Data to use the classes within the static library?
Thanks,
Joe
I solved this by subclassing my CoreData classes within my main application and then setting my .xcdatamodelId file to use those classes. This works because the classes are now in the main bundle.