Explorar o código

Code tidy.
Added preview packages to Github package registry.

Vicente Penades %!s(int64=6) %!d(string=hai) anos
pai
achega
5763b329dd

+ 1 - 1
src/SharpGLTF.Core/Schema2/glb.cs → src/SharpGLTF.Core/IO/BinarySerialization.cs

@@ -7,7 +7,7 @@ namespace SharpGLTF.Schema2
 {
     using ROOT = ModelRoot;
 
-    static class glb
+    static class BinarySerialization
     {
         #region constants
 

+ 9 - 9
src/SharpGLTF.Core/IO/ReadContext.cs

@@ -106,13 +106,13 @@ namespace SharpGLTF.IO
         {
             Guard.NotNull(stream, nameof(stream));
 
-            bool binaryFile = glb._Identify(stream);
+            bool binaryFile = BinarySerialization._Identify(stream);
 
             if (binaryFile)
             {
-                var chunks = glb.ReadBinaryFile(stream);
+                var chunks = BinarySerialization.ReadBinaryFile(stream);
 
-                return Encoding.UTF8.GetString(chunks[glb.CHUNKJSON]);
+                return Encoding.UTF8.GetString(chunks[BinarySerialization.CHUNKJSON]);
             }
 
             using (var streamReader = new StreamReader(stream))
@@ -130,7 +130,7 @@ namespace SharpGLTF.IO
         {
             Guard.NotNull(stream, nameof(stream));
 
-            bool binaryFile = glb._Identify(stream);
+            bool binaryFile = BinarySerialization._Identify(stream);
 
             return binaryFile ? ReadBinarySchema2(stream) : ReadTextSchema2(stream);
         }
@@ -188,7 +188,7 @@ namespace SharpGLTF.IO
         {
             using (var stream = File.OpenRead(filePath))
             {
-                bool isBinary = glb._Identify(stream);
+                bool isBinary = BinarySerialization._Identify(stream);
 
                 if (isBinary) return _ReadGLB(stream).Validation;
 
@@ -226,16 +226,16 @@ namespace SharpGLTF.IO
         {
             Guard.NotNull(stream, nameof(stream));
 
-            var chunks = glb.ReadBinaryFile(stream);
+            var chunks = BinarySerialization.ReadBinaryFile(stream);
 
-            var dom = Encoding.UTF8.GetString(chunks[glb.CHUNKJSON]);
+            var dom = Encoding.UTF8.GetString(chunks[BinarySerialization.CHUNKJSON]);
 
             var context = this;
 
-            if (chunks.ContainsKey(glb.CHUNKBIN))
+            if (chunks.ContainsKey(BinarySerialization.CHUNKBIN))
             {
                 context = new ReadContext(context); // clone instance
-                context._BinaryChunk = chunks[glb.CHUNKBIN];
+                context._BinaryChunk = chunks[BinarySerialization.CHUNKBIN];
             }
 
             return context._ParseGLTF(dom);

+ 2 - 2
src/SharpGLTF.Core/IO/WriteContext.cs

@@ -181,7 +181,7 @@ namespace SharpGLTF.IO
             model = this._PreprocessSchema2(model, this.ImageWriting == ResourceWriteMode.BufferView, true);
             Guard.NotNull(model, nameof(model));
 
-            var ex = glb.IsBinaryCompatible(model);
+            var ex = BinarySerialization.IsBinaryCompatible(model);
             if (ex != null) throw ex;
 
             model._PrepareBuffersForInternalWriting();
@@ -192,7 +192,7 @@ namespace SharpGLTF.IO
             {
                 using (var w = new BinaryWriter(m))
                 {
-                    glb.WriteBinaryModel(w, model);
+                    BinarySerialization.WriteBinaryModel(w, model);
                 }
 
                 WriteAllBytesToEnd($"{baseName}.glb", m.ToArraySegment());

+ 1 - 3
src/SharpGLTF.Core/Schema2/gltf.Buffer.cs

@@ -172,13 +172,11 @@ namespace SharpGLTF.Schema2
         }
 
         /// <summary>
-        /// Merges all the <see cref="ModelRoot.LogicalBuffers"/> instances into a single, big one.
+        /// Merges all the <see cref="ModelRoot.LogicalBuffers"/> instances into a single big one.
         /// </summary>
         /// <remarks>
         /// When merging the buffers, it also adjusts the BufferView offsets so the data they point to remains the same.
-        ///
         /// If images are required to be included in the binary, call <see cref="ModelRoot.MergeImages"/> before calling <see cref="MergeBuffers"/>
-        ///
         /// This action cannot be reversed.
         /// </remarks>
         public void MergeBuffers()

+ 1 - 1
src/SharpGLTF.Core/Schema2/gltf.BufferView.cs

@@ -300,7 +300,7 @@ namespace SharpGLTF.Schema2
         /// <param name="byteStride">For strided vertex buffers, it must be a value multiple of 4, 0 otherwise</param>
         /// <param name="target">The type hardware device buffer, or null</param>
         /// <returns>A <see cref="BufferView"/> instance.</returns>
-        public BufferView UseBufferView(ArraySegment<Byte> data, int byteStride = 0, BufferMode? target = null)
+        public BufferView UseBufferView(BYTES data, int byteStride = 0, BufferMode? target = null)
         {
             Guard.NotNull(data.Array, nameof(data));
             return UseBufferView(data.Array, data.Offset, data.Count, byteStride, target);

+ 1 - 1
src/SharpGLTF.Core/Schema2/gltf.Camera.cs

@@ -243,7 +243,7 @@ namespace SharpGLTF.Schema2
     {
         /// <summary>
         /// Creates a new <see cref="Camera"/> instance.
-        /// and adds it to <see cref="ModelRoot.LogicalCameras"/>.
+        /// and appends it to <see cref="ModelRoot.LogicalCameras"/>.
         /// </summary>
         /// <param name="name">The name of the instance.</param>
         /// <returns>A <see cref="Camera"/> instance.</returns>

+ 1 - 1
src/SharpGLTF.Core/Schema2/gltf.Images.cs

@@ -383,7 +383,7 @@ namespace SharpGLTF.Schema2
     {
         /// <summary>
         /// Creates a new <see cref="Image"/> instance.
-        /// and adds it to <see cref="ModelRoot.LogicalImages"/>.
+        /// and appends it to <see cref="ModelRoot.LogicalImages"/>.
         /// </summary>
         /// <param name="name">The name of the instance.</param>
         /// <returns>A <see cref="Image"/> instance.</returns>

+ 18 - 0
src/SharpGLTF.Core/Schema2/gltf.Material.cs

@@ -96,4 +96,22 @@ namespace SharpGLTF.Schema2
 
         #endregion
     }
+
+    public partial class ModelRoot
+    {
+        /// <summary>
+        /// Creates a new <see cref="Material"/> instance and appends it to <see cref="ModelRoot.LogicalMaterials"/>.
+        /// </summary>
+        /// <param name="name">The name of the instance.</param>
+        /// <returns>A <see cref="Material"/> instance.</returns>
+        public Material CreateMaterial(string name = null)
+        {
+            var mat = new Material();
+            mat.Name = name;
+
+            _materials.Add(mat);
+
+            return mat;
+        }
+    }
 }

+ 0 - 18
src/SharpGLTF.Core/Schema2/gltf.MaterialsFactory.cs

@@ -121,24 +121,6 @@ namespace SharpGLTF.Schema2
         #endregion
     }
 
-    public partial class ModelRoot
-    {
-        /// <summary>
-        /// Creates a new <see cref="Material"/> instance and adds it to <see cref="ModelRoot.LogicalMaterials"/>.
-        /// </summary>
-        /// <param name="name">The name of the instance.</param>
-        /// <returns>A <see cref="Material"/> instance.</returns>
-        public Material CreateMaterial(string name = null)
-        {
-            var mat = new Material();
-            mat.Name = name;
-
-            _materials.Add(mat);
-
-            return mat;
-        }
-    }
-
     internal sealed partial class MaterialPBRMetallicRoughness
     {
         protected override IEnumerable<ExtraProperties> GetLogicalChildren()

+ 1 - 1
src/SharpGLTF.Core/Schema2/gltf.Mesh.cs

@@ -124,7 +124,7 @@ namespace SharpGLTF.Schema2
     {
         /// <summary>
         /// Creates a new <see cref="Mesh"/> instance
-        /// and adds it to <see cref="ModelRoot.LogicalMeshes"/>.
+        /// and appends it to <see cref="ModelRoot.LogicalMeshes"/>.
         /// </summary>
         /// <param name="name">The name of the instance.</param>
         /// <returns>A <see cref="Mesh"/> instance.</returns>

+ 3 - 0
src/build-preview.cmd

@@ -34,4 +34,7 @@ dotnet build -c:Release --version-suffix %VERSIONSUFFIX% SharpGLTF.Toolkit\Sharp
 rem dotnet nuget push "SharpGLTF.Core/bin/Release/SharpGLTF.Core.1.0.0-%VERSIONSUFFIX%.nupkg" --source "github"
 rem dotnet nuget push "SharpGLTF.Toolkit/bin/Release/SharpGLTF.Toolkit.1.0.0-%VERSIONSUFFIX%.nupkg" --source "github"
 
+nuget push "SharpGLTF.Core/bin/Release/SharpGLTF.Core.1.0.0-%VERSIONSUFFIX%.nupkg" -src "github"
+nuget push "SharpGLTF.Toolkit/bin/Release/SharpGLTF.Toolkit.1.0.0-%VERSIONSUFFIX%.nupkg" -src "github"
+
 pause

BIN=BIN
src/nuget.exe


+ 4 - 1
tests/SharpGLTF.Tests/SharpGLTF.Tests.csproj

@@ -22,7 +22,10 @@
 
   <ItemGroup>    
     <PackageReference Include="nunit" Version="3.12.0" />
-    <PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
+    <PackageReference Include="NUnit3TestAdapter" Version="3.16.0">
+      <PrivateAssets>all</PrivateAssets>
+      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
+    </PackageReference>
     <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
     <PackageReference Include="PLplot" Version="5.13.7" />    
   </ItemGroup>