This repository has been archived by the owner on Jul 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated Null handling to fix Bug #146 Fixed Bug #152 (Thanks @conficient) NuGet Update Co-authored-by: Howard Richards <[email protected]>
- Loading branch information
1 parent
626a154
commit c043117
Showing
21 changed files
with
393 additions
and
329 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
@page "/146" | ||
|
||
@using BlazorTable | ||
|
||
<Table TableItem="Root" Items="data" ShowSearchBar="true"> | ||
<Column TableItem="Root" Title="Data" Field="@(x => x.Child.Data)" Sortable="true" Filterable="true"> | ||
<Template> | ||
@(context.Child != null ? context.Child.Data : string.Empty) | ||
</Template> | ||
</Column> | ||
<Column TableItem="Root" Title="Data" Field="@(x => x.Child.Data)" Sortable="true" Filterable="true"> | ||
<Template> | ||
@(context.Child != null ? context.Child.Data : string.Empty) | ||
</Template> | ||
</Column> | ||
<Column TableItem="Root" Title="Data2" Field="@(x => x.Child.Data)" Sortable="true" Filterable="true" /> | ||
</Table> | ||
|
||
@code | ||
{ | ||
private Root[] data; | ||
|
||
protected override void OnInitialized() | ||
{ | ||
data = new Root[] | ||
{ | ||
new Root() | ||
{ | ||
Child = new Child(){ Data = "test1" } | ||
}, | ||
new Root() | ||
{ | ||
Child = new Child(){ Data = "test2" } | ||
}, | ||
new Root() | ||
{ | ||
Child = new Child(){ Data = "test3" } | ||
}, | ||
new Root() | ||
{ | ||
Child = new Child() | ||
}, | ||
new Root() | ||
{ | ||
Child = null | ||
} | ||
}; | ||
} | ||
|
||
public class Root | ||
{ | ||
public Child Child { get; set; } | ||
} | ||
|
||
public class Child | ||
{ | ||
public string Data { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
@page "/152" | ||
|
||
@using BlazorTable | ||
|
||
<Table TableItem="PersonData" Items="data" ShowSearchBar="true" ShowFooter="true"> | ||
<Column TableItem="PersonData" Title="Id" Field="@(x => x.ShortId)" Sortable="false" Filterable="true" SetFooterValue="Count" /> | ||
<DetailTemplate TableItem="PersonData"> | ||
@context.ShortId | ||
</DetailTemplate> | ||
</Table> | ||
|
||
@code | ||
{ | ||
private PersonData[] data; | ||
|
||
protected override void OnInitialized() | ||
{ | ||
data = new PersonData[] | ||
{ | ||
new PersonData() | ||
{ | ||
ShortId = 5 | ||
} | ||
}; | ||
} | ||
|
||
public class PersonData | ||
{ | ||
public int ShortId { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
using Shouldly; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Linq.Expressions; | ||
using Xunit; | ||
|
||
namespace BlazorTable.Tests | ||
{ | ||
public class AddNullChecks | ||
{ | ||
[Fact] | ||
public void AddToSingle() | ||
{ | ||
Expression<Func<Parent, object>> Field = x => x.Child; | ||
var exp = Field.Body.CreateNullChecks(); | ||
exp.ToString().ShouldBe("(x.Child != null)"); | ||
} | ||
|
||
[Fact] | ||
public void AddToMulti() | ||
{ | ||
Expression<Func<Parent, object>> Field = x => x.Child.Name; | ||
var exp = Field.Body.CreateNullChecks(); | ||
exp.ToString().ShouldBe("((x.Child != null) AndAlso (x.Child.Name != null))"); | ||
} | ||
|
||
[Fact] | ||
public void AddToMulti2() | ||
{ | ||
Expression<Func<Parent, object>> Field = x => x.Child.GrandChild.Name; | ||
var exp = Field.Body.CreateNullChecks(); | ||
exp.ToString().ShouldBe("(((x.Child != null) AndAlso (x.Child.GrandChild != null)) AndAlso (x.Child.GrandChild.Name != null))"); | ||
} | ||
|
||
[Fact] | ||
public void Skip() | ||
{ | ||
Expression<Func<Parent, object>> Field = x => x.Child; | ||
var exp = Field.Body.CreateNullChecks(true); | ||
exp.ToString().ShouldBe("(x.Child != null)"); | ||
} | ||
|
||
[Fact] | ||
public void Skip2() | ||
{ | ||
Expression<Func<Parent, object>> Field = x => x.Child.Name; | ||
var exp = Field.Body.CreateNullChecks(true); | ||
exp.ToString().ShouldBe("(x.Child != null)"); | ||
} | ||
|
||
[Fact] | ||
public void Skip3() | ||
{ | ||
Expression<Func<Parent, object>> Field = x => x.Child.GrandChild.Name; | ||
var exp = Field.Body.CreateNullChecks(true); | ||
exp.ToString().ShouldBe("((x.Child != null) AndAlso (x.Child.GrandChild != null))"); | ||
} | ||
|
||
private class Parent | ||
{ | ||
public Child Child { get; set; } | ||
} | ||
|
||
private class Child | ||
{ | ||
public string Name { get; set; } | ||
|
||
public GrandChild GrandChild { get; set; } | ||
} | ||
|
||
private class GrandChild | ||
{ | ||
public string Name { get; set; } | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.