Skip to content

Commit 49e3acb

Browse files
authored
Merge pull request #137 from Tynamix/bug/136
#136 fixed
2 parents 40870da + fb139a2 commit 49e3acb

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
#if NET6_0_OR_GREATER
9+
namespace Tynamix.ObjectFiller.Test.BugfixTests
10+
{
11+
public record Product
12+
{
13+
public string Name { get; init; }
14+
public int CategoryId { get; set; }
15+
}
16+
17+
public record Person(string Name, string Username);
18+
19+
[TestClass]
20+
public class Bug136RecordsObjectReferenceException
21+
{
22+
[TestMethod]
23+
public void RecordsShouldBeFilled()
24+
{
25+
Filler<Product> filler = new Filler<Product>();
26+
var product = filler.Create();
27+
Assert.IsNotNull(product);
28+
Assert.IsFalse(string.IsNullOrWhiteSpace(product.Name));
29+
30+
var filler2 = new Filler<Person>();
31+
var person = filler2.Create();
32+
Assert.IsNotNull(person);
33+
Assert.IsFalse(string.IsNullOrWhiteSpace(person.Name));
34+
Assert.IsFalse(string.IsNullOrWhiteSpace(person.Username));
35+
}
36+
}
37+
}
38+
#endif

Tynamix.ObjectFiller/NetTypeApiExtension.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ internal static IEnumerable<MethodInfo> GetMethods(this Type source)
3737
internal static MethodInfo GetSetterMethod(this PropertyInfo source)
3838
{
3939
#if NETSTANDARD
40-
return source.SetMethod;
40+
return source?.SetMethod;
4141
#else
4242
return source.GetSetMethod(true);
4343
#endif

0 commit comments

Comments
 (0)