Skip to content

Commit 7d2a169

Browse files
authored
Merge pull request #134 from Tynamix/bug/132
Fix Bug #132
2 parents 7d047b6 + b7d1076 commit 7d2a169

11 files changed

+118
-37
lines changed

ObjectFillerNET.sln

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.30907.101
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.32112.339
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{0EC5FD26-A565-4D47-A192-0FC142C3B7F0}"
77
EndProject
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using Microsoft.VisualStudio.TestTools.UnitTesting;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace Tynamix.ObjectFiller.Test.BugfixTests
9+
{
10+
[TestClass]
11+
public class Bug132PropertiesOnBaseClassesNotPopulatedBeyond2Levels
12+
{
13+
public class BaseId
14+
{
15+
public string Id { get; set; }
16+
}
17+
18+
public class BaseWithAudit : BaseId
19+
{
20+
public string CreatedBy { get; set; }
21+
public string UpdatedBy { get; set; }
22+
}
23+
24+
public class Person : BaseWithAudit
25+
{
26+
public string Name { get; set; }
27+
public string LastName { get; set; }
28+
}
29+
[TestMethod]
30+
public void Bug132PropertiesOnBaseClassNotPopulated()
31+
{
32+
var filler = new Filler<Person>();
33+
var x = filler.Create();
34+
Assert.IsFalse(string.IsNullOrWhiteSpace(x.Name));
35+
Assert.IsFalse(string.IsNullOrWhiteSpace(x.LastName));
36+
Assert.IsFalse(string.IsNullOrWhiteSpace(x.CreatedBy));
37+
Assert.IsFalse(string.IsNullOrWhiteSpace(x.UpdatedBy));
38+
Assert.IsFalse(string.IsNullOrWhiteSpace(x.Id));
39+
}
40+
}
41+
}

