ironfede / openmcdf

Microsoft Compound File .net component - pure C# - netstandard 2.0
Mozilla Public License 2.0
309 stars 76 forks source link

Add support for Span #57

Open kucint opened 5 years ago

kucint commented 5 years ago

Hi, CFStream would profit very much if it would support Span. this would let to avoid unnecessary serializing of (some) objects to byte[] array.

I suggest adding following methods to CFStream:

CFStream.Append(ReadOnlySpan<byte> data);
CFStream.SetData(ReadOnlySpan<byte> data);
CFStream.Write(ReadOnlySpan<byte> data, int position);

Best!

Numpsy commented 6 months ago

@ironfede A question on TFMs in the core library (similar to #123) -

As it stands, the core library targets .NET Framework 4,0 and .NET Standard 2.0, neither of which has the Span types built in. There is the System.Memory NuGet package which adds the types, but that only supports .NET Framework 4.5+, not 4.0.

So - I think that in order to support this, either the core library needs to target newer TFMs, or new functions would need to be conditionally compiled.

Also, I think it would be useful to add a target for .NET 6.0 or .NET Standard 2.1 such that users of those get the built in span types without having to reference the extra NuGet packages.

Any preferences in case I get time to look at this properly?