BackwardsCompatibleFeatures 2.3.0
dotnet add package BackwardsCompatibleFeatures --version 2.3.0
NuGet\Install-Package BackwardsCompatibleFeatures -Version 2.3.0
<PackageReference Include="BackwardsCompatibleFeatures" Version="2.3.0" />
paket add BackwardsCompatibleFeatures --version 2.3.0
#r "nuget: BackwardsCompatibleFeatures, 2.3.0"
// Install BackwardsCompatibleFeatures as a Cake Addin #addin nuget:?package=BackwardsCompatibleFeatures&version=2.3.0 // Install BackwardsCompatibleFeatures as a Cake Tool #tool nuget:?package=BackwardsCompatibleFeatures&version=2.3.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 | Added In |
---|---|---|---|
Records | 9 | Immutable data objects. | 1.0.0 |
Record Structs | 10 | Immutable data objects. | 1.0.0 |
CallerArgumentExpressionAttribute | 10 | Implicitly passes argument name as seperate argument to a function. | 2.0.0 |
AllowNullAttribute | N/A | Part of static nullable analysis. | 2.0.0 |
DisallowNullAttribute | N/A | Part of static nullable analysis. | 2.0.0 |
MaybeNullAttribute | N/A | Part of static nullable analysis. | 2.0.0 |
NotNullAttribute | N/A | Part of static nullable analysis. | 2.0.0 |
MaybeNullWhenAttribute | N/A | Part of static nullable analysis. | 2.0.0 |
NotNullAttribute | N/A | Part of static nullable analysis. | 2.0.0 |
NotNullIfNotNullAttribute | N/A | Part of static nullable analysis. | 2.0.0 |
MemberNotNullAttribute | N/A | Part of static nullable analysis. | 2.0.0 |
MemberNotNullWhenAttribute | N/A | Part of static nullable analysis. | 2.0.0 |
DoesNotReturnAttribute | N/A | Part of static nullable analysis. | 2.0.0 |
DoesNotReturnIfAttribute | N/A | Part of static nullable analysis. | 2.0.0 |
TargetPlatformAttribute | N/A | Part of static platform support analysis. | 2.0.0 |
SupportedOSPlatformAttribute | N/A | Part of static platform support analysis. | 2.0.0 |
UnsupportedOSPlatformAttribute | N/A | Part of static platform support analysis. | 2.0.0 |
SupportedOSPlatformGuardAttribute | N/A | Part of static platform support analysis. | 2.0.0 |
UnsupportedOSPlatformGuardAttribute | N/A | Part of static platform support analysis. | 2.0.0 |
ObsoletedInOSPlatformAttribute | N/A | Part of static platform support analysis. | 2.0.0 |
StringSyntaxAttribute | N/A | Provides a hint to IDEs to provide specific syntax highlighting for string parameters. | 2.1.0 |
required modifier | 11 | Enforces initialisation of properties with init during construction. |
2.2.0 |
SetsRequiredMembersAttribute | N/A | Marks constructor as setting all required properties. |
2.2.0 |
PureAttribute | N/A | Marks method as pure (no observable side-effects). | 2.3.0 |
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.3.0" />
To the following:
<PackageReference Include="BackwardsCompatibleFeatures" Version="2.3.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.3.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 | net30 is compatible. net40 is compatible. net403 was computed. net45 is compatible. 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 3.0
- No dependencies.
-
.NETFramework 4.0
- No dependencies.
-
.NETFramework 4.5
- 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,026 | 6/11/2023 |
2.2.0 | 276 | 5/15/2023 |
2.1.0 | 318 | 1/30/2023 |
2.0.0 | 358 | 8/6/2022 |
2.0.0-preview2 | 188 | 8/6/2022 |
2.0.0-preview1 | 197 | 8/6/2022 |