BackwardsCompatibleFeatures 2.1.0
See the version list below for details.
dotnet add package BackwardsCompatibleFeatures --version 2.1.0
NuGet\Install-Package BackwardsCompatibleFeatures -Version 2.1.0
<PackageReference Include="BackwardsCompatibleFeatures" Version="2.1.0" />
paket add BackwardsCompatibleFeatures --version 2.1.0
#r "nuget: BackwardsCompatibleFeatures, 2.1.0"
// Install BackwardsCompatibleFeatures as a Cake Addin #addin nuget:?package=BackwardsCompatibleFeatures&version=2.1.0 // Install BackwardsCompatibleFeatures as a Cake Tool #tool nuget:?package=BackwardsCompatibleFeatures&version=2.1.0
<img src="https://raw.githubusercontent.com/CptWesley/BackwardsCompatibleFeatures/master/logo.png" width="128" height="128">
BackwardsCompatibleFeatures
What is it?
Simple compile-time dependency for allowing the use of record
s and init
and various compiler attributes in older .NET versions such as .NET Core 3.0, .NET Standard and .NET Framework 4.5.
If you follow the configuration instructions, this package will not be included when you publish your project.
Meaning that users of your application or consumers of your library won't even know that you used this and it won't interfere with their usage!
What features are supported?
Feature | Language Version | Description |
---|---|---|
Records | 9 | Immutable data objects. |
Record Structs | 10 | Immutable data objects. |
CallerArgumentExpressionAttribute | 10 | Implicitly passes argument name as seperate argument to a function. |
AllowNullAttribute | N/A | Part of static nullable analysis. |
DisallowNullAttribute | N/A | Part of static nullable analysis. |
MaybeNullAttribute | N/A | Part of static nullable analysis. |
NotNullAttribute | N/A | Part of static nullable analysis. |
MaybeNullWhenAttribute | N/A | Part of static nullable analysis. |
NotNullAttribute | N/A | Part of static nullable analysis. |
NotNullIfNotNullAttribute | N/A | Part of static nullable analysis. |
MemberNotNullAttribute | N/A | Part of static nullable analysis. |
MemberNotNullWhenAttribute | N/A | Part of static nullable analysis. |
DoesNotReturnAttribute | N/A | Part of static nullable analysis. |
DoesNotReturnIfAttribute | N/A | Part of static nullable analysis. |
TargetPlatformAttribute | N/A | Part of static platform support analysis. |
SupportedOSPlatformAttribute | N/A | Part of static platform support analysis. |
UnsupportedOSPlatformAttribute | N/A | Part of static platform support analysis. |
SupportedOSPlatformGuardAttribute | N/A | Part of static platform support analysis. |
UnsupportedOSPlatformGuardAttribute | N/A | Part of static platform support analysis. |
ObsoletedInOSPlatformAttribute | N/A | Part of static platform support analysis. |
StringSyntaxAttribute | N/A | Provides a hint to IDEs to provide specific syntax highlighting for string parameters. |
required modifier | 11 | Enforces initialisation of properties with init during construction. |
SetsRequiredMembersAttribute | N/A | Marks constructor as setting all required properties. |
Where can I get it?
How do I use it?
First we should add the dependency to our project.
Next up we should also add the <LangVersion>10</LangVersion>
tag to the body of the <PropertyGroup>...</PropertyGroup>
in our .csproj
file.
Now the slightly more complex part... We are going to set change the asset settings of the dependency to make sure consumers don't depend on this project.
We should change the package import which should look something like this:
<PackageReference Include="BackwardsCompatibleFeatures" Version="2.2.0" />
To the following:
<PackageReference Include="BackwardsCompatibleFeatures" Version="2.2.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>compile</IncludeAssets>
</PackageReference>
A full example of a what our project could look like:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<LangVersion>11</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BackwardsCompatibleFeatures" Version="2.2.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>compile</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
If you are still struggling, you can take a look at the example project.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 is compatible. 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 is compatible. 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 | netcoreapp1.0 is compatible. netcoreapp1.1 was computed. netcoreapp2.0 is compatible. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 is compatible. netcoreapp3.1 was computed. |
.NET Standard | netstandard1.0 is compatible. netstandard1.1 was computed. netstandard1.2 was computed. netstandard1.3 is compatible. netstandard1.4 was computed. netstandard1.5 was computed. netstandard1.6 is compatible. netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net45 was computed. net451 was computed. net452 was computed. net46 is compatible. net461 was computed. net462 was computed. net463 was computed. net47 is compatible. net471 was computed. net472 was computed. net48 is compatible. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen30 was computed. tizen40 was computed. tizen60 was computed. |
Universal Windows Platform | uap was computed. uap10.0 was computed. |
Windows Phone | wp8 was computed. wp81 was computed. wpa81 was computed. |
Windows Store | netcore was computed. netcore45 was computed. netcore451 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETCoreApp 1.0
- Microsoft.NETCore.App (>= 1.0.5)
-
.NETCoreApp 2.0
- No dependencies.
-
.NETCoreApp 3.0
- No dependencies.
-
.NETFramework 4.6
- No dependencies.
-
.NETFramework 4.7
- No dependencies.
-
.NETFramework 4.8
- No dependencies.
-
.NETStandard 1.0
- NETStandard.Library (>= 1.6.1)
-
.NETStandard 1.3
- NETStandard.Library (>= 1.6.1)
-
.NETStandard 1.6
- NETStandard.Library (>= 1.6.1)
-
.NETStandard 2.0
- No dependencies.
-
.NETStandard 2.1
- No dependencies.
-
net5.0
- No dependencies.
-
net6.0
- No dependencies.
-
net7.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.3.0 | 4,358 | 6/11/2023 |
2.2.0 | 283 | 5/15/2023 |
2.1.0 | 325 | 1/30/2023 |
2.0.0 | 366 | 8/6/2022 |
2.0.0-preview2 | 191 | 8/6/2022 |
2.0.0-preview1 | 200 | 8/6/2022 |