StringBuilder icon indicating copy to clipboard operation
StringBuilder copied to clipboard

Target older .NET verisons

Open AnakinRaW opened this issue 1 year ago • 6 comments

Hey, are there plans to release this package for older .NET versions, namely netstandard2.0?

Regards

AnakinRaW avatar Jan 02 '25 20:01 AnakinRaW

Hey @AnakinRaW

netstandard2.0 doesn't directly support ReadOnlySpan<T> and friends (ISpanFormattable), which would greatly reduce the library's value. Many functions wouldn't be available or wouldn't have the same benefit as they have with net6.0 and beyond.

EDIT: Even netstandard2.1 doesn't know some of the types.

linkdotnet avatar Jan 02 '25 21:01 linkdotnet

Just to clarify: I am interested in backporting this onto older .net versions, but the benefit might be neglectable (in comparison to System.Text.StringBuilder).

linkdotnet avatar Jan 02 '25 21:01 linkdotnet

in some projects i already copied parts of the .NET's value string builder with positive, or at least not negative effects for netstandard2.0. Sure you need to add a few more .AsSpan() there but allocs and perf still benefit from it.

A backport to older versions for me means having it far more easier writing code for all my target platforms. In other words: As long as a backport on netstandard2.0 is fully functional, even with perf "as bad as " System.Text.StringBuilder , i personally would take it.

But i'd understand if you don't want to add that maintenance effort for this package.

AnakinRaW avatar Jan 02 '25 22:01 AnakinRaW

I tried to support netstandard2.0 - most fixes are done via the System.Memory package that backports System.Span and friends. Some other fixes are done via #ifdef !NETSTANDARD2_0. If it would be only for this, I would go a head and support netstandard2.0. But: There is no support for ISpanFormattable in netstandard2.0 (also not in netstandard2.1), which would duplicate much of the code as some of the logic internally relies on those types. For the netstandard2.0 support I would have to write netstandard2.0 specific versions. I would like to avoid this as much as possible.

I will leave it open for now, because there might be something obvious I am missing.

linkdotnet avatar Jan 03 '25 09:01 linkdotnet

other than disabling some public APIs with #if directives for unsupported targets, i do not know anything more clever.

AnakinRaW avatar Jan 03 '25 10:01 AnakinRaW

I'd say don't backport it if these APIs are not supported. .NET Standard 2.0 is 8 years old and now only exists to support .NET Framework. If you're still using .NET Framework you definitely don't care about performance. >_< For multi-targeting libraries that depend on ValueStringBuilder they can always use conditional compilation.

Joy-less avatar May 03 '25 13:05 Joy-less