use primary constructors

This commit is contained in:
Wizou 2024-03-12 19:07:48 +01:00
parent 0738adc3bf
commit d00725e234
5 changed files with 16 additions and 21 deletions

2
.github/dev.yml vendored
View file

@ -1,7 +1,7 @@
pr: none
trigger: [ master ]
name: 3.7.1-dev.$(Rev:r)
name: 3.7.2-dev.$(Rev:r)
pool:
vmImage: ubuntu-latest

View file

@ -815,7 +815,7 @@ namespace WTelegram
_paddedMode = true;
secret = secret[1..17];
}
else if (secret.Length != 16) throw new ArgumentException("Invalid/unsupported secret", nameof(secret));
else if (secret.Length != 16) throw new ArgumentException("Invalid/unsupported secret");
Helpers.Log(2, $"Connecting to DC {dcId} via MTProxy {server}:{port}...");
_tcpClient = await TcpHandler(server, port);
_networkStream = _tcpClient.GetStream();

View file

@ -235,11 +235,10 @@ namespace WTelegram
internal static string GetAppVersion()
=> (Assembly.GetEntryAssembly() ?? Array.Find(AppDomain.CurrentDomain.GetAssemblies(), a => a.EntryPoint != null))?.GetName().Version.ToString() ?? "0.0";
public class IndirectStream : Stream
public class IndirectStream(Stream innerStream) : Stream
{
public IndirectStream(Stream innerStream) => _innerStream = innerStream;
public long? ContentLength;
protected readonly Stream _innerStream;
protected readonly Stream _innerStream = innerStream;
public override bool CanRead => _innerStream.CanRead;
public override bool CanSeek => ContentLength.HasValue || _innerStream.CanSeek;
public override bool CanWrite => _innerStream.CanWrite;

View file

@ -11,7 +11,7 @@ namespace TL
{
public static class Extensions
{
private class CollectorPeer : Peer
internal class CollectorPeer : Peer
{
public override long ID => 0;
internal IDictionary<long, User> _users;

View file

@ -16,26 +16,23 @@ namespace TL
public interface IPeerResolver { IPeerInfo UserOrChat(Peer peer); }
[AttributeUsage(AttributeTargets.Class)]
public class TLDefAttribute : Attribute
public class TLDefAttribute(uint ctorNb) : Attribute
{
public readonly uint CtorNb;
public TLDefAttribute(uint ctorNb) => CtorNb = ctorNb;
public readonly uint CtorNb = ctorNb;
public bool inheritBefore;
}
[AttributeUsage(AttributeTargets.Field)]
public class IfFlagAttribute : Attribute
public class IfFlagAttribute(int bit) : Attribute
{
public readonly int Bit;
public IfFlagAttribute(int bit) => Bit = bit;
public readonly int Bit = bit;
}
public class RpcException : WTelegram.WTException
public class RpcException(int code, string message, int x = -1) : WTelegram.WTException(message)
{
public readonly int Code;
public readonly int Code = code;
/// <summary>The value of X in the message, -1 if no variable X was found</summary>
public readonly int X;
public RpcException(int code, string message, int x = -1) : base(message) { Code = code; X = x; }
public readonly int X = x;
public override string ToString() { var str = base.ToString(); return str.Insert(str.IndexOf(':') + 1, " " + Code); }
}
@ -372,13 +369,12 @@ namespace TL
}
[TLDef(0x5BB8E511)] //message#5bb8e511 msg_id:long seqno:int bytes:int body:Object = Message
public class _Message : IObject
public class _Message(long msgId, int seqNo, IObject obj) : IObject
{
public _Message(long msgId, int seqNo, IObject obj) { msg_id = msgId; seq_no = seqNo; body = obj; }
public long msg_id;
public int seq_no;
public long msg_id = msgId;
public int seq_no = seqNo;
public int bytes;
public IObject body;
public IObject body = obj;
}
[TLDef(0x73F1F8DC)] //msg_container#73f1f8dc messages:vector<%Message> = MessageContainer