[
https://issues.apache.org/jira/browse/THRIFT-1026?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
William Blinn updated THRIFT-1026:
----------------------------------
Summary: C# default value code generation problem (was: C# constant code
generation fails)
> 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.
-
You can reply to this email to add a comment to the issue online.