Skip to content

Commit

Permalink
Adding more frameworks
Browse files Browse the repository at this point in the history
  • Loading branch information
DaanV2 committed Dec 24, 2023
1 parent d64589f commit 0c958ef
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 14 deletions.
23 changes: 23 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "nuget" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "monthly"
groups:
all:
patterns:
- "*"
- package-ecosystem: "github-actions" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "monthly"
groups:
all:
patterns:
- "*"
4 changes: 3 additions & 1 deletion .github/workflows/dotnet-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ jobs:
- name: 🛠️ Setup .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: 7.0.x
dotnet-version: |
7.0.x
8.0.x
- name: 📥 Restore dependencies
run: dotnet restore --verbosity normal
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ jobs:
- name: 🛠️ Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
dotnet-version: |
7.0.x
8.0.x
source-url: https://nuget.pkg.github.com/DaanV2/index.json

- name: 📥 Restore dependencies
Expand Down
2 changes: 1 addition & 1 deletion Library/Library.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFrameworks>net7.0;net8.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AssemblyName>DaanV2.NBT.Net</AssemblyName>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
namespace DaanV2.NBT.Serialization;

/// <summary>A exception that is thrown when a nbt file is not valid</summary>
public partial class DeserializationException : Exception {
/// <summary>The name of the obejct that caused this</summary>
public String? Name { get; set; }
/// <summary>The type of the object</summary>
public NBTTagType Type { get; set; }
/// <summary>The position in stream / file</summary>
public Int64 Position { get; set; }

/// <summary>Creates a new instance of <see cref="DeserializationException"/></summary>
/// <param name="name"></param>
/// <param name="type"></param>
/// <param name="position"></param>
/// <param name="innerException"></param>
public DeserializationException(String? name, NBTTagType type, Int64 position, Exception innerException)
: base(Message(name, type, position), innerException) {
this.Name = name;
this.Type = type;
this.Position = position;
}

/// <summary>Creates a message for the given position and type</summary>
/// <param name="name">The name of the object</param>
/// <param name="type">The type of the object</param>
/// <param name="position">The position in stream / file</param>
/// <returns>A formatted string</returns>
public static String Message(String? name, NBTTagType type, Int64 position) {
String b = $"Error reading nbt at byte offset: {position}";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ private static (ITag List, Type SubType) CreateList(String Name, NBTTagType SubT
ITag Out = NBTTagFactory.Create(NBTTagType.List);
Out.Name = Name;
Out.SetInformation(NBTTagInformation.ListSubtype, SubType);
Type TagType = NBTTagFactory.Types.ContainsKey(SubType) ? Types[SubType] : null;

return (Out, TagType);
if (NBTTagFactory.Types.TryGetValue(SubType, out Type? TagType) == true) {
return (Out, TagType);
}

return (Out, null);
}

/// <summary>Transfers a list of items into a tag as sub tag intems</summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ public static partial class NBTTagFactory {
/// <summary>Creates a tag with the specified tag type</summary>
/// <param name="type">The tag type</param>
/// <returns>Creates a tag with the specified tag type</returns>
public static ITag Create(NBTTagType type) {
return NBTTagFactory.Types.ContainsKey(type) ?
(ITag)Activator.CreateInstance(Types[type]) :
null;
public static ITag? Create(NBTTagType type) {
if (Types.TryGetValue(type, out Type? value)) {
return Activator.CreateInstance(value) as ITag;
}

return null;
}
/// <summary>Creates a tag with the specified information</summary>
/// <param name="type">The tag type</param>
Expand Down
4 changes: 1 addition & 3 deletions Tests/Classes/FuzzyTest/FuzzyTest - Create.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ namespace DaanV2.NBT.Test;

public partial class NBTFuzzyTest {



public NBTTagCompound Create(Random R) {
public static NBTTagCompound Create(Random R) {
var compound = new CompoundBuilder("root");

//Boolean
Expand Down
2 changes: 1 addition & 1 deletion Tests/Classes/FuzzyTest/FuzzyTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public partial class NBTFuzzyTest {
[DataRow(1339913606, NBTCompression.Zlib, Endian.Little)]
public void FuzzyTest(Int32 Seed, NBTCompression compression, Endian endian) {
var R = new Random(Seed);
NBTTagCompound data = this.Create(R);
NBTTagCompound data = NBTFuzzyTest.Create(R);

//Serialize
var stream = new MemoryStream();
Expand Down
2 changes: 1 addition & 1 deletion Tests/UnitTest.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFrameworks>net7.0;net8.0</TargetFrameworks>
<RootNamespace>DaanV2.NBT.Test</RootNamespace>

<IsPackable>false</IsPackable>
Expand Down

0 comments on commit 0c958ef

Please sign in to comment.