IndexRange 1.0.3
dotnet add package IndexRange --version 1.0.3
NuGet\Install-Package IndexRange -Version 1.0.3
<PackageReference Include="IndexRange" Version="1.0.3" />
paket add IndexRange --version 1.0.3
#r "nuget: IndexRange, 1.0.3"
// Install IndexRange as a Cake Addin #addin nuget:?package=IndexRange&version=1.0.3 // Install IndexRange as a Cake Tool #tool nuget:?package=IndexRange&version=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
.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net35 is compatible. net40 was computed. net403 was computed. net45 is compatible. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 is compatible. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Universal Windows Platform | uap10.0.10240 is compatible. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 3.5
- ValueTupleBridge (>= 0.1.5)
-
.NETFramework 4.5
- System.ValueTuple (>= 4.5.0)
-
.NETFramework 4.7
- No dependencies.
-
.NETStandard 2.0
- No dependencies.
-
.NETStandard 2.1
- No dependencies.
-
UAP 10.0.10240
- System.ValueTuple (>= 4.5.0)
NuGet packages (130)
Showing the top 5 NuGet packages that depend on IndexRange:
Package | Downloads |
---|---|
Semver
A semantic version library fully compliant with v2.0.0 of the spec found at http://semver.org. |
|
EventStore.Client
The legacy TCP client API for Event Store. Get the open source or commercial versions of Event Store server from https://eventstore.com/ |
|
Telegram.Bot
This library gives you easy access to Telegram Bot API so you can start building useful bots for Telegram. |
|
Stl
Stl ("ServiceTitan Library") is a collection of relatively small abstractions or methods we couldn't find in BCL. A part of Stl.Fusion. |
|
PhotoSauce.MagicScaler
High-Performance image processing pipeline for .NET. Implements best-of-breed algorithms, linear light processing, and sharpening for the best image resizing quality available. Speed, efficiency, and image quality are unmatched by anything else on the .NET platform. |
GitHub repositories (31)
Showing the top 5 popular GitHub repositories that depend on IndexRange:
Repository | Stars |
---|---|
ldqk/Masuit.Tools
全龄段友好的C#万能工具库,码数吐司库,包含一些常用的操作类,大都是静态类,加密解密,反射操作,权重随机筛选算法,分布式短id,表达式树,linq扩展,文件压缩,多线程下载,硬件信息,字符串扩展方法,日期时间扩展操作,中国农历,大文件拷贝,图像裁剪,验证码,断点续传,集合扩展、Excel导出等常用封装。诸多功能集一身,代码量不到2MB!
|
|
TelegramBots/Telegram.Bot
.NET Client for Telegram Bot API
|
|
reactiveui/Akavache
An asynchronous, persistent key-value store created for writing desktop and mobile applications, based on SQLite3. Akavache is great for both storing important data as well as cached local data that expires.
|
|
shouldly/shouldly
Should testing for .NET—the way assertions should be!
|
|
KSP-CKAN/CKAN
The Comprehensive Kerbal Archive Network
|
* Support uap10.0 target framework.
* Use optimized Index.GetOffset in Range.GetOffsetAndLength.