Skip to content
This repository has been archived by the owner on Jan 23, 2024. It is now read-only.

Bug fix: stack overflow issue #50

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
24 changes: 24 additions & 0 deletions PerpetuumSoft.Knockout.Tests/KnockoutUtilitiesTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PerpetuumSoft.Knockout.Tests
{
[TestClass]
public class KnockoutUtilitiesTest
{
[TestMethod]
public void ConvertDataTest01()
{
TestModel model = new TestModel();
bool doesNotCauseStackOverflow = false;

Knockout.KnockoutUtilities.ConvertData(model);

doesNotCauseStackOverflow = true;
Assert.IsTrue(doesNotCauseStackOverflow);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="KnockoutExpressionConverterTest.cs" />
<Compile Include="KnockoutUtilitiesTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TestModel.cs" />
</ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions PerpetuumSoft.Knockout.Tests/TestModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class TestModel

public TestModel SubModel { get; set; }

public static TestModel StaticReferenceModel { get { return new TestModel(); } }

[ScriptIgnore]
public Expression<Func<string>> Concatenation
{
Expand Down
2 changes: 2 additions & 0 deletions PerpetuumSoft.Knockout/Utilities/KnockoutUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public static void ConvertData(object data)
type = type.BaseType;
foreach (var property in type.GetProperties())
{
if (property.GetGetMethod().IsStatic && property.PropertyType == property.DeclaringType)
continue;
if (property.GetCustomAttributes(typeof(Newtonsoft.Json.JsonIgnoreAttribute), false).Length > 0)
continue;
if (property.GetGetMethod() == null)
Expand Down