Skip to content

Commit

Permalink
fix netcore DecodeArray from stream
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanmaierhofer committed Oct 15, 2022
1 parent d258144 commit 9a1f3cb
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
3 changes: 3 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### 0.3.6
- netcore: fixed DecodeArray from stream

### 0.3.5
- clean up recently added defs

Expand Down
30 changes: 30 additions & 0 deletions src/Aardvark.Data.Durable.Codec/Aardvark.Data.Durable.Codec.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,36 @@
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|netstandard2.0|AnyCPU'">
<DebugType>embedded</DebugType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|netstandard2.0|AnyCPU'">
<DebugType>embedded</DebugType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|netcoreapp3.1|AnyCPU'">
<DebugType>embedded</DebugType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|netcoreapp3.1|AnyCPU'">
<DebugType>embedded</DebugType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net5.0|AnyCPU'">
<DebugType>embedded</DebugType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net5.0|AnyCPU'">
<DebugType>embedded</DebugType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net6.0|AnyCPU'">
<DebugType>embedded</DebugType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net6.0|AnyCPU'">
<DebugType>embedded</DebugType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net472|AnyCPU'">
<DebugType>embedded</DebugType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net472|AnyCPU'">
<DebugType>embedded</DebugType>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Aardvark.Data.Durable\Aardvark.Data.Durable.csproj" />
</ItemGroup>
Expand Down
12 changes: 10 additions & 2 deletions src/Aardvark.Data.Durable.Codec/CodecNetCoreApp31.cs
Original file line number Diff line number Diff line change
Expand Up @@ -661,12 +661,20 @@ static void SkipToNextMultipleOf(Stream s, int numberOfBytes)
};


private static unsafe T[] DecodeArray<T>(Stream s) where T : struct
private static T[] DecodeArray<T>(Stream s) where T : struct
{
var count = s.Read<int>();
var xs = new T[count];
var p = MemoryMarshal.Cast<T, byte>(xs.AsSpan());
if (s.Read(p) != p.Length) throw new Exception("Invariant 24838184-9d56-4c1f-a626-ba006641ef94.");
var totalbytes = p.Length;
var n = 0;
while (n < totalbytes)
{
var byteCount = s.Read(p);
n += byteCount;
p = p[byteCount..];
}
if (n != totalbytes) throw new Exception("Invariant 24838184-9d56-4c1f-a626-ba006641ef94.");
return xs;
}

Expand Down

0 comments on commit 9a1f3cb

Please sign in to comment.