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
8 changes: 4 additions & 4 deletions src/Firmware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,9 @@ class PortPinInfoTypeConverter(IDeserializer deserializer) : IYamlTypeConverter
public object? ReadYaml(IParser parser, Type type, ObjectDeserializer rootDeserializer)
{
var portPin = Deserializer.Deserialize<Dictionary<object, object>>(parser);
if (portPin.TryGetValue(DirectionProperty, out object value))
if (portPin.TryGetValue(DirectionProperty, out var value))
{
var pinDirection = PascalCaseNamingConvention.Instance.Apply((string)value);
var pinDirection = PascalCaseNamingConvention.Instance.Apply(value as string ?? string.Empty);
Type portPinType = pinDirection switch
{
nameof(PinDirection.Input) => typeof(InputPinInfo),
Expand Down Expand Up @@ -429,7 +429,7 @@ public void WriteYaml(IEmitter emitter, object? value, Type type, ObjectSerializ
return;

var scalarStyle = ScalarStyle.Any;
var scalarValue = LowerCaseNamingConvention.Instance.Apply(value.ToString());
var scalarValue = LowerCaseNamingConvention.Instance.Apply(value.ToString() ?? string.Empty);
if (scalarValue == "off")
scalarStyle = ScalarStyle.DoubleQuoted;
emitter.Emit(new Scalar(AnchorName.Empty, TagName.Empty, scalarValue, scalarStyle, true, true));
Expand All @@ -449,7 +449,7 @@ public void WriteYaml(IEmitter emitter, object? value, Type type, ObjectSerializ
if (value is null)
return;

emitter.Emit(new Scalar(CamelCaseNamingConvention.Instance.Apply(value.ToString())));
emitter.Emit(new Scalar(CamelCaseNamingConvention.Instance.Apply(value.ToString() ?? string.Empty)));
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/Harp.Generators.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<Description>Provides source generators for Harp device firmware and software interface.</Description>
<PackageTags>$(PackageTags) Device Firmware Interface</PackageTags>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand All @@ -17,7 +17,7 @@
<ItemGroup>
<PackageReference Include="Bonsai.Harp" Version="3.5.0" />
<PackageReference Include="YamlDotNet" Version="16.3.0" />
<PackageReference Include="T4.BuildTools" Version="3.0.0" />
<PackageReference Include="T4.BuildTools" Version="3.0.0" PrivateAssets="all" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions src/Interface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -561,9 +561,9 @@ static int GetMemberSize(
out PayloadType payloadType)
{
interfaceType = GetInterfaceType(member, register.Type);
if (deviceMetadata.GroupMasks.TryGetValue(interfaceType, out GroupMaskInfo groupMask))
if (deviceMetadata.GroupMasks.TryGetValue(interfaceType, out var groupMask))
interfaceType = groupMask.InterfaceType;
else if (deviceMetadata.BitMasks.TryGetValue(interfaceType, out BitMaskInfo bitMask))
else if (deviceMetadata.BitMasks.TryGetValue(interfaceType, out var bitMask))
interfaceType = bitMask.InterfaceType;

if (GetInterfaceTypeSize(interfaceType, out payloadType, out int size))
Expand Down
4 changes: 2 additions & 2 deletions src/TemplateBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ public string ToStringWithCulture(object value)

var method = value.GetType().GetMethod(nameof(ToString), [typeof(IFormatProvider)]);
if (method is not null)
return (string)method.Invoke(value, [formatProvider]);
return (string?)method.Invoke(value, [formatProvider]) ?? string.Empty;

return value.ToString();
return value.ToString() ?? string.Empty;
}
}
}
Loading