You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+9-27Lines changed: 9 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -71,26 +71,16 @@ flowchart TD
71
71
- SyncZeroMQLayer: to connect to the Synchronizer (connection)
72
72
73
73
### Store generation
74
-
C# stores can be generated from the `<name>Meta.py`. Use the [libstored](https://demcon.github.io/libstored) generator to parse the `<name>.st` and output the `<name>Meta.py`.
75
-
The `generator.py` script in this repository under `/python`
76
74
77
-
Make sure a virtual environment is created, activated and the requirements.txt is installed in it.
78
-
```bash
79
-
cd python
80
-
python -m venv .venv
81
-
./.venv/Scripts/activate
82
-
pip install -r requirements.txt
83
-
```
84
-
85
-
Call the generator script to create a C# store that implements the `Store` abstract class, which can then be mapped to the `Synchronizer` and `Debugger` in LibStored.Net.
75
+
This project uses a C# Source Generator to create strongly-typed store classes from store metadata YAML (.yml) files at compile time.
76
+
This YAML file is automatically created when generating code for a store (.st) using [libstored](https://demcon.github.io/libstored) (from version v2.1.0).
- Add the store metadata files (*.yml) to your project as AdditionalFiles so the source generator can read them during compilation.
80
+
- Reference the LibStored.Net either by adding the NuGet package. This package include the Source Generator.
81
+
- The generator emits C# store classes implementing the `Store` base class. Use them directly from your code after a build.
90
82
91
-
#### Source Generator
92
-
93
-
The C# code can be automatically generated from a metadata`*.yml` file generated by the `generator.py` script (or in the future - see [libstored issue#76](https://github.com/DEMCON/libstored/issues/76)). Reference the store(s) metadata as AddinionalFiles:
83
+
Example csproj snippet:
94
84
```xml
95
85
<ItemGroup>
96
86
<AdditionalFilesInclude="TestStore.yml" />
@@ -116,15 +106,6 @@ Another option would be to create a store per thread, and synchronize them using
116
106
- StdioLayer (use `libstored.Stdio2Zmq` as alternative for local debugging, not production ready)
117
107
- SerialLayer (use `libstored.Serial2Zmq` as alternative for local debugging, not production ready)
118
108
119
-
#### Store source generation
120
-
Currently, C# stores are created manually by running a Python script using the Meta.py output of [libstored](demcon.github.io/libstored).
121
-
A C# Source Generator could automate this process of converting the store data structure to a C# class, using the hash, names, types, offset and
122
-
sizes of all objects in the store.
123
-
124
-
A C# Source Generator could generate the stores automatically during compile-time of the C# application using this library. The input of the source generated is the `.rtf` / `.csv` / `Meta.py`, or parse the actual store definition in `.st` files. Maybe [libstored](demcon.github.io/libstored) can be extended to generate a language agnostic `.json` or `.yml` file with the store definition, which can be used by the C# Source Generator to generate the store class. The `.json` file would be the easiest to implement since its easy to parse and can contain all relevant store data. The Source Generator that transform a `*.yml` has been implemented, as described in the [README.md](src/LibStored.Net.Generator/README.md).
125
-
126
-
Another option is to create a template file for the C# version of the store in [libstored](demcon.github.io/libstored).
127
-
128
109
#### Unsupported features
129
110
130
111
Types: `Pointer`, `Pointer32` and `Pointer64` are not supported, as they are not needed in C# applications. The `ptr32` and `ptr64` types are used to store pointers to other objects in the store, which is not needed in C# applications as the objects are stored in managed memory. These types will be mapped to unsigned integers (`uint` and `ulong`) in the C# implementation.
@@ -139,7 +120,7 @@ using LibStored.Net.ZeroMQ;
139
120
usingNetMQ;
140
121
usingNetMQ.Sockets;
141
122
142
-
// Make sure this ExampleStore is created by the source generator or python script.
123
+
// Make sure this ExampleStore is created by the source generator from ExampleStore.yml.
0 commit comments