diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..b2d2273 --- /dev/null +++ b/.github/dependabot.yml @@ -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: + - "*" diff --git a/.github/workflows/dotnet-test.yml b/.github/workflows/dotnet-test.yml index 3fe3d3e..919513e 100644 --- a/.github/workflows/dotnet-test.yml +++ b/.github/workflows/dotnet-test.yml @@ -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 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index cc5fb53..e3f922d 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -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 diff --git a/Library/Library.csproj b/Library/Library.csproj index d61c993..09427be 100644 --- a/Library/Library.csproj +++ b/Library/Library.csproj @@ -1,7 +1,7 @@ - net7.0 + net7.0;net8.0 enable enable DaanV2.NBT.Net diff --git a/Library/Serialization/Classes/DeserializationException/DeserializationException.cs b/Library/Serialization/Classes/DeserializationException/DeserializationException.cs index e567a67..1d77661 100644 --- a/Library/Serialization/Classes/DeserializationException/DeserializationException.cs +++ b/Library/Serialization/Classes/DeserializationException/DeserializationException.cs @@ -1,10 +1,19 @@ namespace DaanV2.NBT.Serialization; +/// A exception that is thrown when a nbt file is not valid public partial class DeserializationException : Exception { + /// The name of the obejct that caused this public String? Name { get; set; } + /// The type of the object public NBTTagType Type { get; set; } + /// The position in stream / file public Int64 Position { get; set; } + /// Creates a new instance of + /// + /// + /// + /// public DeserializationException(String? name, NBTTagType type, Int64 position, Exception innerException) : base(Message(name, type, position), innerException) { this.Name = name; @@ -12,6 +21,11 @@ public DeserializationException(String? name, NBTTagType type, Int64 position, E this.Position = position; } + /// Creates a message for the given position and type + /// The name of the object + /// The type of the object + /// The position in stream / file + /// A formatted string public static String Message(String? name, NBTTagType type, Int64 position) { String b = $"Error reading nbt at byte offset: {position}"; diff --git a/Library/Static Classes/NBT Tag Factory/NBT Tag Factory - Create - List.cs b/Library/Static Classes/NBT Tag Factory/NBT Tag Factory - Create - List.cs index 8cf1bb1..1568d04 100644 --- a/Library/Static Classes/NBT Tag Factory/NBT Tag Factory - Create - List.cs +++ b/Library/Static Classes/NBT Tag Factory/NBT Tag Factory - Create - List.cs @@ -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); } /// Transfers a list of items into a tag as sub tag intems diff --git a/Library/Static Classes/NBT Tag Factory/NBT Tag Factory - Create.cs b/Library/Static Classes/NBT Tag Factory/NBT Tag Factory - Create.cs index cf86c47..d63a2a2 100644 --- a/Library/Static Classes/NBT Tag Factory/NBT Tag Factory - Create.cs +++ b/Library/Static Classes/NBT Tag Factory/NBT Tag Factory - Create.cs @@ -5,10 +5,12 @@ public static partial class NBTTagFactory { /// Creates a tag with the specified tag type /// The tag type /// Creates a tag with the specified tag type - 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; } /// Creates a tag with the specified information /// The tag type diff --git a/Tests/Classes/FuzzyTest/FuzzyTest - Create.cs b/Tests/Classes/FuzzyTest/FuzzyTest - Create.cs index 32e6d1c..a2b6724 100644 --- a/Tests/Classes/FuzzyTest/FuzzyTest - Create.cs +++ b/Tests/Classes/FuzzyTest/FuzzyTest - Create.cs @@ -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 diff --git a/Tests/Classes/FuzzyTest/FuzzyTest.cs b/Tests/Classes/FuzzyTest/FuzzyTest.cs index 1fd4320..15fead1 100644 --- a/Tests/Classes/FuzzyTest/FuzzyTest.cs +++ b/Tests/Classes/FuzzyTest/FuzzyTest.cs @@ -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(); diff --git a/Tests/UnitTest.csproj b/Tests/UnitTest.csproj index f03916d..3f12d31 100644 --- a/Tests/UnitTest.csproj +++ b/Tests/UnitTest.csproj @@ -1,7 +1,7 @@ - net7.0 + net7.0;net8.0 DaanV2.NBT.Test false