Commit graph

324 commits

Author SHA1 Message Date
Andres Aragoneses 99aa273d55 Tests: wait 1 second between each test to avoid possible hangs 2020-10-17 16:12:27 -07:00
Andres G. Aragoneses 90aef81908 Core: improve flood exception msg 2020-10-18 00:05:13 +02:00
Andres G. Aragoneses c37ecd4621 Core: use better exception types and messages if things go south
One of the problems is related to [1] so if that bug
happens again, now we'll have more info.

[1] https://github.com/nblockchain/TgSharp/issues/22
2020-10-16 21:20:54 +02:00
Andres G. Aragoneses 0dd6d70c60 Core: save session as soon as a the sequence is incremented
Just be safe, let's not wait until other part of the code saves the
session, and let's do it right here on the spot, where we know it
changes.

@Laituex was having a ErrCode=32 'msg_seqno too low' problem and this
is the second thing we suspected to be the culprit, because if there's
any issue (e.g. exception) that makes the session not be saved after
the sequence got incremented, then an old sequence would be used the
next time upon loading an old session file.

(Backported from 1b06473108)
2020-10-14 20:53:27 +02:00
Andres G. Aragoneses 79ad0fc21e Core: make MtProtoSender.GenerateSequence() thread-safe
Even if you're not supposed to use multiple threads with TLSharp,
it might be worth it to try to make this sequence increment in
a thread-safe way. Race conditions are always bad even if you know
you are not supposed to use something in a certain way...

@Laituex was having a ErrCode=32 'msg_seqno too low' problem and this
is the first thing we looked at (even if he swore that he was not
using different threads to access the telegram network).

(Backported from 881bdd27a5 )

# Conflicts:
#	src/TgSharp.Core/Session.cs
2020-10-14 20:48:43 +02:00
Andres G. Aragoneses ef499c6fef Core: refactor FileSessionStore class
* Move it into its own file.
* Fix typo in var name "Exsist"
* Move Session.ToBytes() and Session.FromBytes() methods to it.
2020-10-13 15:18:41 +02:00
Andres G. Aragoneses ef89274e1f Core: refactor around Session vs SessionStore
This will help implementing session storage in JSON
format. WIP PRs:
- https://github.com/nblockchain/TgSharp/pull/18
- https://github.com/nblockchain/TgSharp/pull/29
2020-10-13 15:02:00 +02:00
Andres G. Aragoneses 5ae1024eac gitignore: add .DS_Store (macOS) 2020-10-13 15:01:47 +02:00
Andres G. Aragoneses a1aabb67ac README.md: fix a couple of broken links 2020-09-20 18:03:57 +08:00
Andres G. Aragoneses 8766824b8b Tests: reenable SendMessageByUserName
Also changing messages in other test to differentiate their origin.
2020-09-20 17:56:31 +08:00
Andres G. Aragoneses 5f62ccf7e3 Core,Tests: fix SendUploadedPhoto
It got broken in one [1] of the LayerUpdate PR [2]
commits because TLInputMediaUploadedPhoto's [3]
Caption property was dropped, but somehow the
replacement of it is now TLRequestSendMedia's [4]
Message property.

[1] 07c4812e99
[2] https://github.com/nblockchain/TgSharp/pull/13
[3] 07c4812e99 (diff-8fc2b6f90844589a5a85c31971236c6a)
[4] 07c4812e99 (diff-6579e69beaef1ce3efce20d9f9a087ea)
2020-09-20 16:59:01 +08:00
Andres Aragoneses cec35c6004 Run tests in CI (Windows OS only for now)
The reason for such a hack when runing in CI is because we
need to make sure we're using higher sequence numbers than
any previous times (and even previous runs of the test suite).

And we run 1 test only for now, later we will enable more.

Other notes:

The trick to extract secrets to files was taken from:
https://stackoverflow.com/a/59482124/544947

The binary-to-text encoding/decoding was taken from:
https://stackoverflow.com/a/42725926/544947

The way to add defines to DefineConstants for MSBuild:
https://stackoverflow.com/a/5053070/544947
2020-09-19 17:00:34 +08:00
Andres Aragoneses e304b00089 Tests.NUnit: add NUnitTestAdapter nuget dep
Otherwise the tests can't actually be run in VS for Windows
(follow-up to 90e16c1b1e).
2020-09-18 02:18:48 -07:00
Andres G. Aragoneses d38840f22e GithubCI: build the whole solution in macOS&Linux too
Now that we have removed the only VS-specific project [1],
we can make all pipelines of all OSs consistent, building
the solution instead of a specific project.

[1] 90e16c1b1e
2020-09-18 15:21:36 +08:00
Andres G. Aragoneses 79dd6f087a README.md: add an icon for GitLabCI build status too 2020-09-18 15:19:09 +08:00
Andres G. Aragoneses 652c7d6cbb GitLabCI: remove old mono version pipeline
Because it is red (because nuget doesn't accept old TLS connections,
and only newer versions of Mono support newer TLS versions)
2020-09-18 14:54:50 +08:00
Andres G. Aragoneses 90e16c1b1e TgSharp.Tests.VS: remove VS-tests layer as it's not needed anymore
Fixes https://github.com/nblockchain/TgSharp/issues/24
2020-09-18 14:07:04 +08:00
Andres G. Aragoneses fe60a44fa7 Core,Tests.VS: fix ref names following rename
Similar to recent commit 42468e2881
2020-09-14 23:58:06 +08:00
Afshin Arani 42468e2881 Tests.VS: fix ref name following rename
This should have been done in d4a4c66d35
2020-09-14 23:51:24 +08:00
Andres G. Aragoneses ff4ba68074 Core: cosmetic, fix whitespace in Session.cs
Some tabs to spaces
2020-09-14 23:51:13 +08:00
Afshin Arani a74f8f2252 Removing constructor double write
In "TLObject.Serialize() -> Serialize(BinaryWriter br) -> SerializeBody"
code path, constructor get written two times instead of once, which
since this code path is currently unused and it's only provided for
completeness, It's undetectable while testing.
2020-09-14 19:02:18 +08:00
Andres G. Aragoneses 3ea897402c TgSharp.TL: fix invalid Context type initialization for TLVector
Fixes https://github.com/nblockchain/TgSharp/issues/15
2020-09-13 18:18:28 +08:00
Andres G. Aragoneses 73313ae199 Core: place the DataCenterIPVersion as first optional parameter
It's the most important one so it should be the first.
2020-09-12 17:22:12 +08:00
Andres G. Aragoneses 501ebb936d
Merge pull request #13 from nblockchain/layerUpdate
Layer update (to 108)
2020-09-11 17:26:49 +08:00
Andres G. Aragoneses 9b68b69d14 nugetUpload: change baseVersion from 0.1.1 to 0.3.1
The layer update (and namespaces/assembly/type renames) is a
huge API breaking change.
2020-09-11 17:15:25 +08:00
Andres G. Aragoneses 94edf1b3eb Rename TeleSharp.TL->TgSharp.TL, fixing TgSharp.Core build (5/5) 2020-09-11 17:15:25 +08:00
Andres G. Aragoneses 350d28c7f8 Rename TeleSharp.TL->TgSharp.TL, fixing base types (4/5)
These types are not auto-generated so they needed to be fixed
manually.
2020-09-11 17:15:25 +08:00
Andres G. Aragoneses 2c0352e38d Rename TeleSharp.TL->TgSharp.TL, auto-generating again (3/5) 2020-09-11 17:15:25 +08:00
Andres G. Aragoneses d4a4c66d35 Rename TeleSharp.TL->TgSharp.TL (2/5) 2020-09-11 17:15:25 +08:00
Andres G. Aragoneses dfb8b52bb0 Generator: start rename of TeleSharp.TL->TgSharp.TL assembly (1/5) 2020-09-11 17:14:19 +08:00
Andres G. Aragoneses 8c3ddeb1b2 Rename TeleSharp.Generator->TgSharp.Generator
For consistency.
2020-09-11 17:14:19 +08:00
Andres G. Aragoneses 75fb3c1488 TeleSharp.TL: fix build
Manual edits needed after code autogeneration.
2020-09-11 17:14:19 +08:00
Andres G. Aragoneses a3ebd07d82 TeleSharp.TL: update generated code
This was the result of running the latest version of the generator,
which fixes many whitespace issues such as trailing whitespace.
2020-09-11 17:14:19 +08:00
Andres G. Aragoneses 7be6122381 Generator: fix many whitespace nits (especially in generated code) 2020-09-11 17:14:18 +08:00
Afshin Arani 02c58b78dc README.md: fix outdated information 2020-09-11 17:14:18 +08:00
Afshin Arani f2bdf845e9 README.md: update samples to match Layer 108 API 2020-09-11 17:14:18 +08:00
Afshin Arani 3cb0ef63ca api: change layer number 2020-09-11 17:14:18 +08:00
Afshin Arani a853f1210d fix: Duplicate TLVector and API Changes in SendCode Method 2020-09-11 17:14:18 +08:00
Afshin Arani 07c4812e99 api: Update to Layer 108 2020-09-11 17:14:18 +08:00
Andres G. Aragoneses 58df196e08 nuspec: net45->net46 folder, forgotten change in 4.5->4.6 .NET upgrade
Hopefully fixes https://github.com/nblockchain/TgSharp/issues/8
2020-04-16 19:20:30 +08:00
Andres G. Aragoneses c20b2cddc5 Generator: fix regression caused by a typo
It was introduced in here: 012207251b
2020-04-15 18:22:53 +08:00
Andres G. Aragoneses 313739eb2f nugetUpload: add a dash in pre-release version before the git hash
Otherwise if the hash starts with a non-number it looks weird.
2020-04-14 22:08:58 +08:00
Andres G. Aragoneses ba7e7cbfa9 nugetUpload: change baseVersion from 0.1.0 to 0.1.1
Now that we have diverged from TLSharp[1], the new pre-release
versions pushed to nuget have different API and slightly
different behaviour so we want them to be marked as newer.

