IndexRange 1.1.0
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 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: 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: 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: 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 API (MTProto) library written 100% in C# and .NET Standard | Latest API layer: 199
Release Notes:
- API Layer 199: reCAPTCHA, PaidReactionPrivacy
- Fix Messages_GetAllChats to include only your chats
- Added EmojiStatusBase.DocumentId helper
- Added ForumTopicBase.Title helper
- Better support for HTML &entities; in HtmlText
|
5 |
|
WTelegramClient
Telegram Client API (MTProto) library written 100% in C# and .NET Standard | Latest API layer: 151
Release Notes:
- API Layer 151: media spoiler flag, personal profile photo, UpdateUser...
- Changed the ordering of optional parameters: Moved bool parameters to the end of parameter list
- Helper simplified method for Channels_GetAdminLog
- Signal wrong use of some params[] methods
- Improved documentation
|
4 |
|
WTelegramClient
Telegram Client API (MTProto) library written 100% in C# and .NET Standard | Latest API layer: 203
Release Notes:
Fix fields serialization order on KeyboardButtonSimpleWebView
|
4 |
|
WTelegramClient
Telegram Client API (MTProto) library written 100% in C# and .NET Standard | Latest API layer: 170
Release Notes:
API Layer 170: access to saved dialogs/history/peer
|
4 |
|
WTelegramClient
Telegram Client API (MTProto) library written 100% in C# and .NET Standard | Latest API layer: 210
Release Notes:
API Layer 210: user's Stars Rating, StarGift collections management & more characteristics...
(that might not be the most recent layer. check https://patreon.com/wizou for the latest layers)
|
4 |
|
WTelegramClient
Telegram Client API (MTProto) library written 100% in C# and .NET Standard | Latest API layer: 150
Release Notes:
Changed the ordering of optional parameters: Moved bool parameters to the end of parameter list
|
4 |
|
WTelegramClient
Telegram Client API (MTProto) library written 100% in C# and .NET Standard | Latest API layer: 176
Release Notes:
- Fix ''wrong timestamp'' issues when first msgId is too much in the past
- CollectUsersChats update user/chat fields from min info
- Raise event for Pong and Affected*
- Source code use more recent C# syntaxes
|
4 |
|
WTelegramClient
Telegram Client API (MTProto) library written 100% in C# and .NET Standard | Latest API layer: 163
Release Notes:
$ReleaseNotes
|
4 |
|
WTelegramClient
Telegram Client API (MTProto) library written 100% in C# and .NET Standard | Latest API layer: 174
Release Notes:
using primary constructors, and more [] syntax
|
4 |
|
WTelegramClient
Telegram Client API (MTProto) library written 100% in C# and .NET Standard | Latest API layer: 158
Release Notes:
Layer 158: chat wallpapers, enhanced chat folders/lists & switch-inline, edit bot infos, ...
|
4 |
|
WTelegramClient
Telegram Client API (MTProto) library written 100% in C# and .NET Standard | Latest API layer: 170
Release Notes:
Fix #225: RpcError INPUT_METHOD_INVALID_3105996036 when using client.DisableUpdates()
|
4 |
.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.0)
.NET Framework 4.7
- Microsoft.Bcl.Memory (>= 9.0.0)
UAP 10.0.10240
- System.ValueTuple (>= 4.5.0)
.NET Standard 2.0
- Microsoft.Bcl.Memory (>= 9.0.0)
.NET Standard 2.1
- Microsoft.Bcl.Memory (>= 9.0.0)