VinlandSolutions.CommonCore.Shims 1.0.0-pre.1

This is a prerelease version of VinlandSolutions.CommonCore.Shims.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package VinlandSolutions.CommonCore.Shims --version 1.0.0-pre.1
NuGet\Install-Package VinlandSolutions.CommonCore.Shims -Version 1.0.0-pre.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="VinlandSolutions.CommonCore.Shims" Version="1.0.0-pre.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add VinlandSolutions.CommonCore.Shims --version 1.0.0-pre.1
#r "nuget: VinlandSolutions.CommonCore.Shims, 1.0.0-pre.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install VinlandSolutions.CommonCore.Shims as a Cake Addin
#addin nuget:?package=VinlandSolutions.CommonCore.Shims&version=1.0.0-pre.1&prerelease

// Install VinlandSolutions.CommonCore.Shims as a Cake Tool
#tool nuget:?package=VinlandSolutions.CommonCore.Shims&version=1.0.0-pre.1&prerelease

Vinland Solutions CommonCore.Exceptions Library

License Platform Repository Releases Documentation
Nuget Pipeline Coverage

NOTE: This project should only be used by legacy pre-dotnet core projects and libraries that multi-target net standard 2.0 to reach such projects.

CommonCore.Shims is a .Net Standard 2.0 library that provides shims for C# 9 features like collection slicing and initializable properties.

Installation

The official release versions of the CommonCore.Shims library are hosted on NuGet and can be installed using the standard console means, or found through the Visual Studio NuGet Package Managers.

This library is compatible with projects targeting at least .Net Framework 4.6.1, .Net Core 2.0, or .Net 5.

Usage

This library does not have special usage of it's own. It simply enables C# language features that are usually present but unusable in projects targeting lower than net standard 2.1. When included in multitargeting projects, the library should be conditionally referenced so it is only included for the net standard 2.0 target.

    <ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
        <PackageReference Include="VinlandSolutions.CommonCore.Shims" Version="X.Y.Z" />
    </ItemGroup>

It may also be necessary to explicitly enable C# 9 language features, in which case a LangVersion element must be added to the project file.

    <PropertyGroup>
        <TargetFrameworks>netstandard2.1;netstandard2.0</TargetFrameworks>
        <LangVersion>9.0</LangVersion>
    </PropertyGroup>

Otherwise, usage is normal as per the various shimmed features.

Slicing collections:

int[] array = new int[] { 9, 5, 1 };
int[] subarray;
subarray = array[1..];// { 5, 1 }
subarray = array[..^1];// { 9, 5 }
subarray = array[1..^1];// { 5 }

Externally initializable properties:

public class SomeClass
{
    public int InitProp { get; init; } = 10;
}

var sc = new SomeClass();
Console.WriteLine(sc.InitProp);// InitProp == 10
sc = new SomeClass() { InitProp = 5 };
Console.WriteLine(sc.InitProp);// InitProp == 5
sc.InitProp = 0;// Error

Some code analysis attributes:

public static bool TryParse(
    [NotNullWhen(true)] object? input,
    [NotNullWhen(true), MaybeNullWhen(false)] out SomeType? output)
{
    // if input is not null and can parse input,
    // then set output to result and return true,
    // else set output null and return false.
}

Projects

The CommonCore.Shims repository is composed of three projects with the listed dependencies:

Credits

This library simply wraps some dotnet types that are built-in for net standard 2.1 and greater, so thanks goes to the dotnet team.

Product 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 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  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. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on VinlandSolutions.CommonCore.Shims:

Package Downloads
VinlandSolutions.CommonCore.Exceptions

CommonCore.Exceptions is a .Net Standard 2.0/2.1 library designed to simplify the validating and throwing of common exceptions.

VinlandSolutions.CommonCore.Text

CommonCore.Text is a .Net Standard 2.0/2.1 library ?.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0-pre.3 149 4/10/2022
1.0.0-pre.2 153 4/8/2022
1.0.0-pre.1 105 4/7/2022