Skip to content

Commit a9ff0f1

Browse files
Copilotagocke
andauthored
Upgrade Serde to 1.0.0 (#7)
## Upgrade Serde to 0.9.1 Upgrades Serde from `[0.8.0,0.9.0)` to `0.9.1`. ## API Changes **Signature Updates:** - `TryReadIndex(ISerdeInfo, out string?)` split into two methods: - `TryReadIndex(ISerdeInfo)` - returns just the index - `TryReadIndexWithName(ISerdeInfo)` - returns tuple `(int, string?)` All other APIs remain the same as 0.8.x. ## Status ✅ Main library builds successfully ✅ All tests pass ✅ Benchmarks build successfully <!-- START COPILOT CODING AGENT SUFFIX --> <details> <summary>Original prompt</summary> > Please upgrade to the latest serde version </details> <!-- START COPILOT CODING AGENT TIPS --> --- 💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: agocke <515774+agocke@users.noreply.github.com> Co-authored-by: Andy Gocke <andy@commentout.net>
1 parent 96634b6 commit a9ff0f1

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

Directory.Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</PropertyGroup>
66
<ItemGroup>
77
<PackageVersion Include="BenchmarkDotNet" Version="0.14.0" />
8-
<PackageVersion Include="Serde" Version="[0.8.0,0.9.0)" />
8+
<PackageVersion Include="Serde" Version="0.9.1" />
99
<PackageVersion Include="Spectre.Console" Version="0.54.0" />
1010
<PackageVersion Include="StaticCs" Version="0.3.1" />
1111
<PackageVersion Include="Spectre.Console.Testing" Version="0.54.0" />

src/Deserializer.cs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,17 @@ internal sealed partial class Deserializer(string[] args, bool handleHelp) : IDe
1414

1515
public IReadOnlyList<ISerdeInfo> HelpInfos => _helpInfos;
1616

17-
int ITypeDeserializer.TryReadIndex(ISerdeInfo serdeInfo, out string? errorName)
17+
int ITypeDeserializer.TryReadIndex(ISerdeInfo serdeInfo)
18+
{
19+
var (index, _) = ((ITypeDeserializer)this).TryReadIndexWithName(serdeInfo);
20+
return index;
21+
}
22+
23+
(int, string? errorName) ITypeDeserializer.TryReadIndexWithName(ISerdeInfo serdeInfo)
1824
{
1925
if (_argIndex == args.Length)
2026
{
21-
errorName = null;
22-
return ITypeDeserializer.EndOfType;
27+
return (ITypeDeserializer.EndOfType, null);
2328
}
2429

2530
var arg = args[_argIndex];
@@ -29,8 +34,7 @@ int ITypeDeserializer.TryReadIndex(ISerdeInfo serdeInfo, out string? errorName)
2934
_helpInfos.Add(serdeInfo);
3035
if (_argIndex == args.Length)
3136
{
32-
errorName = null;
33-
return ITypeDeserializer.EndOfType;
37+
return (ITypeDeserializer.EndOfType, null);
3438
}
3539
arg = args[_argIndex];
3640
}
@@ -50,8 +54,7 @@ int ITypeDeserializer.TryReadIndex(ISerdeInfo serdeInfo, out string? errorName)
5054
if (arg == flag)
5155
{
5256
_argIndex++;
53-
errorName = null;
54-
return fieldIndex;
57+
return (fieldIndex, null);
5558
}
5659
}
5760
}
@@ -61,8 +64,7 @@ int ITypeDeserializer.TryReadIndex(ISerdeInfo serdeInfo, out string? errorName)
6164
commandName == arg)
6265
{
6366
_argIndex++;
64-
errorName = null;
65-
return fieldIndex;
67+
return (fieldIndex, null);
6668
}
6769
else if (!arg.StartsWith('-') &&
6870
attr is { AttributeType: { Name: nameof(CommandGroupAttribute) } })
@@ -84,15 +86,14 @@ int ITypeDeserializer.TryReadIndex(ISerdeInfo serdeInfo, out string? errorName)
8486
_throwOnMissing = false;
8587

8688
var deType = this.ReadType(fieldInfo);
87-
int index = deType.TryReadIndex(fieldInfo, out _);
89+
int index = deType.TryReadIndex(fieldInfo);
8890
_argIndex = savedIndex;
8991
_throwOnMissing = savedThrowOnMissing;
9092

9193
if (index >= 0)
9294
{
9395
// We found a match, so we can return the field index.
94-
errorName = null;
95-
return fieldIndex;
96+
return (fieldIndex, null);
9697
}
9798
// No match, so we can continue.
9899
}
@@ -102,8 +103,7 @@ int ITypeDeserializer.TryReadIndex(ISerdeInfo serdeInfo, out string? errorName)
102103
_paramIndex == paramIndex)
103104
{
104105
_paramIndex++;
105-
errorName = null;
106-
return fieldIndex;
106+
return (fieldIndex, null);
107107
}
108108
}
109109
}
@@ -113,8 +113,7 @@ int ITypeDeserializer.TryReadIndex(ISerdeInfo serdeInfo, out string? errorName)
113113
}
114114
else
115115
{
116-
errorName = arg;
117-
return ITypeDeserializer.IndexNotFound;
116+
return (ITypeDeserializer.IndexNotFound, arg);
118117
}
119118
}
120119

0 commit comments

Comments
 (0)