/**
 * Autogenerated by Thrift Compiler (0.14.0)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Thrift;
using Thrift.Collections;
using System.ServiceModel;
using System.Runtime.Serialization;

using Thrift.Protocol;
using Thrift.Protocol.Entities;
using Thrift.Protocol.Utilities;
using Thrift.Transport;
using Thrift.Transport.Client;
using Thrift.Transport.Server;
using Thrift.Processor;


#pragma warning disable IDE0079  // remove unnecessary pragmas
#pragma warning disable IDE1006  // parts of the code use IDL spelling

namespace ThriftTest
{

[DataContract(Namespace="")]
public partial class VersioningTestV2 : TBase
{
  private int _begin_in_both;
  private int _newint;
  private sbyte _newbyte;
  private short _newshort;
  private long _newlong;
  private double _newdouble;
  private global::ThriftTest.Bonk _newstruct;
  private List<int> _newlist;
  private THashSet<int> _newset;
  private Dictionary<int, int> _newmap;
  private string _newstring;
  private int _end_in_both;

  [DataMember(Order = 0)]
  public int Begin_in_both
  {
    get
    {
      return _begin_in_both;
    }
    set
    {
      __isset.begin_in_both = true;
      this._begin_in_both = value;
    }
  }

  [DataMember(Order = 0)]
  public int Newint
  {
    get
    {
      return _newint;
    }
    set
    {
      __isset.newint = true;
      this._newint = value;
    }
  }

  [DataMember(Order = 0)]
  public sbyte Newbyte
  {
    get
    {
      return _newbyte;
    }
    set
    {
      __isset.newbyte = true;
      this._newbyte = value;
    }
  }

  [DataMember(Order = 0)]
  public short Newshort
  {
    get
    {
      return _newshort;
    }
    set
    {
      __isset.newshort = true;
      this._newshort = value;
    }
  }

  [DataMember(Order = 0)]
  public long Newlong
  {
    get
    {
      return _newlong;
    }
    set
    {
      __isset.newlong = true;
      this._newlong = value;
    }
  }

  [DataMember(Order = 0)]
  public double Newdouble
  {
    get
    {
      return _newdouble;
    }
    set
    {
      __isset.newdouble = true;
      this._newdouble = value;
    }
  }

  [DataMember(Order = 0)]
  public global::ThriftTest.Bonk Newstruct
  {
    get
    {
      return _newstruct;
    }
    set
    {
      __isset.newstruct = true;
      this._newstruct = value;
    }
  }

  [DataMember(Order = 0)]
  public List<int> Newlist
  {
    get
    {
      return _newlist;
    }
    set
    {
      __isset.newlist = true;
      this._newlist = value;
    }
  }

  [DataMember(Order = 0)]
  public THashSet<int> Newset
  {
    get
    {
      return _newset;
    }
    set
    {
      __isset.newset = true;
      this._newset = value;
    }
  }

  [DataMember(Order = 0)]
  public Dictionary<int, int> Newmap
  {
    get
    {
      return _newmap;
    }
    set
    {
      __isset.newmap = true;
      this._newmap = value;
    }
  }

  [DataMember(Order = 0)]
  public string Newstring
  {
    get
    {
      return _newstring;
    }
    set
    {
      __isset.newstring = true;
      this._newstring = value;
    }
  }

  [DataMember(Order = 0)]
  public int End_in_both
  {
    get
    {
      return _end_in_both;
    }
    set
    {
      __isset.end_in_both = true;
      this._end_in_both = value;
    }
  }


  [DataMember(Order = 1)]
  public Isset __isset;
  [DataContract]
  public struct Isset
  {
    [DataMember]
    public bool begin_in_both;
    [DataMember]
    public bool newint;
    [DataMember]
    public bool newbyte;
    [DataMember]
    public bool newshort;
    [DataMember]
    public bool newlong;
    [DataMember]
    public bool newdouble;
    [DataMember]
    public bool newstruct;
    [DataMember]
    public bool newlist;
    [DataMember]
    public bool newset;
    [DataMember]
    public bool newmap;
    [DataMember]
    public bool newstring;
    [DataMember]
    public bool end_in_both;
  }

  #region XmlSerializer support

  public bool ShouldSerializeBegin_in_both()
  {
    return __isset.begin_in_both;
  }

  public bool ShouldSerializeNewint()
  {
    return __isset.newint;
  }

  public bool ShouldSerializeNewbyte()
  {
    return __isset.newbyte;
  }

  public bool ShouldSerializeNewshort()
  {
    return __isset.newshort;
  }

  public bool ShouldSerializeNewlong()
  {
    return __isset.newlong;
  }

  public bool ShouldSerializeNewdouble()
  {
    return __isset.newdouble;
  }

  public bool ShouldSerializeNewstruct()
  {
    return __isset.newstruct;
  }

  public bool ShouldSerializeNewlist()
  {
    return __isset.newlist;
  }

  public bool ShouldSerializeNewset()
  {
    return __isset.newset;
  }

  public bool ShouldSerializeNewmap()
  {
    return __isset.newmap;
  }

  public bool ShouldSerializeNewstring()
  {
    return __isset.newstring;
  }

  public bool ShouldSerializeEnd_in_both()
  {
    return __isset.end_in_both;
  }

  #endregion XmlSerializer support

  public VersioningTestV2()
  {
  }

  public VersioningTestV2 DeepCopy()
  {
    var tmp73 = new VersioningTestV2();
    if(__isset.begin_in_both)
    {
      tmp73.Begin_in_both = this.Begin_in_both;
    }
    tmp73.__isset.begin_in_both = this.__isset.begin_in_both;
    if(__isset.newint)
    {
      tmp73.Newint = this.Newint;
    }
    tmp73.__isset.newint = this.__isset.newint;
    if(__isset.newbyte)
    {
      tmp73.Newbyte = this.Newbyte;
    }
    tmp73.__isset.newbyte = this.__isset.newbyte;
    if(__isset.newshort)
    {
      tmp73.Newshort = this.Newshort;
    }
    tmp73.__isset.newshort = this.__isset.newshort;
    if(__isset.newlong)
    {
      tmp73.Newlong = this.Newlong;
    }
    tmp73.__isset.newlong = this.__isset.newlong;
    if(__isset.newdouble)
    {
      tmp73.Newdouble = this.Newdouble;
    }
    tmp73.__isset.newdouble = this.__isset.newdouble;
    if((Newstruct != null) && __isset.newstruct)
    {
      tmp73.Newstruct = (global::ThriftTest.Bonk)this.Newstruct.DeepCopy();
    }
    tmp73.__isset.newstruct = this.__isset.newstruct;
    if((Newlist != null) && __isset.newlist)
    {
      tmp73.Newlist = this.Newlist.DeepCopy();
    }
    tmp73.__isset.newlist = this.__isset.newlist;
    if((Newset != null) && __isset.newset)
    {
      tmp73.Newset = this.Newset.DeepCopy();
    }
    tmp73.__isset.newset = this.__isset.newset;
    if((Newmap != null) && __isset.newmap)
    {
      tmp73.Newmap = this.Newmap.DeepCopy();
    }
    tmp73.__isset.newmap = this.__isset.newmap;
    if((Newstring != null) && __isset.newstring)
    {
      tmp73.Newstring = this.Newstring;
    }
    tmp73.__isset.newstring = this.__isset.newstring;
    if(__isset.end_in_both)
    {
      tmp73.End_in_both = this.End_in_both;
    }
    tmp73.__isset.end_in_both = this.__isset.end_in_both;
    return tmp73;
  }

  public async global::System.Threading.Tasks.Task ReadAsync(TProtocol iprot, CancellationToken cancellationToken)
  {
    iprot.IncrementRecursionDepth();
    try
    {
      TField field;
      await iprot.ReadStructBeginAsync(cancellationToken);
      while (true)
      {
        field = await iprot.ReadFieldBeginAsync(cancellationToken);
        if (field.Type == TType.Stop)
        {
          break;
        }

        switch (field.ID)
        {
          case 1:
            if (field.Type == TType.I32)
            {
              Begin_in_both = await iprot.ReadI32Async(cancellationToken);
            }
            else
            {
              await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
            }
            break;
          case 2:
            if (field.Type == TType.I32)
            {
              Newint = await iprot.ReadI32Async(cancellationToken);
            }
            else
            {
              await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
            }
            break;
          case 3:
            if (field.Type == TType.Byte)
            {
              Newbyte = await iprot.ReadByteAsync(cancellationToken);
            }
            else
            {
              await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
            }
            break;
          case 4:
            if (field.Type == TType.I16)
            {
              Newshort = await iprot.ReadI16Async(cancellationToken);
            }
            else
            {
              await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
            }
            break;
          case 5:
            if (field.Type == TType.I64)
            {
              Newlong = await iprot.ReadI64Async(cancellationToken);
            }
            else
            {
              await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
            }
            break;
          case 6:
            if (field.Type == TType.Double)
            {
              Newdouble = await iprot.ReadDoubleAsync(cancellationToken);
            }
            else
            {
              await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
            }
            break;
          case 7:
            if (field.Type == TType.Struct)
            {
              Newstruct = new global::ThriftTest.Bonk();
              await Newstruct.ReadAsync(iprot, cancellationToken);
            }
            else
            {
              await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
            }
            break;
          case 8:
            if (field.Type == TType.List)
            {
              {
                TList _list74 = await iprot.ReadListBeginAsync(cancellationToken);
                Newlist = new List<int>(_list74.Count);
                for(int _i75 = 0; _i75 < _list74.Count; ++_i75)
                {
                  int _elem76;
                  _elem76 = await iprot.ReadI32Async(cancellationToken);
                  Newlist.Add(_elem76);
                }
                await iprot.ReadListEndAsync(cancellationToken);
              }
            }
            else
            {
              await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
            }
            break;
          case 9:
            if (field.Type == TType.Set)
            {
              {
                TSet _set77 = await iprot.ReadSetBeginAsync(cancellationToken);
                Newset = new THashSet<int>(_set77.Count);
                for(int _i78 = 0; _i78 < _set77.Count; ++_i78)
                {
                  int _elem79;
                  _elem79 = await iprot.ReadI32Async(cancellationToken);
                  Newset.Add(_elem79);
                }
                await iprot.ReadSetEndAsync(cancellationToken);
              }
            }
            else
            {
              await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
            }
            break;
          case 10:
            if (field.Type == TType.Map)
            {
              {
                TMap _map80 = await iprot.ReadMapBeginAsync(cancellationToken);
                Newmap = new Dictionary<int, int>(_map80.Count);
                for(int _i81 = 0; _i81 < _map80.Count; ++_i81)
                {
                  int _key82;
                  int _val83;
                  _key82 = await iprot.ReadI32Async(cancellationToken);
                  _val83 = await iprot.ReadI32Async(cancellationToken);
                  Newmap[_key82] = _val83;
                }
                await iprot.ReadMapEndAsync(cancellationToken);
              }
            }
            else
            {
              await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
            }
            break;
          case 11:
            if (field.Type == TType.String)
            {
              Newstring = await iprot.ReadStringAsync(cancellationToken);
            }
            else
            {
              await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
            }
            break;
          case 12:
            if (field.Type == TType.I32)
            {
              End_in_both = await iprot.ReadI32Async(cancellationToken);
            }
            else
            {
              await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
            }
            break;
          default: 
            await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken);
            break;
        }

        await iprot.ReadFieldEndAsync(cancellationToken);
      }

      await iprot.ReadStructEndAsync(cancellationToken);
    }
    finally
    {
      iprot.DecrementRecursionDepth();
    }
  }

  public async global::System.Threading.Tasks.Task WriteAsync(TProtocol oprot, CancellationToken cancellationToken)
  {
    oprot.IncrementRecursionDepth();
    try
    {
      var struc = new TStruct("VersioningTestV2");
      await oprot.WriteStructBeginAsync(struc, cancellationToken);
      var field = new TField();
      if(__isset.begin_in_both)
      {
        field.Name = "begin_in_both";
        field.Type = TType.I32;
        field.ID = 1;
        await oprot.WriteFieldBeginAsync(field, cancellationToken);
        await oprot.WriteI32Async(Begin_in_both, cancellationToken);
        await oprot.WriteFieldEndAsync(cancellationToken);
      }
      if(__isset.newint)
      {
        field.Name = "newint";
        field.Type = TType.I32;
        field.ID = 2;
        await oprot.WriteFieldBeginAsync(field, cancellationToken);
        await oprot.WriteI32Async(Newint, cancellationToken);
        await oprot.WriteFieldEndAsync(cancellationToken);
      }
      if(__isset.newbyte)
      {
        field.Name = "newbyte";
        field.Type = TType.Byte;
        field.ID = 3;
        await oprot.WriteFieldBeginAsync(field, cancellationToken);
        await oprot.WriteByteAsync(Newbyte, cancellationToken);
        await oprot.WriteFieldEndAsync(cancellationToken);
      }
      if(__isset.newshort)
      {
        field.Name = "newshort";
        field.Type = TType.I16;
        field.ID = 4;
        await oprot.WriteFieldBeginAsync(field, cancellationToken);
        await oprot.WriteI16Async(Newshort, cancellationToken);
        await oprot.WriteFieldEndAsync(cancellationToken);
      }
      if(__isset.newlong)
      {
        field.Name = "newlong";
        field.Type = TType.I64;
        field.ID = 5;
        await oprot.WriteFieldBeginAsync(field, cancellationToken);
        await oprot.WriteI64Async(Newlong, cancellationToken);
        await oprot.WriteFieldEndAsync(cancellationToken);
      }
      if(__isset.newdouble)
      {
        field.Name = "newdouble";
        field.Type = TType.Double;
        field.ID = 6;
        await oprot.WriteFieldBeginAsync(field, cancellationToken);
        await oprot.WriteDoubleAsync(Newdouble, cancellationToken);
        await oprot.WriteFieldEndAsync(cancellationToken);
      }
      if((Newstruct != null) && __isset.newstruct)
      {
        field.Name = "newstruct";
        field.Type = TType.Struct;
        field.ID = 7;
        await oprot.WriteFieldBeginAsync(field, cancellationToken);
        await Newstruct.WriteAsync(oprot, cancellationToken);
        await oprot.WriteFieldEndAsync(cancellationToken);
      }
      if((Newlist != null) && __isset.newlist)
      {
        field.Name = "newlist";
        field.Type = TType.List;
        field.ID = 8;
        await oprot.WriteFieldBeginAsync(field, cancellationToken);
        {
          await oprot.WriteListBeginAsync(new TList(TType.I32, Newlist.Count), cancellationToken);
          foreach (int _iter84 in Newlist)
          {
            await oprot.WriteI32Async(_iter84, cancellationToken);
          }
          await oprot.WriteListEndAsync(cancellationToken);
        }
        await oprot.WriteFieldEndAsync(cancellationToken);
      }
      if((Newset != null) && __isset.newset)
      {
        field.Name = "newset";
        field.Type = TType.Set;
        field.ID = 9;
        await oprot.WriteFieldBeginAsync(field, cancellationToken);
        {
          await oprot.WriteSetBeginAsync(new TSet(TType.I32, Newset.Count), cancellationToken);
          foreach (int _iter85 in Newset)
          {
            await oprot.WriteI32Async(_iter85, cancellationToken);
          }
          await oprot.WriteSetEndAsync(cancellationToken);
        }
        await oprot.WriteFieldEndAsync(cancellationToken);
      }
      if((Newmap != null) && __isset.newmap)
      {
        field.Name = "newmap";
        field.Type = TType.Map;
        field.ID = 10;
        await oprot.WriteFieldBeginAsync(field, cancellationToken);
        {
          await oprot.WriteMapBeginAsync(new TMap(TType.I32, TType.I32, Newmap.Count), cancellationToken);
          foreach (int _iter86 in Newmap.Keys)
          {
            await oprot.WriteI32Async(_iter86, cancellationToken);
            await oprot.WriteI32Async(Newmap[_iter86], cancellationToken);
          }
          await oprot.WriteMapEndAsync(cancellationToken);
        }
        await oprot.WriteFieldEndAsync(cancellationToken);
      }
      if((Newstring != null) && __isset.newstring)
      {
        field.Name = "newstring";
        field.Type = TType.String;
        field.ID = 11;
        await oprot.WriteFieldBeginAsync(field, cancellationToken);
        await oprot.WriteStringAsync(Newstring, cancellationToken);
        await oprot.WriteFieldEndAsync(cancellationToken);
      }
      if(__isset.end_in_both)
      {
        field.Name = "end_in_both";
        field.Type = TType.I32;
        field.ID = 12;
        await oprot.WriteFieldBeginAsync(field, cancellationToken);
        await oprot.WriteI32Async(End_in_both, cancellationToken);
        await oprot.WriteFieldEndAsync(cancellationToken);
      }
      await oprot.WriteFieldStopAsync(cancellationToken);
      await oprot.WriteStructEndAsync(cancellationToken);
    }
    finally
    {
      oprot.DecrementRecursionDepth();
    }
  }

  public override bool Equals(object that)
  {
    if (!(that is VersioningTestV2 other)) return false;
    if (ReferenceEquals(this, other)) return true;
    return ((__isset.begin_in_both == other.__isset.begin_in_both) && ((!__isset.begin_in_both) || (System.Object.Equals(Begin_in_both, other.Begin_in_both))))
      && ((__isset.newint == other.__isset.newint) && ((!__isset.newint) || (System.Object.Equals(Newint, other.Newint))))
      && ((__isset.newbyte == other.__isset.newbyte) && ((!__isset.newbyte) || (System.Object.Equals(Newbyte, other.Newbyte))))
      && ((__isset.newshort == other.__isset.newshort) && ((!__isset.newshort) || (System.Object.Equals(Newshort, other.Newshort))))
      && ((__isset.newlong == other.__isset.newlong) && ((!__isset.newlong) || (System.Object.Equals(Newlong, other.Newlong))))
      && ((__isset.newdouble == other.__isset.newdouble) && ((!__isset.newdouble) || (System.Object.Equals(Newdouble, other.Newdouble))))
      && ((__isset.newstruct == other.__isset.newstruct) && ((!__isset.newstruct) || (System.Object.Equals(Newstruct, other.Newstruct))))
      && ((__isset.newlist == other.__isset.newlist) && ((!__isset.newlist) || (TCollections.Equals(Newlist, other.Newlist))))
      && ((__isset.newset == other.__isset.newset) && ((!__isset.newset) || (TCollections.Equals(Newset, other.Newset))))
      && ((__isset.newmap == other.__isset.newmap) && ((!__isset.newmap) || (TCollections.Equals(Newmap, other.Newmap))))
      && ((__isset.newstring == other.__isset.newstring) && ((!__isset.newstring) || (System.Object.Equals(Newstring, other.Newstring))))
      && ((__isset.end_in_both == other.__isset.end_in_both) && ((!__isset.end_in_both) || (System.Object.Equals(End_in_both, other.End_in_both))));
  }

  public override int GetHashCode() {
    int hashcode = 157;
    unchecked {
      if(__isset.begin_in_both)
      {
        hashcode = (hashcode * 397) + Begin_in_both.GetHashCode();
      }
      if(__isset.newint)
      {
        hashcode = (hashcode * 397) + Newint.GetHashCode();
      }
      if(__isset.newbyte)
      {
        hashcode = (hashcode * 397) + Newbyte.GetHashCode();
      }
      if(__isset.newshort)
      {
        hashcode = (hashcode * 397) + Newshort.GetHashCode();
      }
      if(__isset.newlong)
      {
        hashcode = (hashcode * 397) + Newlong.GetHashCode();
      }
      if(__isset.newdouble)
      {
        hashcode = (hashcode * 397) + Newdouble.GetHashCode();
      }
      if((Newstruct != null) && __isset.newstruct)
      {
        hashcode = (hashcode * 397) + Newstruct.GetHashCode();
      }
      if((Newlist != null) && __isset.newlist)
      {
        hashcode = (hashcode * 397) + TCollections.GetHashCode(Newlist);
      }
      if((Newset != null) && __isset.newset)
      {
        hashcode = (hashcode * 397) + TCollections.GetHashCode(Newset);
      }
      if((Newmap != null) && __isset.newmap)
      {
        hashcode = (hashcode * 397) + TCollections.GetHashCode(Newmap);
      }
      if((Newstring != null) && __isset.newstring)
      {
        hashcode = (hashcode * 397) + Newstring.GetHashCode();
      }
      if(__isset.end_in_both)
      {
        hashcode = (hashcode * 397) + End_in_both.GetHashCode();
      }
    }
    return hashcode;
  }

  public override string ToString()
  {
    var sb = new StringBuilder("VersioningTestV2(");
    int tmp87 = 0;
    if(__isset.begin_in_both)
    {
      if(0 < tmp87++) { sb.Append(", "); }
      sb.Append("Begin_in_both: ");
      Begin_in_both.ToString(sb);
    }
    if(__isset.newint)
    {
      if(0 < tmp87++) { sb.Append(", "); }
      sb.Append("Newint: ");
      Newint.ToString(sb);
    }
    if(__isset.newbyte)
    {
      if(0 < tmp87++) { sb.Append(", "); }
      sb.Append("Newbyte: ");
      Newbyte.ToString(sb);
    }
    if(__isset.newshort)
    {
      if(0 < tmp87++) { sb.Append(", "); }
      sb.Append("Newshort: ");
      Newshort.ToString(sb);
    }
    if(__isset.newlong)
    {
      if(0 < tmp87++) { sb.Append(", "); }
      sb.Append("Newlong: ");
      Newlong.ToString(sb);
    }
    if(__isset.newdouble)
    {
      if(0 < tmp87++) { sb.Append(", "); }
      sb.Append("Newdouble: ");
      Newdouble.ToString(sb);
    }
    if((Newstruct != null) && __isset.newstruct)
    {
      if(0 < tmp87++) { sb.Append(", "); }
      sb.Append("Newstruct: ");
      Newstruct.ToString(sb);
    }
    if((Newlist != null) && __isset.newlist)
    {
      if(0 < tmp87++) { sb.Append(", "); }
      sb.Append("Newlist: ");
      Newlist.ToString(sb);
    }
    if((Newset != null) && __isset.newset)
    {
      if(0 < tmp87++) { sb.Append(", "); }
      sb.Append("Newset: ");
      Newset.ToString(sb);
    }
    if((Newmap != null) && __isset.newmap)
    {
      if(0 < tmp87++) { sb.Append(", "); }
      sb.Append("Newmap: ");
      Newmap.ToString(sb);
    }
    if((Newstring != null) && __isset.newstring)
    {
      if(0 < tmp87++) { sb.Append(", "); }
      sb.Append("Newstring: ");
      Newstring.ToString(sb);
    }
    if(__isset.end_in_both)
    {
      if(0 < tmp87++) { sb.Append(", "); }
      sb.Append("End_in_both: ");
      End_in_both.ToString(sb);
    }
    sb.Append(')');
    return sb.ToString();
  }
}

}