Tynamix.ObjectFiller.Test/BugfixTests/Bug68HashsetCanNotBeCreated.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace Tynamix.ObjectFiller.Test.BugfixTests
66
{
7+
8+
[TestClass]
79
public class Bug68HashsetCanNotBeCreated
810
{
911
[TestMethod]

Tynamix.ObjectFiller.Test/BugfixTests/Bug89FillTypesInheritsFromDictionary.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
namespace Tynamix.ObjectFiller.Test.BugfixTests
77
{
8+
9+
[TestClass]
810
public class Bug89FillTypesInheritsFromDictionary
911
{
1012
public class EntityA

Tynamix.ObjectFiller.Test/BugfixTests/Bug89FillTypesInheritsFromList.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
namespace Tynamix.ObjectFiller.Test.BugfixTests
77
{
8+
9+
[TestClass]
810
public class Bug89FillTypesInheritsFromList
911
{
1012
public class EntityA

Tynamix.ObjectFiller.Test/BugfixTests/Bug91FailToCreateIReadOnlyCollection.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace Tynamix.ObjectFiller.Test.BugfixTests
88
using System.Collections;
99
using Microsoft.VisualStudio.TestTools.UnitTesting;
1010

11+
1112
public class OrderWithObject
1213
{
1314
public IReadOnlyCollection<Book> OrderLines { get; set; }

Tynamix.ObjectFiller.Test/CollectionizerTest.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,16 @@ public class CollectionizerPoco
1212

1313
public List<int> IntRange { get; set; }
1414

15+
#if !NET6
1516
public ArrayList ArrayList { get; set; }
16-
17+
#endif
1718
public string[] StringArray { get; set; }
1819
}
1920

2021
[TestClass]
2122
public class CollectionizerTest
2223
{
24+
#if !NET6
2325
[TestMethod]
2426
public void TestCityNames()
2527
{
@@ -31,6 +33,7 @@ public void TestCityNames()
3133
Assert.IsTrue(arrayList.ArrayList.Count >= 3 && arrayList.ArrayList.Count <= 10);
3234
Assert.IsTrue(arrayList.ArrayList.ToArray().Cast<string>().All(x => x.Length >= 20 && x.Length <= 25));
3335
}
36+
#endif
3437

3538
[TestMethod]
3639
public void TestMnemonicStringPlugin()
Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<TargetFrameworks>net461</TargetFrameworks>
5-
</PropertyGroup>
3+
<PropertyGroup>
4+
<TargetFrameworks>net6;net48</TargetFrameworks>
65

7-
<ItemGroup>
8-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
9-
<PackageReference Include="MSTest.TestAdapter" Version="1.3.2" />
10-
<PackageReference Include="MSTest.TestFramework" Version="1.3.2" />
11-
</ItemGroup>
6+
<IsPackable>false</IsPackable>
7+
</PropertyGroup>
128

13-
<ItemGroup>
14-
<ProjectReference Include="..\Tynamix.ObjectFiller\Tynamix.ObjectFiller.csproj" />
15-
</ItemGroup>
9+
<ItemGroup>
10+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
11+
<PackageReference Include="MSTest.TestAdapter" Version="2.2.7" />
12+
<PackageReference Include="MSTest.TestFramework" Version="2.2.7" />
13+
<PackageReference Include="coverlet.collector" Version="3.1.0" />
14+
</ItemGroup>
1615

17-
<ItemGroup>
18-
<Folder Include="Properties\" />
19-
</ItemGroup>
20-
</Project>
16+
<ItemGroup>
17+
<ProjectReference Include="..\Tynamix.ObjectFiller\Tynamix.ObjectFiller.csproj" />
18+
</ItemGroup>
19+
20+
<PropertyGroup Condition="'$(TargetFramework)' == 'net6'">
21+
<DefineConstants>NET6</DefineConstants>
22+
</PropertyGroup>
23+
24+
25+
</Project>

Tynamix.ObjectFiller/NetTypeApiExtension.cs

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -102,19 +102,12 @@ internal static IEnumerable<PropertyInfo> GetProperties(this Type source, bool i
102102
{
103103
#if NETSTANDARD
104104

105-
var propertyInfos = source.GetTypeInfo().DeclaredProperties.ToList();
106-
107-
if (ignoreInheritance == false && source.GetTypeInfo().BaseType != null)
105+
if (ignoreInheritance)
108106
{
109-
foreach (var property in source.GetTypeInfo().BaseType.GetTypeInfo().DeclaredProperties)
110-
{
111-
if (!propertyInfos.Any(x => x.Name == property.Name))
112-
{
113-
propertyInfos.Add(property);
114-
}
115-
}
107+
return source.GetTypeInfo().DeclaredProperties.ToList();
116108
}
117-
return propertyInfos;
109+
110+
return GetDeclaredPropertyInfosRecursive(new List<PropertyInfo>(), source.GetTypeInfo());
118111
#else
119112

120113
if (ignoreInheritance)
@@ -127,6 +120,30 @@ internal static IEnumerable<PropertyInfo> GetProperties(this Type source, bool i
127120

128121
}
129122

123+
#if NETSTANDARD
124+
125+
internal static List<PropertyInfo> GetDeclaredPropertyInfosRecursive(List<PropertyInfo> propertyInfos, TypeInfo typeInfo)
126+
{
127+
foreach (var property in typeInfo.DeclaredProperties)
128+
{
129+
if (!propertyInfos.Any(x => x.Name == property.Name))
130+
{
131+
propertyInfos.Add(property);
132+
}
133+
}
134+
135+
if(typeInfo.BaseType != null)
136+
{
137+
return GetDeclaredPropertyInfosRecursive(propertyInfos, typeInfo.BaseType.GetTypeInfo());
138+
}
139+
140+
return propertyInfos;
141+
}
142+
143+
#endif
144+
145+
146+
130147
internal static Type[] GetGenericTypeArguments(this Type source)
131148
{
132149
#if NETSTANDARD

Tynamix.ObjectFiller/Tynamix.ObjectFiller.csproj

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netstandard1.0;netstandard1.3;netstandard2.0;net35;net40;net45;net451;net452;</TargetFrameworks>
4+
<TargetFrameworks>netstandard1.0;netstandard1.3;netstandard2.0;net35;net452;</TargetFrameworks>
55
<PackageRequireLicenseAcceptance>False</PackageRequireLicenseAcceptance>
66
<Version>1.5.6</Version>
77
<Authors>Roman Lautner, Hendrik L., Christian Harlass, GothikX</Authors>
88
<Company>Tynamix</Company>
99
<PackageLicenseUrl></PackageLicenseUrl>
1010
<PackageProjectUrl>http://objectfiller.net/</PackageProjectUrl>
1111
<PackageIconUrl></PackageIconUrl>
12-
<PackageReleaseNotes>-1.5.6
13-
* Added target framework nertstandard1.3, netstandard2.0 to improve easier usage with .NET 5
12+
<PackageReleaseNotes>-1.5.7
13+
* Fix multi inheritance bug on .NET Standard
14+
15+
-1.5.6
16+
* Added target framework netstandard1.3, netstandard2.0 to improve easier usage with .NET 5
1417
* Added Long Range plugin (thx to weitzhandler)
1518

1619
-1.5.5
@@ -153,14 +156,19 @@
153156
-1.0.0
154157
* Initial release</PackageReleaseNotes>
155158
<PackageTags>objectfiller tynamix test testdata prototyp prototyping unittest design designviewmodel generator random data randomdata testing poco lorem ipsum fakedata fake faker</PackageTags>
156-
<Description>The Tynamix ObjectFiller.NET fills the properties of your objects with random data. Use it for unittest, prototyping and whereever you need some random testdata. It has a fluent API and is highly customizable. It supports also IEnumerables and Dictionaries and constructors WITH parameters. It is also possible to fill instances and to write private properties.</Description>
159+
<Description>The Tynamix ObjectFiller.NET fills the properties of your objects with random data.
160+
Use it for unittest, prototyping and whereever you need some random testdata.
161+
162+
It has a fluent API and is highly customizable.
163+
It supports also IEnumerables and Dictionaries and constructors WITH parameters.
164+
It is also possible to fill instances and to write private properties.</Description>
157165
<RepositoryUrl>https://github.com/Tynamix/ObjectFiller.NET</RepositoryUrl>
158166
<RepositoryType>GitHub</RepositoryType>
159167
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
160-
<Copyright>Copyright ©Roman Lautner 2021</Copyright>
168+
<Copyright>Copyright ©Roman Lautner 2022</Copyright>
161169
<DocumentationFile>bin\Debug\Tynamix.ObjectFiller.xml</DocumentationFile>
162-
<AssemblyVersion>1.5.6</AssemblyVersion>
163-
<FileVersion>1.5.6</FileVersion>
170+
<AssemblyVersion>1.5.7</AssemblyVersion>
171+
<FileVersion>1.5.7</FileVersion>
164172
<PackageIcon>logo.png</PackageIcon>
165173
<PackageLicenseExpression>MIT</PackageLicenseExpression>
166174
</PropertyGroup>

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
os: Visual Studio 2017
1+
os: Visual Studio 2022
22

33
install:
44
- dotnet restore

0 commit comments

Comments
 (0)