Possible Issues and Solutions¶
This page lists possible issues and solutions for common errors that can occur when using the Beam SDK and how to fix them.
Multiple Microservice Classes Detected¶
Explanation:
Only one Microservice class should exist per microservice project. Multiple classes marked with the [Microservice] attribute will cause conflicts in code generation and runtime behavior.
Example Code Triggering the Error:
1 2 3 4 5 | |
Example Error Message:
1 | |
Solutions:
- Ensure only one class is marked as a Microservice in your project.
Example of Solved Code:
1 2 | |
Non-Partial Microservice Class Detected¶
Explanation:
Microservice classes must be marked as partial to allow code generation tools to extend them.
Example Code Triggering the Error:
1 2 | |
Example Error Message:
1 | |
Solutions:
- Add the partial modifier to the class.
Example of Solved Code:
1 2 | |
Microservice Class Missing Microservice Id¶
Explanation:
The Microservice class must include the [Microservice("Id")] attribute to define its identifier.
Example Code Triggering the Error:
1 | |
Example Error Message:
1 | |
Solutions:
- Add the [Microservice("Id")] attribute to the class.
Example of Solved Code:
1 2 | |
Async Void Callable Methods¶
Explanation:
Methods marked as [Callable], [ClientCallable], [ServerCallable] should not be async void. Using async void makes it impossible to track errors or await completion.
Example Code Triggering the Error:
1 2 3 4 5 6 | |
Example Error Message:
1 | |
Solutions:
- Change the return type to Task.
Example of Solved Code:
1 2 3 4 5 6 | |
Invalid Type Usage in Callable Method¶
Explanation:
Types used in [ClientCallable] methods must be available to both server and client. Declaring types inside the microservice class makes them inaccessible to the Unity client as we're not regenerating DTO for Client.
Example Code Triggering the Error:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | |
Example Error Message:
1 | |
Solutions: - Move shared types (DTOs, Enums, etc.) to a shared project referenced by both Unity and the server.
Example of Solved Code (Microservice):
1 2 3 4 5 6 7 8 9 | |
Shared Project Code:
1 2 3 4 | |
Callable Method Types usage are Nested¶
Explanation:
Types used in [ClientCallable] methods must be declared in outer scope so the Source Code Generator can handle it properly.
Example Code Triggering the Error:
1 2 3 4 5 6 7 8 9 10 11 | |
Example Error Message:
1 | |
Solutions:
- Move named types used by Callable methods to a non-nested scope.
Example of Solved Code:
1 2 3 4 5 6 7 8 9 10 11 | |
Beam Generated Schema Class is a Nested Type¶
Explanation:
Classes that uses the attribute [BeamGenerateSchema] cannot be declared as nested type because the Source Generator Cannot handle it.
Example Code Triggering the Error:
1 2 3 4 5 6 7 8 9 | |
Example Error Message:
1 | |
Solutions:
- Move classes that contains [BeamGenerateSchema] attribute to a non-nested scope.
Example of Solved Code:
1 2 3 4 5 6 7 8 | |
Invalid Microservice ID¶
Explanation:
Microservices IDs must match the <BeamID> property on csproj. If there is none <BeamID> property it needs to match the project's name.
Example Code Triggering the Error:
1 2 | |
Example CSProj Triggering the Error:
1 2 3 4 5 6 7 8 9 | |
Example Error Message:
1 | |
Solutions:
- Switch Microservice attribute parameter to use the same value as <BeamId>
Example of Solved Code:
1 2 3 4 5 6 7 8 | |
<BeamId> property to match the Microservice attribute value
Example of Solved CSProj:
1 2 3 4 5 6 7 8 9 | |
Static Field in Microservice¶
Explanation:
Non-readonly static fields in Microservices are discouraged because they do not behave reliably in horizontally scaled environments. Their state is not shared across instances.
Example Code Triggering the Warning:
1 2 3 4 | |
Example Warning Message:
1 | |
Solutions:
- Make the static field readonly if it's intended to be constant after initialization.
Example of Solved Code:
1 2 3 4 | |
Missing Serializable Attribute on Type¶
Explanation:
All types used in Microservice method signatures or marked with [BeamGenerateSchema] must be annotated with [Serializable] to ensure correct serialization and code generation.
Examples Code Triggering the Error:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | |
Example Error Messages:
1 | |
1 | |
Solution:
- Add the [Serializable] attribute.
Example of Solved Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | |
Property Found in Serializable Type¶
Explanation:
Properties in types used in Microservice method signatures or marked with [BeamGenerateSchema] are ignored by the client code generator. Fields should be used instead.
Example Code Triggering the Warning:
1 2 3 4 5 | |
Example Warning Message:
1 | |
Solution: - Use fields instead of properties. Example of Solved Code:
1 2 3 4 5 | |
Nullable Field in Serializable Type¶
Explanation:
Fields with nullable types (e.g., int?, string?) are not supported in types used in Microservice method signatures or marked with [BeamGenerateSchema]. Use Optional<T> instead to ensure predictable behavior.
Example Code Triggering the Error:
1 2 3 4 5 | |
Example Error Message:
1 | |
Solution:
- Use Optional<T> instead of nullable types.
Example of Solved Code:
1 2 3 4 5 | |
Invalid ContentObject Used¶
Explanation:
Using ContentObject or its subtypes directly in serializable fields or parameters is discouraged, as it may lead to large data payloads. Instead, prefer using ContentRef<T> to reference content objects efficiently.
Example Code Triggering the Error:
1 2 3 4 5 6 7 | |
Example Error Message:
1 | |
Solution:
- Replace the direct
ContentObjectusage withContentRef<T>.
Example of Solved Code:
1 2 3 4 5 6 7 | |
Type Used in BeamGenerateSchema is Missing Attribute¶
Explanation:
When a class is marked with [BeamGenerateSchema], all custom types used in its fields must also be annotated with [BeamGenerateSchema].
Example Code Triggering the Error:
1 2 3 4 5 6 7 8 9 | |
Example Error Message:
1 | |
Solution:
- Add [BeamGenerateSchema] to all nested field types.
Example of Solved Code:
1 2 3 4 5 6 7 8 9 10 | |
Dictionary Key Must Be String on Serializable Types¶
Explanation:\
When using a Dictionary field in a type marked with [BeamGenerateSchema], the key must be of type string. Other key types are not supported.
Example Code Triggering the Error:
1 2 3 4 5 | |
Example Error Message:
1 | |
Solution:
- Change the dictionary key type to
string.
Example of Solved Code:
1 2 3 4 5 | |
Field on Serializable Type Is Subtype From Dictionary¶
Explanation:\
Types that subclass Dictionary are not supported as field types in [BeamGenerateSchema] annotated classes.
Example Code Triggering the Error:
1 2 3 4 5 6 7 | |
Example Error Message:
1 | |
Solution:
- Use
Dictionary<string, T>directly instead of a subclass.
Example of Solved Code:
1 2 3 4 5 | |
Field on Serializable Type Is Subtype From List¶
Explanation:\
Types that subclass List<T> are not supported as field types in [BeamGenerateSchema] annotated classes.
Example Code Triggering the Error:
1 2 3 4 5 6 7 | |
Example Error Message:
1 | |
Solution:
- Use
List<T>directly instead of a subclass.
Example of Solved Code:
1 2 3 4 5 | |
Callable Method Declaration Type Is ContentObject Subtype¶
Explanation:\
Types used in Callable methods cannot inherit from ContentObject. Only the base ContentObject is supported.
Example Code Triggering the Error:
1 2 3 4 5 6 7 | |
Example Error Message:
1 | |
Solution:
- Use
ContentObjectinstead of a derived type.
Example of Solved Code:
1 2 3 4 5 | |
Callable Method Declaration Type Is Invalid Dictionary¶
Explanation:\
Dictionaries in [Callable] method parameters are only valid if their keys are of type string.
Example Code Triggering the Error:
1 2 3 4 5 | |
Example Error Message:
1 | |
Solution:
- Change dictionary key to
string.
Example of Solved Code:
1 2 3 4 5 | |
Callable Method Declaration Type Is Subtype From Dictionary¶
Explanation:\
Types used in [Callable] methods that subclass Dictionary are not supported.
Example Code Triggering the Error:
1 2 3 4 5 6 7 | |
Example Error Message:
1 | |
Solution:
- Use
Dictionary<string, T>directly.
Example of Solved Code:
1 2 3 4 5 | |
Callable Method Declaration Type Is Subtype From List¶
Explanation:\
Types used in [Callable] methods that subclass List<T> are not supported.
Example Code Triggering the Error:
1 2 3 4 5 6 7 | |
Example Error Message:
1 | |
Solution:
- Use
List<T>directly.
Example of Solved Code:
1 2 3 4 5 | |
Invalid Generic Type in Microservice¶
Explanation:
Generic types are not supported in Microservice [Callable] methods or in classes marked with [BeamGenerateSchema], except for a specific set of allowed generic types. The code generator cannot properly handle custom generic types for client-side code generation. The only permitted generic types are: List<T>, Dictionary<TKey, TValue>, Optional<T>, and ContentRef<T>.
Example Code Triggering the Error:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | |
Example Error Message:
1 | |
Solutions:
- Replace custom generic types with concrete types.
- Use one of the allowed generic types (
List<T>,Dictionary<string,T>,Optional<T>,ContentRef<T>) if they fit your use case.
Example of Solved Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | |