zencq / libnom.io Goto Github PK
View Code? Open in Web Editor NEWA .NET class library to read and write save files from the game No Man's Sky for all possible platforms as well as related actions.
License: GNU General Public License v3.0
A .NET class library to read and write save files from the game No Man's Sky for all possible platforms as well as related actions.
License: GNU General Public License v3.0
IEnumerable<byte>
is super-slow. Span<byte>
is super-fast. Both allow you to access sub-sections of a byte array, but Span<byte>
is a much better tool for that. You can use spans in netstandard2.0 by taking a dependency on the System.Memory nuget package for that target platform.
For example, this...
var bytes = File.ReadAllBytes(path);
var headerInteger = bytes.Take(4).GetUInt32().FirstOrDefault();
var headerString = bytes.Take(8).GetString();
...would be a great deal faster and more memory-efficient if it were implemented like this:
// no array allocation/copying!
Span<byte> bytes = File.ReadAllBytes(path);
var headerInteger = MemoryMarshal.Cast<byte, uint>(bytes[..4])[0];
var headerString = Encoding.UTF8.GetString(bytes[..8]);
MemoryMarshal.Cast and the overload of UTF8.GetString that accepts a Span both do not exist in netstandard2.0, but they are so much better than IEnumerable that in my opinion it would be worth a little conditional compilation to take advantage of this. The netstandard2.0 version can use the current code, or it can use Spans from the System.Memory nuget package, and call the ToArray() method before passing things to older API's that accept arrays but not spans.
Apologies if this is a newbie error, I've not used .NET though I have programming experience with Python. My goal is to build and use the CLI on Mac (currently MacOS 14). However, I get the same error below on Windows too.
The DLL builds but I get the following errors when building libNOM.cli:
dotnet build
MSBuild version 17.9.8+b34f75857 for .NET
Determining projects to restore...
Restored /Users/dev/libNOM.io/libNOM.cli/libNOM.cli.csproj (in 404 ms).
1 of 2 projects are up-to-date for restore.
libNOM.io -> /Users/dev/libNOM.io/libNOM.io/bin/Debug/net8.0/libNOM.io.dll
/Users/dev/libNOM.io/libNOM.cli/Executor_FileOperation.cs(42,29): error CS0266: Cannot implicitly convert type 'System.Collections.Generic.IEnumerable<(libNOM.io.Interfaces.IContainer First, libNOM.io.Interfaces.IContainer Second)>' to 'System.Collections.Generic.IEnumerable<(libNOM.io.Container Source, libNOM.io.Container Destination)>'. An explicit conversion exists (are you missing a cast?) [/Users/dev/libNOM.io/libNOM.cli/libNOM.cli.csproj::TargetFramework=net8.0]
/Users/dev/libNOM.io/libNOM.cli/Executor_FileOperation.cs(62,24): error CS1503: Argument 1: cannot convert from 'System.Collections.Generic.IEnumerable<(libNOM.io.Container Source, libNOM.io.Container Destination)>' to 'System.Collections.Generic.IEnumerable<(libNOM.io.Interfaces.IContainer Source, libNOM.io.Interfaces.IContainer Destination)>' [/Users/dev/libNOM.io/libNOM.cli/libNOM.cli.csproj::TargetFramework=net8.0]
/Users/dev/libNOM.io/libNOM.cli/Executor_FileOperation.cs(87,24): error CS1503: Argument 1: cannot convert from 'System.Collections.Generic.IEnumerable<(libNOM.io.Container Source, libNOM.io.Container Destination)>' to 'System.Collections.Generic.IEnumerable<(libNOM.io.Interfaces.IContainer Source, libNOM.io.Interfaces.IContainer Destination)>' [/Users/dev/libNOM.io/libNOM.cli/libNOM.cli.csproj::TargetFramework=net8.0]
/Users/dev/libNOM.io/libNOM.cli/Executor_FileOperation.cs(98,24): error CS1503: Argument 1: cannot convert from 'System.Collections.Generic.IEnumerable<(libNOM.io.Container Source, libNOM.io.Container Destination)>' to 'System.Collections.Generic.IEnumerable<(libNOM.io.Interfaces.IContainer Source, libNOM.io.Interfaces.IContainer Destination)>' [/Users/dev/libNOM.io/libNOM.cli/libNOM.cli.csproj::TargetFramework=net8.0]
Build FAILED.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.