Compare commits

...

3 Commits

  1. 23
      KaitaiStream.cs
  2. 1
      LICENSE.txt
  3. 33
      Properties/AssemblyInfo.cs
  4. 6
      README.md
  5. 78
      kaitai_struct_runtime_csharp.csproj
  6. 20
      kaitai_struct_runtime_csharp.sln

23
KaitaiStream.cs

@ -2,7 +2,6 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Globalization;
namespace Kaitai
@ -615,7 +614,8 @@ namespace Kaitai
{
using (MemoryStream target = new MemoryStream())
{
ds.CopyTo(target);
byte[] buffer = new byte[32768];
CopyTo(target, ds);
return target.ToArray();
}
}
@ -708,5 +708,24 @@ namespace Kaitai
}
#endregion
#region Compatibility methods
/// <summary>
/// Replaces Stream.CopyTo from System.Linq for backwards compatibility.
/// </summary>
/// <param name="source">Stream to copy data from.</param>
/// <param name="destination">Stream to copy data to.</param>
private static void CopyTo(Stream source, Stream destination)
{
byte[] buffer = new byte[32768];
int read;
while ((read = source.Read(buffer, 0, buffer.Length)) > 0)
{
destination.Write(buffer, 0, read);
}
}
#endregion
}
}

1
LICENSE.txt

@ -1,4 +1,5 @@
Copyright 2015-2020 Kaitai Project: MIT license
Copyright 2021 Lucidiot
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

33
Properties/AssemblyInfo.cs

@ -0,0 +1,33 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("KaitaiStruct.Runtime.CSharp")]
[assembly: AssemblyDescription("This library implements Kaitai Struct API for C#.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Kaitai Project")]
[assembly: AssemblyProduct("Kaitai Struct Runtime")]
[assembly: AssemblyCopyright("Copyright © Kaitai Project 2016-2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("cfe65b45-60b5-47f7-85e1-392ef7753f8e")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
[assembly: AssemblyVersion("0.9.0.0")]
[assembly: AssemblyFileVersion("0.9.0.0")]

6
README.md

@ -1,9 +1,8 @@
# Kaitai Struct: runtime library for C# / .NET
[![NuGet version](https://img.shields.io/nuget/v/KaitaiStruct.Runtime.CSharp)](https://www.nuget.org/packages/KaitaiStruct.Runtime.CSharp/)
[![NuGet downloads](https://img.shields.io/nuget/dt/KaitaiStruct.Runtime.CSharp)](https://www.nuget.org/packages/KaitaiStruct.Runtime.CSharp/#:~:text=%20total%20downloads)
This library implements Kaitai Struct API for C#.
This fork downgrades the library to Visual Studio 2005 for compatibility
with .NET Framework 2.0.
Kaitai Struct is a declarative language used for describe various binary
data structures, laid out in files or in memory: i.e. binary file
@ -17,6 +16,7 @@ Further reading:
## Licensing
Copyright 2016-2020 Kaitai Project: MIT license
Copyright 2021 Lucidiot
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the

78
kaitai_struct_runtime_csharp.csproj

@ -1,36 +1,52 @@
<Project Sdk="Microsoft.NET.Sdk">
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<TargetFrameworks>netstandard1.3;net4.5</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>1701;1702;CS1591</NoWarn>
</PropertyGroup>
<PropertyGroup>
<PackageId>KaitaiStruct.Runtime.CSharp</PackageId>
<Authors />
<Company>Kaitai Project</Company>
<Description>This library implements Kaitai Struct API for C#.</Description>
<Product>Kaitai Struct Runtime</Product>
<Copyright>Copyright © Kaitai Project 2016-2020</Copyright>
<AssemblyName>Kaitai.Struct.Runtime</AssemblyName>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{230E538A-2C3E-47EA-B4A7-D938BA0B8A31}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Kaitai</RootNamespace>
<PackageProjectUrl>http://kaitai.io/</PackageProjectUrl>
<RepositoryUrl>https://github.com/kaitai-io/kaitai_struct_csharp_runtime</RepositoryUrl>
<PackageTags>Kaitai Struct File-Format Binary Protocols</PackageTags>
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
<PackageIcon>icon.png</PackageIcon>
<AssemblyVersion>0.9.0.0</AssemblyVersion>
<FileVersion>0.9.0.0</FileVersion>
<Version>0.9.0.0</Version>
<PackageReleaseNotes>Update to version 0.9</PackageReleaseNotes>
<AssemblyName>Kaitai.Struct.Runtime</AssemblyName>
<StartupObject>
</StartupObject>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>
</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\Kaitai.Struct.Runtime.xml</DocumentationFile>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<ItemGroup>
<Compile Include="KaitaiStream.cs" />
<Compile Include="KaitaiStruct.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="LICENSE.txt" Pack="true" PackagePath="" />
<None Include="icon.png" Pack="true" PackagePath="" />
<Reference Include="System" />
</ItemGroup>
</Project>
</Project>

20
kaitai_struct_runtime_csharp.sln

@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "kaitai_struct_runtime_csharp", "kaitai_struct_runtime_csharp.csproj", "{230E538A-2C3E-47EA-B4A7-D938BA0B8A31}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{230E538A-2C3E-47EA-B4A7-D938BA0B8A31}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{230E538A-2C3E-47EA-B4A7-D938BA0B8A31}.Debug|Any CPU.Build.0 = Debug|Any CPU
{230E538A-2C3E-47EA-B4A7-D938BA0B8A31}.Release|Any CPU.ActiveCfg = Release|Any CPU
{230E538A-2C3E-47EA-B4A7-D938BA0B8A31}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Loading…
Cancel
Save