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 Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<Product>Simpra</Product>
<Company>ALTA Software llc.</Company>
<Copyright>Copyright © 2024 ALTA Software llc.</Copyright>
<Version>2.0.1</Version>
<Version>2.0.2</Version>
</PropertyGroup>

<PropertyGroup>
Expand Down
8 changes: 4 additions & 4 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
</PropertyGroup>
<ItemGroup>
<!-- Core Dependencies -->
<PackageVersion Include="AltaSoft.DomainPrimitives" Version="8.0.0" />
<PackageVersion Include="AltaSoft.DomainPrimitives.Generator" Version="8.0.0" />
<PackageVersion Include="AltaSoft.DomainPrimitives" Version="8.0.2" />
<PackageVersion Include="AltaSoft.DomainPrimitives.Generator" Version="8.0.2" />
<PackageVersion Include="Antlr4.Runtime.Standard" Version="4.13.1" />
<!-- Testing Dependencies -->
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.3.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.4.0" />
<PackageVersion Include="xunit" Version="2.9.3" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
<PackageVersion Include="coverlet.collector" Version="8.0.0" />
<PackageVersion Include="coverlet.collector" Version="8.0.1" />
<PackageVersion Include="BenchmarkDotNet" Version="0.15.8" />
</ItemGroup>
</Project>
11 changes: 9 additions & 2 deletions src/AltaSoft.Simpra/Visitor/SimpraParserVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -569,11 +569,18 @@ private static Expression HandleDictionaryIndexAccess(SimpraParser.IndexAccessCo

var keyExpr = index.Type != keyType ? Expression.Convert(index, keyType) : index;
var valueVar = Expression.Variable(valueType, "dictValue");
var dictVar = Expression.Variable(objectType, "dictRef");
var assignDict = Expression.Assign(dictVar, left);

var tryGetValueCall = Expression.Call(left, tryGetValueMethod, keyExpr, valueVar);
var tryGetValueCall = Expression.Call(dictVar, tryGetValueMethod, keyExpr, valueVar);
var notNull = Expression.NotEqual(dictVar, Expression.Constant(null, objectType));

var defaultValue = Expression.Default(valueType);
var block = Expression.Block([valueVar], Expression.Condition(tryGetValueCall, valueVar, defaultValue));
var block = Expression.Block(
[dictVar, valueVar],
assignDict,
Expression.Condition(Expression.AndAlso(notNull, tryGetValueCall), valueVar, defaultValue)
);

return ConvertToSimpraType(block, false, context);
}
Expand Down
17 changes: 17 additions & 0 deletions tests/AltaSoft.Simpra.tests/Models/DebtorAccount.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace AltaSoft.Simpra.Tests.Models;

public sealed class DebtorAccountModel
{
public required DebtorAccount DebtorAccount { get; set; }
}

public sealed class DebtorAccount
{
public Dictionary<string, string?>? Properties { get; set; }
public Dictionary<string, string?>? Attributes { get; set; }
public Dictionary<int, string>? IntKeyedProperties { get; set; }
public Dictionary<string, Customer>? CustomerMap { get; set; }
public DebtorAccount? Nested { get; set; }
public string? Name { get; set; }
public List<string>? Tags { get; set; }
}
Loading
Loading