IndexRange 1.0.3
This package lets you use the C# 8.0 index and range features in projects that target .NET Framework or netstandard2.0.
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 |
|---|---|
|
Telegram.Bot
This library gives you easy access to Telegram Bot API so you can start building useful bots for Telegram.
|
11 |
|
Telegram.Bot
This library gives you easy access to Telegram Bot API so you can start building useful bots for Telegram.
|
12 |
|
Telegram.Bot
This library gives you easy access to Telegram Bot API so you can start building useful bots for Telegram.
|
13 |
|
Telegram.Bot
This library gives you easy access to Telegram Bot API so you can start building useful bots for Telegram.
|
14 |
|
Telegram.Bot
This library gives you easy access to Telegram Bot API so you can start building useful bots for Telegram.
Release Notes:
Added helper methods PlainLength, ToPlain and Truncate in HtmlText
|
12 |
|
Telegram.Bot
This library gives you easy access to Telegram Bot API so you can start building useful bots for Telegram.
Release Notes:
Added property Message.IsServiceMessage
|
11 |
|
Telegram.Bot
This library gives you easy access to Telegram Bot API so you can start building useful bots for Telegram.
Release Notes:
Bot API 9.0
|
13 |
|
Telegram.Bot
This library gives you easy access to Telegram Bot API so you can start building useful bots for Telegram.
Release Notes:
- Bot API 9.0b (CanDeleteSentMessages)
- Added ChatMemberRestricted.IsMuted helper
|
13 |
|
Telegram.Bot
This library gives you easy access to Telegram Bot API so you can start building useful bots for Telegram.
Release Notes:
Cleaning code generation
Merging methods AnswerShippingQuery
Using PollType in Poll
|
11 |
|
Telegram.Bot
This library gives you easy access to Telegram Bot API so you can start building useful bots for Telegram.
Release Notes:
Include ThreadId into a message link creation to mimic original Telegram behavior (#1465)
|
11 |
|
Telegram.Bot
This library gives you easy access to Telegram Bot API so you can start building useful bots for Telegram.
Release Notes:
Make services.ConfigureTelegramBot unnecessary by adding [JsonPropertyName] where necessary
|
12 |
|
Telegram.Bot
This library gives you easy access to Telegram Bot API so you can start building useful bots for Telegram.
Release Notes:
Pushing dev versions as prerelease on Nuget
|
12 |
|
Telegram.Bot
This library gives you easy access to Telegram Bot API so you can start building useful bots for Telegram.
Release Notes:
Sealed some internal types for performance
|
13 |
|
Telegram.Bot
This library gives you easy access to Telegram Bot API so you can start building useful bots for Telegram.
Release Notes:
- Support for Bot API 9.0
- Removed the *Async-suffixed versions of the methods that were marked [Obsolete] since v22.0.
- Services.ConfigureTelegramBot* is no longer necessary to make your Webhook bot compatible with Telegram updates!
- Removed dependency on ASP.NET Core (Microsoft.AspNetCore.App) from the main library
- Merged the Telegram.Bot.Extensions.Passport package into the main library
- New HtmlText helpers method: ToPlain, PlainLength and Truncate to get the plain text only from HTML text (remove the <tags>), the number of plain text characters, or truncate the HTML to a number of plain text characters (useful to comply with the 4096/1024 message limit)
- Added constructor ChatAdministratorRights(bool) to set all fields to true or false (except IsAnonymous)
- Added helper property message.IsServiceMessage to detect service messages vs content messages
2 small breaking changes:
- Merged AnswerShippingQuery method overloads. You'll need to add errorMessage: in your code to pass that argument and indicate failure.
- The Poll.Type is now an enum PollType instead of string
More details: https://telegrambots.github.io/book/migrate/Version-22.x.html#whats-new-in-version-225
|
14 |
- Support uap10.0 target framework.
- Use optimized Index.GetOffset in Range.GetOffsetAndLength.
.NET Framework 3.5
- ValueTupleBridge (>= 0.1.5)
.NET Framework 4.5
- System.ValueTuple (>= 4.5.0)
.NET Framework 4.7
- No dependencies.
UAP 10.0.10240
- System.ValueTuple (>= 4.5.0)
.NET Standard 2.0
- No dependencies.
.NET Standard 2.1
- No dependencies.