Hello,
I was playing with the TreatTypesAsStrings
option of the code generation when I encountered a weird issue.
In .Net I have a request that contains a LocalizedItem
property. This LocalizedItem
inherits from Dictionary< string, string> and it is generated as HashMap<String, String>, however if I set this option TreatTypesAsStrings: LocalizedItem
the generated code is invalid: the property of the Java class correctly uses String
as the type of the property but it also generate a String class
that inherits from Hashmap< string, string>
which hides Java’s String class.
Is this the expected behavior? I included the relevant code below.
.Net code:
[Route("/localizedHello/{Name}", Verbs = "POST")]
public class LocalizedHello : IReturnVoid
{
public string Name { get; set; }
public LocalizedItem LocalizedName { get; set; }
}
public class LocalizedItem : Dictionary<string, string>
{
}
The service:
public object Any(LocalizedHello request)
{
return null;
}
Generated Java code:
/* Options:
Date: 2015-09-11 16:18:35
Version: 4.044
BaseUrl: http://dev.local:50084
Package: GroupId2.ArtefactId2
//GlobalNamespace: dto
//AddPropertyAccessors: True
//SettersReturnThis: True
//AddServiceStackTypes: True
//AddResponseStatus: False
//AddImplicitVersion:
//IncludeTypes:
//ExcludeTypes:
TreatTypesAsStrings: LocalizedItem
//DefaultImports: java.math.*,java.util.*,net.servicestack.client.*
*/
package GroupId2.ArtefactId2;
import java.math.*;
import java.util.*;
import net.servicestack.client.*;
public class dto
{
public static class String extends HashMap<String,String>
{
}
@Route(Path="/localizedHello/{Name}", Verbs="POST")
public static class LocalizedHello implements IReturnVoid
{
public String name = null;
public String localizedName = null;
public String getName() { return name; }
public LocalizedHello setName(String value) { this.name = value; return this; }
public String getLocalizedName() { return localizedName; }
public LocalizedHello setLocalizedName(String value) { this.localizedName = value; return this; }
}
}