Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"CSharpier": {
"version": "1.4.0",
"version": "1.4.1",
"commands": ["csharpier"]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,41 +62,40 @@ bool includeSerializedFields
string context = $"accessibility={accessibility}, serialized={includeSerializedFields}";
CSharpParseOptions options = new(LanguageVersion.CSharp9);

string CreateFixedStorageSource(string attribute, string constructor) =>
$$"""
using DxMessaging.Core.Attributes;

{{attribute}}
public unsafe partial struct Packet
{
public readonly int Value;
{{fieldAttribute}} {{accessibility}} fixed byte _bytes[4];
{{constructor}}
string CreateFixedStorageSource(string attribute, string constructor) => $$"""
using DxMessaging.Core.Attributes;

public int WriteAndRead()
{
fixed (byte* bytes = _bytes)
{
bytes[3] = 73;
return bytes[3];
}
}
}
{{attribute}}
public unsafe partial struct Packet
{
public readonly int Value;
{{fieldAttribute}} {{accessibility}} fixed byte _bytes[4];
{{constructor}}

public static class Probe
public int WriteAndRead()
{
public static int[] Read()
fixed (byte* bytes = _bytes)
{
Packet packet = new Packet(42);
return new[] { packet.Value, packet.WriteAndRead() - 73, 0 };
bytes[3] = 73;
return bytes[3];
}
}
}

namespace UnityEngine
public static class Probe
{
public static int[] Read()
{
public sealed class SerializeField : System.Attribute { }
Packet packet = new Packet(42);
return new[] { packet.Value, packet.WriteAndRead() - 73, 0 };
}
""";
}

namespace UnityEngine
{
public sealed class SerializeField : System.Attribute { }
}
""";

AssertCallerExecutes(
CreateCompilation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,7 @@ private static string Source(
string fieldAttribute,
string constructor,
string consumer
) =>
$$"""
) => $$"""
{{(constructor.Length == 0 ? "using DxMessaging.Core.Attributes;" : "")}}
public enum Choice { None, Other }
public readonly struct Payload
Expand Down
Loading