Skip to content

Compiled property path function #178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
d932f8c
Compiled lambda expression, which is faster than the previous GetValu…
DanielTrommel Jul 11, 2025
323e9aa
Processed Copilot review comments on Github
DanielTrommel Aug 2, 2025
da5a8d5
Merge remote-tracking branch 'remotes/origin/tests' into compiled-pro…
DanielTrommel Aug 5, 2025
067465b
Updated unit test previous GetValue() reflection approach, with the n…
DanielTrommel Aug 5, 2025
e1ba188
Merge remote-tracking branch 'remotes/origin/main' into compiled-prop…
DanielTrommel Aug 5, 2025
34cc106
Simplification of the indexer code
DanielTrommel Aug 7, 2025
99d2f62
Generic support for multi-dimensional indexers
DanielTrommel Aug 7, 2025
dc07aa7
Added NULL checks for Arrays
DanielTrommel Aug 7, 2025
0f6a967
More performant approach that is more readable when reviewing the Exp…
DanielTrommel Aug 7, 2025
5343d41
Added Null-check code for every property access step; return null as …
DanielTrommel Aug 7, 2025
c623f92
Added logic for IDict/IList/ICollection/generic indexer, but not yet …
DanielTrommel Aug 7, 2025
fd1bf26
Added the simplest test; access a property directly on the instance
DanielTrommel Aug 8, 2025
0c2b84c
Test case for List, and edge cases where null should be returned
DanielTrommel Aug 8, 2025
b69b9d5
Added a new test for the ultimate try/catch case for indexers that ca…
DanielTrommel Aug 9, 2025
1cc3e34
Some optimizations;
DanielTrommel Aug 9, 2025
dfa60d6
Another test case; accessing a property on a string. And further refi…
DanielTrommel Aug 9, 2025
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
22 changes: 10 additions & 12 deletions src/Columns/TableViewBoundColumn.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Data;
using System;
using System.Linq.Expressions;
using System.Reflection;
using WinUI.TableView.Extensions;

Expand All @@ -11,25 +12,22 @@ namespace WinUI.TableView;
/// </summary>
public abstract class TableViewBoundColumn : TableViewColumn
{
private Type? _listType;
private string? _propertyPath;
private Binding _binding = new();
private (PropertyInfo, object?)[]? _propertyInfo;

private Func<object, object?>? _funcCompiledPropertyPath;

/// <inheritdoc/>
public override object? GetCellContent(object? dataItem)
{
if (dataItem is null) return null;
if (dataItem is null)
return null;

if (_propertyInfo is null || dataItem.GetType() != _listType)
{
_listType = dataItem.GetType();
dataItem = dataItem.GetValue(_listType, PropertyPath, out _propertyInfo);
}
else
{
dataItem = dataItem.GetValue(_propertyInfo);
}
if (_funcCompiledPropertyPath is null && !string.IsNullOrWhiteSpace(PropertyPath))
_funcCompiledPropertyPath = dataItem.GetFuncCompiledPropertyPath(PropertyPath!);

if (_funcCompiledPropertyPath is not null)
dataItem = _funcCompiledPropertyPath(dataItem);

if (Binding?.Converter is not null)
{
Expand Down
Loading