[1] since 4d09ac711d
2020-04-14 21:59:36 +08:00
Andres G. Aragoneses 0a5ab705f8 TeleSharp.TL: try wildcards in the project file
This makes Layer updates much easier, without having to
include new files manually.
2020-04-14 20:42:32 +08:00
Andres G. Aragoneses b55084d50d nugetUpload: fix version creation
Somehow for the previous commit hash, which had only numbers in its
short version (0122072), nuget failed with:
Run $date = get-date -format "yyyyMMdd-HHmm"
Attempting to build package from 'TgSharp.Core.csproj'.
Error NU5010: Version string specified for package reference '0.1.0-date.20200414-0908.git.0122072' is invalid.
File does not exist (TgSharp.0.1.0-date.20200414-0908.git.0122072.nupkg).

Now we remove the "." after "date" and "git" and use double-dash
to separate initial version from the sub-version.
2020-04-14 18:32:07 +08:00
Andres G. Aragoneses 012207251b Generator: allow running generator from TeleSharp.TL/ folder
Bear with me, the part of the code that traverses the path with ".."
subfolders is actually not needed, but whatever, I had already written
it.
2020-04-14 16:55:34 +08:00
Andres G. Aragoneses a85f0d8e11 Generator: make it work with Unix paths
It was hardcoding the Windows path separator so this could only
run on Windows before.
2020-04-14 15:58:11 +08:00
Andres G. Aragoneses 56448c6410 README.md: prefer OfType<>() LINQ method, it's shorter
Based on dfc89dc3ab
2020-04-14 06:46:44 +08:00
Andres G. Aragoneses 6b9fc62634 README.md: fix code snippets indentation and other things 2020-04-14 06:44:38 +08:00
Andres G. Aragoneses 292d92e4a2 Core: TelegramClient class hardening, adding readonly keywords 2020-04-12 23:29:58 +08:00