Browse Source

docs: Add Extensibility section and C# Libraries guide

- Updated `toc.yml` to include a new "Extensibility" section with a link to `extensibility/index.md`.
- Added a sub-item "C# Libraries" under the new "Extensibility" section, linking to `extensibility/csharp-libraries.md`.
- Created `csharp-libraries.md` to provide information on creating and using C# libraries within a Stride project, including details on adding a module initializer and re-compiling NuGet packages.
- Created `index.md` under the `extensibility` directory to introduce the concept of extending a Stride game project with a regular C# library and link to the detailed guide in `csharp-libraries.md`.
Vaclav Elias 1 year ago
parent
commit
666498d4ba
3 changed files with 40 additions and 0 deletions
  1. 27 0
      en/manual/extensibility/csharp-libraries.md
  2. 7 0
      en/manual/extensibility/index.md
  3. 6 0
      en/manual/toc.yml

+ 27 - 0
en/manual/extensibility/csharp-libraries.md

@@ -0,0 +1,27 @@
+# C# Libraries
+
+<span class="badge text-bg-primary">Advanced</span>
+<span class="badge text-bg-success">Programmer</span>
+
+If you want to share code between multiple projects, or create reusable components, you can create a C# library and reference it in your Stride project.
+
+If your library is utilising @Stride.Core.DataContractAttribute, you need to follow additional steps to make it work with Stride.
+
+1. Add a Module initializer to your library. This will register your library with Stride's serialization system. Example `Module.cs`:
+
+    ```csharp
+    using Stride.Core.Reflection;
+    using System.Reflection;
+
+    namespace MyProjectName;
+
+    internal class Module
+    {
+        [ModuleInitializer]
+        public static void Initialize()
+        {
+            AssemblyRegistry.Register(typeof(Module).GetTypeInfo().Assembly, AssemblyCommonCategories.Assets);
+        }
+    }
+    ```
+1. If you are creating also NuGet packages for your library, these NuGet packages have to be re-compiled with latest version of Stride NuGet packages. 

+ 7 - 0
en/manual/extensibility/index.md

@@ -0,0 +1,7 @@
+# Extensibility
+
+## Introduction
+
+Stride game project is a regular .NET project, and as such, it can be extended by a regular C# library. This is a great way to share code between multiple projects, or to create reusable components.
+
+Read more about this subject in [C# Libraries](extensibility/csharp-libraries.md).

+ 6 - 0
en/manual/toc.yml

@@ -561,6 +561,12 @@ items:
       - name: Create Packages
         href: nuget/create-packages.md
 
+  - name: Extensibility
+    href: extensibility/index.md
+    items:
+      - name: C# Libraries
+        href: extensibility/csharp-libraries.md
+
   - name: Troubleshooting
     href: troubleshooting/index.md
     items: