Any possibility of .NET 4.6.2 support?
Closed this issue · 4 comments
Hi! I'm interested in using Fluent in a plugin for Playnite. Playnite currently requires .NET 4.6, and although there are plans to update to .NET 6+ in the future, there's no concrete timeline yet.
Would it be feasible to support .NET 4.6.2 in Linguini? I tried setting <TargetFrameworks>net4.6.2;netstandard2.1</TargetFrameworks>
in Linguini.Shared to see what would happen, and it looks like it's relying on a few newer features:
NotNullWhen
NotNullWhenAttribute
ReadOnlySpan
ReadOnlyMemory
There's also this:
C:\tmp\Linguini\Linguini.Shared\Types\Bundle\IFluentType.cs(18,14): error CS8701: Target runtime doesn't support default interface implementation. [C:\tmp\Linguini\Linguini.Shared\Linguini.Shared.csproj]
C:\tmp\Linguini\Linguini.Shared\Types\Bundle\IFluentType.cs(32,14): error CS8701: Target runtime doesn't support default interface implementation. [C:\tmp\Linguini\Linguini.Shared\Linguini.Shared.csproj]
If this is something you're open to considering, I'd be happy to try to help (although .NET isn't my specialty).
Hi @mtkennerly. Looking at that list of features NotNullWhen
and NotNullWhenAttribute
are nice to haves but not a big deal. That said, I have no idea how you could put it on net4.6
without ReadOnlySpan
and ReadOnlyMemory
those are crucial pieces of the parser and would be very hard to get it working without that.
As for default interfaces those can be fixed. Is there a lib that can emulate ReadOnlySpan
on net4.6
?
Microsoft has some standalone packages that look like they could work:
- https://www.nuget.org/packages/System.Memory/
- supports
net461
- says it provides
System.ReadOnlySpan
andSystem.ReadOnlyMemory
- supports
- https://www.nuget.org/packages/System.Diagnostics.Tools/
- supports
net45
- says it provides
System.Diagnostics.CodeAnalysis.SuppressMessageAttribute
, so it might have the NotNull* ones in that namespace as well, but I'm not sure
- supports
I got Linguini.Shared working with these dependencies and some minor code changes:
<PackageReference Include="IndexRange" Version="1.0.2" />
<PackageReference Include="Nullable" Version="1.3.0" />
<PackageReference Include="System.Memory" Version="4.5.4" />
<PackageReference Include="TA.System.Runtime.CompilerServices.RuntimeHelpers.GetSubArray" Version="1.0.1" />
I'm working through the errors from the other projects now. I'll report back on how it goes and/or open a PR if I get it working.
@mtkennerly There are some specifically polyfill libraries for that purposes:
https://github.com/Sergio0694/PolySharp
https://github.com/SimonCropp/Polyfill
https://github.com/Tyrrrz/PolyShim