diff --git a/MemoryPack.sln b/MemoryPack.sln
index 7588ff78..5c507cc4 100644
--- a/MemoryPack.sln
+++ b/MemoryPack.sln
@@ -37,6 +37,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MemoryPack.Tests.Roslyn3",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MemoryPack.Generator.Roslyn3", "src\MemoryPack.Generator.Roslyn3\MemoryPack.Generator.Roslyn3.csproj", "{0F57F162-9C68-4E0F-B89B-2EED31B69F38}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClassLibrary", "sandbox\ClassLibrary\ClassLibrary.csproj", "{0ADCE3AF-C900-4FCB-938B-654211EDD6BE}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -122,6 +124,12 @@ Global
{0F57F162-9C68-4E0F-B89B-2EED31B69F38}.Release|Any CPU.Build.0 = Release|Any CPU
{0F57F162-9C68-4E0F-B89B-2EED31B69F38}.WinBenchmark|Any CPU.ActiveCfg = Debug|Any CPU
{0F57F162-9C68-4E0F-B89B-2EED31B69F38}.WinBenchmark|Any CPU.Build.0 = Debug|Any CPU
+ {0ADCE3AF-C900-4FCB-938B-654211EDD6BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {0ADCE3AF-C900-4FCB-938B-654211EDD6BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {0ADCE3AF-C900-4FCB-938B-654211EDD6BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {0ADCE3AF-C900-4FCB-938B-654211EDD6BE}.Release|Any CPU.Build.0 = Release|Any CPU
+ {0ADCE3AF-C900-4FCB-938B-654211EDD6BE}.WinBenchmark|Any CPU.ActiveCfg = Debug|Any CPU
+ {0ADCE3AF-C900-4FCB-938B-654211EDD6BE}.WinBenchmark|Any CPU.Build.0 = Debug|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -140,6 +148,7 @@ Global
{06384E50-13CE-4AA2-90B3-5EC116B06D01} = {C56A9A52-EE3A-44A5-A8EA-AE36C79FFB6C}
{E2C01D05-E7F1-4151-B536-90B138AF18EF} = {204004F9-9B91-4DD1-812C-80D629169ED5}
{0F57F162-9C68-4E0F-B89B-2EED31B69F38} = {81B295E0-EEDE-4D5B-B4AC-1202D5E6B3CF}
+ {0ADCE3AF-C900-4FCB-938B-654211EDD6BE} = {796FB992-A35C-405B-82A7-4C90C5673174}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {01ADF7A3-0758-4A3C-9A18-AEF0F30B6E1B}
diff --git a/sandbox/ClassLibrary/Class1.cs b/sandbox/ClassLibrary/Class1.cs
new file mode 100644
index 00000000..264094a0
--- /dev/null
+++ b/sandbox/ClassLibrary/Class1.cs
@@ -0,0 +1,8 @@
+
+using MemoryPack;
+
+[MemoryPackable]
+public partial class Stat
+{
+
+}
diff --git a/sandbox/ClassLibrary/ClassLibrary.csproj b/sandbox/ClassLibrary/ClassLibrary.csproj
new file mode 100644
index 00000000..3f947bb1
--- /dev/null
+++ b/sandbox/ClassLibrary/ClassLibrary.csproj
@@ -0,0 +1,19 @@
+
+
+
+ net7.0;netstandard2.1
+ enable
+ 11.0
+ enable
+ false
+
+
+
+
+
+ Analyzer
+ false
+
+
+
+
diff --git a/src/MemoryPack.Core/Internal/TypeHelpers.cs b/src/MemoryPack.Core/Internal/TypeHelpers.cs
index c37fd483..8202f645 100644
--- a/src/MemoryPack.Core/Internal/TypeHelpers.cs
+++ b/src/MemoryPack.Core/Internal/TypeHelpers.cs
@@ -50,8 +50,8 @@ static class Cache
public static bool IsReferenceOrNullable;
public static bool IsUnmanagedSZArray;
public static int UnmanagedSZArrayElementSize;
- public static bool IsFixedSizeMemoryPackable;
- public static int MemoryPackableFixedSize;
+ public static bool IsFixedSizeMemoryPackable = false;
+ public static int MemoryPackableFixedSize = 0;
static Cache()
{
diff --git a/src/MemoryPack.Generator/MemoryPackGenerator.Emitter.cs b/src/MemoryPack.Generator/MemoryPackGenerator.Emitter.cs
index 6c278fe3..92ba8b27 100644
--- a/src/MemoryPack.Generator/MemoryPackGenerator.Emitter.cs
+++ b/src/MemoryPack.Generator/MemoryPackGenerator.Emitter.cs
@@ -268,11 +268,13 @@ public void Emit(StringBuilder writer, IGeneratorContext context)
string staticRegisterFormatterMethod, staticMemoryPackableMethod, scopedRef, constraint, registerBody, registerT;
var fixedSizeInterface = "";
var fixedSizeMethod = "";
+ scopedRef = (context.IsCSharp11OrGreater())
+ ? "scoped ref"
+ : "ref";
if (!context.IsNet7OrGreater)
{
staticRegisterFormatterMethod = "public static void ";
staticMemoryPackableMethod = "public static void ";
- scopedRef = "ref";
constraint = context.IsForUnity ? "" : "where TBufferWriter : class, System.Buffers.IBufferWriter";
registerBody = $"MemoryPackFormatterProvider.Register(new {Symbol.Name}Formatter());";
registerT = "RegisterFormatter();";
@@ -281,7 +283,6 @@ public void Emit(StringBuilder writer, IGeneratorContext context)
{
staticRegisterFormatterMethod = $"static void IMemoryPackFormatterRegister.";
staticMemoryPackableMethod = $"static void IMemoryPackable<{TypeName}>.";
- scopedRef = "scoped ref";
constraint = "";
registerBody = $"MemoryPackFormatterProvider.Register(new MemoryPack.Formatters.MemoryPackableFormatter<{TypeName}>());";
registerT = $"MemoryPackFormatterProvider.Register<{TypeName}>();";
@@ -373,7 +374,7 @@ sealed class {{Symbol.Name}}Formatter : MemoryPackFormatter<{{TypeName}}>
}
[global::MemoryPack.Internal.Preserve]
- public override void Deserialize(ref MemoryPackReader reader, ref {{TypeName}} value)
+ public override void Deserialize(ref MemoryPackReader reader, {{scopedRef}} {{TypeName}} value)
{
{{TypeName}}.Deserialize(ref reader, ref value);
}
diff --git a/src/MemoryPack.Generator/Properties/launchSettings.json b/src/MemoryPack.Generator/Properties/launchSettings.json
index 5fa6874c..a6e3d297 100644
--- a/src/MemoryPack.Generator/Properties/launchSettings.json
+++ b/src/MemoryPack.Generator/Properties/launchSettings.json
@@ -2,7 +2,7 @@
"profiles": {
"MemoryPack.Generator": {
"commandName": "DebugRoslynComponent",
- "targetProject": "..\\..\\sandbox\\SandboxConsoleApp\\SandboxConsoleApp.csproj"
+ "targetProject": "..\\..\\sandbox\\ClassLibrary\\ClassLibrary.csproj"
}
}
}
\ No newline at end of file
diff --git a/src/MemoryPack.Unity/Assets/Plugins/MemoryPack/Runtime/MemoryPack.Core/Internal/FixedArrayBufferWriter.cs.meta b/src/MemoryPack.Unity/Assets/Plugins/MemoryPack/Runtime/MemoryPack.Core/Internal/FixedArrayBufferWriter.cs.meta
new file mode 100644
index 00000000..5f0e2e0f
--- /dev/null
+++ b/src/MemoryPack.Unity/Assets/Plugins/MemoryPack/Runtime/MemoryPack.Core/Internal/FixedArrayBufferWriter.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 61f475a704e250d4ab0dd882130e9fdd
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/src/MemoryPack.Unity/Assets/Plugins/MemoryPack/Runtime/MemoryPack.Core/Internal/TypeHelpers.cs b/src/MemoryPack.Unity/Assets/Plugins/MemoryPack/Runtime/MemoryPack.Core/Internal/TypeHelpers.cs
index e465456d..5564a6e1 100644
--- a/src/MemoryPack.Unity/Assets/Plugins/MemoryPack/Runtime/MemoryPack.Core/Internal/TypeHelpers.cs
+++ b/src/MemoryPack.Unity/Assets/Plugins/MemoryPack/Runtime/MemoryPack.Core/Internal/TypeHelpers.cs
@@ -59,8 +59,8 @@ static class Cache
public static bool IsReferenceOrNullable;
public static bool IsUnmanagedSZArray;
public static int UnmanagedSZArrayElementSize;
- public static bool IsFixedSizeMemoryPackable;
- public static int MemoryPackableFixedSize;
+ public static bool IsFixedSizeMemoryPackable = false;
+ public static int MemoryPackableFixedSize = 0;
static Cache()
{
diff --git a/src/MemoryPack.Unity/Assets/Plugins/MemoryPack/Runtime/MemoryPack.Generator/MemoryPack.Generator.Roslyn3.dll b/src/MemoryPack.Unity/Assets/Plugins/MemoryPack/Runtime/MemoryPack.Generator/MemoryPack.Generator.Roslyn3.dll
index d60f72ef..93aaf452 100644
Binary files a/src/MemoryPack.Unity/Assets/Plugins/MemoryPack/Runtime/MemoryPack.Generator/MemoryPack.Generator.Roslyn3.dll and b/src/MemoryPack.Unity/Assets/Plugins/MemoryPack/Runtime/MemoryPack.Generator/MemoryPack.Generator.Roslyn3.dll differ
diff --git a/src/MemoryPack.Unity/UserSettings/Layouts/default-2021.dwlt b/src/MemoryPack.Unity/UserSettings/Layouts/default-2021.dwlt
index 8e312608..b2bbafdf 100644
--- a/src/MemoryPack.Unity/UserSettings/Layouts/default-2021.dwlt
+++ b/src/MemoryPack.Unity/UserSettings/Layouts/default-2021.dwlt
@@ -43,7 +43,7 @@ MonoBehaviour:
width: 2336
height: 2061
m_ShowMode: 4
- m_Title: Console
+ m_Title: Project
m_RootView: {fileID: 10}
m_MinSize: {x: 875, y: 300}
m_MaxSize: {x: 10000, y: 10000}
@@ -97,7 +97,7 @@ MonoBehaviour:
m_MinSize: {x: 310, y: 221}
m_MaxSize: {x: 4000, y: 4021}
vertical: 0
- controlID: 108
+ controlID: 127
--- !u!114 &5
MonoBehaviour:
m_ObjectHideFlags: 52
@@ -175,7 +175,7 @@ MonoBehaviour:
m_MinSize: {x: 300, y: 300}
m_MaxSize: {x: 24288, y: 24288}
vertical: 0
- controlID: 85
+ controlID: 86
--- !u!114 &8
MonoBehaviour:
m_ObjectHideFlags: 52
@@ -324,7 +324,7 @@ MonoBehaviour:
m_MinSize: {x: 100, y: 300}
m_MaxSize: {x: 8096, y: 24288}
vertical: 1
- controlID: 52
+ controlID: 87
--- !u!114 &14
MonoBehaviour:
m_ObjectHideFlags: 52
@@ -427,8 +427,8 @@ MonoBehaviour:
m_Tooltip:
m_Pos:
serializedVersion: 2
- x: 2776
- y: 635
+ x: -32000
+ y: -31416
width: 1151
height: 882
m_ViewDataDictionary: {fileID: 0}
@@ -454,14 +454,14 @@ MonoBehaviour:
m_StartGridSize: 64
m_LastFolders: []
m_LastFoldersGridSize: -1
- m_LastProjectPath: C:\Users\S04451\Documents\GitHub\MemoryPack\src\MemoryPack.Unity
+ m_LastProjectPath: C:\Users\owner\source\repos\MemoryPack\src\MemoryPack.Unity
m_LockTracker:
m_IsLocked: 0
m_FolderTreeState:
scrollPos: {x: 0, y: 0}
m_SelectedIDs: 38600000
m_LastClickedID: 24632
- m_ExpandedIDs: 00000000f0600000
+ m_ExpandedIDs: 0000000066600000
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
@@ -489,7 +489,7 @@ MonoBehaviour:
scrollPos: {x: 0, y: 0}
m_SelectedIDs:
m_LastClickedID: 0
- m_ExpandedIDs: ffffffff00000000f0600000
+ m_ExpandedIDs: ffffffff0000000066600000
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
@@ -619,7 +619,7 @@ MonoBehaviour:
scrollPos: {x: 0, y: 0}
m_SelectedIDs:
m_LastClickedID: 0
- m_ExpandedIDs: b2f5ffff04f6ffff4ef6ffffa0f7ffffb0f8ffff00fbffff
+ m_ExpandedIDs: 00fbffff
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name: