IndexRange 1.1.1
About
This package lets you use the C# 8.0 index and range features in projects that target .NET Framework.
For projects that target netstandard2.0 or .NET Framework 4.6.2 or later, use the Microsoft.Bcl.Memory package instead. This package should be considered deprecated for those target frameworks.
This library is not necessary nor recommended when targeting versions of .NET that include the relevant support.
Using Range with Arrays
The C# compiler needs the RuntimeHelpers.GetSubArray<T> method to be available to create subranges from arrays. This method is only available in netstandard2.1 and .NET Core 3.0, so creating subranges from arrays will fail to compile in .NET Framework.
Use Span<T>
A workaround is to add a reference to System.Memory and use Span<T>. Not only does this compile, it's much more efficient as it doesn't create a new array and copy the sliced data to it:
int[] array = new[] { 1, 2, 3, 4, 5, 6 };
// don't do this:
// var slice = array[1..^1];
// do this:
var slice = array.AsSpan()[1..^1];
Define GetSubArray<T>
The other fix is to define the necessary method in your source code. Copy the following code into your project:
https://gist.github.com/bgrainger/fb2c18659c2cdfce494c82a8c4803360
That type is not in this NuGet package so that the C# compiler doesn't warn that The predefined type 'RuntimeHelpers' is defined in multiple assemblies.
Showing the top 20 packages that depend on IndexRange.
| Packages | Downloads |
|---|---|
|
WTelegramClient
Telegram Client API (MTProto) library written 100% in C# and .NET Standard | Latest API layer: 176
Release Notes:
CollectUsersChats update user/chat fields from min info
|
11 |
|
WTelegramClient
Telegram Client API (MTProto) library written 100% in C# and .NET Standard | Latest API layer: 206
Release Notes:
- API Layer 206: ToDo lists, suggested posts, choose TON vs Stars for gifts/transactions, ...
- Fix DateTime type of *_at fields
(that might not be the most recent API layer. check https://patreon.com/wizou for the latest layers)
|
9 |
|
WTelegramClient
Telegram Client API (MTProto) library written 100% in C# and .NET Standard | Latest API layer: 186
Release Notes:
Fix infinite recursion on Dispose (#274) 🎬Take 2
|
8 |
|
WTelegramClient
Telegram Client API library written 100% in C# and .NET Standard | Latest MTProto & API layer version
|
7 |
|
WTelegramClient
Telegram Client API library written 100% in C# and .NET Standard | Latest MTProto & API layer version
|
6 |
|
WTelegramClient
Telegram Client API (MTProto) library written 100% in C# and .NET Standard | Latest API layer: 165
Release Notes:
- Detect wrong usage of GetMessages
- API Layer 165: minor changes to WebPage, channel boost url
|
6 |
|
WTelegramClient
Telegram client library written 100% in C# and .NET Standard
|
6 |
|
WTelegramClient
Telegram Client API (MTProto) library written 100% in C# and .NET Standard | Latest API layer: 181
Release Notes:
API Layer 181: Fact check, Message effects, Payment stars...
|
5 |
|
WTelegramClient
Telegram Client API (MTProto) library written 100% in C# and .NET Standard | Latest API layer: 216
Release Notes:
- API Layer 216: topics methods/updates moved to prefix Messages_* (to support topics for bots), contact notes, groupcall comments, profile color, stargifts stuff
- Collect: Fix Channel losing participants_count
- Change UserStatusOffline.was_online to a DateTime
- Added missing DownloadFileAsync(doc, videoSize)
- Delete alt-session on AUTH_KEY_UNREGISTERED for renegociation
- Removed annoying Peer implicit long operator (reverts #229)
|
5 |
|
WTelegramClient
Telegram Client API (MTProto) library written 100% in C# and .NET Standard | Latest API layer: 173
Release Notes:
- API Layer 173: no_joined_notifications, SavedReactionTags in peers
- DownloadFileAsync: don't use stream.Position if !CanSeek
|
5 |
|
WTelegramClient
Telegram Client API library written 100% in C# and .NET Standard | Latest MTProto & API layer version
|
5 |
|
WTelegramClient
Telegram Client API (MTProto) library written 100% in C# and .NET Standard | Latest API layer: 209
Release Notes:
- API Layer 207: StarGift.ReleaseBy
- API Layer 209: Reply-to specific ToDo item
- Support single-quote arguments in HTML tags
|
5 |
|
WTelegramClient
Telegram Client API (MTProto) library written 100% in C# and .NET Standard | Latest API layer: 179
Release Notes:
- API Layer 179: poll texts with entities, new SentCodeTypes
- Catch/Log sessionStore.Write exceptions (fix #248)
- New method LoginWithQRCode (fix #247)
|
5 |
|
WTelegramClient
Telegram Client API (MTProto) library written 100% in C# and .NET Standard | Latest API layer: 201
Release Notes:
API Layer 201.2: business bot stars Store less stuff in session data and reduce save frequency for better performance.
|
5 |
|
WTelegramClient
Telegram Client API (MTProto) library written 100% in C# and .NET Standard | Latest API layer: 160
Release Notes:
- API Layer 160: Stories & more...
- Added Contacts_ResolvedPeer.Channel property
- CollectUsersChats allows null dictionaries
- Prevent 'You must connect to Telegram first' during network loss
- Prevent 'recursive' MsgContainer
- Fix Messages_GetAllDialogs (MessageEmpty)
- Fix AnalyzeInviteLink (public channel with join request)
- Fix ReactorError not correctly raised.
Added Program_ReactorError example
- Fix unencrypted padding length in Padded Intermediate
- updated Program_ListenUpdates example & api doc
|
5 |
|
WTelegramClient
Telegram client library written 100% in C# and .NET Standard
|
5 |
|
WTelegramClient
Telegram client library written 100% in C# and .NET Standard | Latest MTProto & API layer version
|
5 |
.NET Framework 3.5
- ValueTupleBridge (>= 0.1.5)
.NET Framework 4.5
- System.ValueTuple (>= 4.5.0)
.NET Framework 4.6.2
- Microsoft.Bcl.Memory (>= 9.0.14)
.NET Framework 4.7
- Microsoft.Bcl.Memory (>= 9.0.14)
UAP 10.0.10240
- System.ValueTuple (>= 4.5.0)
.NET Standard 2.0
- Microsoft.Bcl.Memory (>= 9.0.14)
.NET Standard 2.1
- Microsoft.Bcl.Memory (>= 9.0.14)