├── Icon.png
├── src
├── MasterMemory
│ ├── _InternalVisibleTo.cs
│ ├── Validation
│ │ ├── ITableUniqueValidate.cs
│ │ ├── ValidationDatabase.cs
│ │ ├── ValidateResult.cs
│ │ ├── ExpressionParameterNameModifier.cs
│ │ ├── ValidatableSet.Sequential.tt
│ │ ├── ReferenceSet.cs
│ │ ├── ExpressionDumper.cs
│ │ ├── ValidatableSet.cs
│ │ └── Validator.cs
│ ├── bin
│ │ └── Debug
│ │ │ └── netstandard2.0
│ │ │ ├── package.json.meta
│ │ │ └── package.json
│ ├── _MessagePackResolver.cs
│ ├── IValidatable.cs
│ ├── Internal
│ │ ├── ExpandableArray.cs
│ │ ├── InternStringResolver.cs
│ │ ├── ByteBufferWriter.cs
│ │ └── HeaderFormatterResolver.cs
│ ├── DatabaseBuilderBaseExtensions.cs
│ ├── MasterMemory.csproj
│ ├── ImmutableBuilderBase.cs
│ ├── DatabaseBuilderBase.cs
│ ├── RangeView.cs
│ ├── Meta
│ │ └── Meta.cs
│ └── MemoryDatabaseBase.cs
├── MasterMemory.Unity
│ ├── ProjectSettings
│ │ ├── ProjectVersion.txt
│ │ ├── ClusterInputManager.asset
│ │ ├── PresetManager.asset
│ │ ├── NetworkManager.asset
│ │ ├── VFXManager.asset
│ │ ├── XRSettings.asset
│ │ ├── VersionControlSettings.asset
│ │ ├── TimeManager.asset
│ │ ├── EditorBuildSettings.asset
│ │ ├── AudioManager.asset
│ │ ├── TagManager.asset
│ │ ├── EditorSettings.asset
│ │ ├── UnityConnectSettings.asset
│ │ ├── PackageManagerSettings.asset
│ │ ├── DynamicsManager.asset
│ │ ├── MemorySettings.asset
│ │ ├── NavMeshAreas.asset
│ │ ├── Physics2DSettings.asset
│ │ ├── GraphicsSettings.asset
│ │ ├── SceneTemplateSettings.json
│ │ └── QualitySettings.asset
│ ├── Assets
│ │ ├── Scenes
│ │ │ └── Main.unity.meta
│ │ ├── Packages.meta
│ │ ├── Scenes.meta
│ │ ├── Scripts.meta
│ │ ├── Scripts
│ │ │ ├── NewBehaviourScript.cs.meta
│ │ │ └── NewBehaviourScript.cs
│ │ ├── packages.config
│ │ ├── packages.config.meta
│ │ ├── NuGet.config
│ │ └── NuGet.config.meta
│ └── Packages
│ │ ├── manifest.json
│ │ └── packages-lock.json
├── MasterMemory.SourceGenerator
│ ├── Properties
│ │ └── launchSettings.json
│ ├── Polyfill
│ │ └── System.CodeDom.cs
│ ├── Utility
│ │ ├── IgnoreEquality.cs
│ │ └── EquatableArray.cs
│ ├── GeneratorCore
│ │ ├── DatabaseBuilderTemplate.tt
│ │ ├── Template.cs
│ │ ├── MessagePackResolverTemplate.tt
│ │ ├── ImmutableBuilderTemplate.tt
│ │ └── MemoryDatabaseTemplate.tt
│ ├── MasterMemoryGeneratorOptions.cs
│ ├── DiagnosticDescriptors.cs
│ └── MasterMemory.SourceGenerator.csproj
└── MasterMemory.Annotations
│ ├── MasterMemory.Annotations.csproj
│ └── Attributes.cs
├── tests
├── MasterMemory.Tests
│ ├── MessagePackResolver.cs
│ ├── TestStructures
│ │ ├── UserLevel.cs
│ │ ├── TestMaster.cs
│ │ ├── PersonModel.cs
│ │ ├── SkillMaster.cs
│ │ ├── Sample.cs
│ │ └── QuestMaster.cs
│ ├── MasterMemory.Tests.csproj
│ ├── MetaTest.cs
│ ├── IssueTest.cs
│ ├── MemoryKeyTest.cs
│ ├── RangeViewTest.cs
│ ├── DatabaseTest.cs
│ └── BinarySearchTest.cs
└── MasterMemory.SourceGenerator.Tests
│ ├── TestBase.cs
│ ├── GenerateTest.cs
│ ├── DiagnosticsTest.cs
│ ├── MasterMemory.SourceGenerator.Tests.csproj
│ ├── IncrementalGeneratorTest.cs
│ ├── AssemblyAtrributeTest.cs
│ └── Utility
│ └── CodeGeneratorHelper.cs
├── .github
├── workflows
│ ├── prevent-github-change.yaml
│ ├── stale.yaml
│ ├── toc.yaml
│ ├── build-debug.yaml
│ └── build-release.yaml
└── dependabot.yaml
├── sandbox
├── PerfTest2
│ ├── Engines
│ │ ├── ITest.cs
│ │ ├── MasterMemory_Test.cs
│ │ ├── LiteDB_Test.cs
│ │ ├── RavenDB_Test.cs
│ │ ├── Dictionary_Test.cs
│ │ └── SQLite_Test.cs
│ ├── PerfTest2.csproj
│ ├── Generated
│ │ ├── DatabaseBuilder.cs
│ │ ├── MemoryDatabase.cs
│ │ ├── Tables
│ │ │ └── TestDocTable.cs
│ │ ├── ImmutableBuilder.cs
│ │ └── MasterMemoryResolver.cs
│ ├── Program.cs
│ └── Utils
│ │ └── Helper.cs
├── ConsoleApp
│ └── ConsoleApp.csproj
├── GeneratorSandbox
│ ├── GeneratorSandbox.csproj
│ └── Program.cs
└── Benchmark
│ ├── Benchmark.csproj
│ └── Utils
│ └── Helper.cs
├── LICENSE
├── Directory.Build.props
├── .editorconfig
└── .gitignore
/Icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cysharp/MasterMemory/HEAD/Icon.png
--------------------------------------------------------------------------------
/src/MasterMemory/_InternalVisibleTo.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.CompilerServices;
2 |
3 | [assembly: InternalsVisibleTo("MasterMemory.Tests")]
--------------------------------------------------------------------------------
/src/MasterMemory.Unity/ProjectSettings/ProjectVersion.txt:
--------------------------------------------------------------------------------
1 | m_EditorVersion: 2022.3.12f1
2 | m_EditorVersionWithRevision: 2022.3.12f1 (4fe6e059c7ef)
3 |
--------------------------------------------------------------------------------
/src/MasterMemory.Unity/ProjectSettings/ClusterInputManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!236 &1
4 | ClusterInputManager:
5 | m_ObjectHideFlags: 0
6 | m_Inputs: []
7 |
--------------------------------------------------------------------------------
/src/MasterMemory.Unity/ProjectSettings/PresetManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!1386491679 &1
4 | PresetManager:
5 | m_ObjectHideFlags: 0
6 | m_DefaultList: []
7 |
--------------------------------------------------------------------------------
/src/MasterMemory/Validation/ITableUniqueValidate.cs:
--------------------------------------------------------------------------------
1 | namespace MasterMemory.Validation
2 | {
3 | public interface ITableUniqueValidate
4 | {
5 | void ValidateUnique(ValidateResult resultSet);
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/src/MasterMemory.Unity/Assets/Scenes/Main.unity.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: d5ed035d1a1185e43a6e9d45e3d68f1f
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/src/MasterMemory.Unity/ProjectSettings/NetworkManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!149 &1
4 | NetworkManager:
5 | m_ObjectHideFlags: 0
6 | m_DebugLevel: 0
7 | m_Sendrate: 15
8 | m_AssetToPrefab: {}
9 |
--------------------------------------------------------------------------------
/src/MasterMemory.Unity/ProjectSettings/VFXManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!937362698 &1
4 | VFXManager:
5 | m_ObjectHideFlags: 0
6 | m_IndirectShader: {fileID: 0}
7 | m_RenderPipeSettingsPath:
8 |
--------------------------------------------------------------------------------
/src/MasterMemory.Unity/Assets/Packages.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 26358cf27391727439065c2117eb2e52
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/src/MasterMemory.Unity/Assets/Scenes.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 3e4672a57ce755a44805bc58b4ddea29
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/src/MasterMemory.Unity/Assets/Scripts.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: dfc2745c192a6764a8f038393ed2455c
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/src/MasterMemory/bin/Debug/netstandard2.0/package.json.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b73e5f61035018248a0ae4ff5130ae2a
3 | PackageManifestImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/src/MasterMemory.Unity/ProjectSettings/XRSettings.asset:
--------------------------------------------------------------------------------
1 | {
2 | "m_SettingKeys": [
3 | "VR Device Disabled",
4 | "VR Device User Alert"
5 | ],
6 | "m_SettingValues": [
7 | "False",
8 | "False"
9 | ]
10 | }
--------------------------------------------------------------------------------
/src/MasterMemory.SourceGenerator/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "Profile 1": {
4 | "commandName": "DebugRoslynComponent",
5 | "targetProject": "..\\..\\sandbox\\GeneratorSandbox\\GeneratorSandbox.csproj"
6 | }
7 | }
8 | }
--------------------------------------------------------------------------------
/tests/MasterMemory.Tests/MessagePackResolver.cs:
--------------------------------------------------------------------------------
1 | using MessagePack;
2 | using MessagePack.Resolvers;
3 |
4 | namespace MasterMemory.Tests;
5 |
6 | [CompositeResolver(typeof(MasterMemoryResolver), typeof(StandardResolver))]
7 | public partial class MessagePackResolver;
--------------------------------------------------------------------------------
/src/MasterMemory/_MessagePackResolver.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace MasterMemory;
6 |
7 | [MessagePack.GeneratedMessagePackResolver]
8 | internal partial class _MessagePackResolver
9 | {
10 | }
--------------------------------------------------------------------------------
/src/MasterMemory.Unity/ProjectSettings/VersionControlSettings.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!890905787 &1
4 | VersionControlSettings:
5 | m_ObjectHideFlags: 0
6 | m_Mode: Visible Meta Files
7 | m_CollabEditorSettings:
8 | inProgressEnabled: 1
9 |
--------------------------------------------------------------------------------
/src/MasterMemory.Unity/ProjectSettings/TimeManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!5 &1
4 | TimeManager:
5 | m_ObjectHideFlags: 0
6 | Fixed Timestep: 0.02
7 | Maximum Allowed Timestep: 0.1
8 | m_TimeScale: 1
9 | Maximum Particle Timestep: 0.03
10 |
--------------------------------------------------------------------------------
/.github/workflows/prevent-github-change.yaml:
--------------------------------------------------------------------------------
1 | name: Prevent github change
2 | on:
3 | pull_request:
4 | paths:
5 | - ".github/**/*.yaml"
6 | - ".github/**/*.yml"
7 |
8 | jobs:
9 | detect:
10 | permissions:
11 | contents: read
12 | uses: Cysharp/Actions/.github/workflows/prevent-github-change.yaml@main
13 |
--------------------------------------------------------------------------------
/.github/workflows/stale.yaml:
--------------------------------------------------------------------------------
1 | name: "Close stale issues"
2 |
3 | on:
4 | workflow_dispatch:
5 | schedule:
6 | - cron: "0 0 * * *"
7 |
8 | jobs:
9 | stale:
10 | permissions:
11 | contents: read
12 | pull-requests: write
13 | issues: write
14 | uses: Cysharp/Actions/.github/workflows/stale-issue.yaml@main
15 |
--------------------------------------------------------------------------------
/.github/workflows/toc.yaml:
--------------------------------------------------------------------------------
1 | name: TOC Generator
2 |
3 | on:
4 | push:
5 | paths:
6 | - 'README.md'
7 |
8 | jobs:
9 | toc:
10 | permissions:
11 | contents: write
12 | uses: Cysharp/Actions/.github/workflows/toc-generator.yaml@main
13 | with:
14 | TOC_TITLE: "## Table of Contents"
15 | secrets: inherit
16 |
--------------------------------------------------------------------------------
/src/MasterMemory.Unity/Assets/Scripts/NewBehaviourScript.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: a7e2d905f1c43ee42914ee6de131c41e
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/src/MasterMemory.Unity/ProjectSettings/EditorBuildSettings.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!1045 &1
4 | EditorBuildSettings:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 2
7 | m_Scenes:
8 | - enabled: 1
9 | path: Assets/Scenes/SampleScene.unity
10 | guid: 2cda990e2423bbf4892e6590ba056729
11 | m_configObjects: {}
12 |
--------------------------------------------------------------------------------
/tests/MasterMemory.SourceGenerator.Tests/TestBase.cs:
--------------------------------------------------------------------------------
1 | namespace MasterMemory.SourceGenerator.Tests;
2 |
3 | public abstract class TestBase(ITestOutputHelper testoutputHelper)
4 | {
5 | protected CodeGeneratorHelper Helper = new CodeGeneratorHelper(testoutputHelper, "MAM");
6 |
7 | protected void WriteLine(string message)
8 | {
9 | testoutputHelper.WriteLine(message);
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/MasterMemory.SourceGenerator/Polyfill/System.CodeDom.cs:
--------------------------------------------------------------------------------
1 | #nullable disable
2 |
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Text;
6 |
7 | namespace System.CodeDom.Compiler
8 | {
9 | public class CompilerError
10 | {
11 | public string ErrorText { get; set; }
12 | public bool IsWarning { get; set; }
13 | }
14 |
15 | public class CompilerErrorCollection
16 | {
17 | public void Add(CompilerError error)
18 | {
19 | }
20 | }
21 | }
--------------------------------------------------------------------------------
/src/MasterMemory.Unity/ProjectSettings/AudioManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!11 &1
4 | AudioManager:
5 | m_ObjectHideFlags: 0
6 | m_Volume: 1
7 | Rolloff Scale: 1
8 | Doppler Factor: 1
9 | Default Speaker Mode: 2
10 | m_SampleRate: 0
11 | m_DSPBufferSize: 1024
12 | m_VirtualVoiceCount: 512
13 | m_RealVoiceCount: 32
14 | m_SpatializerPlugin:
15 | m_AmbisonicDecoderPlugin:
16 | m_DisableAudio: 0
17 | m_VirtualizeEffects: 1
18 |
--------------------------------------------------------------------------------
/src/MasterMemory.Unity/Assets/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/MasterMemory/bin/Debug/netstandard2.0/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "com.github.mastermemory.internal",
3 | "displayName": "MasterMemory Internal",
4 | "author": { "name": "MasterMemory", "url": "https://github.com/Cysharp/MasterMemory" },
5 | "version": "1.0.0",
6 | "unity": "2022.3",
7 | "description": "Internal Package of MasterMemory for development time.",
8 | "keywords": [ "Database" ],
9 | "license": "MIT",
10 | "category": "Scripting",
11 | "dependencies": {}
12 | }
13 |
--------------------------------------------------------------------------------
/src/MasterMemory.Unity/Assets/packages.config.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 44858e3667fc6e44c8fc19fd02574910
3 | labels:
4 | - NuGetForUnity
5 | PluginImporter:
6 | externalObjects: {}
7 | serializedVersion: 2
8 | iconMap: {}
9 | executionOrder: {}
10 | defineConstraints: []
11 | isPreloaded: 0
12 | isOverridable: 0
13 | isExplicitlyReferenced: 0
14 | validateReferences: 1
15 | platformData:
16 | - first:
17 | Any:
18 | second:
19 | enabled: 1
20 | settings: {}
21 | userData:
22 | assetBundleName:
23 | assetBundleVariant:
24 |
--------------------------------------------------------------------------------
/tests/MasterMemory.Tests/TestStructures/UserLevel.cs:
--------------------------------------------------------------------------------
1 | using MessagePack;
2 |
3 | namespace MasterMemory.Tests
4 | {
5 | [MemoryTable("UserLevel"), MessagePackObject(true)]
6 | public class UserLevel
7 | {
8 | [PrimaryKey]
9 | public int Level { get; set; }
10 | [SecondaryKey(0)]
11 | public int Exp { get; set; }
12 |
13 | public UserLevel()
14 | {
15 |
16 | }
17 |
18 | public UserLevel(int Level, int Exp)
19 | {
20 | this.Level = Level;
21 | this.Exp = Exp;
22 | }
23 |
24 | }
25 | }
--------------------------------------------------------------------------------
/src/MasterMemory.Unity/ProjectSettings/TagManager.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!78 &1
4 | TagManager:
5 | serializedVersion: 2
6 | tags: []
7 | layers:
8 | - Default
9 | - TransparentFX
10 | - Ignore Raycast
11 | -
12 | - Water
13 | - UI
14 | -
15 | -
16 | -
17 | -
18 | -
19 | -
20 | -
21 | -
22 | -
23 | -
24 | -
25 | -
26 | -
27 | -
28 | -
29 | -
30 | -
31 | -
32 | -
33 | -
34 | -
35 | -
36 | -
37 | -
38 | -
39 | -
40 | m_SortingLayers:
41 | - name: Default
42 | uniqueID: 0
43 | locked: 0
44 |
--------------------------------------------------------------------------------
/tests/MasterMemory.Tests/TestStructures/TestMaster.cs:
--------------------------------------------------------------------------------
1 | using MessagePack;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 |
6 | namespace MasterMemory.Tests.TestStructures
7 | {
8 | [MessagePackObject(true)]
9 | [MemoryTable(nameof(TestMaster))]
10 | public class TestMaster
11 | {
12 | [PrimaryKey, NonUnique]
13 | public int TestID { get; set; }
14 | public int Value { get; set; }
15 |
16 | public TestMaster(int TestID, int Value)
17 | {
18 | this.TestID = TestID;
19 | this.Value = Value;
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/MasterMemory.SourceGenerator/Utility/IgnoreEquality.cs:
--------------------------------------------------------------------------------
1 | namespace MasterMemory;
2 |
3 | public readonly struct IgnoreEquality(T value) : IEquatable>
4 | {
5 | public readonly T Value => value;
6 |
7 | public static implicit operator IgnoreEquality(T value)
8 | {
9 | return new IgnoreEquality(value);
10 | }
11 |
12 | public static implicit operator T(IgnoreEquality value)
13 | {
14 | return value.Value;
15 | }
16 |
17 | public bool Equals(IgnoreEquality other)
18 | {
19 | // always true to ignore equality check.
20 | return true;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/sandbox/PerfTest2/Engines/ITest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data;
4 | using System.Data.SQLite;
5 | using System.Diagnostics;
6 | using System.IO;
7 | using System.Linq;
8 | using System.Text;
9 | using System.Threading.Tasks;
10 | using LiteDB;
11 |
12 | namespace TestPerfLiteDB
13 | {
14 | public interface ITest : IDisposable
15 | {
16 | int Count { get; }
17 | int FileLength { get; }
18 |
19 | void Prepare();
20 | void Insert();
21 | void Bulk();
22 | void Update();
23 | void CreateIndex();
24 | void Query();
25 | //void Delete();
26 | //void Drop();
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/tests/MasterMemory.Tests/TestStructures/PersonModel.cs:
--------------------------------------------------------------------------------
1 | #pragma warning disable
2 | using MessagePack;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Text;
6 |
7 | namespace MasterMemory.Tests.TestStructures
8 | {
9 |
10 | [MemoryTable("people"), MessagePackObject(true)]
11 | public class PersonModel
12 | {
13 | [SecondaryKey(0), NonUnique]
14 | [SecondaryKey(1, keyOrder: 1), NonUnique]
15 | public string LastName { get; set; }
16 |
17 | [SecondaryKey(2), NonUnique]
18 | [SecondaryKey(1, keyOrder: 0), NonUnique]
19 | public string FirstName { get; set; }
20 |
21 | [PrimaryKey] public string RandomId { get; set; }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/.github/dependabot.yaml:
--------------------------------------------------------------------------------
1 | # ref: https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot
2 | version: 2
3 | updates:
4 | - package-ecosystem: "github-actions"
5 | directory: "/"
6 | schedule:
7 | interval: "weekly" # Check for updates to GitHub Actions every week
8 | cooldown:
9 | default-days: 14 # Wait 14 days before creating another PR for the same dependency. This will prevent vulnerability on the package impact.
10 | ignore:
11 | # I just want update action when major/minor version is updated. patch updates are too noisy.
12 | - dependency-name: "*"
13 | update-types:
14 | - version-update:semver-patch
15 |
--------------------------------------------------------------------------------
/src/MasterMemory.Unity/Assets/NuGet.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/MasterMemory.Unity/Packages/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "dependencies": {
3 | "com.cysharp.runtimeunittesttoolkit": "https://github.com/Cysharp/RuntimeUnitTestToolkit.git?path=RuntimeUnitTestToolkit/Assets/RuntimeUnitTestToolkit#2.6.0",
4 | "com.github-glitchenzo.nugetforunity": "https://github.com/GlitchEnzo/NuGetForUnity.git?path=/src/NuGetForUnity",
5 | "com.github.mastermemory.internal": "file:/../../src/MasterMemory/bin/Debug/netstandard2.0",
6 | "com.unity.ide.rider": "3.0.31",
7 | "com.unity.ide.visualstudio": "2.0.22",
8 | "com.unity.ide.vscode": "1.2.5",
9 | "com.unity.test-framework": "1.1.33",
10 | "com.unity.toolchain.win-x86_64-linux-x86_64": "2.0.9",
11 | "com.unity.ugui": "1.0.0"
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/MasterMemory.Annotations/MasterMemory.Annotations.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | 13
6 | Library
7 | enable
8 | False
9 | Cysharp
10 | true
11 | 1701;1702;1705;1591
12 | MasterMemory
13 |
14 |
15 | MasterMemory.Annotations
16 | Attributes of MasterMemory.
17 | true
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/MasterMemory.Unity/ProjectSettings/EditorSettings.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!159 &1
4 | EditorSettings:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 7
7 | m_ExternalVersionControlSupport: Visible Meta Files
8 | m_SerializationMode: 2
9 | m_LineEndingsForNewScripts: 2
10 | m_DefaultBehaviorMode: 1
11 | m_SpritePackerMode: 4
12 | m_SpritePackerPaddingPower: 1
13 | m_EtcTextureCompressorBehavior: 1
14 | m_EtcTextureFastCompressor: 1
15 | m_EtcTextureNormalCompressor: 2
16 | m_EtcTextureBestCompressor: 4
17 | m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd
18 | m_ProjectGenerationRootNamespace:
19 | m_UserGeneratedProjectSuffix:
20 | m_CollabEditorSettings:
21 | inProgressEnabled: 1
22 |
--------------------------------------------------------------------------------
/.github/workflows/build-debug.yaml:
--------------------------------------------------------------------------------
1 | name: Build-Debug
2 |
3 | on:
4 | push:
5 | branches:
6 | - "master"
7 | pull_request:
8 | branches:
9 | - "master"
10 |
11 | jobs:
12 | build-dotnet:
13 | permissions:
14 | contents: read
15 | runs-on: ubuntu-24.04
16 | timeout-minutes: 15
17 | steps:
18 | - uses: Cysharp/Actions/.github/actions/checkout@main
19 | - uses: Cysharp/Actions/.github/actions/setup-dotnet@main
20 | with:
21 | dotnet-version: |
22 | 9.0.x
23 | - run: dotnet build -c Release
24 | - run: dotnet test -c Release --no-build
25 | - run: dotnet pack -c Release --no-build -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg -o $GITHUB_WORKSPACE/artifacts
26 |
--------------------------------------------------------------------------------
/src/MasterMemory/IValidatable.cs:
--------------------------------------------------------------------------------
1 | using MasterMemory.Validation;
2 | using System;
3 | using System.Linq.Expressions;
4 |
5 | namespace MasterMemory
6 | {
7 | public interface IValidatable
8 | {
9 | void Validate(IValidator validator);
10 | }
11 |
12 | public interface IValidator
13 | {
14 | ValidatableSet GetTableSet();
15 | ReferenceSet GetReferenceSet();
16 | void Validate(Expression> predicate);
17 | void Validate(Func predicate, string message);
18 | void ValidateAction(Expression> predicate);
19 | void ValidateAction(Func predicate, string message);
20 | void Fail(string message);
21 | bool CallOnce();
22 | }
23 | }
--------------------------------------------------------------------------------
/sandbox/PerfTest2/PerfTest2.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net9.0
6 | 1701;1702;NU1904
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | Analyzer
18 | false
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/src/MasterMemory/Internal/ExpandableArray.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace MasterMemory.Internal
4 | {
5 | internal struct ExpandableArray
6 | {
7 | internal TElement[] items;
8 | internal int count;
9 |
10 | public ExpandableArray(object dummy)
11 | {
12 | items = Array.Empty();
13 | count = 0;
14 | }
15 |
16 | internal void Add(TElement item)
17 | {
18 | if (items == null || items.Length == 0)
19 | {
20 | items = new TElement[4];
21 | }
22 | else if (items.Length == (count + 1))
23 | {
24 | Array.Resize(ref items, checked(count * 2));
25 | }
26 | items[count++] = item;
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/src/MasterMemory.Unity/Assets/NuGet.config.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e5322b2ac44bca4478137f3076edc3bb
3 | labels:
4 | - NuGetForUnity
5 | PluginImporter:
6 | externalObjects: {}
7 | serializedVersion: 2
8 | iconMap: {}
9 | executionOrder: {}
10 | defineConstraints: []
11 | isPreloaded: 0
12 | isOverridable: 0
13 | isExplicitlyReferenced: 0
14 | validateReferences: 1
15 | platformData:
16 | - first:
17 | Any:
18 | second:
19 | enabled: 0
20 | settings: {}
21 | - first:
22 | Editor: Editor
23 | second:
24 | enabled: 0
25 | settings:
26 | DefaultValueInitialized: true
27 | - first:
28 | Windows Store Apps: WindowsStoreApps
29 | second:
30 | enabled: 1
31 | settings: {}
32 | userData:
33 | assetBundleName:
34 | assetBundleVariant:
35 |
--------------------------------------------------------------------------------
/tests/MasterMemory.SourceGenerator.Tests/GenerateTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Xunit.Abstractions;
7 |
8 | namespace MasterMemory.SourceGenerator.Tests;
9 |
10 | public class GenerateTest(ITestOutputHelper outputHelper) : TestBase(outputHelper)
11 | {
12 | [Fact]
13 | public void GenerateClass()
14 | {
15 | Helper.Ok("""
16 | [MemoryTable("item")]
17 | public class Item
18 | {
19 | [PrimaryKey]
20 | public int ItemId { get; set; }
21 | }
22 | """);
23 | }
24 |
25 | [Fact]
26 | public void GenerateRecord()
27 | {
28 | Helper.Ok("""
29 | [MemoryTable("item")]
30 | public record Item
31 | {
32 | [PrimaryKey]
33 | public int ItemId { get; set; }
34 | }
35 | """);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/sandbox/PerfTest2/Generated/DatabaseBuilder.cs:
--------------------------------------------------------------------------------
1 | //
2 | using LiteDB;
3 | using MasterMemory;
4 | using MessagePack;
5 | using System.Collections.Generic;
6 | using System.Data.SQLite;
7 | using System.Diagnostics;
8 | using System.Linq;
9 | using System.Text;
10 | using System.Threading.Tasks;
11 | using System;
12 | using TestPerfLiteDB;
13 | using TestPerfLiteDB.Tables;
14 |
15 | namespace TestPerfLiteDB
16 | {
17 | public sealed class DatabaseBuilder : DatabaseBuilderBase
18 | {
19 | public DatabaseBuilder() : this(null) { }
20 | public DatabaseBuilder(MessagePack.IFormatterResolver resolver) : base(resolver) { }
21 |
22 | public DatabaseBuilder Append(System.Collections.Generic.IEnumerable dataSource)
23 | {
24 | AppendCore(dataSource, x => x.id, System.Collections.Generic.Comparer.Default);
25 | return this;
26 | }
27 |
28 | }
29 | }
--------------------------------------------------------------------------------
/tests/MasterMemory.SourceGenerator.Tests/DiagnosticsTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace MasterMemory.SourceGenerator.Tests;
8 |
9 | public class DiagnosticsTest(ITestOutputHelper outputHelper) : TestBase(outputHelper)
10 | {
11 | [Fact]
12 | public void RequirePrimaryKey()
13 | {
14 | Helper.Verify(1, """
15 | [MemoryTable("item")]
16 | public class Item
17 | {
18 | // [PrimaryKey] // No PrimaryKey
19 | public int ItemId { get; set; }
20 | }
21 | """, "Item");
22 | }
23 |
24 | [Fact]
25 | public void DuplicateSecondaryKey()
26 | {
27 | Helper.Verify(3, """
28 | [MemoryTable("item")]
29 | public class Item
30 | {
31 | [PrimaryKey]
32 | public int ItemId1 { get; set; }
33 | [SecondaryKey(0), SecondaryKey(1)]
34 | public int ItemId2 { get; set; }
35 | }
36 | """, "ItemId2");
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/tests/MasterMemory.Tests/TestStructures/SkillMaster.cs:
--------------------------------------------------------------------------------
1 | #pragma warning disable
2 | using MessagePack;
3 |
4 | namespace MasterMemory.Tests
5 | {
6 | [MemoryTable("skillmaster"), MessagePackObject(true)]
7 | public class SkillMaster
8 | {
9 | [PrimaryKey]
10 | public int SkillId { get; set; }
11 | [PrimaryKey]
12 | public int SkillLevel { get; set; }
13 | public int AttackPower { get; set; }
14 | public string SkillName { get; set; }
15 | public string Description { get; set; }
16 |
17 | public SkillMaster()
18 | {
19 |
20 | }
21 |
22 | public SkillMaster(int SkillId, int SkillLevel, int AttackPower, string SkillName, string Description)
23 | {
24 | this.SkillId = SkillId;
25 | this.SkillLevel = SkillLevel;
26 | this.AttackPower = AttackPower;
27 | this.SkillName = SkillName;
28 | this.Description = Description;
29 | }
30 |
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/tests/MasterMemory.Tests/MasterMemory.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net9.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | Analyzer
18 | false
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/sandbox/ConsoleApp/ConsoleApp.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net9.0
6 |
7 |
8 |
9 | $(DefineConstants)TRACE;
10 |
11 |
12 |
13 | $(DefineConstants)TRACE;
14 |
15 |
16 |
17 |
18 |
19 |
20 | Analyzer
21 | false
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/src/MasterMemory.SourceGenerator/GeneratorCore/DatabaseBuilderTemplate.tt:
--------------------------------------------------------------------------------
1 | <#@ template debug="false" hostspecific="false" linePragmas="false" language="C#" #>
2 | <#@ assembly name="System.Core" #>
3 | <#@ import namespace="System.Linq" #>
4 | <#@ import namespace="System.Text" #>
5 | <#@ import namespace="System.Collections.Generic" #>
6 | //
7 | #pragma warning disable
8 | #nullable enable
9 |
10 | <#= Using #>
11 |
12 | namespace <#= Namespace #>
13 | {
14 | public sealed class <#= ClassName #> : DatabaseBuilderBase
15 | {
16 | public <#= ClassName #>() : this(null) { }
17 | public <#= ClassName #>(MessagePack.IFormatterResolver? resolver) : base(resolver) { }
18 |
19 | <# foreach(var item in GenerationContexts) { #>
20 | public <#= ClassName #> Append(System.Collections.Generic.IEnumerable<<#= item.ClassName #>> dataSource)
21 | {
22 | AppendCore(dataSource, x => <#= item.PrimaryKey.BuildKeyAccessor("x") #>, <#= item.PrimaryKey.BuildComparer() #>);
23 | return this;
24 | }
25 |
26 | <# } #>
27 | }
28 | }
--------------------------------------------------------------------------------
/tests/MasterMemory.SourceGenerator.Tests/MasterMemory.SourceGenerator.Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net9.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/sandbox/GeneratorSandbox/GeneratorSandbox.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net9.0
6 | enable
7 | enable
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
19 |
20 |
21 |
22 |
23 |
24 | Analyzer
25 | false
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/src/MasterMemory.Unity/ProjectSettings/UnityConnectSettings.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!310 &1
4 | UnityConnectSettings:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 1
7 | m_Enabled: 0
8 | m_TestMode: 0
9 | m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events
10 | m_EventUrl: https://cdp.cloud.unity3d.com/v1/events
11 | m_ConfigUrl: https://config.uca.cloud.unity3d.com
12 | m_DashboardUrl: https://dashboard.unity3d.com
13 | m_TestInitMode: 0
14 | CrashReportingSettings:
15 | m_EventUrl: https://perf-events.cloud.unity3d.com
16 | m_Enabled: 0
17 | m_LogBufferSize: 10
18 | m_CaptureEditorExceptions: 1
19 | UnityPurchasingSettings:
20 | m_Enabled: 0
21 | m_TestMode: 0
22 | UnityAnalyticsSettings:
23 | m_Enabled: 0
24 | m_TestMode: 0
25 | m_InitializeOnStartup: 1
26 | m_PackageRequiringCoreStatsPresent: 0
27 | UnityAdsSettings:
28 | m_Enabled: 0
29 | m_InitializeOnStartup: 1
30 | m_TestMode: 0
31 | m_IosGameId:
32 | m_AndroidGameId:
33 | m_GameIds: {}
34 | m_GameId:
35 | PerformanceReportingSettings:
36 | m_Enabled: 0
37 |
--------------------------------------------------------------------------------
/tests/MasterMemory.Tests/MetaTest.cs:
--------------------------------------------------------------------------------
1 | #pragma warning disable
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 | using Xunit;
6 |
7 | namespace MasterMemory.Tests
8 | {
9 | public class MetaTest
10 | {
11 | [Fact]
12 | public void Meta()
13 | {
14 | var metaDb = MemoryDatabase.GetMetaDatabase();
15 |
16 | var sampleTable = metaDb.GetTableInfo("s_a_m_p_l_e");
17 |
18 | sampleTable.TableName.ShouldBe("s_a_m_p_l_e");
19 |
20 | sampleTable.Properties[0].Name.ShouldBe("Id");
21 | sampleTable.Properties[0].NameLowerCamel.ShouldBe("id");
22 | sampleTable.Properties[0].NameSnakeCase.ShouldBe("id");
23 |
24 | sampleTable.Properties[2].Name.ShouldBe("FirstName");
25 | sampleTable.Properties[2].NameLowerCamel.ShouldBe("firstName");
26 | sampleTable.Properties[2].NameSnakeCase.ShouldBe("first_name");
27 |
28 | var primary = sampleTable.Indexes[0];
29 | primary.IsUnique.ShouldBeTrue();
30 | primary.IndexProperties[0].Name.ShouldBe("Id");
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Yoshifumi Kawai / Cysharp, Inc.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/src/MasterMemory.Unity/ProjectSettings/PackageManagerSettings.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!114 &1
4 | MonoBehaviour:
5 | m_ObjectHideFlags: 53
6 | m_CorrespondingSourceObject: {fileID: 0}
7 | m_PrefabInstance: {fileID: 0}
8 | m_PrefabAsset: {fileID: 0}
9 | m_GameObject: {fileID: 0}
10 | m_Enabled: 1
11 | m_EditorHideFlags: 0
12 | m_Script: {fileID: 13964, guid: 0000000000000000e000000000000000, type: 0}
13 | m_Name:
14 | m_EditorClassIdentifier:
15 | m_EnablePreReleasePackages: 0
16 | m_AdvancedSettingsExpanded: 1
17 | m_ScopedRegistriesSettingsExpanded: 1
18 | m_SeeAllPackageVersions: 0
19 | m_DismissPreviewPackagesInUse: 0
20 | oneTimeWarningShown: 0
21 | m_Registries:
22 | - m_Id: main
23 | m_Name:
24 | m_Url: https://packages.unity.com
25 | m_Scopes: []
26 | m_IsDefault: 1
27 | m_Capabilities: 7
28 | m_ConfigSource: 0
29 | m_UserSelectedRegistryName:
30 | m_UserAddingNewScopedRegistry: 0
31 | m_RegistryInfoDraft:
32 | m_Modified: 0
33 | m_ErrorMessage:
34 | m_UserModificationsInstanceId: -856
35 | m_OriginalInstanceId: -858
36 | m_LoadAssets: 0
37 |
--------------------------------------------------------------------------------
/src/MasterMemory/DatabaseBuilderBaseExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 |
5 | namespace MasterMemory
6 | {
7 | public static class DatabaseBuilderExtensions
8 | {
9 | public static void AppendDynamic(this DatabaseBuilderBase builder, Type dataType, IList