-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #354 from stride3d/master
Deploy latest documentation updates to staging
- Loading branch information
Showing
9 changed files
with
111 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# 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 uses the @Stride.Core.DataContractAttribute and you want to reference it through a **NuGet** package, there are additional steps required to make it compatible with Stride. | ||
|
||
## Adding a Module Initializer | ||
|
||
First, add a module initializer to your library. This ensures your library is properly registered 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); | ||
} | ||
} | ||
``` | ||
|
||
## Updating to the Latest Stride NuGet Packages | ||
|
||
If your library references any Stride NuGet packages, you must recompile it with the latest version of those packages. This ensures compatibility with the current Stride ecosystem. | ||
|
||
## About the Module Initializer Attribute | ||
|
||
The `ModuleInitializer` attribute is now generated using a Roslyn source generator. This means the file `sources/core/Stride.Core.CompilerServices/Generators/ModuleInitializerGenerator.cs` must run during your code's compilation. Otherwise, the module initializer and potentially other source generators added in the future will not function correctly. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.