[
https://issues.apache.org/jira/browse/THRIFT-1026?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12994493#comment-12994493
]
Michael Fischer edited comment on THRIFT-1026 at 2/14/11 9:08 PM:
------------------------------------------------------------------
My suggestion may not be right. The current code matches what java produces.
My guess is that the intention is that the default value is not serialized. Of
course, it would help if someone can comment on the true intention of the code.
Michael Fischer
was (Author: mkfischer):
My suggestion may not be right. The current code matches what java
produces. My guess is that the intention is that the default value does not
serialize the default value.
Michael Fischer
> C# default value code generation problem
> ----------------------------------------
>
> Key: THRIFT-1026
> URL: https://issues.apache.org/jira/browse/THRIFT-1026
> Project: Thrift
> Issue Type: Bug
> Components: C# - Compiler
> Affects Versions: 0.5
> Environment: Windows, Mac
> Reporter: William Blinn
>
> I have a thrift file that looks like this:
> {code}
> // Time stamp with a timezone specification for normalization.
> struct DateTimeZone
> {
> 1: i64 ticks,
> 2: optional string timeZone = "UTC",
> }
> {code}
> When I generate C#, it produces code like this:
> {code}
> [Serializable]
> public partial class DateTimeZone : TBase
> {
> private long _ticks;
> private string _timeZone;
> public long Ticks
> {
> get
> {
> return _ticks;
> }
> set
> {
> __isset.ticks = true;
> this._ticks = value;
> }
> }
> public string TimeZone
> {
> get
> {
> return _timeZone;
> }
> set
> {
> __isset.timeZone = true;
> this._timeZone = value;
> }
> }
> public Isset __isset;
> [Serializable]
> public struct Isset {
> public bool ticks;
> public bool timeZone;
> }
> public DateTimeZone() {
> this.timeZone = "UTC";
> }
> ...
> {code}
> The constructor, which sets the default value should be this.TimeZone = "UTC"
> because the property is TimeZone, not timeZone. The constructor should set
> the property rather than the field so that __isset is marked properly.
> The compile error I get when I try to compile the code that thrift generates
> is like this:
> {code}
> [csc] d:\code\Thrift\Generated\DateTimeZone.cs(59,12): error CS1061:
> 'Thrift.Generated.DateTimeZone' does not contain a definition for 'timeZone'
> and no extension method 'timeZone' accepting a first argument of type
> 'Thrift.Generated.DateTimeZone' could be found (are you missing a using
> directive or an assembly reference?)
> {code}
--
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira